9 typedef struct W_MenuItem
{
15 int shortcutModifierMask
;
20 struct W_Menu
*submenu
;
24 WMPixmap
*onStateImage
;
25 WMPixmap
*offStateImage
;
26 WMPixmap
*mixedStateImage
;
39 WMGetSeparatorMenuItem(void)
46 WMMenuItemIsSeparator(WMMenuItem
*item
)
53 WMCreateMenuItem(void)
57 item
= wmalloc(sizeof(WMMenuItem
));
58 memset(item
, 0, sizeof(WMMenuItem
));
60 item
->flags
.enabled
= 1;
67 WMDestroyMenuItem(WMMenuItem
*item
)
73 WMReleasePixmap(item
->image
);
75 if (item
->shortcutKey
)
76 wfree(item
->shortcutKey
);
78 if (item
->onStateImage
)
79 WMReleasePixmap(item
->onStateImage
);
81 if (item
->offStateImage
)
82 WMReleasePixmap(item
->offStateImage
);
84 if (item
->mixedStateImage
)
85 WMReleasePixmap(item
->mixedStateImage
);
90 WMGetMenuItemEnabled(WMMenuItem
*item
)
92 return item
->flags
.enabled
;
97 WMSetMenuItemEnabled(WMMenuItem
*item
, Bool flag
)
99 item
->flags
.enabled
= flag
;
104 WMGetMenuItemShortcut(WMMenuItem
*item
)
106 return item
->shortcutKey
;
111 WMGetMenuItemShortcutModifierMask(WMMenuItem
*item
)
113 return item
->shortcutModifierMask
;
119 WMSetMenuItemShortcut(WMMenuItem
*item
, char *shortcut
)
121 if (item
->shortcutKey
)
122 wfree(item
->shortcutKey
);
124 item
->shortcutKey
= wstrdup(shortcut
);
129 WMSetMenuItemShortcutModifierMask(WMMenuItem
*item
, unsigned mask
)
131 item
->shortcutModifierMask
= mask
;
136 WMGetMenuItemRepresentedObject(WMMenuItem
*item
)
143 WMSetMenuItemRepresentedObject(WMMenuItem
*item
, void *object
)
145 item
->object
= object
;
150 WMSetMenuItemAction(WMMenuItem
*item
, WMAction
*action
, void *data
)
152 item
->action
= action
;
158 WMGetMenuItemAction(WMMenuItem
*item
)
165 WMGetMenuItemData(WMMenuItem
*item
)
172 WMSetMenuItemTitle(WMMenuItem
*item
, char *title
)
178 item
->title
= wstrdup(title
);
185 WMGetMenuItemTitle(WMMenuItem
*item
)
192 WMSetMenuItemState(WMMenuItem
*item
, int state
)
194 item
->flags
.state
= state
;
199 WMGetMenuItemState(WMMenuItem
*item
)
201 return item
->flags
.state
;
206 WMSetMenuItemPixmap(WMMenuItem
*item
, WMPixmap
*pixmap
)
209 WMReleasePixmap(item
->image
);
211 item
->image
= WMRetainPixmap(pixmap
);
216 WMGetMenuItemPixmap(WMMenuItem
*item
)
223 WMSetMenuItemOnStatePixmap(WMMenuItem
*item
, WMPixmap
*pixmap
)
225 if (item
->onStateImage
)
226 WMReleasePixmap(item
->onStateImage
);
228 item
->onStateImage
= WMRetainPixmap(pixmap
);
233 WMGetMenuItemOnStatePixmap(WMMenuItem
*item
)
235 return item
->onStateImage
;
240 WMSetMenuItemOffStatePixmap(WMMenuItem
*item
, WMPixmap
*pixmap
)
242 if (item
->offStateImage
)
243 WMReleasePixmap(item
->offStateImage
);
245 item
->offStateImage
= WMRetainPixmap(pixmap
);
250 WMGetMenuItemOffStatePixmap(WMMenuItem
*item
)
252 return item
->offStateImage
;
258 WMSetMenuItemMixedStatePixmap(WMMenuItem
*item
, WMPixmap
*pixmap
)
260 if (item
->mixedStateImage
)
261 WMReleasePixmap(item
->mixedStateImage
);
263 item
->mixedStateImage
= WMRetainPixmap(pixmap
);
268 WMGetMenuItemMixedStatePixmap(WMMenuItem
*item
)
270 return item
->mixedStateImage
;
276 WMSetMenuItemSubmenu(WMMenuItem *item, WMMenu *submenu)
278 item->submenu = submenu;
283 WMGetMenuItemSubmenu(WMMenuItem *item)
285 return item->submenu;
291 WMGetMenuItemHasSubmenu(WMMenuItem *item)
293 return item->submenu != NULL;