40 if( aProjectTemplateMgr )
42 m_title->SetLabel(
_(
"Project Field Name Templates" ) );
48 m_title->SetLabel(
_(
"Global Field Name Templates" ) );
54 if( !cfg->m_Drawing.field_names.IsEmpty() )
55 m_templateMgr->AddTemplateFieldNames( cfg->m_Drawing.field_names );
64 m_grid->SetUseNativeColLabels();
70 m_grid->SetupColumnAutosizer( 0 );
71 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
78 m_grid->PopEventHandler(
true );
93 [&]() -> std::pair<int, int>
95 int row =
m_grid->GetNumberRows();
114 m_grid->DeleteRows( row );
124 m_grid->SwapRows( row, row - 1 );
134 m_grid->SwapRows( row, row + 1 );
146 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
151 m_grid->SetCellValue( row, 1,
m_fields[row].m_Visible ? wxS(
"1" ) : wxS(
"0" ) );
152 m_grid->SetCellValue( row, 2,
m_fields[row].m_URL ? wxS(
"1" ) : wxS(
"0" ) );
155 m_grid->SetCellAlignment( row, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
158 m_grid->SetCellRenderer( row, 1,
new wxGridCellBoolRenderer() );
159 m_grid->SetReadOnly( row, 1 );
160 m_grid->SetCellAlignment( row, 1, wxALIGN_CENTRE, wxALIGN_CENTRE );
162 m_grid->SetCellRenderer( row, 2,
new wxGridCellBoolRenderer() );
163 m_grid->SetReadOnly( row, 2 );
164 m_grid->SetCellAlignment( row, 2, wxALIGN_CENTRE, wxALIGN_CENTRE );
175 if( !
m_grid->CommitPendingChanges() )
178 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
181 m_fields[row].m_Visible =
m_grid->GetCellValue( row, 1 ) == wxS(
"1" );
182 m_fields[row].m_URL =
m_grid->GetCellValue( row, 2 ) == wxS(
"1" );
198 if( !field.m_Name.IsEmpty() )
200 wxString trimmedName = field.m_Name;
203 trimmedName.Trim(
false );
206 if( field.m_Name != trimmedName )
210 msg.Printf(
_(
"The field name '%s' contains trailing and/or leading white space." ),
215 dlg.SetExtendedMessage(
_(
"This may result in what appears to be duplicate field "
216 "names but are actually unique names differing only by "
217 "white space characters. Removing the white space "
218 "characters will have no effect on existing symbol "
221 dlg.SetOKCancelLabels( KICAD_MESSAGE_DIALOG::ButtonLabel(
_(
"Remove White Space" ) ),
222 KICAD_MESSAGE_DIALOG::ButtonLabel(
_(
"Keep White Space" ) ) );
224 if( dlg.ShowModal() == wxID_OK )
225 field.m_Name = trimmedName;
241 record.Replace( wxT(
" " ), wxT(
" " ),
true );
243 cfg->m_Drawing.field_names = record.ToStdString();
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
STD_BITMAP_BUTTON * m_bpMoveUp
STD_BITMAP_BUTTON * m_addFieldButton
STD_BITMAP_BUTTON * m_bpMoveDown
STD_BITMAP_BUTTON * m_deleteFieldButton
PANEL_TEMPLATE_FIELDNAMES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
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 ImportSettingsFrom(TEMPLATES *templateMgr)
PANEL_TEMPLATE_FIELDNAMES(wxWindow *aWindow, TEMPLATES *aProjectTemplateMgr)
TEMPLATES m_templateMgrInstance
bool TransferDataFromWindow() override
void OnDeleteButtonClick(wxCommandEvent &event) override
Deletes the selected template fieldname from the template fieldnames data.
bool TransferDataToGrid()
bool TransferDataFromGrid()
const std::vector< TEMPLATE_FIELDNAME > & GetTemplateFieldNames()
Return a template field name list for read only access.
This file is part of the common library.
#define KICAD_MESSAGE_DIALOG
T * GetAppSettings(const char *aFilename)
wxString From_UTF8(const char *cstring)
Hold a name of a symbol's field, field value, and default visibility.