]> icculus.org git repositories - dana/openbox.git/blob - openbox/menu.h
save the window ids in a map for the menus
[dana/openbox.git] / openbox / menu.h
1 #ifndef __menu_h
2 #define __menu_h
3
4 #include "action.h"
5 #include "render/render.h"
6
7 #include <glib.h>
8
9 extern GHashTable *menu_map;
10
11 typedef struct Menu {
12     char *label;
13     char *name;
14     
15     GList *entries;
16     /* GList *tail; */
17
18     /* ? */
19     gboolean shown;
20     gboolean invalid;
21     gpointer render_data; /* where the engine can store anything it likes */
22
23     struct Menu *parent;
24
25     /* waste o' pointers */
26     void (*show)( /* some bummu */);
27     void (*hide)( /* some bummu */);
28     void (*update)( /* some bummu */);
29     void (*mouseover)( /* some bummu */);
30     void (*selected)( /* some bummu */);
31 } Menu;
32
33 typedef struct MenuRenderData {
34     Window frame;
35     Window title;
36     Appearance *a_title;
37     int title_min_w, title_h;
38     Window items;
39     Appearance *a_items;
40     int item_h;
41 } MenuRenderData;
42
43 typedef enum MenuEntryRenderType {
44     MenuEntryRenderType_None = 0,
45     MenuEntryRenderType_Submenu = 1 << 0,
46     MenuEntryRenderType_Boolean = 1 << 1,
47     MenuEntryRenderType_Separator = 1 << 2,
48     
49     MenuEntryRenderType_Other = 1 << 7
50 } MenuEntryRenderType;
51
52 typedef struct {
53     char *label;
54     Menu *parent;
55
56     Action *action;    
57     
58     MenuEntryRenderType render_type;
59     gboolean enabled;
60     gboolean boolean_value;
61     gpointer render_data; /* where the engine can store anything it likes */
62
63     Menu *submenu;
64 } MenuEntry;
65
66 typedef struct MenuEntryRenderData {
67     Window item;
68     Appearance *a_item;
69     int min_w;
70 } MenuEntryRenderData;
71
72 void menu_startup();
73 void menu_shutdown();
74
75 Menu *menu_new(char *label, char *name, Menu *parent);
76 void menu_free(char *name);
77
78 void menu_show(char *name, int x, int y, Client *client);
79
80 MenuEntry *menu_entry_new_full(char *label, Action *action,
81                                MenuEntryRenderType render_type,
82                                gpointer submenu);
83
84 #define menu_entry_new(label, action) \
85   menu_entry_new_full(label, action, MenuEntryRenderType_None, NULL)
86
87 void menu_entry_free(MenuEntry *entry);
88
89 void menu_entry_set_submenu(MenuEntry *entry, Menu *submenu);
90
91 void menu_add_entry(Menu *menu, MenuEntry *entry);
92 #endif