IRadioButton

The IRadioButton class creates and manages radio button control windows. A radio button is a circle or a diamond with associated text representing a choice. When a user selects the choice, the radio button is filled to indicate that the choice is selected. The user can clear the radio button by selecting another radio button. Radio buttons are mutually exclusive.

You can process a radio button's selection by deriving a handler from ISelectHandler and adding your handler either to the radio button or to its owner window.

You can attach the following handlers to this control:

AIX Considerations

The IRadioButton constructor creates objects of this class using the XmToggleButton widget. IWindow::handle returns the handle of the XmToggleButton widget.


IRadioButton - Member Functions and Data by Group

Constructors & Destructor

You can construct and destruct objects of the IRadioButton class. You cannot copy or assign IRadioButton objects because both the copy constructor and assignment operator are private functions.


[view class]
~IRadioButton
public:
virtual ~IRadioButton()

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
IRadioButton


Overload 1
public:
IRadioButton(unsigned long id, IWindow* parent)

Creates an object for a radio button control that exists in a dialog window.

id
The identifier of the existing radio button control.
parent
The parent window.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 2
public:
IRadioButton(const IWindowHandle& handle)

Creates an object for an existing radio button control.

handle
The window handle of an existing radio button control.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Overload 3
public:
IRadioButton( unsigned long id, IWindow* parent, IWindow* owner, const IRectangle& initial = IRectangle ( ), const Style& style = defaultStyle ( ) )

Creates a radio button control and an object for it.

id
A radio button control ID.
parent
The parent window.
owner
The owner window.
initial
The initial position and size of the control you are constructing. Optional.
style
The control's characteristics. Optional.

Exception

IInvalidParameter The parent window pointer specified was invalid. You must specify a valid IWindow pointer as the parent.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Auto Select

Auto select members query and modify the autoSelect style of a radio button object. The autoSelect style determines whether the state of the radio button is automatically changed when the user clicks on it.


[view class]
disableAutoSelect
public:
virtual IRadioButton& disableAutoSelect()

Removes the style autoSelect from the radio button control. If auto select is disabled, the application is responsible for changing the state of the radio buttons when the radio button is clicked.

The application determines when the user clicks on the radio button by attaching a handler derived from ISelectHandler to the radio button or its owner and overriding the ISelectHandler::selected member function. The application can then use the selection functions to change the state of the radio button.

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored

AIX Considerations

The autoSelect style is always in effect in the AIX environment. This function has no effect.


[view class]
enableAutoSelect
public:
virtual IRadioButton& enableAutoSelect(bool enable = true)

Adds or removes the style autoSelect.

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored

AIX Considerations

The autoSelect style is always in effect.


[view class]
isAutoSelect
public:
virtual bool isAutoSelect() const

If the radio button control has the style autoSelect set, true is returned. Otherwise, false is returned.

Supported Platforms

Windows OS/2 AIX
Yes Yes Ignored

AIX Considerations

This function always returns true.


Cursor Select

Cursor select members query and modify the noCursorSelect style of a radio button object. If enabled, the noCursorSelect style prevents the radio button from selecting itself when given the focus as a result of an arrow key or tab key.


[view class]
disableCursorSelect
public:
virtual IRadioButton& disableCursorSelect()

Adds the radio button style noCursorSelect.

Supported Platforms

Windows OS/2 AIX
Ignored Yes Ignored

AIX Considerations

The noCursorSelect style is not supported in the AIX environment. This function has no effect in that environment.

Windows Considerations

The noCursorSelect style is not supported in the Windows environment. This function has no effect in that enviroment.


[view class]
enableCursorSelect
public:
virtual IRadioButton& enableCursorSelect( bool enable = true )

Removes or adds the radio button style noCursorSelect. If removed, the radio button is cursor-selectable.

Supported Platforms

Windows OS/2 AIX
Ignored Yes Ignored

AIX Considerations

The noCursorSelect style is not supported in the AIX environment. This function has no effect in that environment.

Windows Considerations

The noCursorSelect style is not supported in the Windows environment. This function has no effect in that enviroment.


[view class]
isCursorSelect
public:
bool isCursorSelect() const

