AG_NOTEBOOK(3)

NAME
AG_Notebook - agar notebook container widget

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 (equivalent to invoking AG_ExpandHoriz(3)).

AG_NOTEBOOK_VFILL
    Expand vertically in parent (equivalent to invoking AG_ExpandVert(3)).

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)

void AG_NotebookSelect(AG_Notebook *nb, AG_NotebookTab *tab)

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.

The AG_NotebookSelect() function selects the active tabbed container.

EVENTS
The AG_Notebook widget does not generate any event.

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
AG_Intro(3), AG_Widget(3), AG_Window(3)

HISTORY
The AG_Notebook widget first appeared in Agar 1.0.