Checkboxes

OBJECTS

  typedef control  checkbox;

  typedef void (*actionfn)(checkbox c);

FUNCTIONS

  checkbox newcheckbox(char *text, rect r, actionfn fn);

  int      ischecked(checkbox c);	/* is this checkbox checked? */
  void     check(checkbox c);		/* check this checkbox */
  void     uncheck(checkbox c);		/* uncheck this checkbox */

NOTES

The newcheckbox function creates a checkbox (a square box with text displayed to its right). Clicking on the box causes an X to appear within the box, and clicking on it again causes the X to vanish. Each time either of these happens, the call-back function fn is called after the event and the checkbox is passed to the function as its argument.

Normally this action function can be set to NULL, which means no function should be called in response to checking or unchecking the checkbox.

The function ischecked can be used to determine if the checkbox is currently checked. The function check can be used to check a checkbox, and uncheck can be used to remove a check-mark from the checkbox.

A checkbox can be freely switched on or off by the user, unlike radio buttons, which are mutually exclusive. See the section on radio buttons for more details.