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