Tabwindows

A tab-window is a node within a regular window. It consists of the tab-bar (a row of tab-selectors) at the top, and the rest of the node which will display different sets of object depending on which tab that is currently selected.
The tab-bar is limited to one row of tabs (or "selectors"). These actually works similar to radio-buttons, but looks like "tabs". There must be at least one tab. Each tab has a text-label.
When the user clicks on a tab, your call-back function associated with that tab will be invoked (see AddTab). The point is that the call-back function shall create all the objects corresponding to the tab. The regular functions for creating objects may be used, which implies the possibility of nested tab-windows.
If there is not space enough for all the tabs the excess ones will be clipped, which is not as bad as it seems. However: The main point with tabs-windows is to make quick access to the different controls, and this is not not fulfilled anyway if you add too many tabs.
See also: Windows, Objects, Menus, Containers, Listboxes.
int CreateTabWindow(int x, int y, int width, int height, int *status);

Creates the node object of the entire tab-selector. Returns object-id.
Return value is the identification key for the entire tab-window (including the tab bar at the top).
Parameters:
See also: AddTab.
int AddTab(int id, void (*callback)(void *data, int id), void *data, const char *label);

Adds one tab into the bar of tabs in a tab-window. The callback, which is a function you must code, will be called when the tab is clicked by the user or initially by DisplayWindow(). The callback is not supposed to open a new window. The only thing it shall bother about is to create the objects for the tab-subwindow. This has always been cleaned before callback is invoked (i.e the objects created by a previous selection has been removed before call). The callback shall not refresh the objects in the tab-window, this will also be done automatically after return.
All objects created by the callback will be but in the tab-window. If absolute co-ordinates are used for such objects (x,y) these shall refer to the upper left corner of the free area in the tab-window.
Like other objects tabs may be added also after the window has been built with a call to DisplayWin. The same applies to removal of tabs.
Parameters:
See also: DisplayWin, CreateTabWindow.
void HookLeaveTab(void (*callback)(void *data), void *data);

This function registers 'callback' to be a function that will be called with 'data' when a tab in a tab-window is left. The tab will be left either because the user selects some other tab in the same tab-window or because the entire window is closed.
HookLeaveTab must be called when generating the tab-window (i.e. by the function installed by 'AddTab'), only at this stage the tab-window is prepared to receive such a call.
The purpose is to give your program the possibility to release memory that you needed to allocate for the objects in the tab-window.
See also: AddTab.

Back to contents