BeRTOS
Data Structures | Typedefs | Functions
Menu handling module
BeRTOS GUI toolkit

Common menu handling API. More...

Data Structures

struct  MenuItem
 Menu item description. More...
struct  Menu
 Menu description. More...

Typedefs

typedef iptr_t(* MenuHook )(iptr_t userdata)
 Menu callback function.
typedef void(* RenderHook )(struct Bitmap *bitmap, int ypos, bool selected, const struct MenuItem *item)
 Render hook callback function prototype.

Functions

iptr_t menu_handle (const struct Menu *menu)
 Handle a menu and invoke hook functions for the selected menu items.
int menu_setFlags (struct Menu *menu, int idx, int flags)
 Set flags on a menuitem.
int menu_clearFlags (struct Menu *menu, int idx, int flags)
 Clear flags on a menuitem.

Flags for MenuItem.flags.

#define MIF_EXCLUDE_MASK   0x00FF
 Mask for mutual exclusion map (shared with priority).
#define MIF_PRI_MASK   0x00FF
 Mask for priority value (shared with mutual exclusion).
#define MIF_PRI(x)   ((x) & MIF_PRI_MASK)
 Set menu item priority.
#define MIF_EXCLUDE_0   BV(0)
 Exclude item 0 when this item is checked.
#define MIF_EXCLUDE_1   BV(1)
 Exclude item 1 when this item is checked.
#define MIF_EXCLUDE_2   BV(2)
 Exclude item 2 when this item is checked.
#define MIF_EXCLUDE_3   BV(3)
 Exclude item 3 when this item is checked.
#define MIF_EXCLUDE_4   BV(4)
 Exclude item 4 when this item is checked.
#define MIF_EXCLUDE_5   BV(5)
 Exclude item 5 when this item is checked.
#define MIF_EXCLUDE_6   BV(6)
 Exclude item 6 when this item is checked.
#define MIF_EXCLUDE_7   BV(7)
 Exclude item 7 when this item is checked.
#define MIF_CHECKED   BV(8)
 Item is currently checked.
#define MIF_CHECKIT   BV(9)
 Automatically check this item when selected.
#define MIF_TOGGLE   BV(10)
 Toggle MIF_CHECKED when item is selected.
#define MIF_HIDDEN   BV(11)
 This menu item is not visible.
#define MIF_DISABLED   BV(12)
 This menu item is not visible.
#define MIF_RAMLABEL   BV(13)
 Item label is stored in RAM, not in program memory.
#define MIF_RENDERHOOK   BV(14)
 Menu render function is passed in label field.

Flags for Menu.flags.

#define MF_STICKY   BV(0)
 Stay in the menu when the items called return.
#define MF_TOPLEVEL   BV(1)
 Top-level menu (do not display "back" label)
#define MF_ROMITEMS   BV(2)
 Menu items are stored in ROM (default is RAM)
#define MF_SAVESEL   BV(3)
 Remember the selected item across invocations.

Special result codes for menu_handle().

#define MENU_OK   ((iptr_t)0)
#define MENU_CANCEL   ((iptr_t)-1)
#define MENU_TIMEOUT   ((iptr_t)-2)
#define MENU_ABORT   ((iptr_t)-3)
#define MENU_DISABLED   ((iptr_t)-4)

Detailed Description

Common menu handling API.

Author:
Bernie Innocenti <bernie@codewiz.org>
Stefano Fedrigo <aleph@develer.com>

Define Documentation

#define MF_SAVESEL   BV(3)

Remember the selected item across invocations.

Definition at line 115 of file menu.h.

#define MIF_EXCLUDE_MASK   0x00FF

Mask for mutual exclusion map (shared with priority).

Definition at line 75 of file menu.h.

#define MIF_PRI (   x)    ((x) & MIF_PRI_MASK)

Set menu item priority.

Definition at line 77 of file menu.h.

#define MIF_PRI_MASK   0x00FF

Mask for priority value (shared with mutual exclusion).

Definition at line 76 of file menu.h.


Function Documentation

int menu_clearFlags ( struct Menu menu,
int  idx,
int  flags 
)

Clear flags on a menuitem.

Parameters:
menuMenu owner of the item to change.
idxIndex of the menu item.
flagsBit mask of the flags to clear.
Returns:
Old flags.

Definition at line 574 of file menu.c.

int menu_setFlags ( struct Menu menu,
int  idx,
int  flags 
)

Set flags on a menuitem.

Parameters:
menuMenu owner of the item to change.
idxIndex of the menu item.
flagsBit mask of the flags to set.
Returns:
Old flags.

Definition at line 554 of file menu.c.