To add menus to your interface you must first specify the menus themselves, and then a menu bar of which they will be a part.
Let us add some menus that duplicate the proposed functionality for the buttons. We will add:
The extra code needed in the
define-interface
call is this:
(:menus
(file-menu "File"
("Open"))
(page-menu "Page"
("Page Up" "Page Down")))
(:menu-bar file-menu page-menu)
Menu definitions give a slot name for the menu, followed by the title of the menu, a list of menu item descriptions, and then, optionally, a list of keyword arguments for the menu.
In this instance the menu item descriptions are just strings naming each item, but you may wish to supply initialization arguments for an item -- in which case you would enclose the name and those arguments in a list.
The menu bar definition simply names all the menus that will be on the bar, in the order that they will appear. By default, of course, the environment may add menus of its own to an interface -- for example the Works menu in the LispWorks IDE.
The code for the new interface is:
(define-interface demo ()
()
(:panes
(page-up push-button
:text "Page Up")
(page-down push-button
:text "Page Down")
(open-file push-button
:text "Open File")
(viewer editor-pane
:title "File:"
:text "No file selected."
:visible-min-height '(:character 8)
:reader viewer-pane))
(:layouts
(main-layout column-layout
'(row-of-buttons row-with-editor-pane))
(row-of-buttons row-layout
'(page-up page-down open-file))
(row-with-editor-pane row-layout
'(viewer)))
(:menus
(file-menu "File"
("Open"))
(page-menu "Page"
("Page Up" "Page Down")))
(:menu-bar file-menu page-menu)
(:default-initargs :title "Demo"))
Figure 10.3 A CAPI interface with menu items
The menus contain the items specified -- try it out to be sure.
CAPI User Guide (Unix version) - 30 Aug 2011