]> Dogcows Code - chaz/openbox/blob - openbox/menu.h
lwindow needs a type
[chaz/openbox] / openbox / menu.h
1 #ifndef __menu_h
2 #define __menu_h
3
4 #include "action.h"
5 #include "window.h"
6 #include "render/render.h"
7 #include "geom.h"
8
9 #include <glib.h>
10
11 struct _ObClient;
12
13 typedef struct _ObMenu ObMenu;
14 typedef struct _ObMenuEntry ObMenuEntry;
15
16 typedef void(*menu_controller_show)(ObMenu *self, int x, int y,
17 struct _ObClient *);
18 typedef void(*menu_controller_update)(ObMenu *self);
19 typedef void(*menu_controller_mouseover)(ObMenuEntry *self, gboolean enter);
20 typedef void(*menu_controller_selected)(ObMenuEntry *self, unsigned int button,
21 unsigned int x, unsigned int y);
22 typedef void(*menu_controller_hide)(ObMenu *self);
23
24
25 extern GHashTable *menu_hash;
26 extern GList *menu_visible;
27
28 struct _ObMenu
29 {
30 ObWindow obwin;
31
32 gchar *label;
33 gchar *name;
34
35 GList *entries;
36
37 gboolean shown;
38 gboolean invalid;
39
40 ObMenu *parent;
41
42 ObMenu *open_submenu;
43
44 /* place a menu on screen */
45 menu_controller_show show;
46 menu_controller_hide hide;
47
48 /* render a menu */
49 menu_controller_update update;
50 menu_controller_mouseover mouseover;
51 menu_controller_selected selected;
52
53
54 /* render stuff */
55 struct _ObClient *client;
56 Window frame;
57 Window title;
58 RrAppearance *a_title;
59 gint title_min_w, title_h;
60 Window items;
61 RrAppearance *a_items;
62 gint bullet_w;
63 gint item_h;
64 Point location;
65 Size size;
66 guint xin_area; /* index of the xinerama head/area */
67
68 /* plugin stuff */
69 char *plugin;
70 void *plugin_data;
71 };
72
73 typedef enum
74 {
75 OB_MENU_ENTRY_RENDER_TYPE_NONE,
76 OB_MENU_ENTRY_RENDER_TYPE_SUBMENU,
77 OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN,
78 OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR,
79 OB_MENU_ENTRY_RENDER_TYPE_OTHER /* XXX what is this? */
80 } ObMenuEntryRenderType;
81
82 struct _ObMenuEntry
83 {
84 char *label;
85 ObMenu *parent;
86
87 Action *action;
88
89 ObMenuEntryRenderType render_type;
90 gboolean hilite;
91 gboolean enabled;
92 gboolean boolean_value;
93
94 ObMenu *submenu;
95
96 /* render stuff */
97 Window item;
98 RrAppearance *a_item;
99 RrAppearance *a_disabled;
100 RrAppearance *a_hilite;
101 gint y;
102 gint min_w;
103 } MenuEntry;
104
105 typedef struct PluginMenuCreateData{
106 xmlDocPtr doc;
107 xmlNodePtr node;
108 ObMenu *parent;
109 } PluginMenuCreateData;
110
111
112 void menu_startup();
113 void menu_shutdown();
114
115 void menu_noop();
116
117 #define menu_new(l, n, p) \
118 menu_new_full(l, n, p, menu_show_full, menu_render, menu_entry_fire, \
119 menu_hide, menu_control_mouseover)
120
121 ObMenu *menu_new_full(char *label, char *name, ObMenu *parent,
122 menu_controller_show show, menu_controller_update update,
123 menu_controller_selected selected,
124 menu_controller_hide hide,
125 menu_controller_mouseover mouseover);
126
127 void menu_free(char *name);
128
129 void menu_show(char *name, int x, int y, struct _ObClient *client);
130 void menu_show_full(ObMenu *menu, int x, int y, struct _ObClient *client);
131
132 void menu_hide(ObMenu *self);
133
134 void menu_clear(ObMenu *self);
135
136 ObMenuEntry *menu_entry_new_full(char *label, Action *action,
137 ObMenuEntryRenderType render_type,
138 gpointer submenu);
139
140 #define menu_entry_new(label, action) \
141 menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_NONE, NULL)
142
143 #define menu_entry_new_separator(label) \
144 menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SEPARATOR, NULL)
145
146 #define menu_entry_new_submenu(label, submenu) \
147 menu_entry_new_full(label, NULL, OB_MENU_ENTRY_RENDER_TYPE_SUBMENU, submenu)
148
149 #define menu_entry_new_boolean(label, action) \
150 menu_entry_new_full(label, action, OB_MENU_ENTRY_RENDER_TYPE_BOOLEAN, NULL)
151
152 void menu_entry_free(ObMenuEntry *entry);
153
154 void menu_entry_set_submenu(ObMenuEntry *entry, ObMenu *submenu);
155
156 void menu_add_entry(ObMenu *menu, ObMenuEntry *entry);
157
158 ObMenuEntry *menu_find_entry(ObMenu *menu, Window win);
159 ObMenuEntry *menu_find_entry_by_submenu(ObMenu *menu, ObMenu *submenu);
160 ObMenuEntry *menu_find_entry_by_pos(ObMenu *menu, int x, int y);
161
162 void menu_entry_render(ObMenuEntry *self);
163
164 void menu_entry_fire(ObMenuEntry *self, unsigned int button, unsigned int x,
165 unsigned int y);
166
167 void menu_render(ObMenu *self);
168 void menu_render_full(ObMenu *self);
169
170 /*so plugins can call it? */
171 void parse_menu_full(xmlDocPtr doc, xmlNodePtr node, void *data, gboolean new);
172 void menu_control_mouseover(ObMenuEntry *entry, gboolean enter);
173 ObMenuEntry *menu_control_keyboard_nav(ObMenuEntry *over, ObKey key);
174 #endif
This page took 0.045414 seconds and 4 git commands to generate.