AG_Radio *
AG_RadioNew
(AG_Widget
*parent, Uint
flags, const char
*items[]);
AG_Radio *
AG_RadioNewFn
(AG_Widget
*parent, Uint
flags, const char
*items[], AG_EventFn
fn, const char
*fmt, ...);
AG_Radio *
AG_RadioNewInt
(AG_Widget
*parent, Uint
flags, const char
*items[], int
*value);
AG_Radio *
AG_RadioNewUint
(AG_Widget
*parent, Uint
flags, const char
*items[], Uint
*value);
void
AG_RadioSetDisposition
(AG_Radio
*radio, AG_RadioType
type);
void
AG_RadioItemsFromArray
(AG_Radio
*radio, const char
*items[]);
void
AG_RadioSizeHint
(AG_Radio
*radio, Uint
nLines, const char
*text);
int
AG_RadioAddItem
(AG_Radio
*radio, const char
*format, ...);
int
AG_RadioAddItemS
(AG_Radio
*radio, const char
*text);
int
AG_RadioAddItemHK
(AG_Radio
*radio, AG_KeySym
hotkey, const char
*format, ...);
int
AG_RadioAddItemHKS
(AG_Radio
*radio, AG_KeySym
hotkey, const char
*text);
void
AG_RadioClearItems
(AG_Radio
*radio);
The
AG_RadioNew
()
function allocates, initializes, and attaches a new
AG_Radio
widget. If items is
not NULL, it should point to a NULL-terminated array of strings. Acceptable
flags include:
- AG_RADIO_HOMOGENOUS
- Divide space equally between radio items.
- AG_RADIO_HFILL
- Expand horizontally in parent container.
- AG_RADIO_VFILL
- Expand vertically in parent container.
- AG_RADIO_EXPAND
- Shorthand for
AG_RADIO_HFILL
|
AG_RADIO_VFILL
.
AG_RadioNewFn
()
creates a new radio group and also sets an event handler for the
‘radio-changed’ event.
AG_RadioNew{Int,Uint}
()
creates a new radio group bound to an integer.
AG_RadioSetDisposition
()
selects whether items are packed horizontally or vertically (the
default):
typedef enum ag_radio_type {
AG_RADIO_VERT, /* Vertical disposition */
AG_RADIO_HORIZ /* Horizontal disposition */
} AG_RadioType;
AG_RadioItemsFromArray
()
generates (appends) a set of radio buttons from the given NULL-terminated
array of C strings.
AG_RadioSizeHint
()
specifies an alternate initial size requisition expressed as a number of
lines nLines (or -1 = auto) and the rendered pixel
width of text (or NULL = auto). By default,
AG_Radio
will auto-size based on the set of radio
items at the time of the size requisition.
AG_RadioAddItem
()
inserts a single radio button. The
AG_RadioAddItemHK
() variant also assigns a hotkey to
the button.
AG_RadioClearItems
()
removes all radio buttons from the group.
The following code fragment connects an
AG_Radio
to an enum:
enum fruit {
APPLE,
ORANGE,
BANANA
} fruit = APPLE;
const char *fruitNames[] = {
"Apple",
"Orange",
"Banana",
NULL
};
AG_RadioNewInt(NULL, 0, fruitNames, &fruit);
The following code fragment specifies a callback routine:
void
MyCallback(AG_Event *event)
{
const int newSelection = AG_INT(1);
printf("Selected item %d\n", newSelection);
}
...
AG_Radio *rad;
rad = AG_RadioNewFn(NULL, 0, fruitNames, MyCallback, NULL);
AG_BindInt(rad, "value", &fruit);