RadioButtons and RadioGroups

OBJECTS

  typedef control  radiobutton;
  typedef object   radiogroup;

  typedef void (*actionfn)(radiobutton rb);

FUNCTIONS

  radiobutton newradiobutton(char *text, rect r, actionfn fn);
  radiogroup  newradiogroup(void);

  int     ischecked(radiobutton rb);	/* is this button checked? */
  void    check(radiobutton rb);	/* check this button */
  void    uncheck(radiobutton rb);	/* uncheck this button */

NOTES

The newradiobutton function creates a radio button control, which is similar to a checkbox except that it has a circle which is filled in with a large dot when the user clicks with the mouse.

Whenever the user changes the checked-state of a radio button, the action function fn is called after the change. Normally this parameter is left as NULL, which signifies that no function need be called in response to a change of state.

One difference between checkboxes and radio buttons is that a checkbox can be freely switched on and off by the user, while radio buttons automatically belong to a mutually exclusive set of radio buttons, known as a 'radio group'. Activating one radio button will therefore switch off the previously active radio button.

Initially, no radio buttons in a radio group will be checked. If a 'default' option needs to be specified, use the check function to check one radio button after creating it.

To begin a new radio group, the newradiogroup function can be used. After calling this function, all subsequently created radio buttons will belong to a new mutually exclusive set of buttons. Radio button groups exist only within one window, so creating a new window starts a new radio group automatically.

The function ischecked can be used to determine if a radio button is currently checked. The function check can be used to activate a radio button while uncheck can be used to remove a dot from a radio button.