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