43 if( aProjectTemplateMgr )
45 m_title->SetLabel(
_(
"Project Field Name Templates" ) );
51 m_title->SetLabel(
_(
"Global Field Name Templates" ) );
57 if( !cfg->m_Drawing.field_names.IsEmpty() )
69 m_grid->SetUseNativeColLabels();
75 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
82 m_grid->PopEventHandler(
true );
97 [&]() -> std::pair<int, int>
99 int row =
m_grid->GetNumberRows();
118 m_grid->DeleteRows( row );
150 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
155 m_grid->SetCellValue( row, 1,
m_fields[row].m_Visible ? wxS(
"1" ) : wxS(
"0" ) );
156 m_grid->SetCellValue( row, 2,
m_fields[row].m_URL ? wxS(
"1" ) : wxS(
"0" ) );
159 m_grid->SetCellAlignment( row, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
162 m_grid->SetCellRenderer( row, 1,
new wxGridCellBoolRenderer() );
163 m_grid->SetReadOnly( row, 1 );
164 m_grid->SetCellAlignment( row, 1, wxALIGN_CENTRE, wxALIGN_CENTRE );
166 m_grid->SetCellRenderer( row, 2,
new wxGridCellBoolRenderer() );
167 m_grid->SetReadOnly( row, 2 );
168 m_grid->SetCellAlignment( row, 2, wxALIGN_CENTRE, wxALIGN_CENTRE );
182 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
185 m_fields[row].m_Visible =
m_grid->GetCellValue( row, 1 ) == wxS(
"1" );
186 m_fields[row].m_URL =
m_grid->GetCellValue( row, 2 ) == wxS(
"1" );
202 if( !field.m_Name.IsEmpty() )
204 wxString trimmedName = field.m_Name;
207 trimmedName.Trim(
false );
210 if( field.m_Name != trimmedName )
214 msg.Printf(
_(
"The field name '%s' contains trailing and/or leading white space." ),
217 wxMessageDialog dlg(
this, msg,
_(
"Warning" ), wxOK|wxCANCEL|wxCENTER|wxICON_WARNING );
219 dlg.SetExtendedMessage(
_(
"This may result in what appears to be duplicate field "
220 "names but are actually unique names differing only by "
221 "white space characters. Removing the white space "
222 "characters will have no effect on existing symbol "
225 dlg.SetOKCancelLabels( wxMessageDialog::ButtonLabel(
_(
"Remove White Space" ) ),
226 wxMessageDialog::ButtonLabel(
_(
"Keep White Space" ) ) );
228 if( dlg.ShowModal() == wxID_OK )
229 field.m_Name = trimmedName;
245 record.Replace( wxT(
" " ), wxT(
" " ),
true );
247 cfg->m_Drawing.field_names = record.ToStdString();
261 aWidth -= (
m_grid->GetSize().x -
m_grid->GetClientSize().x );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Class PANEL_TEMPLATE_FIELDNAMES_BASE.
STD_BITMAP_BUTTON * m_bpMoveUp
STD_BITMAP_BUTTON * m_addFieldButton
STD_BITMAP_BUTTON * m_bpMoveDown
STD_BITMAP_BUTTON * m_deleteFieldButton
void OnAddButtonClick(wxCommandEvent &event) override
Adds a new template fieldname (with default values) to the template fieldnames data.
~PANEL_TEMPLATE_FIELDNAMES() override
std::vector< TEMPLATE_FIELDNAME > m_fields
void OnMoveDown(wxCommandEvent &event) override
bool TransferDataToWindow() override
void OnMoveUp(wxCommandEvent &event) override
TEMPLATES * m_templateMgr
void AdjustGridColumns(int aWidth)
void ImportSettingsFrom(TEMPLATES *templateMgr)
PANEL_TEMPLATE_FIELDNAMES(wxWindow *aWindow, TEMPLATES *aProjectTemplateMgr)
TEMPLATES m_templateMgrInstance
bool TransferDataFromWindow() override
void OnSizeGrid(wxSizeEvent &event) override
void OnDeleteButtonClick(wxCommandEvent &event) override
Deletes the selected template fieldname from the template fieldnames data.
bool TransferDataToGrid()
bool TransferDataFromGrid()
void AddTemplateFieldName(const TEMPLATE_FIELDNAME &aFieldName, bool aGlobal)
Insert or append a wanted symbol field name into the field names template.
void AddTemplateFieldNames(const wxString &aSerializedFieldNames)
Add a serialized list of template field names.
const std::vector< TEMPLATE_FIELDNAME > & GetTemplateFieldNames()
Return a template field name list for read only access.
void DeleteAllFieldNameTemplates(bool aGlobal)
Delete the entire contents.
void Format(OUTPUTFORMATTER *out, bool aGlobal) const
Serialize this object out as text into the given OUTPUTFORMATTER.
void OnMoveRowUp(const std::function< void(int row)> &aMover)
void SwapRows(int aRowA, int aRowB)
These aren't that tricky, but might as well share code.
void OnMoveRowDown(const std::function< void(int row)> &aMover)
void OnDeleteRows(const std::function< void(int row)> &aDeleter)
Handles a row deletion event.
void OnAddRow(const std::function< std::pair< int, int >()> &aAdder)
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
wxString From_UTF8(const char *cstring)
Hold a name of a symbol's field, field value, and default visibility.