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 #define MENUITEM_SUBMENU_PROC 12
18 #define MENUITEM_STATE_VAL_PAIR 13
19
20
21 #define MENUITEM_ERROR 14
22 #define MENUITEM_WARNING 15
23
24
25 #define MENUITEM_F_MASK 0x00f0
26 #define MENUITEM_F_UNSIGNED 0x0010
27 #define MENUITEM_F_MIN 0x0020
28 #define MENUITEM_F_MAX 0x0040
29 #define MENUITEM_F_MINMAX 0x0060
30
31
32 #define MENUITEM_ARG_MASK 0x0300
33
34 #define MENUITEM_ARG_CALLBACK 0x0100
35
36
37 #define MENUITEM_USER_MODULE 0x0400
38
39 #define MENUITEM_HHMMSS 0x1000
40 #define MENUITEM_DECIMAL 0x2000
41 #define MENUITEM_SD_INT 0x4000
42 #define MENUITEM_SCRIPT_PARAM 0x8000
43
44 #define MENU_MINMAX(min, max) (((max)<<16)|(min&0xFFFF))
45 #define MENU_MIN_UNSIGNED(arg) ((unsigned short)(arg & 0xFFFF))
46 #define MENU_MAX_UNSIGNED(arg) ((unsigned short)((arg>>16) & 0xFFFF))
47 #define MENU_MIN_SIGNED(arg) ((short)(arg & 0xFFFF))
48 #define MENU_MAX_SIGNED(arg) ((short)((arg>>16) & 0xFFFF))
49
50
51 typedef struct {
52 char symbol;
53 char opt_len;
54 short type;
55 int text;
56 int *value;
57
58
59 int arg;
60
61
62 } CMenuItem;
63
64 typedef struct {
65 char symbol;
66 int title;
67 const CMenuItem *menu;
68 } CMenu;
69
70
71 #define MENU_ITEM(sym, txt, typ, val, arg) { (char)sym, 0, (short)typ, (int)txt, (int*)val, (int)arg }
72 #define MENU_ENUM2(sym, txt, val, arg) { (char)sym, sizeof(arg)/sizeof(arg[0]), MENUITEM_ENUM2, (int)txt, (int*)val, (int)arg }
73 #define MENU_ENUM2a(sym, txt, val, arg, num){ (char)sym, (char)num, MENUITEM_ENUM2, (int)txt, (int*)val, (int)arg }
74
75
76 extern void gui_menu_init(CMenu *menu_ptr);
77 extern void gui_menu_erase_and_redraw();
78 extern void gui_menu_cancel_redraw();
79 extern int gui_menu_kbd_process();
80 extern void gui_menu_draw(int enforce_redraw);
81 extern void gui_menu_force_redraw();
82 extern int menu_get_increment_factor();
83 extern void menu_set_increment_factor(int n);
84 extern char *menu_increment_factor_string();
85 extern int menu_calc_max_increment_factor(int max_value);
86 extern CMenu* get_curr_menu();
87
88 extern void gui_menu_back();
89 extern void gui_activate_sub_menu(CMenu *sub_menu);
90
91
92 extern gui_handler menuGuiHandler;
93
94
95 extern CMenu root_menu;
96
97 extern CMenuItem* find_menu_item(CMenu *curr_menu, int itemid );
98
99
100 #endif