-
Notifications
You must be signed in to change notification settings - Fork 1
/
menu.h
92 lines (67 loc) · 2.15 KB
/
menu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*
Menu handling
*/
#define MENU_CANCEL 0
#define MENU_YES 1
#define MENU_NO 0
extern unsigned char menu_bc; /* border color */
extern unsigned char menu_tc; /* title color */
extern unsigned char menu_nc; /* normal item color */
extern unsigned char menu_ic; /* inactive item color */
extern unsigned char menu_xpos; /* default menu position */
extern unsigned char menu_ypos;
typedef enum itemstates {
ISTATE_NORMAL,
ISTATE_INACTIVE
} ItemState;
typedef struct item {
struct item *next;
struct item *prev;
unsigned char id;
unsigned char *name;
ItemState state;
} Item;
typedef struct menu {
unsigned char visible;
unsigned char numitems;
unsigned char current;
unsigned char xpos;
unsigned char ypos;
unsigned char width;
unsigned char height;
unsigned char *title;
Item *firstitem;
} Menu;
/* Set menu colors */
#define SetMenuColors(BC, TC, NC, IC) \
menu_bc = (BC); \
menu_tc = (TC); \
menu_nc = (NC); \
menu_ic = (IC);
/* Set default menu position */
#define SetMenuDefaultPosition(XPOS, YPOS) \
menu_xpos = (XPOS); \
menu_ypos = (YPOS);
/* Initialize an empty menu. */
Menu *NewMenu(void);
/* Deallocate menu resources. */
void DestroyMenu(Menu *menu);
/* Set the title. */
void SetMenuTitle(Menu *menu, unsigned char *title);
/* Add an item to the menu. id is the value that SelectMenu will return, which must not be 0. */
signed char AddMenuItem(Menu *menu, unsigned char id, ItemState state, unsigned char *name);
/* Delete an item from the menu. */
signed char DelMenuItem(Menu *menu, unsigned char id);
/* Set item state to normal or inactive. */
signed char SetItemState(Menu *menu, unsigned char id, ItemState state);
/* Display the menu on the screen. */
void ShowMenu(Menu *menu);
signed char DrawMenu(Menu *menu);
/* Erase the menu from the screen. */
void HideMenu(Menu *menu);
/* Let the user choose a menu item. ShowMenu() first. */
signed char SelectMenu(Menu *menu);
/* Ask if user is sure */
unsigned char AskAreYouSure(Menu *menu);
/* Display message, wait for enter */
void DisplayMessage(unsigned char *message);