40 if( aProjectTemplateMgr )
42 m_title->SetLabel(
_(
"Project Field Name Templates" ) );
43 m_scope = TEMPLATES::SCOPE::PROJECT;
48 m_title->SetLabel(
_(
"Global Field Name Templates" ) );
49 m_scope = TEMPLATES::SCOPE::GLOBAL;
58 m_grid->SetUseNativeColLabels();
64 m_grid->SetupColumnAutosizer( 0 );
65 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
72 m_grid->PopEventHandler(
true );
87 [&]() -> std::pair<int, int>
89 int row =
m_grid->GetNumberRows();
92 const wxString untitledName =
_(
"Untitled Field" );
93 wxString
name = untitledName;
99 return aField.m_Name == name;
102 name = wxString::Format( wxS(
"%s %d" ), untitledName, suffix++ );
121 m_grid->DeleteRows( row );
131 m_grid->SwapRows( row, row - 1 );
141 m_grid->SwapRows( row, row + 1 );
153 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
158 m_grid->SetCellValue( row, 1,
m_fields[row].m_Visible ? wxS(
"1" ) : wxS(
"0" ) );
159 m_grid->SetCellValue( row, 2,
m_fields[row].m_URL ? wxS(
"1" ) : wxS(
"0" ) );
162 m_grid->SetCellAlignment( row, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
165 m_grid->SetCellRenderer( row, 1,
new wxGridCellBoolRenderer() );
166 m_grid->SetReadOnly( row, 1 );
167 m_grid->SetCellAlignment( row, 1, wxALIGN_CENTRE, wxALIGN_CENTRE );
169 m_grid->SetCellRenderer( row, 2,
new wxGridCellBoolRenderer() );
170 m_grid->SetReadOnly( row, 2 );
171 m_grid->SetCellAlignment( row, 2, wxALIGN_CENTRE, wxALIGN_CENTRE );
182 if( !
m_grid->CommitPendingChanges() )
185 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
188 m_fields[row].m_Visible =
m_grid->GetCellValue( row, 1 ) == wxS(
"1" );
189 m_fields[row].m_URL =
m_grid->GetCellValue( row, 2 ) == wxS(
"1" );
201 std::set<wxString> names;
203 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
207 if( !field.
m_Name.IsEmpty() )
209 wxString trimmedName = field.
m_Name;
212 trimmedName.Trim(
false );
215 if( field.
m_Name != trimmedName )
219 msg.Printf(
_(
"The field name '%s' contains trailing and/or leading white space." ),
224 dlg.SetExtendedMessage(
_(
"This may result in what appears to be duplicate field "
225 "names but are actually unique names differing only by "
226 "white space characters. Removing the white space "
227 "characters will have no effect on existing symbol "
230 dlg.SetOKCancelLabels( KICAD_MESSAGE_DIALOG::ButtonLabel(
_(
"Remove White Space" ) ),
231 KICAD_MESSAGE_DIALOG::ButtonLabel(
_(
"Keep White Space" ) ) );
233 if( dlg.ShowModal() == wxID_OK )
235 field.
m_Name = trimmedName;
236 m_grid->SetCellValue( row, 0, trimmedName );
245 _(
"Field name template '%s' already exists as a mandatory field." ),
247 m_grid->MakeCellVisible( row, 0 );
248 m_grid->SetGridCursor( row, 0 );
254 if( !names.insert( field.
m_Name ).second )
257 _(
"Field name template '%s' already exists." ), field.
m_Name ) );
258 m_grid->MakeCellVisible( row, 0 );
259 m_grid->SetGridCursor( row, 0 );
270 if( !field.m_Name.IsEmpty() )
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
TEMPLATES m_FieldNameTemplates
Global field name templates shared by all project editors.
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)
bool TransferDataFromWindow() override
void OnDeleteButtonClick(wxCommandEvent &event) override
Deletes the selected template fieldname from the template fieldnames data.
bool TransferDataToGrid()
bool TransferDataFromGrid()
virtual COMMON_SETTINGS * GetCommonSettings() const
const std::vector< TEMPLATE_FIELDNAME > & GetTemplateFieldNames(SCOPE aScope)
Return a specific list (global or project) for read only access.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
#define KICAD_MESSAGE_DIALOG
PGM_BASE & Pgm()
The global program "get" accessor.
Hold a name of a symbol's field, field value, and default visibility.
wxString GetDefaultFieldName(FIELD_T aFieldId, TRANSLATION aTranslation)
Return a default symbol field name for a mandatory field type.
FIELD_T
The set of all field indices assuming an array like sequence that a SCH_COMPONENT or LIB_PART can hol...