Adding Menus
iTool menus are created using the CW_ITMENU compound widget. The signature of the CW_ITMENU function is:
Result = CW_ITMENU(Parent, UI, Target [, KEYWORDS])
where:
- Parent is the widget ID of the base widget on which the menu will be displayed.
- UI is the user interface object associated with the interface.
- Target is the iTool identifier, relative to the iTool associated with UI, of the container whose operations should be included in the menu.
- KEYWORDS are keywords either handled explicitly by the widget, or passed through to the widgets that make up the compound widget.
Standard Menus
Operations registered in the iTool containers that create the standard menus are automatically sensitized and desensitized to reflect whether the individual operation can be applied at the time the menu is displayed. Some items are sensitized when the selected item is of the correct data or visualization type, others (such as Undo and Redo) are sensitized when some other criteria are met. Still others (such as the Open operation on the File menu) are always available.
The following statements create the menus used by the standard iTools:
wFile = CW_ITMENU(wMenubar, oUI, 'Operations/File') wEdit = CW_ITMENU(wMenubar, oUI, 'Operations/Edit') wInsert = CW_ITMENU(wMenubar, oUI, 'Operations/Insert') wOperations = CW_ITMENU(wMenubar, oUI, 'Operations/Operations') wWindow = CW_ITMENU(wMenubar, oUI, 'Operations/Window') wHelp = CW_ITMENU(wMenubar, oUI, 'Operations/Help')
You can include any subset of these menus, or your own menus, in your interface.
Modifying Menu Contents
Each iTool menu contains an entry for each item that is registered in the container. This has two ramifications:
- If you register a new operation in one of the standard menu containers, it will appear on the menu for your iTool, and be sensitized and desensitized according to the same rules as the other items.
- If you unregister an operation from one of the standard menu containers, it will be removed from the menu for your iTool.
Operations are generally registered and unregistered in the Init method of an iTool creation routine. See Creating an Operation for details. For an example that shows how to unregister standard menu items, see Example: a Custom iTool Interface.
Resizing Menus
Because menubars are treated as part of the top level base widget, no special resizing code is required to resize menus. If you are concerned that your menus always appear in a single line, you may want to consider setting a minimum width on your top level base sufficient to ensure that the menus never wrap to a second line.