blob: c0c63a89ddc3b6a34f88a7c7663394154f5f3aef [file] [log] [blame]
wdenkc7de8292002-11-19 11:04:11 +00001#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);
wdenk8bde7f72003-06-27 21:31:46 +000044
wdenkc7de8292002-11-19 11:04:11 +000045 for (i=0; i<MAX_MENU_OPTIONS; i++) odata[i].used = 0;
wdenk8bde7f72003-06-27 21:31:46 +000046
wdenkc7de8292002-11-19 11:04:11 +000047 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{