.so draw-menubar \c{

Menus

The second component of our drawing tool is the menubar. The class {\em menu_bar}, depicted in slide draw-menubar is derived from the hush widget menubar. Its constructor requires an ancestor widget, a tablet and a toolbox. The tablet is passed as a parameter to the {\em file_menu}, and the toolbox to the {\em edit_menu}. In addition, a {\em help_button} is created, which provides online help in a hypertext format when pressed. The help facility will be discussed in section hyper. } .so draw-file \c{ A menubar consists of menubuttons to which actual menus are attached. Each menu consists of a number of entries, which may possibly lead to cascaded menus. The {\em file_menu} class, depicted in slide draw-file, defines a menu, but is derived from menubutton in order to attach the menu to its menubar ancestor (a). Its constructor defines the appearance of the button and creates a {\em file_handler} (b). It then defines the actual menu (c). The menu must explicitly be attached to the menubutton by invoking the menubar member function menu. For creating the menu, the keyword class is needed to disambiguate between the creation of an instance of the class menu and the call of the menubar::menu function. Before defining the various entries of the menu, the {\em file_menu} instance is declared as the handler for the menu entries (d). However, except for the entry Quit, which is handled by calling the kit::quit function (e), the calls are delegated to the previously created {\em file_handler}. } \c{ The second button of the {\em menu_bar} is defined by the {\em edit_menu}. The {\em edit_menu} requires a toolbox and creates a menubutton. It configures the button and defines a menu containing two entries, one of which is a cascaded menu. Both the main menu and the cascaded menu are given the toolbox as a handler. This makes sense only because for our simple application, the functionality offered by the toolbox and {\it edit_menu} coincide. }