29#include <wx/tooltip.h>
42 wxToolTip::Enable(
true );
57 m_fieldsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
77 for(
const auto& field : source )
79 m_fields[field.first] = field.second;
110 m_fieldsGrid->SetCellAlignment( row, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
111 m_fieldsGrid->SetCellAlignment( row, 1, wxALIGN_LEFT, wxALIGN_CENTRE );
124 wxArrayInt selectedRows =
m_fieldsGrid->GetSelectedRows();
126 if( selectedRows.empty() &&
m_fieldsGrid->GetGridCursorRow() >= 0 )
127 selectedRows.push_back(
m_fieldsGrid->GetGridCursorRow() );
129 if( selectedRows.empty() )
133 selectedRows.Sort( [](
int* first,
int* second ) {
return *second - *first; } );
135 for(
int row : selectedRows )
200 for(
const auto& [fieldName, fieldValue] :
m_fields )
206 m_fieldsGrid->SetCellAlignment( row, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
207 m_fieldsGrid->SetCellAlignment( row, 1, wxALIGN_LEFT, wxALIGN_CENTRE );
223 nlohmann::ordered_map<wxString, wxString> newFields;
225 for(
int row = 0; row <
m_fieldsGrid->GetNumberRows(); row++ )
227 wxString fieldName =
m_fieldsGrid->GetCellValue( row, 0 ).Strip();
228 fieldName.Replace( wxT(
"\n" ), wxT(
"" ),
true );
229 fieldName.Replace( wxT(
" " ), wxT(
" " ),
true );
231 if( newFields.count( fieldName ) )
233 wxMessageBox(
_(
"Duplicate fields are not allowed." ) );
237 newFields[fieldName] =
m_fieldsGrid->GetCellValue( row, 1 );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
void SetLibDescription(const wxString &aDesc)
void SetKeywords(const wxString &aKeywords)
const wxString & GetKeywords() const
const wxString & GetLibDescription() const
void SetLibId(const LIB_ID &aName)
void SetFields(nlohmann::ordered_map< wxString, wxString > &aFields)
const LIB_ID & GetLibId() const
const nlohmann::ordered_map< wxString, wxString > & GetFields() const
Class DIALOG_DESIGN_BLOCK_PROPERTIES_BASE.
wxTextCtrl * m_textKeywords
wxBitmapButton * m_bpDelete
wxTextCtrl * m_textDescription
wxBitmapButton * m_bpMoveUp
wxBitmapButton * m_bpMoveDown
void OnDeleteField(wxCommandEvent &aEvent) override
DESIGN_BLOCK * m_designBlock
void OnSizeGrid(wxSizeEvent &event) override
DIALOG_DESIGN_BLOCK_PROPERTIES(SCH_EDIT_FRAME *aParent, DESIGN_BLOCK *aDesignBlock)
void OnMoveFieldUp(wxCommandEvent &aEvent) override
bool TransferDataToWindow() override
void OnMoveFieldDown(wxCommandEvent &aEvent) override
void OnAddField(wxCommandEvent &aEvent) override
bool TransferDataFromGrid()
~DIALOG_DESIGN_BLOCK_PROPERTIES() override
bool TransferDataToGrid()
void AdjustGridColumns(int aWidth)
bool TransferDataFromWindow() override
nlohmann::ordered_map< wxString, wxString > m_fields
void SetupStandardButtons(std::map< int, wxString > aLabels={})
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
A logical library item identifier and consists of various portions much like a URI.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
Schematic editor (Eeschema) main window.
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.