Fix segfault setting MenuFace pixmap style for menus.
[fvwm.git] / fvwm / menustyle.h
blob19c4cfff1f4ec20908810b6fb5480c5089f6b25b
1 /* -*-c-*- */
3 #ifndef MENUSTYLE_H
4 #define MENUSTYLE_H
6 /* ---------------------------- included header files ---------------------- */
8 /* ---------------------------- global definitions ------------------------- */
10 /* ---------------------------- global macros ------------------------------ */
12 #define ST_NAME(s) ((s)->name)
13 #define MST_NAME(m) ((m)->s->ms->name)
14 #define ST_NEXT_STYLE(s) ((s)->next_style)
15 #define MST_NEXT_STYLE(m) ((m)->s->ms->next_style)
16 #define ST_USAGE_COUNT(s) ((s)->usage_count)
17 #define MST_USAGE_COUNT(m) ((m)->s->ms->usage_count)
18 /* flags */
19 #define ST_IS_UPDATED(s) ((s)->flags.is_updated)
20 #define MST_IS_UPDATED(m) ((m)->s->ms->flags.is_updated)
21 /* look */
22 #define ST_FACE(s) ((s)->look.face)
23 #define MST_FACE(m) ((m)->s->ms->look.face)
24 #define ST_DO_HILIGHT_BACK(s) ((s)->look.flags.do_hilight_back)
25 #define MST_DO_HILIGHT_BACK(m) ((m)->s->ms->look.flags.do_hilight_back)
26 #define ST_DO_HILIGHT_FORE(s) ((s)->look.flags.do_hilight_fore)
27 #define MST_DO_HILIGHT_FORE(m) ((m)->s->ms->look.flags.do_hilight_fore)
28 #define ST_DO_HILIGHT_TITLE_BACK(s) ((s)->look.flags.do_hilight_title_back)
29 #define MST_DO_HILIGHT_TITLE_BACK(m) \
30 ((m)->s->ms->look.flags.do_hilight_title_back)
31 #define ST_HAS_ACTIVE_FORE(s) ((s)->look.flags.has_active_fore)
32 #define MST_HAS_ACTIVE_FORE(m) ((m)->s->ms->look.flags.has_active_fore)
33 #define ST_HAS_ACTIVE_BACK(s) ((s)->look.flags.has_active_back)
34 #define MST_HAS_ACTIVE_BACK(m) ((m)->s->ms->look.flags.has_active_back)
35 #define ST_HAS_STIPPLE_FORE(s) ((s)->look.flags.has_stipple_fore)
36 #define MST_HAS_STIPPLE_FORE(m) ((m)->s->ms->look.flags.has_stipple_fore)
37 #define ST_HAS_LONG_SEPARATORS(s) ((s)->look.flags.has_long_separators)
38 #define MST_HAS_LONG_SEPARATORS(m) \
39 ((m)->s->ms->look.flags.has_long_separators)
40 #define ST_HAS_TRIANGLE_RELIEF(s) ((s)->look.flags.has_triangle_relief)
41 #define MST_HAS_TRIANGLE_RELIEF(m) \
42 ((m)->s->ms->look.flags.has_triangle_relief)
43 #define ST_HAS_SIDE_COLOR(s) ((s)->look.flags.has_side_color)
44 #define MST_HAS_SIDE_COLOR(m) ((m)->s->ms->look.flags.has_side_color)
45 #define ST_HAS_MENU_CSET(s) ((s)->look.flags.has_menu_cset)
46 #define MST_HAS_MENU_CSET(m) ((m)->s->ms->look.flags.has_menu_cset)
47 #define ST_HAS_ACTIVE_CSET(s) ((s)->look.flags.has_active_cset)
48 #define MST_HAS_ACTIVE_CSET(m) ((m)->s->ms->look.flags.has_active_cset)
49 #define ST_HAS_GREYED_CSET(s) ((s)->look.flags.has_greyed_cset)
50 #define MST_HAS_GREYED_CSET(m) ((m)->s->ms->look.flags.has_greyed_cset)
51 #define ST_HAS_TITLE_CSET(s) ((s)->look.flags.has_title_cset)
52 #define MST_HAS_TITLE_CSET(m) ((m)->s->ms->look.flags.has_title_cset)
53 #define ST_IS_ITEM_RELIEF_REVERSED(s) ((s)->look.flags.is_item_relief_reversed)
54 #define MST_IS_ITEM_RELIEF_REVERSED(m) \
55 ((m)->s->ms->look.flags.is_item_relief_reversed)
56 #define ST_USING_DEFAULT_FONT(s) ((s)->look.flags.using_default_font)
57 #define MST_USING_DEFAULT_FONT(m) \
58 ((m)->s->ms->look.flags.using_default_font)
59 #define ST_USING_DEFAULT_TITLEFONT(s) ((s)->look.flags.using_default_titlefont)
60 #define MST_USING_DEFAULT_TITLEFONT(m) \
61 ((m)->s->ms->look.flags.using_default_titlefont)
62 #define ST_TRIANGLES_USE_FORE(s) ((s)->look.flags.triangles_use_fore)
63 #define MST_TRIANGLES_USE_FORE(m) \
64 ((m)->s->ms->look.flags.triangles_use_fore)
65 #define ST_RELIEF_THICKNESS(s) ((s)->look.ReliefThickness)
66 #define MST_RELIEF_THICKNESS(m) ((m)->s->ms->look.ReliefThickness)
67 #define ST_TITLE_UNDERLINES(s) ((s)->look.TitleUnderlines)
68 #define MST_TITLE_UNDERLINES(m) ((m)->s->ms->look.TitleUnderlines)
69 #define ST_BORDER_WIDTH(s) ((s)->look.BorderWidth)
70 #define MST_BORDER_WIDTH(m) ((m)->s->ms->look.BorderWidth)
71 #define ST_ITEM_GAP_ABOVE(s) ((s)->look.vertical_spacing.item_above)
72 #define MST_ITEM_GAP_ABOVE(m) \
73 ((m)->s->ms->look.vertical_spacing.item_above)
74 #define ST_ITEM_GAP_BELOW(s) ((s)->look.vertical_spacing.item_below)
75 #define MST_ITEM_GAP_BELOW(m) \
76 ((m)->s->ms->look.vertical_spacing.item_below)
77 #define ST_TITLE_GAP_ABOVE(s) ((s)->look.vertical_spacing.title_above)
78 #define MST_TITLE_GAP_ABOVE(m) \
79 ((m)->s->ms->look.vertical_spacing.title_above)
80 #define ST_TITLE_GAP_BELOW(s) ((s)->look.vertical_spacing.title_below)
81 #define MST_TITLE_GAP_BELOW(m) \
82 ((m)->s->ms->look.vertical_spacing.title_below)
83 #define ST_SEPARATOR_GAP_ABOVE(s) \
84 ((s)->look.vertical_spacing.separator_above)
85 #define MST_SEPARATOR_GAP_ABOVE(m) \
86 ((m)->s->ms->look.vertical_spacing.separator_above)
87 #define ST_SEPARATOR_GAP_BELOW(s) \
88 ((s)->look.vertical_spacing.separator_below)
89 #define MST_SEPARATOR_GAP_BELOW(m) \
90 ((m)->s->ms->look.vertical_spacing.separator_below)
91 #define ST_CSET_MENU(s) ((s)->look.cset.menu)
92 #define MST_CSET_MENU(m) ((m)->s->ms->look.cset.menu)
93 #define ST_CSET_ACTIVE(s) ((s)->look.cset.active)
94 #define MST_CSET_ACTIVE(m) ((m)->s->ms->look.cset.active)
95 #define ST_CSET_TITLE(s) ((s)->look.cset.title)
96 #define MST_CSET_TITLE(m) ((m)->s->ms->look.cset.title)
97 #define ST_CSET_GREYED(s) ((s)->look.cset.greyed)
98 #define MST_CSET_GREYED(m) ((m)->s->ms->look.cset.greyed)
99 #define ST_SIDEPIC(s) ((s)->look.side_picture)
100 #define MST_SIDEPIC(m) ((m)->s->ms->look.side_picture)
101 #define ST_SIDE_COLOR(s) ((s)->look.side_color)
102 #define MST_SIDE_COLOR(m) ((m)->s->ms->look.side_color)
103 #define ST_MENU_ACTIVE_GCS(s) ((s)->look.active_gcs)
104 #define MST_MENU_ACTIVE_GCS(m) ((m)->s->ms->look.active_gcs)
105 #define ST_MENU_INACTIVE_GCS(s) ((s)->look.inactive_gcs)
106 #define MST_MENU_INACTIVE_GCS(m) ((m)->s->ms->look.inactive_gcs)
107 #define ST_MENU_STIPPLE_GCS(s) ((s)->look.stipple_gcs)
108 #define MST_MENU_STIPPLE_GCS(m) ((m)->s->ms->look.stipple_gcs)
109 #define ST_MENU_TITLE_GCS(s) ((s)->look.title_gcs)
110 #define MST_MENU_TITLE_GCS(m) ((m)->s->ms->look.title_gcs)
111 #define FORE_GC(g) ((g).fore_gc)
112 #define BACK_GC(g) ((g).back_gc)
113 #define HILIGHT_GC(g) ((g).hilight_gc)
114 #define SHADOW_GC(g) ((g).shadow_gc)
115 #define ST_MENU_STIPPLE_GC(s) ((s)->look.MenuStippleGC)
116 #define MST_MENU_STIPPLE_GC(m) ((m)->s->ms->look.MenuStippleGC)
117 #define ST_MENU_COLORS(s) ((s)->look.MenuColors)
118 #define MST_MENU_COLORS(m) ((m)->s->ms->look.MenuColors)
119 #define ST_MENU_ACTIVE_COLORS(s) ((s)->look.MenuActiveColors)
120 #define MST_MENU_ACTIVE_COLORS(m) ((m)->s->ms->look.MenuActiveColors)
121 #define ST_MENU_STIPPLE_COLORS(s) ((s)->look.MenuStippleColors)
122 #define MST_MENU_STIPPLE_COLORS(m) ((m)->s->ms->look.MenuStippleColors)
123 #define ST_PSTDFONT(s) ((s)->look.pStdFont)
124 #define MST_PSTDFONT(m) ((m)->s->ms->look.pStdFont)
125 #define ST_PTITLEFONT(s) ((s)->look.pTitleFont)
126 #define MST_PTITLEFONT(m) ((m)->s->ms->look.pTitleFont)
127 #define ST_FONT_HEIGHT(s) ((s)->look.FontHeight)
128 #define MST_FONT_HEIGHT(m) ((m)->s->ms->look.FontHeight)
129 /* feel */
130 #define ST_IS_ANIMATED(s) ((s)->feel.flags.is_animated)
131 #define MST_IS_ANIMATED(m) ((m)->s->ms->feel.flags.is_animated)
132 #define ST_DO_POPUP_IMMEDIATELY(s) ((s)->feel.flags.do_popup_immediately)
133 #define MST_DO_POPUP_IMMEDIATELY(m) \
134 ((m)->s->ms->feel.flags.do_popup_immediately)
135 #define ST_DO_POPDOWN_IMMEDIATELY(s) ((s)->feel.flags.do_popdown_immediately)
136 #define MST_DO_POPDOWN_IMMEDIATELY(m) \
137 ((m)->s->ms->feel.flags.do_popdown_immediately)
138 #define ST_DO_WARP_TO_TITLE(s) ((s)->feel.flags.do_warp_to_title)
139 #define MST_DO_WARP_TO_TITLE(m) ((m)->s->ms->feel.flags.do_warp_to_title)
140 #define ST_DO_POPUP_AS(s) ((s)->feel.flags.do_popup_as)
141 #define MST_DO_POPUP_AS(m) ((m)->s->ms->feel.flags.do_popup_as)
142 #define ST_DO_UNMAP_SUBMENU_ON_POPDOWN(s) \
143 ((s)->feel.flags.do_unmap_submenu_on_popdown)
144 #define MST_DO_UNMAP_SUBMENU_ON_POPDOWN(m) \
145 ((m)->s->ms->feel.flags.do_unmap_submenu_on_popdown)
146 #define ST_USE_LEFT_SUBMENUS(s) ((s)->feel.flags.use_left_submenus)
147 #define MST_USE_LEFT_SUBMENUS(m) \
148 ((m)->s->ms->feel.flags.use_left_submenus)
149 #define ST_USE_AUTOMATIC_HOTKEYS(s) ((s)->feel.flags.use_automatic_hotkeys)
150 #define MST_USE_AUTOMATIC_HOTKEYS(m) \
151 ((m)->s->ms->feel.flags.use_automatic_hotkeys)
152 #define ST_MOUSE_WHEEL(s) ((s)->feel.flags.mouse_wheel)
153 #define MST_MOUSE_WHEEL(m) ((m)->s->ms->feel.flags.mouse_wheel)
154 #define ST_SCROLL_OFF_PAGE(s) ((s)->feel.flags.scroll_off_page)
155 #define MST_SCROLL_OFF_PAGE(m) ((m)->s->ms->feel.flags.scroll_off_page)
156 #define ST_FLAGS(s) ((s)->feel.flags)
157 #define MST_FLAGS(m) ((m)->s->ms->feel.flags)
158 #define ST_POPUP_OFFSET_PERCENT(s) ((s)->feel.PopupOffsetPercent)
159 #define MST_POPUP_OFFSET_PERCENT(m) ((m)->s->ms->feel.PopupOffsetPercent)
160 #define ST_POPUP_OFFSET_ADD(s) ((s)->feel.PopupOffsetAdd)
161 #define MST_POPUP_OFFSET_ADD(m) ((m)->s->ms->feel.PopupOffsetAdd)
162 #define ST_ACTIVE_AREA_PERCENT(s) \
163 ((s)->feel.ActiveAreaPercent)
164 #define MST_ACTIVE_AREA_PERCENT(m) \
165 ((m)->s->ms->feel.ActiveAreaPercent)
166 #define ST_POPDOWN_DELAY(s) ((s)->feel.PopdownDelay10ms)
167 #define MST_POPDOWN_DELAY(m) ((m)->s->ms->feel.PopdownDelay10ms)
168 #define ST_POPUP_DELAY(s) ((s)->feel.PopupDelay10ms)
169 #define MST_POPUP_DELAY(m) ((m)->s->ms->feel.PopupDelay10ms)
170 #define ST_DOUBLE_CLICK_TIME(s) ((s)->feel.DoubleClickTime)
171 #define MST_DOUBLE_CLICK_TIME(m) ((m)->s->ms->feel.DoubleClickTime)
172 #define ST_ITEM_FORMAT(s) ((s)->feel.item_format)
173 #define MST_ITEM_FORMAT(m) ((m)->s->ms->feel.item_format)
174 #define ST_SELECT_ON_RELEASE_KEY(s) ((s)->feel.select_on_release_key)
175 #define MST_SELECT_ON_RELEASE_KEY(m) ((m)->s->ms->feel.select_on_release_key)
176 #define ST_VERTICAL_MARGIN_TOP(s) ((s)->look.vertical_margins.top)
177 #define MST_VERTICAL_MARGIN_TOP(m) ((m)->s->ms->look.vertical_margins.top)
178 #define ST_VERTICAL_MARGIN_BOTTOM(s) ((s)->look.vertical_margins.bottom)
179 #define MST_VERTICAL_MARGIN_BOTTOM(m) ((m)->s->ms->look.vertical_margins.bottom)
181 /* ---------------------------- type definitions --------------------------- */
183 typedef enum
185 /* menu types */
186 SimpleMenu = 0,
187 GradientMenu,
188 PixmapMenu,
189 TiledPixmapMenu,
190 SolidMenu
191 /* max button is 8 (0x8) */
192 } MenuFaceType;
194 typedef enum
196 MDP_POST_MENU = 0,
197 MDP_ROOT_MENU = 1,
198 MDP_IGNORE = 2,
199 MDP_CLOSE = 3
200 } ms_do_popup_as_t;
202 typedef enum
204 MMW_OFF = 0,
205 MMW_MENU_BACKWARDS = 1,
206 MMW_MENU = 2,
207 MMW_POINTER = 3
208 } ms_mouse_wheel_t;
210 typedef struct MenuFeel
212 struct
214 unsigned is_animated : 1;
215 unsigned do_popdown_immediately : 1;
216 unsigned do_popup_immediately : 1;
217 unsigned do_popup_as : 2;
218 unsigned do_warp_to_title : 1;
219 unsigned do_unmap_submenu_on_popdown : 1;
220 unsigned use_left_submenus : 1;
221 unsigned use_automatic_hotkeys : 1;
222 unsigned mouse_wheel : 2;
223 unsigned scroll_off_page : 1;
224 } flags;
225 int PopdownDelay10ms;
226 int PopupOffsetPercent;
227 int ActiveAreaPercent;
228 int PopupOffsetAdd;
229 int PopupDelay10ms;
230 int DoubleClickTime;
231 char *item_format;
232 KeyCode select_on_release_key;
233 } MenuFeel;
235 typedef struct MenuFace
237 union
239 FvwmPicture *p;
240 Pixel back;
241 struct
243 int npixels;
244 XColor *xcs;
245 Bool do_dither;
246 } grad;
247 } u;
248 MenuFaceType type;
249 char gradient_type;
250 } MenuFace;
252 typedef struct
254 GC fore_gc;
255 GC back_gc;
256 GC hilight_gc;
257 GC shadow_gc;
258 } gc_quad_t;
260 typedef struct MenuLook
262 MenuFace face;
263 struct
265 unsigned do_hilight_back : 1;
266 unsigned do_hilight_fore : 1;
267 unsigned has_active_fore : 1;
268 unsigned has_active_back : 1;
269 unsigned has_stipple_fore : 1;
270 unsigned has_long_separators : 1;
271 unsigned has_triangle_relief : 1;
272 unsigned has_side_color : 1;
273 unsigned has_menu_cset : 1;
274 unsigned has_active_cset : 1;
275 unsigned has_greyed_cset : 1;
276 unsigned is_item_relief_reversed : 1;
277 unsigned using_default_font : 1;
278 unsigned triangles_use_fore : 1;
279 unsigned has_title_cset : 1;
280 unsigned do_hilight_title_back : 1;
281 unsigned using_default_titlefont : 1;
282 } flags;
283 unsigned char ReliefThickness;
284 unsigned char TitleUnderlines;
285 unsigned char BorderWidth;
286 struct
288 signed char item_above;
289 signed char item_below;
290 signed char title_above;
291 signed char title_below;
292 signed char separator_above;
293 signed char separator_below;
294 } vertical_spacing;
295 struct
297 unsigned char top;
298 unsigned char bottom;
299 } vertical_margins;
300 struct
302 int menu;
303 int active;
304 int greyed;
305 int title;
306 } cset;
307 FvwmPicture *side_picture;
308 Pixel side_color;
309 gc_quad_t inactive_gcs;
310 gc_quad_t active_gcs;
311 gc_quad_t stipple_gcs;
312 gc_quad_t title_gcs;
313 ColorPair MenuColors;
314 ColorPair MenuActiveColors;
315 ColorPair MenuStippleColors;
316 FlocaleFont *pStdFont;
317 FlocaleFont *pTitleFont;
318 int FontHeight;
319 } MenuLook;
321 typedef struct MenuStyle
323 char *name;
324 struct MenuStyle *next_style;
325 int usage_count;
326 MenuLook look;
327 MenuFeel feel;
328 struct
330 unsigned is_updated : 1;
331 } flags;
332 } MenuStyle;
334 /* ---------------------------- exported variables (globals) --------------- */
336 /* ---------------------------- interface functions ------------------------ */
338 void menustyle_free(MenuStyle *ms);
339 MenuStyle *menustyle_find(char *name);
340 void menustyle_update(MenuStyle *ms);
341 MenuStyle *menustyle_parse_style(F_CMD_ARGS);
342 MenuStyle *menustyle_get_default_style(void);
343 void menustyle_copy(MenuStyle *origms, MenuStyle *destms);
345 #endif /* MENUSTYLE_H */