37 _( "Select an <b>Option Choice</b> in the listbox above, and then click the <b>Append Selected Option</b> button." )
41 const wxString& aNickname,
42 const std::map<std::string, UTF8>& aPluginOptions,
43 const wxString& aFormattedOptions,
46 m_callers_options( aFormattedOptions ),
48 m_choices( aPluginOptions ),
50 m_grid_widths_dirty( true )
52 SetTitle( wxString::Format(
_(
"Options for Library '%s'" ), aNickname ) );
55 m_grid->SetDefaultRowSize(
m_grid->GetDefaultRowSize() + 4 );
57 m_grid->SetSelectionMode( wxGrid::wxGridSelectionModes::wxGridSelectRows );
67 for( std::map<std::string, UTF8>::const_iterator it =
m_choices.begin(); it !=
m_choices.end();
70 wxString item =
From_UTF8( it->first.c_str() );
89DIALOG_PLUGIN_OPTIONS ::~DIALOG_PLUGIN_OPTIONS()
92 m_grid->PopEventHandler(
true );
98 if( !DIALOG_SHIM::TransferDataToWindow() )
108 if( (
int) props->size() >
m_grid->GetNumberRows() )
109 m_grid->AppendRows( props->size() -
m_grid->GetNumberRows() );
113 for( std::map<std::string, UTF8>::const_iterator it = props->begin(); it != props->end();
117 m_grid->SetCellValue( row, 1, it->second );
132 if( !DIALOG_SHIM::TransferDataFromWindow() )
135 std::map<std::string, UTF8> props;
136 const int rowCount =
m_grid->GetNumberRows();
138 for(
int row = 0; row<rowCount; ++row )
140 std::string
name =
TO_UTF8(
m_grid->GetCellValue( row, 0 ).Trim(
false ).Trim() );
141 UTF8 value =
m_grid->GetCellValue( row, 1 ).Trim(
false ).Trim();
156 int row =
m_grid->GetNumberRows();
161 m_grid->MakeCellVisible( row, 0 );
162 m_grid->SetGridCursor( row, 0 );
170 int selected_row =
m_listbox->GetSelection();
171 if( selected_row != wxNOT_FOUND )
173 wxString option =
m_listbox->GetString( selected_row );
175 int row_count =
m_grid->GetNumberRows();
178 for( row=0; row<row_count; ++row )
180 wxString col0 =
m_grid->GetCellValue( row, 0 );
186 if( row == row_count )
189 m_grid->SetCellValue( row, 0, option );
200 if( event.IsSelection() )
202 std::string option =
TO_UTF8( event.GetString() );
241 int curRow =
m_grid->GetGridCursorRow();
243 m_grid->DeleteRows( curRow );
246 curRow = std::max( 0, curRow - 1 );
247 m_grid->MakeCellVisible( curRow,
m_grid->GetGridCursorCol() );
248 m_grid->SetGridCursor( curRow,
m_grid->GetGridCursorCol() );
264 int width =
m_grid->GetClientRect().GetWidth();
266 m_grid->AutoSizeColumn( 0 );
267 m_grid->SetColSize( 0, std::max( 72,
m_grid->GetColSize( 0 ) ) );
269 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.