26#include <wx/hyperlink.h>
60 m_grid =
new WX_GRID(
this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
63 m_grid->EnableEditing(
true );
64 m_grid->EnableGridLines(
true );
65 m_grid->EnableDragGridSize(
false );
66 m_grid->SetMargins( 0, 0 );
67 m_grid->SetCellHighlightROPenWidth( 0 );
69 m_grid->EnableDragColMove(
false );
70 m_grid->EnableDragColSize(
false );
71 m_grid->SetColLabelSize( 0 );
72 m_grid->EnableDragRowMove(
false );
73 m_grid->EnableDragRowSize(
false );
74 m_grid->SetRowLabelSize( 0 );
75 m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
80 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
82 for(
int col = 0; col <
m_table->GetColCount(); ++col )
85 wxGridCellAttr* attr =
new wxGridCellAttr;
96 [
this, cell]( wxStyledTextEvent& aEvent,
SCINTILLA_TRICKS* aScintillaTricks )
100 [
this, cell](
const wxString& xRef, wxArrayString* tokens )
102 m_frame->GetContextualTextVars( cell, xRef, tokens );
107 m_grid->SetAttr( row, col, attr );
111 if(
m_table->GetParentFootprint() )
126 for(
const auto& [lineStyle, lineStyleDesc] :
lineTypeNames )
136 m_syntaxHelp =
new wxHyperlinkCtrl(
this, wxID_ANY,
_(
"Syntax help" ), wxEmptyString, wxDefaultPosition,
137 wxDefaultSize, wxHL_DEFAULT_STYLE );
153 m_grid->PopEventHandler(
true );
164 if( !wxDialog::TransferDataToWindow() )
171 wxColour coveredColor = wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE );
174 coveredColor = coveredColor.ChangeLightness( 140 );
176 coveredColor = coveredColor.ChangeLightness( 100 );
178 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
180 for(
int col = 0; col <
m_table->GetColCount(); ++col )
182 PCB_TABLECELL* tableCell;
185 tableCell =
m_table->GetCell( row,
m_table->GetColCount() - 1 - col );
187 tableCell =
m_table->GetCell( row, col );
191 m_grid->SetCellValue( row, col, coveredColor.GetAsString() );
207 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
209 for(
int col = 0; col <
m_table->GetColCount(); ++col )
211 PCB_TABLECELL* tableCell =
m_table->GetCell( row, col );
215 m_grid->SetGridCursor( row, col );
216 m_grid->EnableCellEditControl();
217 m_grid->ShowCellEditControl();
236 if(
m_table->GetBorderStroke().GetWidth() >= 0 )
239 int style =
static_cast<int>(
m_table->GetBorderStroke().GetLineStyle() );
250 bool rows =
m_table->StrokeRows() &&
m_table->GetSeparatorsStroke().GetWidth() >= 0;
251 bool cols =
m_table->StrokeColumns() &&
m_table->GetSeparatorsStroke().GetWidth() >= 0;
256 if(
m_table->GetSeparatorsStroke().GetWidth() >= 0 )
259 style =
static_cast<int>(
m_table->GetSeparatorsStroke().GetLineStyle() );
330 if( !
m_grid->CommitPendingChanges() )
333 if( !wxDialog::TransferDataFromWindow() )
337 BOARD_COMMIT commit(
m_frame );
342 bool pushCommit = (
m_table->GetEditFlags() == 0 );
349 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
351 for(
int col = 0; col <
m_table->GetColCount(); ++col )
353 PCB_TABLECELL* tableCell;
356 tableCell =
m_table->GetCell( row,
m_table->GetColCount() - 1 - col );
358 tableCell =
m_table->GetCell( row, col );
360 wxString txt =
m_grid->GetCellValue( row, col );
372 txt.Replace(
"\r",
"\n" );
373#elif defined( __WINDOWS__ )
376 txt.Replace(
"\r",
"" );
390 STROKE_PARAMS stroke =
m_table->GetBorderStroke();
405 m_table->SetBorderStroke( stroke );
411 STROKE_PARAMS stroke =
m_table->GetSeparatorsStroke();
426 m_table->SetSeparatorsStroke( stroke );
440 wxSize availableGridSize =
m_grid->GetClientSize();
442 if( availableGridSize.x == 0 || availableGridSize.y == 0 )
446 double scalerX =
static_cast<double>( availableGridSize.x ) / tableBBox.
GetWidth();
447 double scalerY =
static_cast<double>( availableGridSize.y ) / tableBBox.
GetHeight();
449 for(
int row = 0; row <
m_table->GetRowCount(); ++row )
450 m_grid->SetRowSize( row, std::floor(
m_table->GetRowHeight( row ) * scalerY ) );
452 for(
int col = 0; col <
m_table->GetColCount(); ++col )
453 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
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)
const std::map< LINE_STYLE, struct LINE_STYLE_DESC > lineTypeNames
Conversion map between LINE_STYLE values and style names displayed.