SYNOPSIS
#include <agar/core.h> #include <agar/gui.h>
DESCRIPTION
The
AG_Toolbar widget is a specialized container for a set of buttons which allows single
or multiple selections.
The buttons may be arranged in multiple rows.
INHERITANCE HIERARCHY ↑
INITIALIZATION ↑
AG_Toolbar * AG_ToolbarNew (AG_Widget *parent, enum ag_toolbar_type, int nRows, Uint flags)
void AG_ToolbarRow (AG_Toolbar *toolbar, int row_name)
AG_Button * AG_ToolbarButton (AG_Toolbar *toolbar, const char *text, int enable_default, void (*fn)(AG_Event *), const char *fnArgs, ...)
AG_Button * AG_ToolbarButtonIcon (AG_Toolbar *toolbar, AG_Surface *icon, int enable_default, void (*fn)(AG_Event *), const char *fnArgs, ...)
void AG_ToolbarSeparator (AG_Toolbar *toolbar)
void AG_ToolbarSelect (AG_Toolbar *toolbar, AG_Button *button)
void AG_ToolbarDeselect (AG_Toolbar *toolbar, AG_Button *button)
void AG_ToolbarSelectOnly (AG_Toolbar *toolbar, AG_Button *button)
void AG_ToolbarSelectAll (AG_Toolbar *toolbar)
void AG_ToolbarDeselectAll (AG_Toolbar *toolbar)
The AG_ToolbarNew() function allocates, initializes, and attaches a new AG_Toolbar widget. Acceptable flags include:
AG_TOOLBAR_HOMOGENOUS | Scale the buttons so that they cover the whole toolbar area, instead of using their preferred sizes. |
AG_TOOLBAR_STICKY | Buttons should preserve their state, and only one button can be selected at any given time. |
AG_TOOLBAR_MULTI_STICKY | Button should preserve their state but multiple buttons can be selected. |
AG_TOOLBAR_HFILL | Expand horizontally in parent container. |
AG_TOOLBAR_VFILL | Expand veritcally in parent container. |
AG_TOOLBAR_EXPAND | Shorthand for AG_TOOLBAR_HFILL AG_TOOLBAR_VFILL|. |
AG_ToolbarRow() specifies the row number for all subsequent operations.
The AG_ToolbarButton() function creates a new button displaying the given text and attaches it to the current row. If the enable_default argument is 1, the button is enabled by default. The arguments fn and fnArg specify the event handler function (see AG_Event(3) for details). The callback function will be invoked whenever the user clicks on the button.
The AG_ToolbarButtonIcon() variant creates a button displaying a given surface instead of a label, usually an icon.
AG_ToolbarSeparator() creates a separator of appropriate orientation in the current row.
The functions AG_ToolbarSelect() and AG_ToolbarDeselect() are used to enable or disable a given button. AG_ToolbarSelectOnly() enables the given button, disabling any other button that is currently active. AG_ToolbarSelectAll() enables all attached buttons and AG_ToolbarDeselectAll() disables all attached buttons.
EVENTS ↑
The
AG_Toolbar widget does not generate any event.
STRUCTURE DATA ↑
For the
AG_Toolbar object:
AG_Box *rows[] | Containers for the rows (read-only). Widgets can be attached manually to those containers with AG_ObjectAttach(3) if AG_ToolbarButton() is not suitable. |
int nRows | Number of rows (read-only). |
int nButtons | Total button count (read-only). |
int curRow | Current row, as selected by AG_ToolbarRow() (read-only). |
SEE ALSO ↑
HISTORY ↑
The
AG_Toolbar widget first appeared in
Agar 1.1.