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