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