pub fn menu_box_rect(bounds: Rect, menu: &Menu) -> RectExpand description
Compute the box bounds that fit menu inside bounds.
Width starts at a floor of 10 and grows to the widest item. The per-item column budget is:
- command with shortcut text:
cstrlen(name) + 6 + cstrlen(param) + 2 - submenu entry:
cstrlen(name) + 6 + 3(the+3reserves a column for►) - command without shortcut:
cstrlen(name) + 6 - separator: no width contribution (but still adds a row)
Height is 2 + item_count — 2 for the top and bottom borders plus one
row per item, separators included. The computed (width, height) is then
clamped into bounds: the box prefers its preferred size but is pushed
against the far edge when the available space is smaller.
The menu session calls this to size each submenu box as it opens; you can
also call it directly to pre-compute a popup box’s bounds before passing them
to popup_menu.
§Turbo Vision heritage
Ports the static getRect sizing helper (tmenubox.cpp).