#include <wx/persist/combobox.h>
Persistence adapter for wxComboBox.
This adapter saves and restores the items of wxComboBox. A persistent combobox can be used to preserve history of user entries.
Example of using it:
Public Member Functions | |
wxPersistentComboBox (wxComboBox *combobox) | |
Constructor. More... | |
virtual void | Save () const |
Save the current items and value. More... | |
virtual bool | Restore () |
Restore the combobox items. More... | |
![]() | |
wxPersistentWindow (WindowType *win) | |
Constructor for a persistent window object. More... | |
WindowType * | Get () const |
virtual wxString | GetName () const |
Implements the base class pure virtual method using wxWindow::GetName(). More... | |
![]() | |
wxPersistentObject (void *obj) | |
Constructor takes the object which we're associated with. More... | |
virtual | ~wxPersistentObject () |
Trivial but virtual destructor. More... | |
void * | GetObject () const |
Return the associated object. More... | |
virtual wxString | GetKind () const =0 |
Returns the string uniquely identifying the objects supported by this adapter. More... | |
Additional Inherited Members | |
![]() | |
typedef wxComboBox | WindowType |
The type of the associated window. More... | |
![]() | |
template<typename T > | |
bool | SaveValue (const wxString &name, T value) const |
Save the specified value using the given name. More... | |
template<typename T > | |
bool | RestoreValue (const wxString &name, T *value) |
Restore a value saved by SaveValue(). More... | |
|
explicit |
Constructor.
combobox | The associated combobox. |
|
virtual |
Restore the combobox items.
This function doesn't change the current combobox value, you need to call SetSelection(0)
explicitly, after verifying that the combobox is not empty using its IsListEmpty() method, if you want to restore the last used value automatically. Otherwise the user can always do it by opening the combobox and selecting it manually.
Implements wxPersistentObject.
|
virtual |
Save the current items and value.
The current control value is saved as the first item, so that calling SetSelection(0)
when the control is created the next time will restore the value which was last used. If the current value is the same as one of the existing items, this item is moved to the front of the list, instead of being added again.
If the current value is empty, it is not saved at all.
At most 10 items are saved, if the combobox has more than 10 items, or exactly 10 items and the current value is different from all of them, the items beyond the tenth one are discarded.
Implements wxPersistentObject.