]> git.decadent.org.uk Git - ion3.git/blob - mod_menu/menu.h
8d856e0c509986e24a8a955bed34f4303fdf05a5
[ion3.git] / mod_menu / menu.h
1 /*
2  * ion/mod_menu/menu.h
3  *
4  * Copyright (c) Tuomo Valkonen 1999-2007. 
5  *
6  * Ion is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1 of the License, or
9  * (at your option) any later version.
10  */
11
12 #ifndef ION_MOD_MENU_MENU_H
13 #define ION_MOD_MENU_MENU_H
14
15 #include <ioncore/common.h>
16 #include <ioncore/window.h>
17 #include <ioncore/gr.h>
18 #include <ioncore/rectangle.h>
19 #include <ioncore/binding.h>
20
21 INTRCLASS(WMenu);
22 INTRSTRUCT(WMenuEntry);
23
24 #define WMENUENTRY_SUBMENU 0x0001
25
26 DECLSTRUCT(WMenuEntry){
27     char *title;
28     int flags;
29     GrStyleSpec attr;
30 };
31
32 DECLCLASS(WMenu){
33     WWindow win;
34     GrBrush *brush;
35     GrBrush *entry_brush;
36
37     WFitParams last_fp;
38     
39     bool pmenu_mode;
40     bool big_mode;
41     int n_entries, selected_entry;
42     int first_entry, vis_entries;
43     int max_entry_w, entry_h, entry_spacing;
44     WMenuEntry *entries;
45     
46     WMenu *submenu;
47     
48     ExtlTab tab;
49     ExtlFn handler;
50     
51     char *typeahead;
52     
53     uint gm_kcb, gm_state;
54     
55     /*WBindmap *cycle_bindmap;*/
56 };
57
58
59 INTRSTRUCT(WMenuCreateParams);
60
61 DECLSTRUCT(WMenuCreateParams){
62     ExtlFn handler;
63     ExtlTab tab;
64     bool pmenu_mode;
65     bool submenu_mode;
66     bool big_mode;
67     int initial;
68     WRectangle refg;
69 };
70
71
72 extern WMenu *create_menu(WWindow *par, const WFitParams *fp,
73                           const WMenuCreateParams *params);
74 extern bool menu_init(WMenu *menu, WWindow *par, const WFitParams *fp,
75                       const WMenuCreateParams *params);
76 extern void menu_deinit(WMenu *menu);
77
78 extern bool menu_fitrep(WMenu *menu, WWindow *par, const WFitParams *fp);
79
80 extern void menu_finish(WMenu *menu);
81 extern void menu_cancel(WMenu *menu);
82 extern bool menu_rqclose(WMenu *menu);
83 extern void menu_updategr(WMenu *menu);
84
85 extern int menu_entry_at_root(WMenu *menu, int root_x, int root_y);
86 extern void menu_release(WMenu *menu, XButtonEvent *ev);
87 extern void menu_motion(WMenu *menu, XMotionEvent *ev, int dx, int dy);
88 extern void menu_button(WMenu *menu, XButtonEvent *ev);
89 extern int menu_press(WMenu *menu, XButtonEvent *ev, WRegion **reg_ret);
90
91 extern void mod_menu_set_scroll_params(int delay, int amount);
92
93 extern void menu_typeahead_clear(WMenu *menu);
94
95 extern void menu_select_nth(WMenu *menu, int n);
96 extern void menu_select_prev(WMenu *menu);
97 extern void menu_select_next(WMenu *menu);
98
99 #endif /* ION_MOD_MENU_MENU_H */