Add explanatory comments to the #endif part of multiple inclusion guards.
[mplayer/greg.git] / libmenu / menu.h
blob7d4defaacf79a3b5a68c74d7939f2e09fdedaee4
2 struct menu_priv_s;
3 typedef struct menu_s menu_t;
5 typedef struct menu_def_st menu_def_t;
7 struct m_struct_st;
9 struct menu_s {
10 struct MPContext *ctx;
11 void (*draw)(menu_t* menu,mp_image_t* mpi);
12 void (*read_cmd)(menu_t* menu,int cmd);
13 int (*read_key)(menu_t* menu,int cmd);
14 void (*close)(menu_t* menu);
15 struct m_struct_st* priv_st;
16 struct menu_priv_s* priv;
17 int show; // Draw it ?
18 int cl; // Close request (user sent a close cmd or
19 menu_t* parent;
20 menu_def_t *type;
23 typedef struct menu_info_s {
24 const char *info;
25 const char *name;
26 const char *author;
27 const char *comment;
28 struct m_struct_st priv_st; // Config struct definition
29 // cfg is a config struct as defined in cfg_st, it may be used as a priv struct
30 // cfg is filled from the attributs found in the cfg file
31 // the args param hold the content of the balise in the cfg file (if any)
32 int (*open)(menu_t* menu, char* args);
33 } menu_info_t;
36 #define MENU_CMD_UP 0
37 #define MENU_CMD_DOWN 1
38 #define MENU_CMD_OK 2
39 #define MENU_CMD_CANCEL 3
40 #define MENU_CMD_LEFT 4
41 #define MENU_CMD_RIGHT 5
42 #define MENU_CMD_ACTION 6
43 #define MENU_CMD_HOME 7
44 #define MENU_CMD_END 8
45 #define MENU_CMD_PAGE_UP 9
46 #define MENU_CMD_PAGE_DOWN 10
47 #define MENU_CMD_CLICK 11
49 /// Global init/uninit
50 int menu_init(struct MPContext *mpctx, char* cfg_file);
51 void menu_uninit(void);
53 /// Open a menu defined in the config file
54 menu_t* menu_open(char *name);
56 void menu_draw(menu_t* menu,mp_image_t* mpi);
57 void menu_read_cmd(menu_t* menu,int cmd);
58 void menu_close(menu_t* menu);
59 int menu_read_key(menu_t* menu,int cmd);
61 //// Default implementation
62 int menu_dflt_read_key(menu_t* menu,int cmd);
64 /// Receive mouse position events.
65 void menu_update_mouse_pos(double x, double y);
67 /////////// Helpers
69 #define MENU_TEXT_TOP (1<<0)
70 #define MENU_TEXT_VCENTER (1<<1)
71 #define MENU_TEXT_BOT (1<<2)
72 #define MENU_TEXT_VMASK (MENU_TEXT_TOP|MENU_TEXT_VCENTER|MENU_TEXT_BOT)
73 #define MENU_TEXT_LEFT (1<<3)
74 #define MENU_TEXT_HCENTER (1<<4)
75 #define MENU_TEXT_RIGHT (1<<5)
76 #define MENU_TEXT_HMASK (MENU_TEXT_LEFT|MENU_TEXT_HCENTER|MENU_TEXT_RIGHT)
77 #define MENU_TEXT_CENTER (MENU_TEXT_VCENTER|MENU_TEXT_HCENTER)
79 void menu_draw_text(mp_image_t* mpi, char* txt, int x, int y);
80 int menu_text_length(char* txt);
81 int menu_text_num_lines(char* txt, int max_width);
83 void menu_text_size(char* txt,int max_width,
84 int vspace, int warp,
85 int* _w, int* _h);
87 void menu_draw_text_full(mp_image_t* mpi,char* txt,
88 int x, int y,int w, int h,
89 int vspace, int warp, int align, int anchor);
91 void menu_draw_box(mp_image_t* mpi, unsigned char grey, unsigned char alpha, int x, int y, int w, int h);