comparison libmenu/menu.h @ 8197:b31caec933e9

OSD menus initial version
author albeu
date Thu, 14 Nov 2002 23:47:11 +0000
parents
children 98f4e3704a76
comparison
equal deleted inserted replaced
8196:419bdbfdb660 8197:b31caec933e9
1
2 struct menu_priv_s;
3 typedef struct menu_s menu_t;
4
5 struct menu_s {
6 void (*draw)(menu_t* menu,mp_image_t* mpi);
7 void (*read_cmd)(menu_t* menu,int cmd);
8 void (*read_key)(menu_t* menu,int cmd);
9 void (*close)(menu_t* menu);
10 m_struct_t* priv_st;
11 struct menu_priv_s* priv;
12 int show; // Draw it ?
13 int cl; // Close request (user sent a close cmd or
14 menu_t* parent;
15 };
16
17 typedef struct menu_info_s {
18 const char *info;
19 const char *name;
20 const char *author;
21 const char *comment;
22 m_struct_t priv_st; // Config struct definition
23 // cfg is a config struct as defined in cfg_st, it may be used as a priv struct
24 // cfg is filled from the attributs found in the cfg file
25 // the args param hold the content of the balise in the cfg file (if any)
26 int (*open)(menu_t* menu, char* args);
27 } menu_info_t;
28
29
30 #define MENU_CMD_UP 0
31 #define MENU_CMD_DOWN 1
32 #define MENU_CMD_OK 2
33 #define MENU_CMD_CANCEL 3
34
35 /// Global init/uninit
36 int menu_init(char* cfg_file);
37 void menu_unint(void);
38
39 /// Open a menu defined in the config file
40 menu_t* menu_open(char *name);
41
42 void menu_draw(menu_t* menu,mp_image_t* mpi);
43 void menu_read_cmd(menu_t* menu,int cmd);
44 void menu_close(menu_t* menu);
45 void menu_read_key(menu_t* menu,int cmd);
46
47 //// Default implementation
48 void menu_dflt_read_key(menu_t* menu,int cmd);
49
50 /////////// Helpers
51
52 #define MENU_TEXT_TOP (1<<0)
53 #define MENU_TEXT_VCENTER (1<<1)
54 #define MENU_TEXT_BOT (1<<2)
55 #define MENU_TEXT_VMASK (MENU_TEXT_TOP|MENU_TEXT_VCENTER|MENU_TEXT_BOT)
56 #define MENU_TEXT_LEFT (1<<3)
57 #define MENU_TEXT_HCENTER (1<<4)
58 #define MENU_TEXT_RIGHT (1<<5)
59 #define MENU_TEXT_HMASK (MENU_TEXT_LEFT|MENU_TEXT_HCENTER|MENU_TEXT_RIGHT)
60 #define MENU_TEXT_CENTER (MENU_TEXT_VCENTER|MENU_TEXT_HCENTER)
61
62 void menu_draw_text(mp_image_t* mpi, char* txt, int x, int y);
63 int menu_text_length(char* txt);
64 int menu_text_num_lines(char* txt, int max_width);
65
66 void menu_text_size(char* txt,int max_width,
67 int vspace, int warp,
68 int* _w, int* _h);
69
70 void menu_draw_text_full(mp_image_t* mpi,char* txt,
71 int x, int y,int w, int h,
72 int vspace, int warp, int align, int anchor);