Version: 3.1.5
wxPersistentComboBox Class Reference

#include <wx/persist/combobox.h>

+ Inheritance diagram for wxPersistentComboBox:

Detailed Description

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:

// Suppose you need to ask the user to select their favourite Linux
// distribution, for some reason:
wxComboBox* combo = new wxComboBox(this, wxID_ANY);
if ( !wxPersistentRegisterAndRestore(combo, "distribution") )
// Seed it with some default contents.
// Optionally, you might want to restore the last used entry:

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...
- Public Member Functions inherited from wxPersistentWindow< wxComboBox >
 wxPersistentWindow (WindowType *win)
 Constructor for a persistent window object. More...
WindowTypeGet () const
virtual wxString GetName () const
 Implements the base class pure virtual method using wxWindow::GetName(). More...
- Public Member Functions inherited from wxPersistentObject
 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

- Public Types inherited from wxPersistentWindow< wxComboBox >
typedef wxComboBox WindowType
 The type of the associated window. More...
- Protected Member Functions inherited from wxPersistentObject
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...

Constructor & Destructor Documentation

wxPersistentComboBox::wxPersistentComboBox ( wxComboBox combobox)


comboboxThe associated combobox.

Member Function Documentation

virtual bool wxPersistentComboBox::Restore ( )

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 void wxPersistentComboBox::Save ( ) const

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.