28#include <wx/tooltip.h>
29#include <wx/wupdlock.h>
43 wxToolTip::Enable(
true );
55 [
this]( wxCommandEvent& aEvent )
59 m_fieldsGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
80 for(
const auto& field : source )
82 m_fields[field.first] = field.second;
95 if( illegalCh == 0 &&
m_textName->GetValue().Find(
'/' ) != wxNOT_FOUND )
100 wxString msg = wxString::Format(
_(
"Illegal character '%c' in name '%s'." ),
104 wxMessageDialog errdlg(
this, msg,
_(
"Error" ) );
120 [&]() -> std::pair<int, int>
129 m_fieldsGrid->SetCellAlignment( row, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
130 m_fieldsGrid->SetCellAlignment( row, 1, wxALIGN_LEFT, wxALIGN_CENTRE );
176 for(
const auto& [fieldName, fieldValue] :
m_fields )
182 m_fieldsGrid->SetCellAlignment( row, 0, wxALIGN_LEFT, wxALIGN_CENTRE );
183 m_fieldsGrid->SetCellAlignment( row, 1, wxALIGN_LEFT, wxALIGN_CENTRE );
199 for(
int row = 0; row <
m_fieldsGrid->GetNumberRows(); row++ )
201 wxString fieldName =
m_fieldsGrid->GetCellValue( row, 0 ).Strip();
202 fieldName.Replace( wxT(
"\n" ), wxT(
"" ),
true );
203 fieldName.Replace( wxT(
" " ), wxT(
" " ),
true );
207 wxMessageBox(
_(
"Duplicate fields are not allowed." ) );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
void SetLibDescription(const wxString &aDesc)
void SetKeywords(const wxString &aKeywords)
const wxString & GetKeywords() const
const wxString & GetLibDescription() const
void SetLibId(const LIB_ID &aName)
const LIB_ID & GetLibId() const
const nlohmann::ordered_map< wxString, wxString > & GetFields() const
Class DIALOG_DESIGN_BLOCK_PROPERTIES_BASE.
STD_BITMAP_BUTTON * m_bpMoveUp
STD_BITMAP_BUTTON * m_bpMoveDown
STD_BITMAP_BUTTON * m_bpDelete
STD_BITMAP_BUTTON * m_bpAdd
wxTextCtrl * m_textKeywords
wxTextCtrl * m_textDescription
void OnDeleteField(wxCommandEvent &aEvent) override
DESIGN_BLOCK * m_designBlock
void OnSizeGrid(wxSizeEvent &event) override
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
DIALOG_DESIGN_BLOCK_PROPERTIES(wxWindow *aParent, DESIGN_BLOCK *aDesignBlock, bool aDisableName=false)
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.
static unsigned FindIllegalLibraryNameChar(const UTF8 &aLibraryName)
Looks for characters that are illegal in library nicknames.
const UTF8 & GetLibItemName() const
const UTF8 & GetLibNickname() const
Return the logical library name portion of a LIB_ID.
void OnMoveRowUp(const std::function< void(int row)> &aMover)
void SwapRows(int aRowA, int aRowB)
These aren't that tricky, but might as well share code.
void OnDeleteRows(const std::function< void(int row)> &aDeleter)
Handles a row deletion event.
void OnAddRow(const std::function< std::pair< int, int >()> &aAdder)
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.