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
)
36 /* Parameter not used, but tell the compiler that it is ok */
42 WMMenuItem
*WMCreateMenuItem(void)
46 item
= wmalloc(sizeof(MenuItem
));
48 item
->flags
.enabled
= 1;
53 void WMDestroyMenuItem(WMMenuItem
* item
)
59 WMReleasePixmap(item
->image
);
61 if (item
->shortcutKey
)
62 wfree(item
->shortcutKey
);
64 if (item
->onStateImage
)
65 WMReleasePixmap(item
->onStateImage
);
67 if (item
->offStateImage
)
68 WMReleasePixmap(item
->offStateImage
);
70 if (item
->mixedStateImage
)
71 WMReleasePixmap(item
->mixedStateImage
);
74 Bool
WMGetMenuItemEnabled(WMMenuItem
* item
)
76 return item
->flags
.enabled
;
79 void WMSetMenuItemEnabled(WMMenuItem
* item
, Bool flag
)
81 item
->flags
.enabled
= ((flag
== 0) ? 0 : 1);
84 char *WMGetMenuItemShortcut(WMMenuItem
* item
)
86 return item
->shortcutKey
;
89 unsigned WMGetMenuItemShortcutModifierMask(WMMenuItem
* item
)
91 return item
->shortcutModifierMask
;
94 void WMSetMenuItemShortcut(WMMenuItem
* item
, const char *shortcut
)
96 if (item
->shortcutKey
)
97 wfree(item
->shortcutKey
);
99 item
->shortcutKey
= wstrdup(shortcut
);
102 void WMSetMenuItemShortcutModifierMask(WMMenuItem
* item
, unsigned mask
)
104 item
->shortcutModifierMask
= mask
;
107 void *WMGetMenuItemRepresentedObject(WMMenuItem
* item
)
112 void WMSetMenuItemRepresentedObject(WMMenuItem
* item
, void *object
)
114 item
->object
= object
;
117 void WMSetMenuItemAction(WMMenuItem
* item
, WMAction
* action
, void *data
)
119 item
->action
= action
;
123 WMAction
*WMGetMenuItemAction(WMMenuItem
* item
)
128 void *WMGetMenuItemData(WMMenuItem
* item
)
133 void WMSetMenuItemTitle(WMMenuItem
* item
, const char *title
)
139 item
->title
= wstrdup(title
);
144 char *WMGetMenuItemTitle(WMMenuItem
* item
)
149 void WMSetMenuItemState(WMMenuItem
* item
, int state
)
151 item
->flags
.state
= state
;
154 int WMGetMenuItemState(WMMenuItem
* item
)
156 return item
->flags
.state
;
159 void WMSetMenuItemPixmap(WMMenuItem
* item
, WMPixmap
* pixmap
)
162 WMReleasePixmap(item
->image
);
164 item
->image
= WMRetainPixmap(pixmap
);
167 WMPixmap
*WMGetMenuItemPixmap(WMMenuItem
* item
)
172 void WMSetMenuItemOnStatePixmap(WMMenuItem
* item
, WMPixmap
* pixmap
)
174 if (item
->onStateImage
)
175 WMReleasePixmap(item
->onStateImage
);
177 item
->onStateImage
= WMRetainPixmap(pixmap
);
180 WMPixmap
*WMGetMenuItemOnStatePixmap(WMMenuItem
* item
)
182 return item
->onStateImage
;
185 void WMSetMenuItemOffStatePixmap(WMMenuItem
* item
, WMPixmap
* pixmap
)
187 if (item
->offStateImage
)
188 WMReleasePixmap(item
->offStateImage
);
190 item
->offStateImage
= WMRetainPixmap(pixmap
);
193 WMPixmap
*WMGetMenuItemOffStatePixmap(WMMenuItem
* item
)
195 return item
->offStateImage
;
198 void WMSetMenuItemMixedStatePixmap(WMMenuItem
* item
, WMPixmap
* pixmap
)
200 if (item
->mixedStateImage
)
201 WMReleasePixmap(item
->mixedStateImage
);
203 item
->mixedStateImage
= WMRetainPixmap(pixmap
);
206 WMPixmap
*WMGetMenuItemMixedStatePixmap(WMMenuItem
* item
)
208 return item
->mixedStateImage
;
212 void WMSetMenuItemSubmenu(WMMenuItem
* item
, WMMenu
* submenu
)
214 item
->submenu
= submenu
;
217 WMMenu
*WMGetMenuItemSubmenu(WMMenuItem
* item
)
219 return item
->submenu
;
222 Bool
WMGetMenuItemHasSubmenu(WMMenuItem
* item
)
224 return item
->submenu
!= NULL
;