To best understand this section, you should find the
pcb-menu.res
file that your Pcb uses and refer to it for
examples (see Menu Files and Defaults).
A resource defines a menu when it meets certain semantic requirements. The menu hierarchy is reflected as a hierarchy of unnamed subresources, with the first string of each subresource defining the label used for the menu button. A subresource that itself contains subresources becomes a submenu, a subresource that does not becomes a button.
A submenu should only contain subresources for the buttons or submenus within that submenu. Two exceptions are allowed: an initial string sets the label, and the string "-" (a single dash) will create a separator.
A button should not contain subresources, but will contain many strings, named and unnamed. The first member shall be an unnamed string which is the label for the button. Any other unnamed strings within the button's resource will be used as actions (much like the .Xdefaults action strings), which are functions that will be called when the button is pressed (or popped up, or created, depending on the action). As a convenience, if a left parenthesis is seen, the current "word" will continue at least until the matching right parenthesis. This allows you to pass strings with spaces as arguments to actions without needing to quote the action.
Named resources in button resources will be used as X resources. Such resources can be used to set the font, color, and spacing of buttons. As a convenience, "fg" can be used as an abbreviation for "foreground".
Within the menu's resource file, Pcb will look for a few key named
subresources. At the moment, the only one it looks for is one called
MainMenu
. This will be used for the main menu bar. In the
future, other named subresources will be used for popup resources.
Given all this, a small sample pcb-menu.res
would be:
MainMenu = { {File {"Load layout" Load(Layout)} - {"Quit Program" Quit() fg=red font=10x20} } }
Within the Pcb sources are specially crafted comments that mark all
the actions, flags, menu hooks, and whatnot that Pcb offers. Read the
file src/gather-actions
in the Pcb source tree for
documentation for these comments.