Note: The Agar manual pages follow certain conventions, notably concerning function return values. Please read AG_Intro(3) first.
SYNOPSIS
#include <agar/core.h> #include <agar/gui.h> |
DESCRIPTION
| The AG_Checkbox widget displays a string of text next to a button used to trigger an int binding. |
INHERITANCE HIERARCHY
| AG_Object(3)-> AG_Widget(3)-> AG_Checkbox. |
INITIALIZATION
|
The AG_CheckboxNew() function allocates, initializes, and attaches a AG_Checkbox widget. AG_CheckboxNew() accepts an optional text label argument. The AG_CheckboxNewFn() variant also assigns the specified callback function to the checkbox-changed event. Acceptable values for the flags argument include:
The AG_CheckboxNewInt() variant binds the state to a boolean integer. AG_CheckboxNewFlag() binds the state to a specified set of bits bitmask in pFlags. The utility function AG_CheckboxSetFromFlags() creates a set of checkboxes for the given set of flags, described by an array of AG_FlagDescr structures: typedef struct ag_flag_descr {
Uint bitmask; /* Bitmask */
const char *descr; /* Bit(s) description */
int writeable; /* User-editable */
} AG_FlagDescr;
The AG_CheckboxToggle() function inverts the current state of checkbox. |
BINDINGS
The
AG_Checkbox widget provides the following bindings:
|
EVENTS
The
AG_Checkbox widget reacts to the following events:
The AG_Checkbox widget generates the following events:
|
STRUCTURE DATA
For the
AG_Checkbox object:
|
EXAMPLES
The following code fragment ties an
AG_Checkbox to a boolean variable represented by an
int: int someOption = 0; AG_Window *win = AG_WindowNew(0); AG_CheckboxNewInt(win, 0, "Some option", &someOption); AG_WindowShow(win); The following code fragment uses an AG_Checkbox to trigger a callback function: static void
MyCallback(AG_Event *event)
{
AG_TextInfo(NULL, "Callback invoked");
}
AG_Window *win = AG_WindowNew(0);
AG_CheckboxNewFn(win, 0, "Execute callback", MyCallback, NULL);
AG_WindowShow(win);
The following code fragment creates an array of checkboxes, each tied to a specific bit in a word: #define FLAG_FOO 0x01
#define FLAG_BAR 0x02
#define FLAG_BAZ 0x04
int myWord = 0;
AG_FlagDescr myFlagDescr[] = {
{ FLAG_FOO, "foo flag", 1 },
{ FLAG_BAR, "bar flag", 1 },
{ FLAG_BAZ, "baz flag (readonly)", 0 },
{ 0, NULL, 0 }
};
AG_Window *win = AG_WindowNew(0);
AG_CheckboxSetFromFlags(win, 0, &myWord, myFlagDescr);
AG_WindowShow(win);
|
SEE ALSO
| AG_Intro(3), AG_Button(3), AG_Event(3), AG_Radio(3), AG_Widget(3), AG_Window(3) |
HISTORY
| The AG_Checkbox widget first appeared in Agar 1.0. |
