]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/MAI/menu/menu.c
* Code cleanup:
[people/ms/u-boot.git] / board / MAI / menu / menu.c
CommitLineData
c7de829c
WD
1#include "menu.h"
2
3#define SINGLE_BOX 0
4#define DOUBLE_BOX 1
5
6void video_draw_box(int style, int attr, char *title, int separate, int x, int y, int w, int h);
7void video_draw_text(int x, int y, int attr, char *text);
8void video_save_rect(int x, int y, int w, int h, void *save_area, int clearchar, int clearattr);
9void video_restore_rect(int x, int y, int w, int h, void *save_area);
10int video_rows(void);
11int video_cols(void);
12
13#define MAX_MENU_OPTIONS 200
14
15typedef struct
16{
17 int used; /* flag if this entry is used */
18 int entry_x; /* Character column of the menu entry */
19 int entry_y; /* Character line of the entry */
20 int option_x; /* Character colum of the option (entry is same) */
21} option_data_t;
22
23option_data_t odata[MAX_MENU_OPTIONS];
24
25int normal_attr = 0x0F;
26int select_attr = 0x2F;
27int disabled_attr = 0x07;
28
29menu_t *root_menu;
30
31int menu_init (menu_t *root)
32{
33 char *s;
34 int i;
35
36 s = getenv("menu_normal");
37 if (s) normal_attr = atoi(s);
38
39 s = getenv("menu_select");
40 if (s) select_attr = atoi(s);
41
42 s = getenv("menu_disabled");
43 if (s) disabled_attr = atoi(s);
8bde7f77 44
c7de829c 45 for (i=0; i<MAX_MENU_OPTIONS; i++) odata[i].used = 0;
8bde7f77 46
c7de829c
WD
47 root_menu = root;
48}
49
50option_data_t *menu_alloc_odata(void)
51{
52 int i;
53 for (int i=0; i<MAX_MENU_OPTIONS; i++)
54 {
55 if (odata[i].used == 0) return &odata[i];
56 }
57 return NULL;
58}
59
60void menu_free_odata(option_data_t *odata)
61{
62 odata->used = 0;
63}
64
65void menu_layout (menu_t *menu)
66{