EZwgl provides a convenient way to create simple menus, menus that uses only menu-normal-buttons, menu-submenus and menu-separators.
int EZ_CreateSimpleMenu(char *str, ...)
Specifing a Simple Menu
A simple menu is specified by a string and an optional set of arguments that provide callback procedures and/or submenus for the menu and menu items.
The string is a number of fields separated by |
's. Each field
may contain any number of the following specifications:
%t
Makes non-formatting text in this item as the menu title string.
%F
Gets the callback-procedure and call-data for the menu
from the optional arguments.
%f
Gets the callback-procedure and call-data for this menu-item
from the optional arguments.
%l
Inserts a menu-separator.
%m
Marks this item as a menu-submenu item and
gets the menu from the optional arguments.
%n
Sets the instance name of the this menu item to
be the substring after the current formating characters and
before the next formating character or |
.
%c
Sets the class name of the this menu item to
be the substring after the current formating characters and
before the next formating character or |
.
%x
[0-9]+ Sets the return value for this item. This value overrides
the default position-based value assigned to this menu item.
You must enter the numeric value as the part of the text
Here are some examples.
void submenu1Callback(EZ_Widget *, void *); void Item2Callback(EZ_Widget *, void *); EZ_Widget *submenu1 = EZ_CreateSimpleMenu("%F|red|green%x123|blue|%l|||", submenu1Callback, NULL); EZ_Widget *menu = EZ_CreateSimpleMenu("%T Test Menu|Item 1|Item 2%f|submenu%m|last item" Item2Callback, NULL, submenu1);
The first two lines declare two callbacks, one for a submenu and one for a menu item.
The third line creates a simple menu. This submenu has callback
submenu1Callback
with call data NULL
. It contains 5 menu
items and a menu-separator. The first three items are labeled by
"red", "green" and "blue" respectively. The second item has a
numeric return value of 123
. The other items have the default
return values (their position in the menu). The last two items have
no lables specified, so the default lable item #
will be
used for them.
The forth line create a menu with title "Test Menu" and no
callbacks. It contains four items. The second item has a callback
procedure Item2Callback
with call-data NULL
. The third
menu is a submenu-item with menu submenu1
.