43 if( aProjectTemplateMgr )
45 m_title->SetLabel(
_(
"Project Field Name Templates" ) );
51 m_title->SetLabel(
_(
"Global Field Name Templates" ) );
69 m_grid->SetUseNativeColLabels();
75 m_grid->SetSelectionMode( wxGrid::wxGridSelectRows );
82 m_grid->PopEventHandler(
true );
99 int row =
m_grid->GetNumberRows();
108 m_grid->MakeCellVisible( row, 0 );
109 m_grid->SetGridCursor( row, 0 );
111 m_grid->EnableCellEditControl(
true );
112 m_grid->ShowCellEditControl();
121 wxArrayInt selectedRows =
m_grid->GetSelectedRows();
123 if( selectedRows.empty() &&
m_grid->GetGridCursorRow() >= 0 )
124 selectedRows.push_back(
m_grid->GetGridCursorRow() );
126 if( selectedRows.empty() )
131 [](
int* first,
int* second )
133 return *second - *first;
136 for(
int row : selectedRows )
139 m_grid->DeleteRows( row );
141 m_grid->MakeCellVisible( std::max( 0, row-1 ),
m_grid->GetGridCursorCol() );
142 m_grid->SetGridCursor( std::max( 0, row-1 ),
m_grid->GetGridCursorCol() );
149 for(
int col = 0; col < aGrid->GetNumberCols(); ++col )
151 wxString temp = aGrid->GetCellValue( aRowA, col );
152 aGrid->SetCellValue( aRowA, col, aGrid->GetCellValue( aRowB, col ) );
153 aGrid->SetCellValue( aRowB, col, temp );
163 int i =
m_grid->GetGridCursorRow();
169 m_grid->SetGridCursor( i - 1,
m_grid->GetGridCursorCol() );
184 int i =
m_grid->GetGridCursorRow();
186 if( i >= 0 && i + 1 <
m_grid->GetNumberRows() )
190 m_grid->SetGridCursor( i + 1,
m_grid->GetGridCursorCol() );
207 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
212 m_grid->SetCellValue( row, 1,
m_fields[row].m_Visible ? wxS(
"1" ) : wxS(
"0" ) );
213 m_grid->SetCellValue( row, 2,
m_fields[row].m_URL ? wxS(
"1" ) : wxS(
"0" ) );
216 m_grid->SetCellAlignment( row, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
219 m_grid->SetCellRenderer( row, 1,
new wxGridCellBoolRenderer() );
220 m_grid->SetReadOnly( row, 1 );
221 m_grid->SetCellAlignment( row, 1, wxALIGN_CENTRE, wxALIGN_CENTRE );
223 m_grid->SetCellRenderer( row, 2,
new wxGridCellBoolRenderer() );
224 m_grid->SetReadOnly( row, 2 );
225 m_grid->SetCellAlignment( row, 2, wxALIGN_CENTRE, wxALIGN_CENTRE );
239 for(
int row = 0; row <
m_grid->GetNumberRows(); ++row )
242 m_fields[row].m_Visible =
m_grid->GetCellValue( row, 1 ) == wxS(
"1" );
243 m_fields[row].m_URL =
m_grid->GetCellValue( row, 2 ) == wxS(
"1" );
259 if( !field.m_Name.IsEmpty() )
261 wxString trimmedName = field.m_Name;
264 trimmedName.Trim(
false );
267 if( field.m_Name != trimmedName )
271 msg.Printf(
_(
"The field name '%s' contains trailing and/or leading white space." ),
274 wxMessageDialog dlg(
this, msg,
_(
"Warning" ), wxOK|wxCANCEL|wxCENTER|wxICON_WARNING );
276 dlg.SetExtendedMessage(
_(
"This may result in what appears to be duplicate field "
277 "names but are actually unique names differing only by "
278 "white space characters. Removing the white space "
279 "characters will have no effect on existing symbol "
282 dlg.SetOKCancelLabels( wxMessageDialog::ButtonLabel(
_(
"Remove White Space" ) ),
283 wxMessageDialog::ButtonLabel(
_(
"Keep White Space" ) ) );
285 if( dlg.ShowModal() == wxID_OK )
286 field.m_Name = trimmedName;
305 record.Replace( wxT(
" " ), wxT(
" " ),
true );
321 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()
virtual SETTINGS_MANAGER & GetSettingsManager() const
T * GetAppSettings(const char *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.
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 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.
void swapRows(WX_GRID *aGrid, int aRowA, int aRowB)
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.