Lots of cleanups to fvwm-menu-desktop
[fvwm.git] / fvwm / menuroot.h
blobd9f33d657d6e4d3fc496e651f736a65d613a749f
1 /* -*-c-*- */
3 #ifndef MENU_ROOT_H
4 #define MENU_ROOT_H
6 /* ---------------------------- included header files ---------------------- */
8 /* Do not #include any files - the file including this file has to take care of
9 * it. */
11 /* ---------------------------- forward declarations ----------------------- */
13 struct MenuItem;
14 struct MenuStyle;
16 /* ---------------------------- type definitions --------------------------- */
19 * MENU ROOT STRUCTURES
22 /* This struct contains the parts of a root menu that are shared among all
23 * copies of the menu */
24 typedef struct MenuRootStatic
26 /* first item in menu */
27 struct MenuItem *first;
28 /* last item in menu */
29 struct MenuItem *last;
31 /* # of copies, 0 if none except this one */
32 int copies;
33 /* # of mapped instances */
34 int usage_count;
35 /* name of root */
36 char *name;
37 struct MenuDimensions dim;
38 int items;
39 FvwmPicture *sidePic;
40 Pixel sideColor;
41 int used_mini_icons;
42 /* Menu Face */
43 struct MenuStyle *ms;
44 /* permanent flags */
45 struct
47 unsigned has_side_color : 1;
48 unsigned is_left_triangle : 1;
49 unsigned is_updated : 1;
50 } flags;
51 struct
53 char *popup_action;
54 char *popdown_action;
55 char *missing_submenu_func;
56 } dynamic;
57 } MenuRootStatic;
59 /* access macros to static menu members */
60 #define MR_FIRST_ITEM(m) ((m)->s->first)
61 #define MR_LAST_ITEM(m) ((m)->s->last)
62 #define MR_COPIES(m) ((m)->s->copies)
63 #define MR_MAPPED_COPIES(m) ((m)->s->usage_count)
64 #define MR_NAME(m) ((m)->s->name)
65 #define MR_DIM(m) ((m)->s->dim)
66 #define MR_WIDTH(m) MDIM_WIDTH((m)->s->dim)
67 #define MR_HEIGHT(m) MDIM_HEIGHT((m)->s->dim)
68 #define MR_ITEM_WIDTH(m) MDIM_ITEM_WIDTH((m)->s->dim)
69 #define MR_SIDEPIC_X_OFFSET(m) MDIM_SIDEPIC_X_OFFSET((m)->s->dim)
70 #define MR_ICON_X_OFFSET(m) MDIM_ICON_X_OFFSET((m)->s->dim)
71 #define MR_TRIANGLE_X_OFFSET(m) MDIM_TRIANGLE_X_OFFSET((m)->s->dim)
72 #define MR_ITEM_X_OFFSET(m) MDIM_ITEM_X_OFFSET((m)->s->dim)
73 #define MR_ITEM_TEXT_Y_OFFSET(m) MDIM_ITEM_TEXT_Y_OFFSET((m)->s->dim)
74 #define MR_HILIGHT_X_OFFSET(m) MDIM_HILIGHT_X_OFFSET((m)->s->dim)
75 #define MR_HILIGHT_WIDTH(m) MDIM_HILIGHT_WIDTH((m)->s->dim)
76 #define MR_SCREEN_WIDTH(m) MDIM_SCREEN_WIDTH((m)->s->dim)
77 #define MR_SCREEN_HEIGHT(m) MDIM_SCREEN_HEIGHT((m)->s->dim)
78 #define MR_ITEMS(m) ((m)->s->items)
79 #define MR_SIDEPIC(m) ((m)->s->sidePic)
80 #define MR_SIDECOLOR(m) ((m)->s->sideColor)
81 #define MR_USED_MINI_ICONS(m) ((m)->s->used_mini_icons)
82 #define MR_STYLE(m) ((m)->s->ms)
83 /* flags */
84 #define MR_FLAGS(m) ((m)->s->flags)
85 #define MR_POPUP_ACTION(m) ((m)->s->dynamic.popup_action)
86 #define MR_POPDOWN_ACTION(m) ((m)->s->dynamic.popdown_action)
87 #define MR_MISSING_SUBMENU_FUNC(m) ((m)->s->dynamic.missing_submenu_func)
88 #define MR_HAS_SIDECOLOR(m) ((m)->s->flags.has_side_color)
89 #define MR_IS_LEFT_TRIANGLE(m) ((m)->s->flags.is_left_triangle)
90 #define MR_IS_UPDATED(m) ((m)->s->flags.is_updated)
92 /* This struct contains the parts of a root menu that differ in all copies of
93 * the menu */
94 typedef struct MenuRootDynamic
96 /* the first copy of the current menu */
97 struct MenuRoot *original_menu;
98 /* next in list of root menus */
99 struct MenuRoot *next_menu;
100 /* continuation of this menu (too tall for screen) */
101 struct MenuRoot *continuation_menu;
102 /* can get the menu that this popped up through selected_item->mr when
103 * selected is a popup menu item */
104 /* the menu that popped this up, if any */
105 struct MenuRoot *parent_menu;
106 /* the menu item that popped this up, if any */
107 struct MenuItem *parent_item;
108 /* the display used to create the menu. Can't use the normal display
109 * because 'xkill' would kill the window manager if used on a tear off
110 * menu. */
111 Display *create_dpy;
112 /* the window of the menu */
113 Window window;
114 /* the selected item in menu */
115 struct MenuItem *selected_item;
116 /* item that has it's submenu mapped */
117 struct MenuItem *submenu_item;
118 /* x distance window was moved by animation */
119 int xanimation;
120 /* dynamic temp flags */
121 struct
123 /* is win background set? */
124 unsigned is_background_set : 1;
125 unsigned is_destroyed : 1;
126 /* menu direction relative to parent menu */
127 unsigned is_left : 1;
128 unsigned is_right : 1;
129 unsigned is_up : 1;
130 unsigned is_down : 1;
131 unsigned is_painted : 1;
132 unsigned is_tear_off_menu : 1;
133 unsigned has_popped_up_left : 1;
134 unsigned has_popped_up_right : 1;
135 } dflags;
136 struct
138 Pixmap stored;
139 int width;
140 int height;
141 int y;
142 } stored_item;
143 struct
145 Pixel *d_pixels;
146 int d_npixels;
147 } stored_pixels;
148 /* alloc pixels when dithering is used for gradients */
149 } MenuRootDynamic;
151 /* access macros to dynamic menu members */
152 #define MR_ORIGINAL_MENU(m) ((m)->d->original_menu)
153 #define MR_NEXT_MENU(m) ((m)->d->next_menu)
154 #define MR_CONTINUATION_MENU(m) ((m)->d->continuation_menu)
155 #define MR_PARENT_MENU(m) ((m)->d->parent_menu)
156 #define MR_PARENT_ITEM(m) ((m)->d->parent_item)
157 #define MR_CREATE_DPY(m) ((m)->d->create_dpy)
158 #define MR_WINDOW(m) ((m)->d->window)
159 #define MR_SELECTED_ITEM(m) ((m)->d->selected_item)
160 #define MR_SUBMENU_ITEM(m) ((m)->d->submenu_item)
161 #define MR_XANIMATION(m) ((m)->d->xanimation)
162 #define MR_STORED_ITEM(m) ((m)->d->stored_item)
163 #define MR_STORED_PIXELS(m) ((m)->d->stored_pixels)
164 /* flags */
165 #define MR_DYNAMIC_FLAGS(m) ((m)->d->dflags)
166 #define MR_IS_BACKGROUND_SET(m) ((m)->d->dflags.is_background_set)
167 #define MR_IS_DESTROYED(m) ((m)->d->dflags.is_destroyed)
168 #define MR_IS_LEFT(m) ((m)->d->dflags.is_left)
169 #define MR_IS_RIGHT(m) ((m)->d->dflags.is_right)
170 #define MR_IS_UP(m) ((m)->d->dflags.is_up)
171 #define MR_IS_DOWN(m) ((m)->d->dflags.is_down)
172 #define MR_IS_PAINTED(m) ((m)->d->dflags.is_painted)
173 #define MR_IS_TEAR_OFF_MENU(m) ((m)->d->dflags.is_tear_off_menu)
174 #define MR_HAS_POPPED_UP_LEFT(m) ((m)->d->dflags.has_popped_up_left)
175 #define MR_HAS_POPPED_UP_RIGHT(m) ((m)->d->dflags.has_popped_up_right)
177 typedef struct MenuRoot
179 MenuRootStatic *s;
180 MenuRootDynamic *d;
181 } MenuRoot;
182 /* don't forget to initialise new members in NewMenuRoot()! */
184 #endif /* MENU_ROOT_H */