62wxArrayString alignChoices()
64 wxArrayString choices;
65 choices.Add(
_(
"Left" ) );
66 choices.Add(
_(
"Center" ) );
67 choices.Add(
_(
"Right" ) );
85 SetTitle( wxString::Format(
_(
"%s Properties" ),
m_table->GetFriendlyName() ) );
96 m_columnGrid->SetColLabelValue( COL_HEADING,
_(
"Heading" ) );
100 m_columnGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
133 const wxArrayString aligns = alignChoices();
135 for(
size_t row = 0; row <
m_rows.size(); ++row )
137 const int r =
static_cast<int>( row );
140 m_columnGrid->SetCellRenderer( r, COL_SHOW,
new wxGridCellBoolRenderer );
141 m_columnGrid->SetCellEditor( r, COL_SHOW,
new wxGridCellBoolEditor );
142 m_columnGrid->SetCellValue( r, COL_SHOW,
m_rows[row].m_Shown ? wxT(
"1" ) : wxEmptyString );
149 m_columnGrid->SetCellEditor( r, COL_ALIGN,
new wxGridCellChoiceEditor( aligns ) );
154 col.
m_Width > 0 ? std::optional<int>( col.
m_Width ) : std::nullopt );
167 const wxArrayString aligns = alignChoices();
169 for(
size_t row = 0; row <
m_rows.size(); ++row )
171 const int r =
static_cast<int>( row );
177 const int align = aligns.Index(
m_columnGrid->GetCellValue( r, COL_ALIGN ) );
179 if( align != wxNOT_FOUND )
195 m_rows.push_back( { col,
true } );
199 const bool present = std::any_of( aColumns.begin(), aColumns.end(),
202 return aCol.m_Id == def.m_Id;
215 std::vector<GENERATED_TABLE_COLUMN> columns;
220 columns.push_back( row.m_Column );
251 if( !wxDialog::TransferDataToWindow() )
274 if(
m_table->GetBorderStroke().GetWidth() >= 0 )
277 if(
m_table->GetSeparatorsStroke().GetWidth() >= 0 )
292 if( !wxDialog::TransferDataFromWindow() )
295 std::vector<GENERATED_TABLE_COLUMN> columns =
shownColumns();
297 if( columns.empty() )
299 DisplayError(
this,
_(
"A table needs at least one column." ) );
303 if( !
m_table->Schema().Validate( columns ) )
305 DisplayError(
this,
_(
"The columns are too wide in total." ) );
334 const auto strokeWidth =
337 return aStroked ? std::max( 0, aWidth.GetIntValue() ) : -1;
342 m_table->SetBorderStroke( border );
346 m_table->SetSeparatorsStroke( separators );
363 if( cols < 1 || width < 1 )
370 for(
int col = 0; col < cols; ++col )
372 if( col !=
COL_NAME && col != COL_HEADING )
376 const int spare = width - fixed;
382 m_columnGrid->SetColSize( COL_HEADING, spare - spare / 2 );
395 const int defaultWidth =
418 const int target = row + aDelta;
420 if( row < 0 || target < 0 || target >=
static_cast<int>(
m_rows.size() ) )
void Push(const wxString &aMessage=wxEmptyString, int aCommitFlags=0) override
Execute the changes.
void Revert() override
Revert the commit by restoring the modified items state.
Information pertinent to a Pcbnew printed circuit board.
COMMIT & Modify(EDA_ITEM *aItem, BASE_SCREEN *aScreen=nullptr, RECURSE_MODE aRecurse=RECURSE_MODE::NO_RECURSE)
Modify a given item in the model.
wxBoxSizer * m_optionsSizer
wxStaticText * m_separatorsWidthLabel
wxTextCtrl * m_separatorsWidthCtrl
wxStaticText * m_borderWidthUnits
PCB_LAYER_BOX_SELECTOR * m_LayerSelectionCtrl
wxCheckBox * m_borderCheckbox
DIALOG_GENERATED_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)
wxStaticText * m_separatorsWidthUnits
wxCheckBox * m_colSeparators
wxStaticText * m_borderWidthLabel
wxCheckBox * m_headerBorder
wxSpinCtrl * m_precisionCtrl
wxTextCtrl * m_borderWidthCtrl
wxCheckBox * m_rowSeparators
void setColumns(const std::vector< GENERATED_TABLE_COLUMN > &aColumns)
Show aColumns checked and in order, then every other schema column unchecked so turning one back on d...
bool harvestColumnGrid()
Read the grid back into m_rows.
void onMoveUp(wxCommandEvent &aEvent) override
void onResetColumns(wxCommandEvent &aEvent) override
PCB_GENERATED_TABLE * m_table
DIALOG_GENERATED_TABLE_PROPERTIES(PCB_BASE_EDIT_FRAME *aFrame, PCB_GENERATED_TABLE *aTable, GENERATED_TABLE_OPTIONS_FACTORY aOptions)
aOptions may be empty. When given, the panel is created on the dialog and put below the column grid
void setFormat(const GENERATED_TABLE_FORMAT &aFormat)
void fillColumnGrid()
Fill the column grid from m_rows.
GENERATED_TABLE_OPTIONS_PANEL * m_options
std::vector< GENERATED_TABLE_COLUMN > shownColumns() const
UNIT_BINDER m_separatorsWidth
void onMoveDown(wxCommandEvent &aEvent) override
void onBorderChecked(wxCommandEvent &aEvent) override
std::optional< GENERATED_TABLE_FORMAT > getFormat()
PCB_BASE_EDIT_FRAME * m_frame
bool TransferDataToWindow() override
bool TransferDataFromWindow() override
std::vector< COLUMN_ROW > m_rows
Every known column, checked ones first in table order.
void onColumnGridSize(wxSizeEvent &aEvent)
void moveColumn(int aDelta)
void fitColumnGrid()
Share the grid's width out across its columns so none of it goes unused.
UNIT_BINDER m_borderWidth
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...
One pass of rebuilding tables.
The columns one generator (the drill chart, a stackup table, ...) can produce, and the units and prec...
const GENERATED_TABLE_COLUMN_DEF * Find(int aId) const
Common, abstract interface for edit frames.
A table whose cell text is derived from the board and rebuilt whenever it goes stale.
Simple container to manage line stroke parameters.
void SetWidth(int aWidth)
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
std::function< GENERATED_TABLE_OPTIONS_PANEL *(wxWindow *aParent)> GENERATED_TABLE_OPTIONS_FACTORY
The options panel must be created with its real parent, since a wxPanel cannot be reparented reliably...
LSET DocumentationLayers()
Layers a drill chart or drill map may live on.
constexpr int GENERATED_TABLE_MAX_COLUMN_WIDTH
A column can be no wider than this.
PCB_LAYER_ID ToLAYER_ID(int aLayer)
#define SKIP_CONNECTIVITY
The column a schema knows how to build, independent of whether any particular table shows it.
A column as a generated table actually carries it: what a row's cell in that column holds and how it ...
GENERATED_TABLE_ALIGN m_Align