22#include <wx/hyperlink.h>
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;
91 attr->SetRenderer(
new wxGridCellAutoWrapStringRenderer );
94 [
this, cell]( wxStyledTextEvent& aEvent,
SCINTILLA_TRICKS* aScintillaTricks )
98 [
this, cell](
const wxString& xRef, wxArrayString* tokens )
100 m_frame->GetContextualTextVars( cell, xRef, tokens );
105 m_grid->SetAttr( row, col, attr );
109 if(
m_table->GetParentFootprint() )
124 for(
const auto& [lineStyle, lineStyleDesc] :
lineTypeNames )
134 m_syntaxHelp =
new wxHyperlinkCtrl(
this, wxID_ANY,
_(
"Syntax help" ), wxEmptyString, wxDefaultPosition,
135 wxDefaultSize, wxHL_DEFAULT_STYLE );
151 m_grid->PopEventHandler(
true );
162 if( !wxDialog::TransferDataToWindow() )
169 wxColour coveredColor = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
172 coveredColor = coveredColor.ChangeLightness( 140 );
174 coveredColor = coveredColor.ChangeLightness( 100 );
176 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
178 for(
int col = 0; col <
m_table->GetColCount(); ++col )
180 PCB_TABLECELL* tableCell;
183 tableCell =
m_table->GetCell( row,
m_table->GetColCount() - 1 - col );
185 tableCell =
m_table->GetCell( row, col );
189 m_grid->SetCellValue( row, col, coveredColor.GetAsString() );
205 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
207 for(
int col = 0; col <
m_table->GetColCount(); ++col )
209 PCB_TABLECELL* tableCell =
m_table->GetCell( row, col );
213 m_grid->SetGridCursor( row, col );
214 m_grid->EnableCellEditControl();
215 m_grid->ShowCellEditControl();
234 if(
m_table->GetBorderStroke().GetWidth() >= 0 )
237 int style =
static_cast<int>(
m_table->GetBorderStroke().GetLineStyle() );
248 bool rows =
m_table->StrokeRows() &&
m_table->GetSeparatorsStroke().GetWidth() >= 0;
249 bool cols =
m_table->StrokeColumns() &&
m_table->GetSeparatorsStroke().GetWidth() >= 0;
254 if(
m_table->GetSeparatorsStroke().GetWidth() >= 0 )
257 style =
static_cast<int>(
m_table->GetSeparatorsStroke().GetLineStyle() );
328 if( !
m_grid->CommitPendingChanges() )
331 if( !wxDialog::TransferDataFromWindow() )
335 BOARD_COMMIT commit(
m_frame );
340 bool pushCommit = (
m_table->GetEditFlags() == 0 );
347 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
349 for(
int col = 0; col <
m_table->GetColCount(); ++col )
351 PCB_TABLECELL* tableCell;
354 tableCell =
m_table->GetCell( row,
m_table->GetColCount() - 1 - col );
356 tableCell =
m_table->GetCell( row, col );
358 wxString txt =
m_grid->GetCellValue( row, col );
370 txt.Replace(
"\r",
"\n" );
371#elif defined( __WINDOWS__ )
374 txt.Replace(
"\r",
"" );
388 STROKE_PARAMS stroke =
m_table->GetBorderStroke();
403 m_table->SetBorderStroke( stroke );
409 STROKE_PARAMS stroke =
m_table->GetSeparatorsStroke();
424 m_table->SetSeparatorsStroke( stroke );
438 wxSize availableGridSize =
m_grid->GetClientSize();
440 if( availableGridSize.x == 0 || availableGridSize.y == 0 )
444 double scalerX =
static_cast<double>( availableGridSize.x ) / tableBBox.
GetWidth();
445 double scalerY =
static_cast<double>( availableGridSize.y ) / tableBBox.
GetHeight();
447 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
448 m_grid->SetRowSize( row, std::floor(
m_table->GetRowHeight( row ) * scalerY ) );
450 for(
int col = 0; col <
m_table->GetColCount(); ++col )
451 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...
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
HTML_MESSAGE_BOX * m_helpWindow
bool TransferDataFromWindow() override
UNIT_BINDER m_borderWidth
DIALOG_TABLE_PROPERTIES(SCH_EDIT_FRAME *aParentFrame, SCH_TABLE *aTable)
wxHyperlinkCtrl * m_syntaxHelp
~DIALOG_TABLE_PROPERTIES()
void onSyntaxHelp(wxHyperlinkEvent &aEvent)
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.
static HTML_MESSAGE_BOX * ShowSyntaxHelp(wxWindow *aParentWindow)
Display a syntax help window for text variables and expressions.
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)
#define SKIP_CONNECTIVITY
const std::map< LINE_STYLE, struct LINE_STYLE_DESC > lineTypeNames
Conversion map between LINE_STYLE values and style names displayed.