RadioButton Class

Radio buttons consist of a round button and a programmer defined label, icon, or bitmap that indicates to the user a choice. Radio buttons are typically grouped together as a set of mutually exclusive options. Radio buttons can be either standard or automatic. The system manages the check state of automatic radio buttons. The state of a radio button can be either checked or cleared (unchecked.)

The RadioButton class provides methods to query and modify radio button controls.

Requires:

The RadioButton class requires the class definition file oodWin32.cls :

::requires "oodWin32.cls"

Subclass of:

The radio button class is a direct subclass of the ButtonControl class, and therefore an indirect subclass of the DialogControl class class. Thus it inherits all the methods of both classes.

Mixin Class Inherits:

The radio button class inherits from the following mixin classes, (indirectly through the DialogControl class.)

The WindowBase

The WindowExtensions

Instantiation:

Use the getRadioControl() method to retrieve an object of the radio button class.

Dynamic Definition:

To dynamically define a radio button in a UserDialog class, use one of the add button methods described in the Add Button Control section. That section also describes methods for adding push buttons, check boxes, etc.. All the methods to add radio buttons begin with: addRadio.

Event Notification

A radio button, is a button, and the programmer uses the same methods to recieve notifications of of events as with a ButtonControl: the connectButton() method, or the connectButtonNotify() method.

Methods:

The RadioControl class implements the class and instance methods listed in the following table:

Table 14-3. RadioButton Class and Instance Methods

Method......Description
checkInGroup (Class)checkInGroup
checkcheck
checkedchecked
getCheckStategetCheckState
indeterminate Deprecatedindeterminate
isChecked DeprecatedisChecked
uncheckuncheck

checkInGroup (Class)

>>--checkInGroup(--dlg--,--idFirst--,--idLast--,--,--idCheck--)----------------><

Adds a check mark to (checks) the specified radio button in a group and removes a check mark from (clears) all other radio buttons in the group.

Details

Raises syntax errors when incorrect arguments are detected.

Arguments:

The arguments are:

dlg

The dialog that contains the radio button to be checked.

idFirst

The resource ID of the first radio button in the group.

idLast

The resource ID of the last radio button in the group.

idCheck

The resource ID of the radio button that is to be checked.

Return value:

This method return 0 on success and a system error code if a problem is detected.

Example:

This method is simple to use:

ret = .RadioButton~checkInGroup(self, IDC_RB_WHITE, IDC_RB_BLACK, IDC_GREEN)
return 0

checked

>>--checked--------------------------------------><

Determines if the button is checked, or not.

Arguments:

There are no arguments.

Return value:

Returns true if the button is checked, otherwise false.

Example:

This example determines if the user is choosing to print the current page, all pages, or a selection:

if self~getRadioControl(IDC_RB_CURRENT)~checked then do
  --Print the current page ...
end
else if self~getRadioControl(IDC_RB_ALL)~checked then do
  -- Print all pages ...
end
else do
  -- Must be print the selection ...
end

getCheckState

>>--getCheckState----------------------------------------------------><

Returns a keyword indicating the check state of the radio button, checked or unchecked.

Arguments:

There are no arguments to this method.

Return value:

The return value is a keyword indicating the checked state of the radio button and will be exactly one of the following:

UNCHECKEDThe radio button is not checked.
CHECKED The radio button is checked.
UNKNOWN The object is not a radio button.

Example:

This method is straightforward to use:

rb = self~getRadioControl(IDC_RB_ITALIC)
if rb~getCheckState == "CHECKED" then self~printInItalics()
...

check

>>--check-----------------------------------------><

The check method puts the button in the checked state. The system will redraw the button with the check mark appropriate for the button.

uncheck

>>--uncheck--------------------------------------><

The uncheck method puts the button in the unchecked state. The system will redraw the button without the check mark.

isChecked (deprecated)

Note: This method is deprecated. It is replaced by the functionally equivalent getCheckState() method for radio buttons, and the overridden getCheckState() method for check boxes. This method was poorly named and in some circumstances produced inconsistent results. Do not use this method in new code. Try to migrate existing code to the appropriate getCheckState() method. This method may not exist in future versions of ooDialog.

indeterminate (deprecated)

Note: This method is deprecated. It is replaced by the functionally equivalent setIndeterminate() method of the CheckBox class. Radio buttons can not be set to indeterminate. Using this method with a radio button sets it to the checked state, not the indeterminate state. In addition, this method was poorly named. One can check a button, but one does not indeterminate a check box. Do not use this method in new code. Try to migrate existing code to the setIndeterminate() method. This method may not exist in future versions of ooDialog.