SYNOPSIS
#include <agar/core.h> #include <agar/gui.h>
DESCRIPTION
The
AG_Notebook widget maintains a set of
AG_Box(3) containers, only one of which is visible at any given time.
The user can select the visible container by clicking on a tab, or it can
be selected programmatically.
INHERITANCE HIERARCHY ↑
AG_Object(3)-> AG_Widget(3)-> AG_Notebook.
INITIALIZATION ↑
AG_Notebook * AG_NotebookNew (AG_Widget *parent, Uint flags)
void AG_NotebookSetPadding (AG_Notebook *nb, int padding)
void AG_NotebookSetSpacing (AG_Notebook *nb, int spacing)
void AG_NotebookSetTabAlignment (AG_Notebook *nb, enum ag_notebook_tab_alignment alignment)
void AG_NotebookSetTabVisibility (AG_Notebook *nb, int flag)
The AG_NotebookNew() function allocates, initializes, and attaches a new AG_Notebook widget. Acceptable flags include:
AG_NOTEBOOK_HIDE_TABS | Don't display the tab selector controls. |
AG_NOTEBOOK_HFILL | Expand horizontally in parent container. |
AG_NOTEBOOK_VFILL | Expand vertically in parent container. |
AG_NOTEBOOK_EXPAND | Shorthand for AG_NOTEBOOK_HFILL AG_NOTEBOOK_VFILL|. |
AG_NotebookSetPadding() and AG_NotebookSetSpacing() sets the default AG_Box(3) padding and spacing to use for new tabs.
By default, tabs are drawn at the top of the widget. AG_NotebookSetTabAlignment() changes the location of the tabs, where the argument is one of:
enum ag_notebook_tab_alignment { AG_NOTEBOOK_TABS_TOP, AG_NOTEBOOK_TABS_BOTTOM, AG_NOTEBOOK_TABS_LEFT, AG_NOTEBOOK_TABS_RIGHT };
AG_NotebookSetTabVisibility() toggles the visibility of the tab header.
TAB MANAGEMENT ↑
AG_NotebookTab * AG_NotebookAdd (AG_Notebook *nb, const char *name, enum ag_box_type type)
void AG_NotebookDel (AG_Notebook *nb, AG_NotebookTab *tab)
AG_NotebookTab * AG_NotebookGetByID (AG_Notebook *nb, int tabID)
AG_NotebookTab * AG_NotebookGetByName (AG_Notebook *nb, const char *text)
void AG_NotebookSelect (AG_Notebook *nb, AG_NotebookTab *tab)
void AG_NotebookSelectByID (AG_Notebook *nb, int id)
AG_NotebookAdd() creates a new tabbed container. name is an arbitrary text label to be displayed on the tab header. The type argument sets the type of AG_Box(3), that is either for AG_BOX_HORIZ horizontal packing, or AG_BOX_VERT for vertical packing (see AG_Box(3) for details). AG_NotebookAdd() returns a pointer to the newly created AG_NotebookTab container widget (a subclass of AG_Box(3)).
AG_NotebookDel() removes the given tabbed container, detaching and freeing all associated child widgets.
AG_NotebookGetByID() returns the tab with given numerical ID (or NULL).
AG_NotebookGetByName() looks up a tab based on the contents of its text label and returns a pointer to the tab (or NULL).
The AG_NotebookSelect() function selects the active tabbed container.
AG_NotebookSelectByID() selects the container by numerical ID.
EVENTS ↑
The
AG_Notebook widget does not generate any event.
STRUCTURE DATA ↑
For the
AG_Notebook object:
For the AG_NotebookTab object:
TAILQ tabs | The list of tabs as AG_NotebookTab objects. |
Uint nTabs | Total number of tabs. |
AG_NotebookTab *selTab | Pointer to the currently selected tab. |
int selTabID | Numerical ID of currently selected tab. |
For the AG_NotebookTab object:
AG_Label *lbl | Pointer to the AG_Label(3) of the tab (or NULL). |
int id | The numerical ID associated with the tab. |
EXAMPLES ↑
The following code fragment creates a notebook with two tabs:
AG_Notebook *nb; AG_Notebook *ntab; nb = AG_NotebookNew(parent, AG_NOTEBOOK_EXPAND); { ntab = AG_NotebookAdd(nb, "Tab #1", AG_BOX_VERT); AG_LabelNew(ntab, 0, "This is Tab #1"); ntab = AG_NotebookAdd(nb, "Tab #2", AG_BOX_VERT); AG_LabelNew(ntab, 0, "This is Tab #2"); }
SEE ALSO ↑
HISTORY ↑
The
AG_Notebook widget first appeared in
Agar 1.0.
AG_NotebookGetByID() and
AG_NotebookSelectByID() appeared in
Agar 1.6.0.