Module: reefvision.widgets.menubar
Source: ./reefvision/widgets/menubar.reef
Overview
reefvision.widgets.menubar — top menu bar, pull-downs, one-level submenus, accelerators, and free-floating popup menus (context menus).
object MenuBar extends view.View. Desktop holds it as chrome (row 0), not as a Group child. Menu / MenuItem / PopupMenu stay value types.
Usage: let mb = new menubar.MenuBar(4) let _ = mb.add(menu_create("File", 8)) app.set_menubar(mb)
Types
SubItem
Leaf entry inside a one-level submenu.
Fields:
| Name | Type |
|---|---|
label |
string |
command |
int |
has_accel |
bool |
accel |
event.KeyEvent |
accel_text |
string |
MenuItem
Fields:
| Name | Type |
|---|---|
label |
string |
command |
int |
is_sep |
bool |
has_accel |
bool |
accel |
event.KeyEvent |
accel_text |
string |
is_submenu |
bool |
sub_items |
[SubItem] |
sub_cap |
int |
sub_count |
int |
Menu
Fields:
| Name | Type |
|---|---|
title |
string |
items |
[MenuItem] |
capacity |
int |
count |
int |
bar_x |
int |
bar_w |
int |
PopupMenu
Context / free-floating menu (no nested submenus in v1).
Fields:
| Name | Type |
|---|---|
items |
[MenuItem] |
capacity |
int |
count |
int |
x |
int |
y |
int |
open |
bool |
item_idx |
int |
last_command |
int |
Objects
MenuBar
Extends: view.View
Fields:
| Name | Type |
|---|---|
menus |
[Menu] |
capacity |
int |
count |
int |
open_idx |
int |
item_idx |
int |
sub_open |
bool |
sub_item_idx |
int |
last_command |
int |
cmds |
commands.CommandTable |
has_cmds |
bool |
proc init(capacity: int)
Methods:
exclusive fn add(menu: Menu): bool
shared fn count(): int
shared fn open_idx(): int
shared fn is_open(): bool
shared fn selected_item(): int
shared fn last_command(): int
exclusive proc clear_command()
exclusive proc close()
exclusive proc set_commands(cmds: commands.CommandTable)
exclusive proc register_accels(cmds: commands.CommandTable)
override exclusive proc draw(buf: cell.CellBuffer, abs: cell.Rect, clip: cell.Rect, focused: bool, th: theme.Theme)
override exclusive fn handle_event(e: event.Event): view.EventResult
Functions
fn max_menus(): int
fn max_items(): int
fn max_sub(): int
fn empty_key(): event.KeyEvent
fn empty_sub(): SubItem
fn empty_item(): MenuItem
fn fkey_label(n: int): string
fn format_accel(ke: event.KeyEvent): string
fn str_letter(ch: int): string
fn str_digit(ch: int): string
fn menu_item(label: string, command: int): MenuItem
fn menu_item_accel(label: string, command: int, ke: event.KeyEvent): MenuItem
fn menu_item_with_accel(label: string, command: int, ke: event.KeyEvent, accel_label: string): MenuItem
fn menu_item_sep(): MenuItem
fn menu_item_submenu(label: string): MenuItem
fn menu_item_add_sub(parent: MenuItem, label: string, command: int): bool
fn menu_item_add_sub_accel(parent: MenuItem, label: string, command: int, ke: event.KeyEvent): bool
fn menu_item_is_sep(it: MenuItem): bool
fn menu_item_is_submenu(it: MenuItem): bool
fn menu_item_label(it: MenuItem): string
fn menu_item_command(it: MenuItem): int
fn menu_item_has_accel(it: MenuItem): bool
fn menu_item_get_accel_text(it: MenuItem): string
fn menu_item_accel_key(it: MenuItem): event.KeyEvent
fn menu_create(title: string, capacity: int): Menu
fn menu_title(m: Menu): string
fn menu_count(m: Menu): int
fn menu_add(m: Menu, item: MenuItem): bool
fn menu_get(m: Menu, idx: int): MenuItem
fn empty_menu(): Menu
fn menubar_is_open(mb: MenuBar): bool
fn item_enabled(it: MenuItem, cmds: commands.CommandTable, has_cmds: bool): bool
fn sub_enabled(s: SubItem, cmds: commands.CommandTable, has_cmds: bool): bool
fn row_width_label_accel(label: string, accel_text: string, is_sub: bool): int
Width of a row: " label accel " or " label ▶ "
fn popup_width_menu(m: Menu): int
fn popup_width_subs(it: MenuItem): int
fn popup_width_items(items: [MenuItem], count: int): int
fn first_enabled_item(m: Menu, start: int, dir: int, cmds: commands.CommandTable, has_cmds: bool): int
fn first_enabled_sub(it: MenuItem, start: int, dir: int): int
fn activate_item(mb: MenuBar, cmds: commands.CommandTable, has_cmds: bool): bool
fn handle_menubar(mb: MenuBar, e: event.Event, y: int, width: int, cmds: commands.CommandTable, has_cmds: bool): bool
fn popup_create(capacity: int): PopupMenu
fn popup_count(p: PopupMenu): int
fn popup_add(p: PopupMenu, item: MenuItem): bool
fn popup_is_open(p: PopupMenu): bool
fn popup_last_command(p: PopupMenu): int
fn popup_first_item(p: PopupMenu, start: int, dir: int): int
fn popup_activate(p: PopupMenu, cmds: commands.CommandTable, has_cmds: bool): bool
fn handle_popup_menu(p: PopupMenu, e: event.Event, cmds: commands.CommandTable, has_cmds: bool): bool
Procedures
proc menu_register_accels(m: Menu, cmds: commands.CommandTable)
proc menubar_close(mb: MenuBar)
proc menubar_open(mb: MenuBar, idx: int)
proc draw_menubar(mb: MenuBar, buf: cell.CellBuffer, y: int, width: int, th: theme.Theme)
proc draw_menu_row(buf: cell.CellBuffer, px: int, iy: int, pw: int, label: string, accel_text: string, is_sub: bool, st: cell.Style, arrow: int)
Paint one row inside a popup body (pw = inner width).
proc draw_box_popup(buf: cell.CellBuffer, outer: cell.Rect, th: theme.Theme)
proc draw_menubar_popup(mb: MenuBar, buf: cell.CellBuffer, y: int, th: theme.Theme, cmds: commands.CommandTable, has_cmds: bool)
proc open_sub_if_any(mb: MenuBar)
proc popup_open_at(p: PopupMenu, x: int, y: int)
proc popup_close(p: PopupMenu)
proc popup_clear_command(p: PopupMenu)
proc draw_popup_menu(p: PopupMenu, buf: cell.CellBuffer, th: theme.Theme, cmds: commands.CommandTable, has_cmds: bool)
Generated by reefc doc