Menus

A menu bar has to be "opened" first. The menu bar serves as a container for the different menus. It is required one call for each menu. Each of them will establish a call-back function. It is necessary to terminate the sequence of created menus by "closing" the container.

Each menu is connected to a call-back function which is a part of the application. This call-back function will be activated when the user wants to drop down the menu. The only thing it shall do is to create the items in the dropped down menu. Each of these are in the same manner connected to a call-back function, which may either drop yet another (sub-)menu or perform a direct action.

See also: Objects, Containers, Windows, Listboxes, Tabwindows.
int MakeMenuBar(void);

Creates a container specially designed for entering menus-items in a window. The point is to issue subsequent calls to MkMenuBarItem. NB! The sequence of calls to MkMenuBarItem must be terminated by a call to EndMenuBar. If you forget this other objects will be placed together with the menu-items, and it will all look junky.
MakeMenuBar returns an id-number.
See also: EndMenuBar, MkMenuBarItem.
void EndMenuBar(void);

Closes a container opened by MakeMenuBar.
See also: MkMenuBarItem, MakeMenuBar.
int MkMenuBarItem(const char *text, void (*CallBack) (void *), void *data);

Creates one menu-item within an opened menu bar (opened by MakeMenuBar).

Return value: the id of the menu item (non-zero)

Parameters:

See also: MakeMenuBar, MkMenuItem, MkMenuRadio, MkMenuCheck.
int MkScratchMenu(int id, void (*CallBack)(void*), void *data);

`MkScratchMenu' will immediately drop down a menu and invoke `CallBack'. The position of the menu will be at the mouse cursor position. Return value: the id of the drop-menu (non-zero)

Parameters:

See also: MkMenuBarItem, MkMenuItem, MkSingleMenu.
int MkSingleMenu(int x, int y, char *label, void (*CallBack) (void *), void *data);

`MkSingleMenu' does the same work as `MakeMenuBar' + `MkMenuBarItem' + `EndMenuBar' with one call to `MkMenuBarItem'. I.e. it creates amenu-bar containing one menu-item. It looks slightly different (it is indicated that it is a menu by a "down-arrow".
Return value: the id of the menu (non-zero)

Parameters:

See also: MkMenuBarItem, MkMenuItem, MkScratchMenu, Direction commands for object positioning, Labels.
int MkMenuItem(int sub, const char *text, const char *shortcut, void (*CallBack) (void *), void *data);

Creates one menu-item within a dropped down menu. There is actually two different types that can be created by this function: (1) A menu-item that is the selection point for a sub-menu, and (2)a menu-item that is just a simple selection (that closes all menus).
Return value: the id of the menu item (non-zero)

Parameters:

See also: MkMenuBarItem, MkMenuRadio, MkMenuCheck, MkGroove, Labels.
int MkMenuRadio(int *selvar, int n, ...);

Works similar to AddRadioButton, but is intended only for menus.

Return value: the id of the menu item (non-zero)

Parameters:

See also: AddRadioButton, MkMenuCheck, MkMenuItem.
int MkMenuCheck(int *checkvar, const char *text);

Works similar to AddCheck-button, but is intended only for menus. Return value: the id of the menu item (non-zero)

Parameters:

See also: MkMenuRadio, MkMenuItem, AddCheck.
int HookMenuClose(void (*CloseHook)(void*), void *data);

This function installs CloseHook. This is a pointer to a function written by you. It will be called when the menu is closed. HookMenuClose will do nothing if it is not called from a "menu drop-down" -function like the call-back passed to `MkMenuItem'. Actually it will do the same thing as `HookExit', with the difference that you don't need to now the id-number (which you normally don't know).

The benefit of installing the CloseHook may be e.g. to get the chance to free memory allocated by the drop-down function. If the menu is closed because the user made a selection of an item (or some item in a sub-menu) the call-back of that item will be called prior to CloseHook.

Returns non-zero on sucess.

See also: MkMenuItem.
int MkGroove(void);

A horizontal groove will be put into any node as a delimiter. The purpose is to visually group objects into logical groups. This may be specially useful in menus.
Return value: the id of the groove
See also: Menus, Objects.

Back to contents