Guide API
Skip to main content

Module menu_view

Module menu_view 

Source
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:

  1. 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.
  2. Passive accelerator dispatch — the key branch of handle_event that posts the command of a menu item whose accelerator matches a pressed key, even when no menu is open (see hot_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§

MenuColors
The four (lo, hi) style pairs a menu item is drawn in, one per enabled/disabled × normal/selected combination, resolved once per draw. The lo style paints the label and hi the highlighted hotkey character. Shared by MenuBar and MenuBox so the matrix lives in one place.
MenuViewState
Runtime view state shared by the menu views that MenuBar and MenuBox build on.

Traits§

MenuView
The shared interface a MenuBar and a MenuBox implement 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 key and return its Command.
update_menu_commands
Regray the menu tree against the program’s live disabled-command set.