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.
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.
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:
- text: the menu text to display
- CallBack: a pointer to a function written by you. This function will
be called by CGUI when the user wants the menu to be dropped down.
Prior to the call, CGUI has prepared for receiving calls from
your `CallBack' in order to create menu-items (i.e. calls to
MkMenu*). There is no restriction on the object types that may be
created by `CallBack', but the menu may appear crazy if you put
other than the special menu-item-objects there (the menu and the
menu items co-operate in the event processing to make mouse events
and key-presses to work as expected). `CallBack' is supposed to NOT
open or close any window, since a window build is in progress when
it is called. The parameter passed to CallBack is the "data"-pointer
that you pass as last argument.
- data: a pointer to any data that you want your call-back function to
receive.
See also:
MakeMenuBar,
MkMenuItem,
MkMenuRadio,
MkMenuCheck.
`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:
- id: typically you want a scratch-menu dropped down if the user
clicked on a certian object. If you prefere that the menu shall be
placed at the edge of this object rather than above it, then pass
the is of that object.
- CallBack: a pointer to a function written by you. This function will
be called by CGUI when the user wants the menu to be dropped down.
Prior to the call, CGUI has prepared for receiving calls from
your `CallBack' in order to create menu-items (i.e. calls to
MkMenu*). There is no restriction on the object types that may be
created by `CallBack', but the menu may appear crazy if you put
other than the special menu-item-objects there (the menu and the
menu items co-operate in the event processing to make mouse events
and key-presses to work as expected). `CallBack' is supposed to NOT
open or close any window, since a window build is in progress when
it is called. The parameter passed to CallBack is the "data"-pointer
that you pass as last argument.
- data: a pointer to any data that you want your call-back function to
receive.
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:
- x,y: The position of the object (or you can use "direction commands").
- label: the label text that will be displayed on the menu
- CallBack: a pointer to a function written by you. This function will
be called by CGUI when the user wants the menu to be dropped down.
Prior to the call, CGUI has prepared for receiving calls from
your `CallBack' in order to create menu-items (i.e. calls to
MkMenu*). There is no restriction on the object types that may be
created by `CallBack', but the menu may appear crazy if you put
other than the special menu-item-objects there (the menu and the
menu items co-operate in the event processing to make mouse events
and key-presses to work as expected). `CallBack' is supposed to NOT
open or close any window, since a window build is in progress when
it is called. The parameter passed to CallBack is the "data"-pointer
that you pass as last argument.
- data: a pointer to any data that you want your call-back function to
receive.
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:
- sub: A flag indicating if this menu-item will open another sub-menu
or if it is just a direct selection.
- label: The text to label the menu-item. See section `Labels' for
details about commands embedded in the label-string.
- shortcut: another (optional) text. This text is right-aligned. It is
intended to be used to inform about a shortcut. Just pass the empty
string ,"", if you have no need for it. (There is no check for this
short-cut, it's up to you to tell the truth to the user).
- CallBack: A pointer to a function written by you.
Case (1), `sub' was non-zero: This function will
be called by CGUI when the user wants the menu to be dropped down.
Prior to the call, CGUI has prepared for receiving calls from
your `CallBack' in order to create menu-items (i.e. calls to
MkMenu*). There is no restriction on the object types that may be
created by `CallBack', but the menu may appear crazy if you put
other than the special menu-item-objects there (the menu and the
menu items co-operate in the event processing to make mouse events
and key-presses to work as expected). `CallBack' is supposed to NOT
open or close any window, since a window build is in progress when
it is called.
Case (2), `sub' was zero : This function will be called when the user
selects this item. The menu(s) will be closed before the call. There
is no restriction on what the CallBack can do (actually a typical
task is probably to open or close some window).
The parameter passed to CallBack is the "data"-pointer that you pass
as last argument.
- data: A pointer passed to "CallBack".
See also:
MkMenuBarItem,
MkMenuRadio,
MkMenuCheck,
MkGroove,
Labels.
Works similar to AddRadioButton, but is intended only for menus.
Return value: the id of the menu item (non-zero)
Parameters:
- selvar: the variable which value is controlled by the radio-buttons
(and which value contols the initial display of them).
- n: the number of radio-buttons connected to "selvar". The first one
representing value 0, next value 1 etc.
- ...: This must be (NOTE IMPORTANT!)exactly n text-strings, each
one telling the text label to put on the corresponding radio-button
selector
See also:
AddRadioButton,
MkMenuCheck,
MkMenuItem.
Works similar to AddCheck-button, but is intended only for menus.
Return value: the id of the menu item (non-zero)
Parameters:
- checkvar: the variable which value is controlled by the check-button
(and which value cont rols the initial display of it).
- text: the label of the selection
See also:
MkMenuRadio,
MkMenuItem,
AddCheck.
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.
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