Implement method to set items of wxPGChoiceEditor

In addition to the current methods to add/delete one item to the control
we would need a method to replace all existing control items with new ones
at once.
This commit is contained in:
Artur Wieczorek
2020-05-01 17:57:46 +02:00
parent 9d4bb47050
commit 8a9e5e5ac7
2 changed files with 18 additions and 0 deletions

View File

@@ -167,6 +167,10 @@ public:
// Default implementation does nothing.
virtual void DeleteItem( wxWindow* ctrl, int index ) const;
// Sets items of existing control.
// Default implementation does nothing.
virtual void SetItems(wxWindow* ctrl, const wxArrayString& labels) const;
// Extra processing when control gains focus. For example, wxTextCtrl
// based controls should select all text.
virtual void OnFocus( wxPGProperty* property, wxWindow* wnd ) const;
@@ -273,6 +277,8 @@ public:
const wxString& label,
int index ) const wxOVERRIDE;
virtual void DeleteItem( wxWindow* ctrl, int index ) const wxOVERRIDE;
virtual void SetItems(wxWindow* ctrl, const wxArrayString& labels) const wxOVERRIDE;
virtual bool CanContainCustomImage() const wxOVERRIDE;
// CreateControls calls this with CB_READONLY in extraStyle

View File

@@ -164,6 +164,9 @@ void wxPGEditor::DeleteItem( wxWindow*, int ) const
return;
}
void wxPGEditor::SetItems(wxWindow* WXUNUSED(ctrl), const wxArrayString& WXUNUSED(labels)) const
{
}
void wxPGEditor::OnFocus( wxPGProperty*, wxWindow* ) const
{
@@ -1091,6 +1094,15 @@ void wxPGChoiceEditor::DeleteItem( wxWindow* ctrl, int index ) const
cb->Delete(index);
}
void wxPGChoiceEditor::SetItems(wxWindow* ctrl, const wxArrayString& labels) const
{
wxASSERT( ctrl );
wxOwnerDrawnComboBox* cb = wxDynamicCast(ctrl, wxOwnerDrawnComboBox);
wxASSERT( cb );
cb->Set(labels);
}
bool wxPGChoiceEditor::OnEvent( wxPropertyGrid* propGrid, wxPGProperty* property,
wxWindow* ctrl, wxEvent& event ) const
{