If the radio button is cursor-selectable, true is returned. Otherwise, false is returned.

Supported Platforms

Windows OS/2 AIX
Ignored Yes Ignored

AIX Considerations

This function returns false.

Windows Considerations

Radio buttons are always cursor-selectable in the Windows environment. This function always returns true in that environment.


Layout Support

Layout support members supply information used by the canvas classes to provide dialog-like behavior.


[view class]
calcMinimumSize
protected:
virtual ISize calcMinimumSize() const

Returns the minimum size that this radio button control based on the text string length and the current font.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Selection

Use these members to query the index of the selected radio button. The selection state of a button is typically changed by the user clicking on it using the mouse or pressing a key to select it. You can also change or query the state using Open Class Library functions.


[view class]
selectedIndex
public:
unsigned long selectedIndex() const

Returns the 0-based index of the selected radio button in a group. If no radio button is selected, noSelections is returned.
Note: The index returned includes all windows that are part of the group, not just radio buttons. To ensure that the index only includes radio buttons, be sure that the group does not contain any other windows.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes

OS/2 Considerations

The index of any control in the group can be returned.


[view class]
noSelections
public:
static const unsigned long noSelections

The value returned by selectedIndex when there are no buttons selected in the group.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


Styles

These style members provide a set of valid styles for this class. Use these members to query and set the radio button styles. You can use these styles with the styles in the following classes:


[view class]
convertToGUIStyle
public:
virtual unsigned long convertToGUIStyle( const IBitFlag& style, bool extendedOnly = false ) const

Converts a style object into a value appropriate for the presentation system. The default action is to return the base GUI styles for the platform. Extended styles defined by the application are returned if you set extendedOnly to true.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
defaultStyle
public:
static Style defaultStyle()

Returns the default style. The default style is classDefaultStyle unless you have changed the style using setDefaultStyle.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
setDefaultStyle
public:
static void setDefaultStyle(const Style& style)

Sets the default style for all subsequent radio buttons.

style
Use the styles provided by IRadioButton Styles to specify the default style.

This member function is not thread safe. In a multithreaded application, it should only be called when a conflict is not possible. A conflict can arise if you set the default style on one thread at the same time that it is being queried on another. In this situation, the query would take place while the style is in an unknown state.

When you create a window class and do not specifically specify window styles in the constructor, the Open Class Library queries the default style. Therefore, the only safe place to call this member function is when no other application threads that create windows are active.

Another way to avoid a conflict in a multithreaded application is to specifically specify window styles on window construction, rather than calling this member function.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
autoSelect
public:
static const Style autoSelect

Specifies a selection technique in which the user changes the current selection automatically by moving the keyboard cursor. If auto select is enabled, the state of the button automatically changes to the next appropriate state. For radio buttons, when auto select is enabled, all other buttons in the same group are deselected automatically when a button is selected. If auto select is disabled, the application must change the state of the button when it is clicked.

The application determines when the user clicks on the radio button by attaching a handler derived from ISelectHandler to the radio button or its owner and overriding the ISelectHandler::selected member function. The application can then use the selection functions to change the state of the radio button.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes

AIX Considerations

The autoSelect style is always enabled in the Motif version.


[view class]
classDefaultStyle
public:
static const Style classDefaultStyle

Provides the original default style for this class, which is the following: IRadioButton::autoSelect | IWindow::visible.

Supported Platforms

Windows OS/2 AIX
Yes Yes Yes


[view class]
noCursorSelect
public:
static const Style noCursorSelect

Prevents the radio button from selecting itself when given the focus as a result of an arrow key or tab key.

Supported Platforms

Windows OS/2 AIX
Ignored Yes Yes

AIX Considerations

The Motif version ignores the noCursorSelect style.

Windows Considerations

This style is ignored in the windows environment.


IRadioButton - Inherited Member Functions and Data

Inherited Public Functions

IButton
IControl
INotifier
ISettingButton
ITextControl
IWindow

Inherited Public Data

IWindow
INotifier
IButton
ISettingButton
ITextControl

Inherited Protected Functions

IWindow
INotifier
IButton
IControl
ITextControl
ISettingButton

Inherited Protected Data