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
));
44 memset(item
, 0, sizeof(MenuItem
));
46 item
->flags
.enabled
= 1;
51 void WMDestroyMenuItem(WMMenuItem
* item
)
57 WMReleasePixmap(item
->image
);
59 if (item
->shortcutKey
)
60 wfree(item
->shortcutKey
);
62 if (item
->onStateImage
)
63 WMReleasePixmap(item
->onStateImage
);
65 if (item
->offStateImage
)
66 WMReleasePixmap(item
->offStateImage
);
68 if (item
->mixedStateImage
)
69 WMReleasePixmap(item
->mixedStateImage
);
72 Bool
WMGetMenuItemEnabled(WMMenuItem
* item
)
74 return item
->flags
.enabled
;
77 void WMSetMenuItemEnabled(WMMenuItem
* item
, Bool flag
)
79 item
->flags
.enabled
= ((flag
== 0) ? 0 : 1);
82 char *WMGetMenuItemShortcut(WMMenuItem
* item
)
84 return item
->shortcutKey
;
87 unsigned WMGetMenuItemShortcutModifierMask(WMMenuItem
* item
)
89 return item
->shortcutModifierMask
;
92 void WMSetMenuItemShortcut(WMMenuItem
* item
, char *shortcut
)
94 if (item
->shortcutKey
)
95 wfree(item
->shortcutKey
);
97 item
->shortcutKey
= wstrdup(shortcut
);
100 void WMSetMenuItemShortcutModifierMask(WMMenuItem
* item
, unsigned mask
)
102 item
->shortcutModifierMask
= mask
;
105 void *WMGetMenuItemRepresentedObject(WMMenuItem
* item
)
110 void WMSetMenuItemRepresentedObject(WMMenuItem
* item
, void *object
)
112 item
->object
= object
;
115 void WMSetMenuItemAction(WMMenuItem
* item
, WMAction
* action
, void *data
)
117 item
->action
= action
;
121 WMAction
*WMGetMenuItemAction(WMMenuItem
* item
)
126 void *WMGetMenuItemData(WMMenuItem
* item
)
131 void WMSetMenuItemTitle(WMMenuItem
* item
, char *title
)
137 item
->title
= wstrdup(title
);
142 char *WMGetMenuItemTitle(WMMenuItem
* item
)
147 void WMSetMenuItemState(WMMenuItem
* item
, int state
)
149 item
->flags
.state
= state
;
152 int WMGetMenuItemState(WMMenuItem
* item
)
154 return item
->flags
.state
;
157 void WMSetMenuItemPixmap(WMMenuItem
* item
, WMPixmap
* pixmap
)
160 WMReleasePixmap(item
->image
);
162 item
->image
= WMRetainPixmap(pixmap
);
165 WMPixmap
*WMGetMenuItemPixmap(WMMenuItem
* item
)
170 void WMSetMenuItemOnStatePixmap(WMMenuItem
* item
, WMPixmap
* pixmap
)
172 if (item
->onStateImage
)
173 WMReleasePixmap(item
->onStateImage
);
175 item
->onStateImage
= WMRetainPixmap(pixmap
);
178 WMPixmap
*WMGetMenuItemOnStatePixmap(WMMenuItem
* item
)
180 return item
->onStateImage
;
183 void WMSetMenuItemOffStatePixmap(WMMenuItem
* item
, WMPixmap
* pixmap
)
185 if (item
->offStateImage
)
186 WMReleasePixmap(item
->offStateImage
);
188 item
->offStateImage
= WMRetainPixmap(pixmap
);
191 WMPixmap
*WMGetMenuItemOffStatePixmap(WMMenuItem
* item
)
193 return item
->offStateImage
;
196 void WMSetMenuItemMixedStatePixmap(WMMenuItem
* item
, WMPixmap
* pixmap
)
198 if (item
->mixedStateImage
)
199 WMReleasePixmap(item
->mixedStateImage
);
201 item
->mixedStateImage
= WMRetainPixmap(pixmap
);
204 WMPixmap
*WMGetMenuItemMixedStatePixmap(WMMenuItem
* item
)
206 return item
->mixedStateImage
;
210 void WMSetMenuItemSubmenu(WMMenuItem
* item
, WMMenu
* submenu
)
212 item
->submenu
= submenu
;
215 WMMenu
*WMGetMenuItemSubmenu(WMMenuItem
* item
)
217 return item
->submenu
;
220 Bool
WMGetMenuItemHasSubmenu(WMMenuItem
* item
)
222 return item
->submenu
!= NULL
;