4 typedef struct W_MenuItem
{
10 int shortcutModifierMask
;
15 struct W_Menu
*submenu
;
19 WMPixmap
*onStateImage
;
20 WMPixmap
*offStateImage
;
21 WMPixmap
*mixedStateImage
;
29 WMMenuItem
*WMGetSeparatorMenuItem(void)
34 Bool
WMMenuItemIsSeparator(WMMenuItem
* item
)
39 WMMenuItem
*WMCreateMenuItem(void)
43 item
= wmalloc(sizeof(MenuItem
));
45 item
->flags
.enabled
= 1;
50 void WMDestroyMenuItem(WMMenuItem
* item
)
56 WMReleasePixmap(item
->image
);
58 if (item
->shortcutKey
)
59 wfree(item
->shortcutKey
);
61 if (item
->onStateImage
)
62 WMReleasePixmap(item
->onStateImage
);
64 if (item
->offStateImage
)
65 WMReleasePixmap(item
->offStateImage
);
67 if (item
->mixedStateImage
)
68 WMReleasePixmap(item
->mixedStateImage
);
71 Bool
WMGetMenuItemEnabled(WMMenuItem
* item
)
73 return item
->flags
.enabled
;
76 void WMSetMenuItemEnabled(WMMenuItem
* item
, Bool flag
)
78 item
->flags
.enabled
= ((flag
== 0) ? 0 : 1);
81 char *WMGetMenuItemShortcut(WMMenuItem
* item
)
83 return item
->shortcutKey
;
86 unsigned WMGetMenuItemShortcutModifierMask(WMMenuItem
* item
)
88 return item
->shortcutModifierMask
;
91 void WMSetMenuItemShortcut(WMMenuItem
* item
, const char *shortcut
)
93 if (item
->shortcutKey
)
94 wfree(item
->shortcutKey
);
96 item
->shortcutKey
= wstrdup(shortcut
);
99 void WMSetMenuItemShortcutModifierMask(WMMenuItem
* item
, unsigned mask
)
101 item
->shortcutModifierMask
= mask
;
104 void *WMGetMenuItemRepresentedObject(WMMenuItem
* item
)
109 void WMSetMenuItemRepresentedObject(WMMenuItem
* item
, void *object
)
111 item
->object
= object
;
114 void WMSetMenuItemAction(WMMenuItem
* item
, WMAction
* action
, void *data
)
116 item
->action
= action
;
120 WMAction
*WMGetMenuItemAction(WMMenuItem
* item
)
125 void *WMGetMenuItemData(WMMenuItem
* item
)
130 void WMSetMenuItemTitle(WMMenuItem
* item
, const char *title
)
136 item
->title
= wstrdup(title
);
141 char *WMGetMenuItemTitle(WMMenuItem
* item
)
146 void WMSetMenuItemState(WMMenuItem
* item
, int state
)
148 item
->flags
.state
= state
;
151 int WMGetMenuItemState(WMMenuItem
* item
)
153 return item
->flags
.state
;
156 void WMSetMenuItemPixmap(WMMenuItem
* item
, WMPixmap
* pixmap
)
159 WMReleasePixmap(item
->image
);
161 item
->image
= WMRetainPixmap(pixmap
);
164 WMPixmap
*WMGetMenuItemPixmap(WMMenuItem
* item
)
169 void WMSetMenuItemOnStatePixmap(WMMenuItem
* item
, WMPixmap
* pixmap
)
171 if (item
->onStateImage
)
172 WMReleasePixmap(item
->onStateImage
);
174 item
->onStateImage
= WMRetainPixmap(pixmap
);
177 WMPixmap
*WMGetMenuItemOnStatePixmap(WMMenuItem
* item
)
179 return item
->onStateImage
;
182 void WMSetMenuItemOffStatePixmap(WMMenuItem
* item
, WMPixmap
* pixmap
)
184 if (item
->offStateImage
)
185 WMReleasePixmap(item
->offStateImage
);
187 item
->offStateImage
= WMRetainPixmap(pixmap
);
190 WMPixmap
*WMGetMenuItemOffStatePixmap(WMMenuItem
* item
)
192 return item
->offStateImage
;
195 void WMSetMenuItemMixedStatePixmap(WMMenuItem
* item
, WMPixmap
* pixmap
)
197 if (item
->mixedStateImage
)
198 WMReleasePixmap(item
->mixedStateImage
);
200 item
->mixedStateImage
= WMRetainPixmap(pixmap
);
203 WMPixmap
*WMGetMenuItemMixedStatePixmap(WMMenuItem
* item
)
205 return item
->mixedStateImage
;
209 void WMSetMenuItemSubmenu(WMMenuItem
* item
, WMMenu
* submenu
)
211 item
->submenu
= submenu
;
214 WMMenu
*WMGetMenuItemSubmenu(WMMenuItem
* item
)
216 return item
->submenu
;
219 Bool
WMGetMenuItemHasSubmenu(WMMenuItem
* item
)
221 return item
->submenu
!= NULL
;