[Home] [Prev] [Next] [Up]
Each application built by YAAF contains at least one menu bar. A menu bar in this case is the visible menu bar along the top of the Macintosh screen, or along the top of the window on a Microsoft Windows application.
Normally you would define the menu bar by defining a standard resource containing the shape and structure of the menu bar. If you need to manipulate the contents of a menu bar, you would obtain a pointer to the XGMenuBar object representing that menu bar, and manipulate the contents there.
Note: wish list thing to do is to come up with a consistant way to get the correct menu bar. Currently, there is only one for both single window and multiwindow applications; however, in the future, I wish to also include a multi-window application which appears like multiple single windows, each with it's own menu bar.
On Windows, the menu bar is simply defined using the standard MENU resource. On the Macintosh, however, it's a bit more complicated. Two new resources have been added, which combined with a 'MENU' and a 'MBAR' resource, completely defines all the parameters needed by the YAAF menu management core.
The first resource needed is the 'MCmd' resource. Each item in a menu has associated with it a unique command identifier. Identifiers are normally not a part of the Macintosh OS; in the case of the YAAF engine, a 'MCmd' resource is associated with each 'MENU' resource which gives the commands for each menu item in the similarly numbered 'MENU' resource.
The second (optional) resource is the 'MInv' resource. This is a list of 'MENU's which are invisible, such as submenus in a hierarchical menu, which are in the current menu bar. For each 'MBAR' resource there is an optional 'MInv' resource with the same number which gives the list of invisible menus (submenus) in this menu bar. If there are none, the 'MInv' resource doesn't need to be present.
Both templates are defined in the file 'ResEdit Templates' in the :Resources: subdirectory. Their format is as follows:
struct MCmd { long cmdID[len]; /* 'len' == length of MENU res */ }; struct MInv { short len; /* # items following */ short menuID[len];/* length is the 'len' param above */ };
The menu bar class itself; this provides a simple interface to the menu bar class.