43 if( aProjectTemplateMgr )
45 m_title->SetLabel(
_(
"Project Field Name Templates" ) );
51 m_title->SetLabel(
_(
"Global Field Name Templates" ) );
67 m_grid->SetUseNativeColLabels();
73 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
80 m_grid->PopEventHandler(
true );
97 int row =
m_grid->GetNumberRows();
106 m_grid->MakeCellVisible( row, 0 );
107 m_grid->SetGridCursor( row, 0 );
116 wxArrayInt selectedRows =
m_grid->GetSelectedRows();
118 if( selectedRows.empty() &&
m_grid->GetGridCursorRow() >= 0 )
119 selectedRows.push_back(
m_grid->GetGridCursorRow() );
121 if( selectedRows.empty() )
125 selectedRows.Sort( [](
int* first,
int* second ) {
return *second - *first; } );
127 for(
int row : selectedRows )
130 m_grid->DeleteRows( row );
132 m_grid->MakeCellVisible( std::max( 0, row-1 ),
m_grid->GetGridCursorCol() );
133 m_grid->SetGridCursor( std::max( 0, row-1 ),
m_grid->GetGridCursorCol() );
145 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
150 m_grid->SetCellValue( row, 1,
m_fields[row].m_Visible ? wxS(
"1" ) : wxS(
"0" ) );
151 m_grid->SetCellValue( row, 2,
m_fields[row].m_URL ? wxS(
"1" ) : wxS(
"0" ) );
154 m_grid->SetCellAlignment( row, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
157 m_grid->SetCellRenderer( row, 1,
new wxGridCellBoolRenderer() );
158 m_grid->SetReadOnly( row, 1 );
159 m_grid->SetCellAlignment( row, 1, wxALIGN_CENTRE, wxALIGN_CENTRE );
161 m_grid->SetCellRenderer( row, 2,
new wxGridCellBoolRenderer() );
162 m_grid->SetReadOnly( row, 2 );
163 m_grid->SetCellAlignment( row, 2, wxALIGN_CENTRE, wxALIGN_CENTRE );
177 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
180 m_fields[row].m_Visible =
m_grid->GetCellValue( row, 1 ) == wxS(
"1" );
181 m_fields[row].m_URL =
m_grid->GetCellValue( row, 2 ) == wxS(
"1" );
197 if( !field.m_Name.IsEmpty() )
199 wxString trimmedName = field.m_Name;
202 trimmedName.Trim(
false );
205 if( field.m_Name != trimmedName )
209 msg.Printf(
_(
"The field name \"%s\" contains trailing and/or leading white"
210 "space." ), field.m_Name );
212 wxMessageDialog dlg(
this, msg,
_(
"Warning" ),
213 wxOK | wxCANCEL | wxCENTER | wxICON_WARNING );
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( wxMessageDialog::ButtonLabel(
_(
"Remove White Space" ) ),
222 wxMessageDialog::ButtonLabel(
_(
"Keep White Space" ) ) );
224 if( dlg.ShowModal() == wxID_OK )
225 field.m_Name = trimmedName;
244 record.Replace( wxT(
" "), wxT(
" "),
true );
260 aWidth -= (
m_grid->GetSize().x -
m_grid->GetClientSize().x );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
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_addFieldButton
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
bool TransferDataToWindow() override
TEMPLATES * m_templateMgr
TEMPLATE_FIELDNAMES m_fields
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()
virtual SETTINGS_MANAGER & GetSettingsManager() const
T * GetAppSettings(const wxString &aFilename)
Return a handle to the a given settings by type.
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.
void DeleteAllFieldNameTemplates(bool aGlobal)
Delete the entire contents.
const TEMPLATE_FIELDNAMES & GetTemplateFieldNames()
Return a template field name list for read only access.
void Format(OUTPUTFORMATTER *out, bool aGlobal) const
Serialize this object out as text into the given OUTPUTFORMATTER.
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.
PGM_BASE & Pgm()
The global program "get" accessor.
wxString From_UTF8(const char *cstring)
Hold a name of a symbol's field, field value, and default visibility.