AG_Button *
AG_ButtonNew
(AG_Widget
*parent, Uint flags,
const char *format,
...);
AG_Button *
AG_ButtonNewS
(AG_Widget
*parent, Uint
flags, const char
*label);
AG_Button *
AG_ButtonNewFn
(AG_Widget
*parent, Uint
flags, const char
*label, void
(*fn)(AG_Event *), const
char *fnArgs,
...);
AG_Button *
AG_ButtonNew{Int,Uint8,Uint16,Uint32}
(AG_Widget
*parent, Uint
flags, const char
*label, <Type>
*p);
AG_Button *
AG_ButtonNew{Flag,Flag8,Flag16,Flag32}
(AG_Widget
*parent, Uint
flags, const char
*label, Uint *p,
<Type>
bitmask);
void
AG_ButtonSetPadding
(AG_Button
*button, int lPad,
int rPad,
int tPad,
int bPad);
void
AG_ButtonSetFocusable
(AG_Button
*button, int
flag);
void
AG_ButtonSetSticky
(AG_Button
*button, int
flag);
void
AG_ButtonInvertState
(AG_Button
*button, int
flag);
void
AG_ButtonJustify
(AG_Button
*button, enum
ag_text_justify justify);
void
AG_ButtonValign
(AG_Button
*button, enum
ag_text_valign valign);
void
AG_ButtonSetRepeatMode
(AG_Button
*button, int
repeat_flag);
void
AG_ButtonSurface
(AG_Button
*button, const AG_Surface
*su);
void
AG_ButtonSurfaceNODUP
(AG_Button
*button, AG_Surface
*su);
void
AG_ButtonText
(AG_Button
*button, const char
*format, ...);
void
AG_ButtonTextS
(AG_Button
*button, const char
*label);
The AG_ButtonNew
() function allocates,
initializes, and attaches a AG_Button
widget. If the
label argument is given, it sets a default text
caption. For the list of acceptable flags, see
BUTTON FLAGS section.
The AG_ButtonNewFn
() variant creates a
button and implicitely sets a callback (event handler) function to be
executed whenever the button is pressed. See
AG_Event(3)
for details on Agar event handlers. Since function-triggering buttons rarely
make use of the "state" binding,
AG_ButtonNewFn
() implies
AG_BUTTON_EXCL
(unless
AG_BUTTON_NOEXCL
is passed).
The
AG_ButtonNew{Int,Uint8,Uint16,Uint32}
() functions
tie the state of the button (the ‘state’ binding) with the
given integer variable, where 1 = True and 0 = False.
The
AG_ButtonNew{Flag,Flag8,Flag16,Flag32}
(), functions
tie the state of the button with the state of the bits described by
bitmask in the specified integer variable.
AG_ButtonNewFlag
() binds to an
int, AG_ButtonNewFlag8
() binds
to an Uint8, etc.
The AG_ButtonSetPadding
() function sets
the padding around the label in pixels. If a parameter is -1, its current
value is preserved. Note that when using a text label, this setting is
independent from that of the label (use
AG_LabelSetPadding(3)
on the lbl member of the
AG_Button
to configure the text label padding as
well).
The AG_ButtonSetFocusable
() function with
an argument of 0 prevents the button from gaining focus. The default is to
allow buttons to gain focus.
The AG_ButtonSetSticky
() function enables
or disable sticky mode. Under sticky mode, the button will not spring back
to its previous state following a click event. This mode is mostly useful
when the button's state is bound to a boolean variable.
The AG_ButtonInvertState
() function
defines whether to invert the meaning of the boolean variable bound to the
button.
AG_ButtonJustify
() sets the justification
for the button text label (or icon):
enum ag_text_justify {
AG_TEXT_LEFT,
AG_TEXT_CENTER,
AG_TEXT_RIGHT
};
AG_ButtonValign
() sets the vertical
alignment for the button text label (or icon):
enum ag_text_valign {
AG_TEXT_TOP,
AG_TEXT_MIDDLE,
AG_TEXT_BOTTOM
};
The AG_ButtonSetRepeatMode
() flag enables
or disables repeat mode. Repeat mode causes multiple
‘button-pushed’ events to be posted periodically for as long
as the button is triggered. Repeat mode is used notably by
AG_Numerical(3).
AG_ButtonSurface
() sets the button label
to a copy of the given surface. The
AG_ButtonSurfaceNODUP
() variant uses the given
surface as source without copying. If a text label currently exists, it is
removed.
AG_ButtonText
() sets the label of the
button from the specified text string. If a surface is currently set, it is
removed.