| Version: 3.3.1

Public Member Functions | List of all members
wxPersistentRadioButton Class Reference

`#include <wx/persist/radiobut.h>`

Inheritance diagram for wxPersistentRadioButton:
[legend]

## Detailed Description

Persistence adapter for wxRadioButton controls.

This adapter saves and restores the index of the selected wxRadioButton in a group of radio buttons, to allow to retain the selection across program executions.

Example of using it:

// Assume that all these controls are added to some sizer elsewhere.
auto* label = new wxStaticText(this, wxID_ANY, "Play with:");
auto* black = new wxRadioButton(this, wxID_ANY, "&Black",
wxDefaultPosition,
wxDefaultSize,
wxRB_GROUP);
auto* white = new wxRadioButton(this, wxID_ANY, "&White");
// We register the first radio button here, but all radio buttons in the
// same group are potentially affected by this call.
wxPersistentRegisterAndRestore(black);
wxRadioButton
A radio button item is a button which usually denotes one of several mutually exclusive options.
Definition: radiobut.h:55
wxStaticText
A static text control displays one or more lines of read-only text.
Definition: stattext.h:54
wxRB_GROUP
#define wxRB_GROUP
Definition: defs.h:391
wxID_ANY
@ wxID_ANY
Any id: means that we don't care about the id, whether when installing an event handler or when creat...
Definition: defs.h:591
wxDefaultSize
const wxSize wxDefaultSize
Global instance of a wxSize object initialized to (-1,-1).
Definition: gdicmn.h:1223
wxDefaultPosition
const wxPoint wxDefaultPosition
Global instance of a wxPoint initialized with values (-1,-1).
Definition: gdicmn.h:814
wxPersistentRegisterAndRestore
bool wxPersistentRegisterAndRestore(T *obj, const wxString &name=wxString())
A shorter synonym for wxPersistenceManager::RegisterAndRestore().

During the first program execution, black colour will be selected, but if the user selects white pieces, this selection will be restored during the subsequent run.

Since
  3.3.1

## Public Member Functions
| wxPersistentRadioButton (wxRadioButton *radiobutton)
| Constructor. More...
virtual void | Save () const
| Save the currently selected button index. More...
virtual bool | Restore ()
| Restore the previously saved selection. More...
Public Member Functions inherited from wxPersistentWindow< wxRadioButton >
| 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...
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< wxRadioButton >
typedef wxRadioButton | 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

## ◆ wxPersistentRadioButton()

wxPersistentRadioButton::wxPersistentRadioButton | ( | wxRadioButton * | radiobutton | ) |
| explicit

Constructor.

Please note that the radio button must be the first one in the group, i.e. have wxRB_GROUP style set, otherwise an assertion will be triggered.

Also note that currently wxRB_SINGLE style is not supported.

Parameters

  radiobutton | The associated radiobutton.

## Member Function Documentation

## ◆ Restore()

virtual bool wxPersistentRadioButton::Restore | ( |  | ) |
| virtual

Restore the previously saved selection.

If the saved index is valid, i.e. is positive and less than the number of radio buttons in the group, the radio button with the corresponding index will be selected.

Implements wxPersistentObject.

## ◆ Save()

virtual void wxPersistentRadioButton::Save | ( |  | ) | const
| virtual

Save the currently selected button index.

The 0-based index of the selected radio button in the group is saved as radio button value.

Implements wxPersistentObject.