#include <wx/radiobut.h>
A radio button item is a button which usually denotes one of several mutually exclusive options.
It has a text label next to a (usually) round button.
Radio buttons are typically used in groups of mutually-exclusive buttons, i.e. exactly one of the buttons in the group is checked, and the other ones are unchecked automatically. Such groups are created implicitly, but can also be started explicitly by using wxRB_GROUP style: a button with this style starts a new group and will become the initial selection in this group. Alternatively, a radio button may be excluded from the group that it would otherwise belong to by using wxRB_SINGLE style.
To find the other elements of the same radio button group, you can use GetFirstInGroup(), GetPreviousInGroup(), GetNextInGroup() and GetLastInGroup() functions.
This class supports the following styles:
The following event handler macros redirect the events to member function handlers 'func' with prototypes like:
Event macros for events emitted by this class:
wxEVT_RADIOBUTTON event, when the radiobutton is clicked.
wxMSW Appearance |
wxGTK Appearance |
wxOSX Appearance |
Public Member Functions | |
| wxRadioButton () | |
| Default constructor. | |
| wxRadioButton (wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxRadioButtonNameStr) | |
| Constructor, creating and showing a radio button. | |
| virtual | ~wxRadioButton () |
| Destructor, destroying the radio button item. | |
| bool | Create (wxWindow *parent, wxWindowID id, const wxString &label, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxRadioButtonNameStr) |
| Creates the choice for two-step construction. | |
| virtual bool | GetValue () const |
| Returns true if the radio button is checked, false otherwise. | |
| virtual void | SetValue (bool value) |
| Sets the radio button to checked or unchecked status. | |
| wxRadioButton * | GetFirstInGroup () const |
| Returns the first button of the radio button group this button belongs to. | |
| wxRadioButton * | GetLastInGroup () const |
| Returns the last button of the radio button group this button belongs to. | |
| wxRadioButton * | GetPreviousInGroup () const |
| Returns the previous radio button in the same group. | |
| wxRadioButton * | GetNextInGroup () const |
| Returns the next radio button in the same group. | |
| Public Member Functions inherited from wxControl | |
| wxControl (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxControlNameStr) | |
| Constructs a control. | |
| wxControl () | |
| Default constructor to allow 2-phase creation. | |
| bool | Create (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxControlNameStr) |
| virtual void | Command (wxCommandEvent &event) |
| Simulates the effect of the user issuing a command to the item. | |
| wxString | GetLabel () const |
| Returns the control's label, as it was passed to SetLabel(). | |
| wxString | GetLabelText () const |
| Returns the control's label without mnemonics. | |
| wxSize | GetSizeFromTextSize (int xlen, int ylen=-1) const |
| Determine the size needed by the control to leave the given area for its text. | |
| wxSize | GetSizeFromTextSize (const wxSize &tsize) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| wxSize | GetSizeFromText (const wxString &text) const |
| Determine the minimum size needed by the control to display the given text. | |
| void | SetLabel (const wxString &label) |
| Sets the control's label. | |
| void | SetLabelText (const wxString &text) |
| Sets the control's label to exactly the given string. | |
| bool | SetLabelMarkup (const wxString &markup) |
| Sets the controls label to a string using markup. | |
| Public Member Functions inherited from wxWindow | |
| wxWindow () | |
| Default constructor. | |
| wxWindow (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxPanelNameStr) | |
| Constructs a window, which can be a child of a frame, dialog or any other non-control window. | |
| virtual | ~wxWindow () |
| Destructor. | |
| bool | Create (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxPanelNameStr) |
| Construct the actual window object after creating the C++ object. | |
| virtual bool | AcceptsFocus () const |
| This method may be overridden in the derived classes to return false to indicate that this control doesn't accept input at all (i.e. behaves like e.g. wxStaticText) and so doesn't need focus. | |
| virtual bool | AcceptsFocusFromKeyboard () const |
| This method may be overridden in the derived classes to return false to indicate that while this control can, in principle, have focus if the user clicks it with the mouse, it shouldn't be included in the TAB traversal chain when using the keyboard. | |
| virtual bool | AcceptsFocusRecursively () const |
| Overridden to indicate whether this window or one of its children accepts focus. | |
| void | DisableFocusFromKeyboard () |
| Disable giving focus to this window using the keyboard navigation keys. | |
| void | EnableFocusFromKeyboard () |
| Allow giving focus to this window using the keyboard navigation keys. | |
| bool | IsFocusable () const |
| Can this window itself have focus? | |
| bool | CanAcceptFocus () const |
| Can this window have focus right now? | |
| bool | CanAcceptFocusFromKeyboard () const |
| Can this window be assigned focus from keyboard right now? | |
| virtual bool | HasFocus () const |
| Returns true if the window (or in case of composite controls, its main child window) has focus. | |
| virtual void | SetCanFocus (bool canFocus) |
| This method is only implemented by ports which have support for native TAB traversal (such as GTK+ 2.0). | |
| virtual void | EnableVisibleFocus (bool enable) |
| Enables or disables visible indication of keyboard focus. | |
| virtual void | SetFocus () |
| This sets the window to receive keyboard input. | |
| virtual void | SetFocusFromKbd () |
This function is called by wxWidgets keyboard navigation code when the user gives the focus to this window from keyboard (e.g. using TAB key). | |
| void | EnableInputMethod (bool enable=true) |
| Enable or disable input method for this window. | |
| bool | IsInputMethodEnabled () const |
| Return true if input method is enabled for this window. | |
| void | UpdateInputMethodCursorRect (const wxRect &rect) |
| Set the area where the text is being entered. | |
| wxRect | GetInputMethodCursorRect () const |
| Return the area where the text is being entered. | |
| virtual void | AddChild (wxWindow *child) |
| Adds a child window. | |
| template<typename T> | |
| void | CallForEachChild (const T &functor) |
| Invoke the given functor for all children of the given window recursively. | |
| bool | DestroyChildren () |
| Destroys all children of a window. | |
| wxWindow * | FindWindow (long id) const |
| Find a child of this window, by id. | |
| wxWindow * | FindWindow (const wxString &name) const |
| Find a child of this window, by name. | |
| wxWindowList & | GetChildren () |
| Returns a reference to the list of the window's children. | |
| const wxWindowList & | GetChildren () const |
| Returns a const reference to the list of the window's children. | |
| virtual void | RemoveChild (wxWindow *child) |
| Removes a child window. | |
| wxWindow * | GetGrandParent () const |
| Returns the grandparent of a window, or nullptr if there isn't one. | |
| wxWindow * | GetNextSibling () const |
| Returns the next window after this one among the parent's children or nullptr if this window is the last child. | |
| wxWindow * | GetParent () const |
| Returns the parent of the window, or nullptr if there is no parent. | |
| wxWindow * | GetPrevSibling () const |
Returns the previous window before this one among the parent's children or nullptr if this window is the first child. | |
| bool | IsDescendant (wxWindow *win) const |
| Check if the specified window is a descendant of this one. | |
| virtual bool | Reparent (wxWindow *newParent) |
| Reparents the window, i.e. the window will be removed from its current parent window (e.g. | |
| virtual void | AlwaysShowScrollbars (bool hflag=true, bool vflag=true) |
| Call this function to force one or both scrollbars to be always shown, even if the window is big enough to show its entire contents without scrolling. | |
| virtual int | GetScrollPos (int orientation) const |
| Returns the built-in scrollbar position. | |
| virtual int | GetScrollRange (int orientation) const |
| Returns the built-in scrollbar range. | |
| virtual int | GetScrollThumb (int orientation) const |
| Returns the built-in scrollbar thumb size. | |
| void | GetViewStartPixels (int *x, int *y) const |
| Get the position at which the visible portion of the window starts. | |
| wxPoint | GetViewStartPixels () const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| bool | CanScroll (int orient) const |
| Returns true if this window can have a scroll bar in this orientation. | |
| bool | HasScrollbar (int orient) const |
| Returns true if this window currently has a scroll bar for this orientation. | |
| virtual int | GetScrollbarSize (int orient) const |
| Returns the space taken by the scrollbar of the given orientation when it is shown in this window. | |
| virtual bool | IsScrollbarAlwaysShown (int orient) const |
| Return whether a scrollbar is always shown. | |
| virtual bool | ScrollLines (int lines) |
| Scrolls the window by the given number of lines down (if lines is positive) or up. | |
| virtual bool | ScrollPages (int pages) |
| Scrolls the window by the given number of pages down (if pages is positive) or up. | |
| virtual void | ScrollWindow (int dx, int dy, const wxRect *rect=nullptr) |
| Physically scrolls the pixels in the window and move child windows accordingly. | |
| bool | LineUp () |
| Same as ScrollLines (-1). | |
| bool | LineDown () |
| Same as ScrollLines (1). | |
| bool | PageUp () |
| Same as ScrollPages (-1). | |
| bool | PageDown () |
| Same as ScrollPages (1). | |
| virtual void | SetScrollPos (int orientation, int pos, bool refresh=true) |
| Sets the position of one of the built-in scrollbars. | |
| virtual void | SetScrollbar (int orientation, int position, int thumbSize, int range, bool refresh=true) |
| Sets the scrollbar properties of a built-in scrollbar. | |
| void | Center (int dir=wxBOTH) |
| A synonym for Centre(). | |
| void | CenterOnParent (int dir=wxBOTH) |
| A synonym for CentreOnParent(). | |
| void | Centre (int direction=wxBOTH) |
| Centres the window. | |
| void | CentreOnParent (int direction=wxBOTH) |
| Centres the window on its parent. | |
| void | GetPosition (int *x, int *y) const |
| This gets the position of the window in pixels, relative to the parent window for the child windows or relative to the display origin for the top level windows. | |
| wxPoint | GetPosition () const |
| This gets the position of the window in pixels, relative to the parent window for the child windows or relative to the display origin for the top level windows. | |
| wxRect | GetRect () const |
| Returns the position and size of the window as a wxRect object. | |
| void | GetScreenPosition (int *x, int *y) const |
| Returns the window position in screen coordinates, whether the window is a child window or a top level one. | |
| wxPoint | GetScreenPosition () const |
| Returns the window position in screen coordinates, whether the window is a child window or a top level one. | |
| wxRect | GetScreenRect () const |
| Returns the position and size of the window on the screen as a wxRect object. | |
| virtual wxPoint | GetClientAreaOrigin () const |
| Get the origin of the client area of the window relative to the window top left corner (the client area may be shifted because of the borders, scrollbars, other decorations...). | |
| wxRect | GetClientRect () const |
| Get the client rectangle in window (i.e. client) coordinates. | |
| void | Move (int x, int y, int flags=wxSIZE_USE_EXISTING) |
| Moves the window to the given position. | |
| void | Move (const wxPoint &pt, int flags=wxSIZE_USE_EXISTING) |
| Moves the window to the given position. | |
| void | SetPosition (const wxPoint &pt) |
| Moves the window to the specified position. | |
| void | ClientToScreen (int *x, int *y) const |
| Converts to screen coordinates from coordinates relative to this window. | |
| wxPoint | ClientToScreen (const wxPoint &pt) const |
| Converts to screen coordinates from coordinates relative to this window. | |
| wxPoint | ConvertDialogToPixels (const wxPoint &pt) const |
| Converts a point or size from dialog units to pixels. | |
| wxSize | ConvertDialogToPixels (const wxSize &sz) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| wxPoint | ConvertPixelsToDialog (const wxPoint &pt) const |
| Converts a point or size from pixels to dialog units. | |
| wxSize | ConvertPixelsToDialog (const wxSize &sz) const |
| This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
| void | ScreenToClient (int *x, int *y) const |
| Converts from screen to client window coordinates. | |
| wxPoint | ScreenToClient (const wxPoint &pt) const |
| Converts from screen to client window coordinates. | |
| virtual void | ClearBackground () |
| Clears the window by filling it with the current background colour. | |
| void | Freeze () |
| Freezes the window or, in other words, prevents any updates from taking place on screen, the window is not redrawn at all. | |
| void | Thaw () |
| Re-enables window updating after a previous call to Freeze(). | |
| bool | IsFrozen () const |
| Returns true if the window is currently frozen by a call to Freeze(). | |
| wxColour | GetBackgroundColour () const |
| Returns the background colour of the window. | |
| virtual wxBackgroundStyle | GetBackgroundStyle () const |
| Returns the background style of the window. | |
| virtual int | GetCharHeight () const |
| Returns the character height for this window. | |
| virtual int | GetCharWidth () const |
| Returns the average character width for this window. | |
| virtual wxVisualAttributes | GetDefaultAttributes () const |
| Currently this is the same as calling wxWindow::GetClassDefaultAttributes(wxWindow::GetWindowVariant()). | |
| virtual wxSize | GetDPI () const |
| Return the DPI of the display used by this window. | |
| wxFont | GetFont () const |
| Returns the font for this window. | |
| wxColour | GetForegroundColour () const |
| Returns the foreground colour of the window. | |
| void | GetTextExtent (const wxString &string, int *w, int *h, int *descent=nullptr, int *externalLeading=nullptr, const wxFont *font=nullptr) const |
| Gets the dimensions of the string as it would be drawn on the window with the currently selected font. | |
| wxSize | GetTextExtent (const wxString &string) const |
| Gets the dimensions of the string as it would be drawn on the window with the currently selected font. | |
| const wxRegion & | GetUpdateRegion () const |
| Returns the region specifying which parts of the window have been damaged. | |
| wxRect | GetUpdateClientRect () const |
| Get the update rectangle bounding box in client coords. | |
| virtual bool | HasTransparentBackground () |
| Returns true if this window background is transparent (as, for example, for wxStaticText) and should show the parent window background. | |
| virtual void | Refresh (bool eraseBackground=true, const wxRect *rect=nullptr) |
| Causes this window, and all of its children recursively, to be repainted. | |
| void | RefreshRect (const wxRect &rect, bool eraseBackground=true) |
| Redraws the contents of the given rectangle: only the area inside it will be repainted. | |
| virtual void | Update () |
| Immediately repaints the invalidated area of the window and all of its children recursively. | |
| virtual bool | SetBackgroundColour (const wxColour &colour) |
| Sets the background colour of the window. | |
| virtual bool | SetBackgroundStyle (wxBackgroundStyle style) |
| Sets the background style of the window. | |
| virtual bool | IsTransparentBackgroundSupported (wxString *reason=nullptr) const |
| Checks whether using transparent background might work. | |
| virtual bool | SetFont (const wxFont &font) |
| Sets the font for this window. | |
| virtual bool | SetForegroundColour (const wxColour &colour) |
| Sets the foreground colour of the window. | |
| void | SetOwnBackgroundColour (const wxColour &colour) |
| Sets the background colour of the window but prevents it from being inherited by the children of this window. | |
| bool | InheritsBackgroundColour () const |
| Return true if this window inherits the background colour from its parent. | |
| bool | UseBgCol () const |
| Return true if a background colour has been set for this window. | |
| bool | UseBackgroundColour () const |
| Return true if a background colour has been set for this window. | |
| void | SetOwnFont (const wxFont &font) |
| Sets the font of the window but prevents it from being inherited by the children of this window. | |
| void | SetOwnForegroundColour (const wxColour &colour) |
| Sets the foreground colour of the window but prevents it from being inherited by the children of this window. | |
| bool | UseForegroundColour () const |
| Return true if a foreground colour has been set for this window. | |
| bool | InheritsForegroundColour () const |
| Return true if this window inherits the foreground colour from its parent. | |
| void | SetPalette (const wxPalette &pal) |
| virtual bool | ShouldInheritColours () const |
| Return true from here to allow the colours of this window to be changed by InheritAttributes(). | |
| virtual void | SetThemeEnabled (bool enable) |
| This function tells a window if it should use the system's "theme" code to draw the windows' background instead of its own background drawing code. | |
| virtual bool | GetThemeEnabled () const |
| Returns true if the window uses the system theme for drawing its background. | |
| virtual bool | CanSetTransparent () |
| Returns true if the system supports transparent windows and calling SetTransparent() may succeed. | |
| virtual bool | SetTransparent (wxByte alpha) |
| Set the transparency of the window. | |
| wxEvtHandler * | GetEventHandler () const |
| Returns the event handler for this window. | |
| bool | HandleAsNavigationKey (const wxKeyEvent &event) |
| This function will generate the appropriate call to | |