43 if( aProjectTemplateMgr )
45 m_title->SetLabel(
_(
"Project field name templates:" ) );
51 m_title->SetLabel(
_(
"Global field name templates:" ) );
66 m_grid->SetUseNativeColLabels();
72 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
79 m_grid->PopEventHandler(
true );
96 int row =
m_grid->GetNumberRows();
105 m_grid->MakeCellVisible( row, 0 );
106 m_grid->SetGridCursor( row, 0 );
115 wxArrayInt selectedRows =
m_grid->GetSelectedRows();
117 if( selectedRows.empty() &&
m_grid->GetGridCursorRow() >= 0 )
118 selectedRows.push_back(
m_grid->GetGridCursorRow() );
120 if( selectedRows.empty() )
124 selectedRows.Sort( [](
int* first,
int* second ) {
return *second - *first; } );
126 for(
int row : selectedRows )
129 m_grid->DeleteRows( row );
131 m_grid->MakeCellVisible( std::max( 0, row-1 ),
m_grid->GetGridCursorCol() );
132 m_grid->SetGridCursor( std::max( 0, row-1 ),
m_grid->GetGridCursorCol() );
144 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
148 m_grid->SetCellValue( row, 1,
m_fields[row].m_Visible ? wxS(
"1" ) : wxS(
"0" ) );
149 m_grid->SetCellValue( row, 2,
m_fields[row].m_URL ? wxS(
"1" ) : wxS(
"0" ) );
152 m_grid->SetCellAlignment( row, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
155 m_grid->SetCellRenderer( row, 1,
new wxGridCellBoolRenderer() );
156 m_grid->SetReadOnly( row, 1 );
157 m_grid->SetCellAlignment( row, 1, wxALIGN_CENTRE, wxALIGN_CENTRE );
159 m_grid->SetCellRenderer( row, 2,
new wxGridCellBoolRenderer() );
160 m_grid->SetReadOnly( row, 2 );
161 m_grid->SetCellAlignment( row, 2, wxALIGN_CENTRE, wxALIGN_CENTRE );
175 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
178 m_fields[row].m_Visible =
m_grid->GetCellValue( row, 1 ) == wxS(
"1" );
179 m_fields[row].m_URL =
m_grid->GetCellValue( row, 2 ) == wxS(
"1" );
195 if( !field.m_Name.IsEmpty() )
197 wxString trimmedName = field.m_Name;
200 trimmedName.Trim(
false );
203 if( field.m_Name != trimmedName )
207 msg.Printf(
_(
"The field name \"%s\" contains trailing and/or leading white"
208 "space." ), field.m_Name );
210 wxMessageDialog dlg(
this, msg,
_(
"Warning" ),
211 wxOK | wxCANCEL | wxCENTER | wxICON_WARNING );
213 dlg.SetExtendedMessage(
_(
"This may result in what appears to be duplicate field "
214 "names but are actually unique names differing only by "
215 "white space characters. Removing the white space "
216 "characters will have no effect on existing symbol "
219 dlg.SetOKCancelLabels( wxMessageDialog::ButtonLabel(
_(
"Remove White Space" ) ),
220 wxMessageDialog::ButtonLabel(
_(
"Keep White Space" ) ) );
222 if( dlg.ShowModal() == wxID_OK )
223 field.m_Name = trimmedName;
241 record.Replace( wxT(
"\n"), wxT(
""),
true );
242 record.Replace( wxT(
" "), wxT(
" "),
true );
258 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()
Returns a handle to the a given settings by type If the settings have already been loaded,...
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, int nestLevel, 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.