Fix segfault when creating a tearoff menu using a Pixmap background.
[fvwm.git] / fvwm / menuitem.h
blobff7caa134ce6ffe560c92a15a15b6297e70f133d
1 /* -*-c-*- */
3 #ifndef MENUITEM_H
4 #define MENUITEM_H
6 /* ---------------------------- included header files ---------------------- */
8 /* ---------------------------- global definitions ------------------------- */
10 /* ---------------------------- global macros ------------------------------ */
12 #define MI_NEXT_ITEM(i) ((i)->next)
13 #define MI_PREV_ITEM(i) ((i)->prev)
14 #define MI_LABEL(i) ((i)->label)
15 #define MI_LABEL_OFFSET(i) ((i)->label_offset)
16 #define MI_LABEL_STRLEN(i) ((i)->label_strlen)
17 #define MI_PICTURE(i) ((i)->picture)
18 #define MI_MINI_ICON(i) ((i)->lpicture)
19 #define MI_Y_OFFSET(i) ((i)->y_offset)
20 #define MI_HEIGHT(i) ((i)->height)
21 #define MI_ACTION(i) ((i)->action)
22 #define MI_FUNC_TYPE(i) ((i)->func_type)
23 #define MI_HOTKEY_COFFSET(i) ((i)->hotkey_coffset)
24 #define MI_HOTKEY_COLUMN(i) ((i)->hotkey_column)
25 /* flags */
26 #define MI_IS_SEPARATOR(i) ((i)->flags.is_separator)
27 #define MI_IS_TEAR_OFF_BAR(i) ((i)->flags.is_tear_off_bar)
28 #define MI_IS_TITLE(i) ((i)->flags.is_title)
29 #define MI_IS_TITLE_CENTERED(i) ((i)->flags.is_title_centered)
30 #define MI_IS_POPUP(i) ((i)->flags.is_popup)
31 #define MI_IS_MENU(i) ((i)->flags.is_menu)
32 #define MI_IS_CONTINUATION(i) ((i)->flags.is_continuation)
33 #define MI_HAS_TEXT(i) ((i)->flags.has_text)
34 #define MI_HAS_PICTURE(i) ((i)->flags.has_picture)
35 #define MI_HAS_HOTKEY(i) ((i)->flags.has_hotkey)
36 #define MI_IS_HOTKEY_AUTOMATIC(i) ((i)->flags.is_hotkey_automatic)
37 #define MI_IS_SELECTABLE(i) ((i)->flags.is_selectable)
38 /* temporary flags */
39 #define MI_WAS_DESELECTED(i) ((i)->flags.was_deselected)
41 /* ---------------------------- forward declarations ----------------------- */
43 struct MenuStyle;
45 /* ---------------------------- type definitions --------------------------- */
47 /* IMPORTANT NOTE: Don't put members into this struct that can change while the
48 * menu is visible! This will wreak havoc on recursive menus. */
49 typedef struct MenuItem
51 /* next and prev menu items */
52 struct MenuItem *next;
53 struct MenuItem *prev;
55 /* the strings displayed in the item */
56 char *label[MAX_MENU_ITEM_LABELS];
57 /* witdh of label[i] */
58 int label_offset[MAX_MENU_ITEM_LABELS];
59 /* strlen(label[i]) */
60 int label_strlen[MAX_MENU_ITEM_LABELS];
62 /* Pixmap to show above label*/
63 FvwmPicture *picture;
64 /* Pics to show left/right of label */
65 FvwmPicture *lpicture[MAX_MENU_ITEM_MINI_ICONS];
67 /* y offset and height for item */
68 int y_offset;
69 int height;
71 /* action to be performed */
72 char *action;
73 /* type of built in function */
74 short func_type;
75 /* Hot key offset (pete@tecc.co.uk). */
76 int hotkey_coffset;
77 /* The column number the hotkey is defined in*/
78 char hotkey_column;
79 struct
81 unsigned is_continuation : 1;
82 unsigned is_separator : 1;
83 unsigned is_tear_off_bar : 1;
84 unsigned is_title : 1;
85 unsigned is_title_centered : 1;
86 unsigned is_popup : 1;
87 unsigned is_menu : 1;
88 unsigned has_text : 1;
89 unsigned has_picture : 1;
90 unsigned has_hotkey : 1;
91 unsigned is_hotkey_automatic : 1;
92 unsigned is_selectable : 1;
93 /* temporary flags */
94 unsigned was_deselected : 1;
95 } flags;
96 } MenuItem;
98 typedef struct MenuItemPartSizesT
100 int label_width[MAX_MENU_ITEM_LABELS];
101 int icon_width[MAX_MENU_ITEM_MINI_ICONS];
102 int picture_width;
103 int triangle_width;
104 int title_width;
105 } MenuItemPartSizesT;
107 typedef struct MenuPaintItemParameters
109 struct MenuStyle *ms;
110 Window w;
111 struct MenuItem *selected_item;
112 struct MenuDimensions *dim;
113 FvwmWindow *fw;
114 XEvent *ev;
115 int used_mini_icons;
116 struct MenuRoot *cb_mr;
117 /* number of item labels present in the item format */
118 Bool (*cb_reset_bg)(struct MenuRoot *mr, XEvent *pevent);
119 struct
121 unsigned is_first_item : 1;
122 unsigned is_left_triangle : 1;
123 } flags;
124 } MenuPaintItemParameters;
126 /* ---------------------------- exported variables (globals) --------------- */
128 /* ---------------------------- interface functions ------------------------ */
130 struct MenuItem *menuitem_clone(struct MenuItem *mi);
131 struct MenuItem *menuitem_create(void);
132 void menuitem_free(struct MenuItem *mi);
133 void menuitem_get_size(
134 struct MenuItem *mi, struct MenuItemPartSizesT *mipst,
135 FlocaleFont *font, Bool do_reverse_icon_order);
136 void menuitem_paint(
137 struct MenuItem *mi, struct MenuPaintItemParameters *mpip);
138 int menuitem_middle_y_offset(struct MenuItem *mi, struct MenuStyle *ms);
140 #endif /* MENUITEM_H */