37 _( "Select an <b>Option Choice</b> in the listbox above, and then click the " \
38 "<b>Append Selected Option</b> button." )
42 const wxString& aNickname,
43 const std::map<std::string, UTF8>& aPluginOptions,
44 const wxString& aFormattedOptions,
47 m_callers_options( aFormattedOptions ),
49 m_choices( aPluginOptions ),
51 m_grid_widths_dirty( true )
53 SetTitle( wxString::Format(
_(
"Options for Library '%s'" ), aNickname ) );
56 m_grid->SetDefaultRowSize(
m_grid->GetDefaultRowSize() + 4 );
58 m_grid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
68 for( std::map<std::string, UTF8>::const_iterator it =
m_choices.begin();
71 wxString item =
From_UTF8( it->first.c_str() );
90DIALOG_PLUGIN_OPTIONS ::~DIALOG_PLUGIN_OPTIONS()
93 m_grid->PopEventHandler(
true );
99 if( !DIALOG_SHIM::TransferDataToWindow() )
109 if( (
int) props->size() >
m_grid->GetNumberRows() )
110 m_grid->AppendRows( props->size() -
m_grid->GetNumberRows() );
114 for( std::map<std::string, UTF8>::const_iterator it = props->begin(); it != props->end();
118 m_grid->SetCellValue( row, 1, it->second );
133 if( !DIALOG_SHIM::TransferDataFromWindow() )
136 std::map<std::string, UTF8> props;
137 const int rowCount =
m_grid->GetNumberRows();
139 for(
int row = 0; row<rowCount; ++row )
141 std::string
name =
TO_UTF8(
m_grid->GetCellValue( row, 0 ).Trim(
false ).Trim() );
142 UTF8 value =
m_grid->GetCellValue( row, 1 ).Trim(
false ).Trim();
157 int row =
m_grid->GetNumberRows();
162 m_grid->MakeCellVisible( row, 0 );
163 m_grid->SetGridCursor( row, 0 );
171 int selected_row =
m_listbox->GetSelection();
172 if( selected_row != wxNOT_FOUND )
174 wxString option =
m_listbox->GetString( selected_row );
176 int row_count =
m_grid->GetNumberRows();
179 for( row=0; row<row_count; ++row )
181 wxString col0 =
m_grid->GetCellValue( row, 0 );
187 if( row == row_count )
190 m_grid->SetCellValue( row, 0, option );
201 if( event.IsSelection() )
203 std::string option =
TO_UTF8( event.GetString() );
242 int curRow =
m_grid->GetGridCursorRow();
244 m_grid->DeleteRows( curRow );
247 curRow = std::max( 0, curRow - 1 );
248 m_grid->MakeCellVisible( curRow,
m_grid->GetGridCursorCol() );
249 m_grid->SetGridCursor( curRow,
m_grid->GetGridCursorCol() );
265 int width =
m_grid->GetClientRect().GetWidth();
267 m_grid->AutoSizeColumn( 0 );
268 m_grid->SetColSize( 0, std::max( 72,
m_grid->GetColSize( 0 ) ) );
270 m_grid->SetColSize( 1, std::max( 120, width -
m_grid->GetColSize( 0 ) ) );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Class DIALOG_PLUGIN_OPTIONS_BASE.
STD_BITMAP_BUTTON * m_delete_button
STD_BITMAP_BUTTON * m_append_button
DIALOG_PLUGIN_OPTIONS(wxWindow *aParent, const wxString &aNickname, const std::map< std::string, UTF8 > &aPluginOptions, const wxString &aFormattedOptions, wxString *aResult)
void onAppendOption(wxCommandEvent &) override
void onListBoxItemSelected(wxCommandEvent &event) override
void onDeleteRow(wxCommandEvent &) override
bool TransferDataToWindow() override
std::map< std::string, UTF8 > m_choices
const wxString & m_callers_options
void onUpdateUI(wxUpdateUIEvent &) override
void onSize(wxSizeEvent &aEvent) override
bool TransferDataFromWindow() override
void onGridCellChange(wxGridEvent &aEvent) override
void onListBoxItemDoubleClicked(wxCommandEvent &event) override
void onAppendRow(wxCommandEvent &) override
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
void SetupStandardButtons(std::map< int, wxString > aLabels={})
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
bool SetPage(const wxString &aSource) override
static std::map< std::string, UTF8 > * ParseOptions(const std::string &aOptionsList)
Parses aOptionsList and places the result into a #PROPERTIES object which is returned.
static UTF8 FormatOptions(const std::map< std::string, UTF8 > *aProperties)
Returns a list of options from the aProperties parameter.
An 8 bit string that is assuredly encoded in UTF8, and supplies special conversion support to and fro...
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
wxString From_UTF8(const char *cstring)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.