WwRadioBox Function
Creates a box containing radio buttons.
Usage
radio = WwRadioBox(parent, [labels,] callback)
Input Parameters
parent — The widget ID of the parent widget.
labels — (optional) A string array of button labels. If the labels parameter is not defined or is an array of null strings, the function looks for the button labels in a resource specification (see Discussion).
callback — A string containing the name of the callback that is executed when a radio button is selected or unselected.
Note: |
The callback procedure is called twice if the Oneofmany keyword is specified. It is called once when the previously select button is unselected and again for the newly selected button. Use WwGetValue to determine if a button is currently selected or unselected. |
Returned Value
radio — The widget ID of the radio box widget when more than one radio button is used. If only one button is requested, the widget ID of the layout around that one button is returned. To get the widget ID of that single button, use the Toggles output keyword.
Keywords
AlignLeft — If nonzero, aligns the text to the right of the toggle to be left-justified. This keyword is only useful if you have multiple toggle buttons that are vertically oriented. By default, buttons are center-justified.
AlignRight — If nonzero, aligns the text to the right of the toggle to be right-justified. This keyword is only useful if you have multiple toggle buttons that are vertically oriented. By default, buttons are center-justified.
Border — Specifies the width in pixels of the radio box and button borders.
Center — Array specifying position of left and right edge of buttons as a percentage of radio box width. The buttons are evenly spaced in the box.
Form — When present and nonzero, buttons are placed in a form layout and all specified attachment keywords are honored (i.e., /Left, /Right, /Top, /Bottom). By default, buttons are placed in a row/column layout.
Horizontal — When present and nonzero, creates a horizontally aligned row of radio buttons.
Layout_name — Specifies the name of the layout widget. This name is part of the resource specification. Layout_name names the Form widget (if Form is specified), the SimpleRadioBox widget (if Oneofmany is specified), or the SimpleCheckBox widget (if Nofmany is specified). (Default: radio.)
Measure — Specifies the number of columns of radio buttons (for a vertical box) or rows (for a horizontal box).
Name — A string array specifying the button widget names. The button widget names specified are part of the resource specifications containing the button labels. The Name keyword can be used in place of the labels parameter, although labels (if other than an array of null strings) will take precedence if both are given. (Default: button_1, button_2, ..., button_n.)
Nofmany — When present and nonzero, creates nonexclusive radio buttons, where any number of buttons can be selected at once.
Oneofmany — When present and nonzero, creates exclusive radio buttons, where only one button can be selected at a time.
Position — If the radio box widget is to be placed in a bulletin board layout, use this keyword to specify the x, y coordinates of the radio box widget within the bulletin board.
Spacing — Specifies the space in pixels between radio buttons.
Tab_WinOff — (Windows only) If this keyword is present and nonzero, the tab navigation feature is turned off for this widget. For radio box widgets the Tab key selects the group, use the arrow keys to navigate within the group.
Note: |
Once one of the Oneofmany radio buttons has been selected, using the arrow keys highlights a button and visually changes the selection, but does not select it nor activate its callback. You must hit the Return key or the Spacebar to select the highlighted button and activate its callback. |
Toggles — Returns an array of toggle button widget IDs.
Vertical — When present and nonzero, creates a vertically aligned column of radio buttons.
Color/Font Keywords
Background — Specifies the background color name.
Basecolor — Specifies the base color.
Font — Specifies the name of the font used for text.
MSFont — Adds support for Windows fonts.
Foreground — Specifies the foreground color name.
Attachment Keywords
Bottom — If a widget ID is specified (for example, Bottom=wid), then the bottom of the radio box widget is attached to the top of the specified widget. If no widget ID is specified (for example, /Bottom), then the bottom of the radio box widget is attached to the bottom of the parent widget.
Left — If a widget ID is specified (for example, Left=wid), then the left side of the radio box widget is attached to the right side of the specified widget. If no widget ID is specified (for example, /Left), then the left side of the radio box widget is attached to the left side of the parent widget.
Right — If a widget ID is specified (for example, Right=wid), then the right side of the radio box widget is attached to the left side of the specified widget. If no widget ID is specified (for example, /Right), then the right side of the radio box widget is attached to the right side of the parent widget.
Top — If a widget ID is specified (for example, Top=wid), then the top of the radio box widget is attached to the bottom of the specified widget. If no widget ID is specified (for example, /Top), then the top of the radio box widget is attached to the top of the parent widget.
Get/Set Value
getvalue — Gets the state of the selected radio button. Set = 1; unset = 0.
setvalue — Sets the state of the selected radio button. Set = 1; unset = 0.
Callback Parameters
Any radio button callback procedure must have the following two parameters:
wid — Toggle button widget ID.
index — Index of the toggle button changed (1 – n).
Discussion
This function creates a box containing a specified number of rows or columns of labeled toggle buttons. If only one button is created, a box is not created; instead, only a single button widget is created.
Part of the button label resource specification can be specified using the Name keyword, otherwise the default is the *button_n.labelString resource (where labelString is the attribute).
Note: |
The labels parameter provides a method for “hard-coding” the button labels. For greater flexibility, create a resource file containing the button labels using a text editor, and load the button label resources using WtResource. The Name keyword can then be used in the WwRadioBox calling sequence to specify the resources. |
Example 1
This example creates a box containing radio buttons. The callback is executed when the user clicks on a button.
Enter the callback procedure into a file, and compile the procedure with the .RUN command. Then, enter the widget commands at the WAVE> prompt. To dismiss the radio button box, select the appropriate function (such as Close) from the window manager menu.
Callback Procedure
PRO RadioCB, wid, which
CASE which OF
1: PRINT,'First Toggle Selected'
2: PRINT,'Second Toggle Selected'
3: PRINT,'Third Toggle Selected'
ENDCASE
value = WwGetValue(wid)
PRINT, value
END
Widget Commands
top = WwInit('ww_ex33', 'Examples', layout)
labels = ['System', 'Owner', 'Group']
rbox = WwRadioBox(layout, labels, 'RadioCB', $
/Vertical, Border=2, Spacing=20)
status = WwSetValue(top, /Display)
WwLoop
Example 2
A typical resource specification for a button label used in WwRadioBox is:
myapp*radio.shade_g.labelString: Gouraud
See Also
For detailed information on GUI development, refer to the PV‑WAVE Application Developer’s Guide.
For more information about how to write an application program based on PV‑WAVE Widgets, refer to Using Wave Widgets in the PV‑WAVE Application Developer’s Guide.
For additional information on the color and font keywords, see "Setting Colors and Fonts" in the PV‑WAVE Application Developer’s Guide.
For additional information on attachment keywords, see "Form Layout: Attachments" in the PV‑WAVE Application Developer’s Guide.
For information on Get and Set values, see "Setting and Getting Widget Values" in the PV‑WAVE Application Developer’s Guide.