Expand description
The shared, non-interactive layer behind the menu bar and menu boxes:
MenuViewState (the data every menu view holds) plus the free functions for
command-graying and passive accelerator dispatch.
Two responsibilities live here:
- The command-graying broker (
update_menu_commands) — driven by the command-set-changed broadcast, it walks the menu tree and marks each item enabled/disabled to match the live command set. - Passive accelerator dispatch — the key branch of
handle_eventthat posts the command of a menu item whose accelerator matches a pressed key, even when no menu is open (seehot_key).
The interactive modal layer (opening, navigating, and selecting) lives in
MenuBar, MenuBox, and the
MenuSession capture handler. The parent-of relationship
between an open box and the level above it is modeled by that session’s level
stack rather than a field on the view, so MenuViewState carries no
parent pointer.
§Turbo Vision heritage
Ports the passive half of TMenuView (tmnuview.cpp/menus.h). The
current/parentMenu up-pointers become an item index plus the session’s
level stack (deviation D3); the disabled-command set is held as a denylist
(deviation D1) and TStreamable persistence is dropped (deviation D12).
Structs§
- Menu
Colors - The four
(lo, hi)style pairs a menu item is drawn in, one per enabled/disabled × normal/selected combination, resolved once per draw. Thelostyle paints the label andhithe highlighted hotkey character. Shared byMenuBarandMenuBoxso the matrix lives in one place. - Menu
View State - Runtime view state shared by the menu views that
MenuBarandMenuBoxbuild on.
Traits§
- Menu
View - The shared interface a
MenuBarand aMenuBoximplement so menu navigation can treat them uniformly.
Functions§
- handle_
event - The passive event layer of a menu view.
- hot_key
- Find the menu item whose accelerator matches
keyand return itsCommand. - update_
menu_ commands - Regray the menu tree against the program’s live disabled-command set.