]> Dogcows Code - chaz/openbox/blob - openbox/menu.h
kill a warning
[chaz/openbox] / openbox / menu.h
1 #ifndef __menu_h
2 #define __menu_h
3
4 #include "action.h"
5 #include "render/render.h"
6 #include "geom.h"
7
8 #include <glib.h>
9
10 struct Menu;
11 struct MenuEntry;
12
13 typedef void(*menu_controller_show)(struct Menu *self, int x, int y, Client *);
14 typedef void(*menu_controller_update)(struct Menu *self);
15 typedef void(*menu_controller_mouseover)(struct MenuEntry *self,
16 gboolean enter);
17
18 extern GHashTable *menu_hash;
19
20 typedef struct Menu {
21 ObWindow obwin;
22
23 char *label;
24 char *name;
25
26 GList *entries;
27
28 gboolean shown;
29 gboolean invalid;
30
31 struct Menu *parent;
32
33 struct Menu *open_submenu;
34
35 /* place a menu on screen */
36 menu_controller_show show;
37 void (*hide)( /* some bummu */);
38
39 /* render a menu */
40 menu_controller_update update;
41 menu_controller_mouseover mouseover;
42 void (*selected)( /* some bummu */);
43
44
45 /* render stuff */
46 Client *client;
47 Window frame;
48 Window title;
49 RrAppearance *a_title;
50 int title_min_w, title_h;
51 Window items;
52 RrAppearance *a_items;
53 int bullet_w;
54 int item_h;
55 Point location;
56 Size size;
57
58 /* plugin stuff */
59 char *plugin;
60 void *plugin_data;
61 } Menu;
62
63 typedef enum MenuEntryRenderType {
64 MenuEntryRenderType_None = 0,
65 MenuEntryRenderType_Submenu = 1 << 0,
66 MenuEntryRenderType_Boolean = 1 << 1,
67 MenuEntryRenderType_Separator = 1 << 2,
68
69 MenuEntryRenderType_Other = 1 << 7
70 } MenuEntryRenderType;
71
72 typedef struct MenuEntry {
73 char *label;
74 Menu *parent;
75
76 Action *action;
77
78 MenuEntryRenderType render_type;
79 gboolean hilite;
80 gboolean enabled;
81 gboolean boolean_value;
82
83 Menu *submenu;
84
85 /* render stuff */
86 Window item;
87 RrAppearance *a_item;
88 RrAppearance *a_disabled;
89 RrAppearance *a_hilite;
90 int y;
91 int min_w;
92 } MenuEntry;
93
94 void menu_startup();
95 void menu_shutdown();
96
97 #define menu_new(l, n, p) \
98 menu_new_full(l, n, p, NULL, NULL)
99
100 Menu *menu_new_full(char *label, char *name, Menu *parent,
101 menu_controller_show show, menu_controller_update update);
102 void menu_free(char *name);
103
104 void menu_show(char *name, int x, int y, Client *client);
105 void menu_show_full(Menu *menu, int x, int y, Client *client);
106
107 void menu_hide(Menu *self);
108
109 void menu_clear(Menu *self);
110
111 MenuEntry *menu_entry_new_full(char *label, Action *action,
112 MenuEntryRenderType render_type,
113 gpointer submenu);
114
115 #define menu_entry_new(label, action) \
116 menu_entry_new_full(label, action, MenuEntryRenderType_None, NULL)
117
118 #define menu_entry_new_separator(label) \
119 menu_entry_new_full(label, NULL, MenuEntryRenderType_Separator, NULL)
120
121 #define menu_entry_new_submenu(label, submenu) \
122 menu_entry_new_full(label, NULL, MenuEntryRenderType_Submenu, submenu)
123
124 #define menu_entry_new_boolean(label, action) \
125 menu_entry_new_full(label, action, MenuEntryRenderType_Boolean, NULL)
126
127 void menu_entry_free(MenuEntry *entry);
128
129 void menu_entry_set_submenu(MenuEntry *entry, Menu *submenu);
130
131 void menu_add_entry(Menu *menu, MenuEntry *entry);
132
133 MenuEntry *menu_find_entry(Menu *menu, Window win);
134
135 void menu_entry_render(MenuEntry *self);
136
137 void menu_entry_fire(MenuEntry *self);
138
139 void menu_render(Menu *self);
140 void menu_render_full(Menu *self);
141
142 void menu_control_mouseover(MenuEntry *entry, gboolean enter);
143 #endif
This page took 0.046347 seconds and 5 git commands to generate.