typedef void (*ControlFunc) (Control *c);
Control *new_check_box(Window *w, Rect r, char *text, ControlFunc fn); Control *add_check_box(Control *c, Rect r, char *text, ControlFunc fn); int is_checked(Control *c); /* is it checked? */ void check(Control *c); /* check the check box */ void uncheck(Control *c); /* uncheck the check box */
The new_check_box function creates a check box (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 the state changes between checked and unchecked, the call-back function fn is called after the event and the check box is passed to the function as its parameter. This call-back function can be set to NULL, which means no function should be called in response to checking or unchecking the check box.
The add_check_box function works in the same way as new_check_box, except that it attaches the check box to a control rather than directly to a window.
The function is_checked can be used to determine if the check box is currently checked. The function check can be used to check a check box, and uncheck can be used to remove a check-mark from the check box.
A check box can be freely switched on or off by the user, unlike radio buttons, which are part of mutually exclusive sets. See the section on radio buttons for more details.