57 m_grid =
new WX_GRID(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
60 m_grid->EnableEditing(
true );
61 m_grid->EnableGridLines(
true );
62 m_grid->EnableDragGridSize(
false );
63 m_grid->SetMargins( 0, 0 );
64 m_grid->SetCellHighlightROPenWidth( 0 );
66 m_grid->EnableDragColMove(
false );
67 m_grid->EnableDragColSize(
false );
68 m_grid->SetColLabelSize( 0 );
69 m_grid->EnableDragRowMove(
false );
70 m_grid->EnableDragRowSize(
false );
71 m_grid->SetRowLabelSize( 0 );
72 m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
77 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
79 for(
int col = 0; col <
m_table->GetColCount(); ++col )
82 wxGridCellAttr* attr =
new wxGridCellAttr;
92 [
this, cell]( wxStyledTextEvent& aEvent,
SCINTILLA_TRICKS* aScintillaTricks )
96 [
this, cell](
const wxString& xRef, wxArrayString* tokens )
98 m_frame->GetContextualTextVars( cell, xRef, tokens );
103 m_grid->SetAttr( row, col, attr );
107 if(
m_table->GetParentFootprint() )
122 for(
const auto& [lineStyle, lineStyleDesc] :
lineTypeNames )
139 m_grid->PopEventHandler(
true );
147 if( !wxDialog::TransferDataToWindow() )
154 wxColour coveredColor = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
157 coveredColor = coveredColor.ChangeLightness( 140 );
159 coveredColor = coveredColor.ChangeLightness( 100 );
161 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
163 for(
int col = 0; col <
m_table->GetColCount(); ++col )
165 PCB_TABLECELL* tableCell;
168 tableCell =
m_table->GetCell( row,
m_table->GetColCount() - 1 - col );
170 tableCell =
m_table->GetCell( row, col );
174 m_grid->SetCellValue( row, col, coveredColor.GetAsString() );
189 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
191 for(
int col = 0; col <
m_table->GetColCount(); ++col )
193 PCB_TABLECELL* tableCell =
m_table->GetCell( row, col );
197 m_grid->SetGridCursor( row, col );
198 m_grid->EnableCellEditControl();
199 m_grid->ShowCellEditControl();
218 if(
m_table->GetBorderStroke().GetWidth() >= 0 )
221 int style =
static_cast<int>(
m_table->GetBorderStroke().GetLineStyle() );
232 bool rows =
m_table->StrokeRows() &&
m_table->GetSeparatorsStroke().GetWidth() >= 0;
233 bool cols =
m_table->StrokeColumns() &&
m_table->GetSeparatorsStroke().GetWidth() >= 0;
238 if(
m_table->GetSeparatorsStroke().GetWidth() >= 0 )
241 style =
static_cast<int>(
m_table->GetSeparatorsStroke().GetLineStyle() );
312 if( !
m_grid->CommitPendingChanges() )
315 if( !wxDialog::TransferDataFromWindow() )
319 BOARD_COMMIT commit(
m_frame );
324 bool pushCommit = (
m_table->GetEditFlags() == 0 );
331 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
333 for(
int col = 0; col <
m_table->GetColCount(); ++col )
335 PCB_TABLECELL* tableCell;
338 tableCell =
m_table->GetCell( row,
m_table->GetColCount() - 1 - col );
340 tableCell =
m_table->GetCell( row, col );
342 wxString txt =
m_grid->GetCellValue( row, col );
354 txt.Replace(
"\r",
"\n" );
355#elif defined( __WINDOWS__ )
358 txt.Replace(
"\r",
"" );
372 STROKE_PARAMS stroke =
m_table->GetBorderStroke();
387 m_table->SetBorderStroke( stroke );
393 STROKE_PARAMS stroke =
m_table->GetSeparatorsStroke();
408 m_table->SetSeparatorsStroke( stroke );
422 wxSize availableGridSize =
m_grid->GetClientSize();
424 if( availableGridSize.x == 0 || availableGridSize.y == 0 )
428 double scalerX =
static_cast<double>( availableGridSize.x ) / tableBBox.
GetWidth();
429 double scalerY =
static_cast<double>( availableGridSize.y ) / tableBBox.
GetHeight();
431 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
432 m_grid->SetRowSize( row, std::floor(
m_table->GetRowHeight( row ) * scalerY ) );
434 for(
int col = 0; col <
m_table->GetColCount(); ++col )
435 m_grid->SetColSize( col, std::floor(
m_table->GetColWidth( col ) * scalerX ) );
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
#define SKIP_CONNECTIVITY
Container for design settings for a BOARD object.
int GetLineThickness(PCB_LAYER_ID aLayer) const
Return the default graphic segment thickness from the layer class for the given layer.
wxString ConvertCrossReferencesToKIIDs(const wxString &aSource) const
Convert cross-references back and forth between ${refDes:field} and ${kiid:field}.
wxString ConvertKIIDsToCrossReferences(const wxString &aSource) const
constexpr size_type GetWidth() const
constexpr size_type GetHeight() const
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
wxCheckBox * m_headerBorder
wxStaticText * m_separatorsStyleLabel
wxStaticText * m_separatorsWidthLabel
wxStaticText * m_borderStyleLabel
wxBitmapComboBox * m_borderStyleCombo
wxCheckBox * m_borderCheckbox
wxStaticText * m_borderWidthLabel
DIALOG_TABLE_PROPERTIES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Table Properties"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
wxTextCtrl * m_borderWidthCtrl
wxCheckBox * m_rowSeparators
PCB_LAYER_BOX_SELECTOR * m_LayerSelectionCtrl
wxBitmapComboBox * m_separatorsStyleCombo
wxCheckBox * m_colSeparators
wxStaticText * m_borderWidthUnits
wxStaticText * m_separatorsWidthUnits
wxTextCtrl * m_separatorsWidthCtrl
bool TransferDataFromWindow() override
UNIT_BINDER m_borderWidth
DIALOG_TABLE_PROPERTIES(SCH_EDIT_FRAME *aParentFrame, SCH_TABLE *aTable)
~DIALOG_TABLE_PROPERTIES()
UNIT_BINDER m_separatorsWidth
void onBorderChecked(wxCommandEvent &aEvent) override
void onHeaderChecked(wxCommandEvent &aEvent) override
bool TransferDataToWindow() override
void onSize(wxSizeEvent &aEvent) override
virtual const wxString & GetText() const
Return the string associated with the text object.
virtual void SetText(const wxString &aText)
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
int GetLayerSelection() const
Common, abstract interface for edit frames.
void SetLayer(PCB_LAYER_ID aLayer) override
Set the layer this item is on.
Add cut/copy/paste, dark theme, autocomplete and brace highlighting to a wxStyleTextCtrl instance.
void DoTextVarAutocomplete(const std::function< void(const wxString &xRef, wxArrayString *tokens)> &getTokensFn)
void SetLineStyle(LINE_STYLE aLineStyle)
void SetWidth(int aWidth)
void Enable(bool aEnable)
Enable/disable the label, widget and units label.
virtual long long int GetValue() const
Return the current value in Internal Units.
virtual void SetValue(long long int aValue)
Set new value (in Internal Units) for the text field, taking care of units conversion.
This file is part of the common library.
#define IN_EDIT
Item currently edited.
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
PCB_LAYER_ID
A quick note on layer IDs:
PCB_LAYER_ID ToLAYER_ID(int aLayer)
wxString UnescapeString(const wxString &aSource)
const std::map< LINE_STYLE, struct LINE_STYLE_DESC > lineTypeNames
Conversion map between LINE_STYLE values and style names displayed.