Skip to main content

Module menu

Module menu 

Source
Expand description

The NeXTSTEP application menu (spec Β§4.1): a vertical floating panel with a black title bar and beveled items, whose submenus cascade to the right.

The menu knows nothing about the app. show draws it and returns the Command the user picked, and the caller runs it. key_command maps the key equivalents (Ctrl on Linux and Windows, Cmd on macOS) to the same commands. Everything is painted with painter shapes and text.

StructsΒ§

MenuState
Where the menu sits and which submenu is open. Lives on the app.
Row πŸ”’
One row of a menu panel, as drawn.

EnumsΒ§

Command
Something the user can ask for from the menu or a key equivalent.
Top πŸ”’
What a top-level item does.

ConstantsΒ§

BORDER πŸ”’
FONT_SIZE πŸ”’
ITEM_HEIGHT πŸ”’
MENU πŸ”’
The menu tree. Top level per spec Β§4.1; submenus hold the commands the app can already run, plus disabled placeholders for File.
MENU_W πŸ”’
Room the main menu takes from the workspace’s left edge: its ~110 px panel plus its margin. A fresh worksheet window opens clear of it.
MIN_WIDTH πŸ”’
MODEL_BROWSER πŸ”’
NO_VIEWS πŸ”’
PAD πŸ”’
RIGHT_SLOT πŸ”’
Room between a label and the right-hand marker, plus the marker itself.
TITLE πŸ”’
TITLE_HEIGHT πŸ”’

FunctionsΒ§

bold πŸ”’
font πŸ”’
key_command
Map a key equivalent (pressed with Ctrl/Cmd) to its command, read off the MENU tree so the two can’t disagree: a lowercase letter is the plain chord, an uppercase one the chord with Shift. Y is a Redo alias.
keyed_items πŸ”’
Every menu item with a key equivalent, top level and submenus.
menu_id
The menu panel’s area id.
paint_row πŸ”’
Paint one beveled item: face, 1 px white top-left, 1 px black bottom-right, label left and its marker right-aligned.
panel πŸ”’
Draw one menu panel (title bar plus rows) in its own foreground [Area] at pos. Returns the panel’s outer rect and each row’s response.
panel_size πŸ”’
Outer size of a menu panel titled title holding rows.
show
Draw the menu and return the command picked this frame, if any. views fills the View submenu as (name, is_current); picking the n-th returns Command::OpenView(n). enabled greys out commands that can’t run now. The menu’s top-left starts at home; after that it stays where it’s dragged.
sub_id πŸ”’

Type AliasesΒ§

Leaf πŸ”’
A submenu row: label, key equivalent, command. None is not built yet and draws disabled.