source: branches/reyalp-flt/core/gui_menu.h @ 1488

Revision 1488, 2.9 KB checked in by tsv, 18 months ago (diff)

Flat branch update. Collection of fixes and small improvements, required for futher module.

  • Fixed Makefiles to correct clean/create modules
  • Make menu title possible to have non langid values
  • Make load_from_file() much more universal
  • variable names enhahcements
  • Property svn:eol-style set to native
Line 
1#ifndef GUI_MENU_H
2#define GUI_MENU_H
3
4//-------------------------------------------------------------------
5#define MENUITEM_MASK           0x000f
6#define MENUITEM_BOOL           1
7#define MENUITEM_INT            2
8#define MENUITEM_SUBMENU        3
9#define MENUITEM_PROC           4
10#define MENUITEM_UP             5
11#define MENUITEM_TEXT           6
12#define MENUITEM_SEPARATOR      7
13#define MENUITEM_ENUM           8
14#define MENUITEM_COLOR_BG       9
15#define MENUITEM_COLOR_FG       10
16#define MENUITEM_ENUM2          11
17
18// Flags, which describe limits of F_INT value
19#define MENUITEM_F_MASK         0x00f0
20#define MENUITEM_F_UNSIGNED     0x0010
21#define MENUITEM_F_MIN          0x0020
22#define MENUITEM_F_MAX          0x0040
23#define MENUITEM_F_MINMAX       0x0060
24
25// Value, which specify specific kind of argument
26#define MENUITEM_ARG_MASK       0x0f00
27    // menuitem.arg contain incrementor value
28#define MENUITEM_ARG_INC        0x0100
29    // menuitem.arg contain (int*) to incrementor
30#define MENUITEM_ARG_ADDR_INC   0x0200
31    // menuitem.arg contain ptr to callback function
32#define MENUITEM_ARG_CALLBACK   0x0300
33
34#define MENU_MINMAX(min, max)   (((max)<<16)|(min))
35
36//-------------------------------------------------------------------
37typedef struct {
38    char                symbol;     // menuitem icon symbol
39    char                opt_len;    // ENUM2 num of elements
40    short               type;       // MENUITEM_MASKS
41    int                 text;       // Text
42    int                 *value;     // pointer to binded variable
43                                    //   exceptions: _PROC = pointer to processing func
44                                    //               _ENUM = pointer to processing func
45    int                 arg;        // additional argument
46                                    //     by default type is controled by _ARG_MASK and by _F_MINMAX
47                                    //     for ENUM2 - pointer to string list
48} CMenuItem;
49
50typedef struct {
51    char                symbol;
52    int                 title;
53    void                (*on_change)(unsigned int item);
54    const CMenuItem     *menu;
55} CMenu;
56
57// Menu item constructor macros
58#define MENU_ITEM(sym, txt, typ, val, arg)  { (char)sym, 0, (short)typ, (int)txt, (int*)val, (int)arg }
59#define MENU_ENUM2(sym, txt, val, arg)      { (char)sym, sizeof(arg)/sizeof(arg[0]), MENUITEM_ENUM2, (int)txt, (int*)val, (int)arg }
60#define MENU_ENUM2a(sym, txt, val, arg, num){ (char)sym, (char)num, MENUITEM_ENUM2, (int)txt, (int*)val, (int)arg }
61
62//-------------------------------------------------------------------
63extern void gui_menu_init(CMenu *menu_ptr);
64extern void gui_menu_kbd_process();
65extern void gui_menu_draw(int enforce_redraw);
66extern void mod_user_menu(CMenuItem curr_menu_item, int* gui_menu_add_item, int mod);
67extern void gui_menu_force_redraw();
68//-------------------------------------------------------------------
69#endif
Note: See TracBrowser for help on using the repository browser.