Mercurial > dwindows
comparison mac/dw.m @ 1375:611893219ba9
Implemented dw_menu_delete_item() on the Mac.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 22 Nov 2011 21:22:36 +0000 |
parents | 890890c31ba6 |
children | 52bbb1acce61 |
comparison
equal
deleted
inserted
replaced
1374:d5c1ce21577e | 1375:611893219ba9 |
---|---|
7248 } | 7248 } |
7249 } | 7249 } |
7250 } | 7250 } |
7251 | 7251 |
7252 /* | 7252 /* |
7253 * Deletes the menu item specified. | |
7254 * Parameters: | |
7255 * menu: The handle to the menu in which the item was appended. | |
7256 * id: Menuitem id. | |
7257 * Returns: | |
7258 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure. | |
7259 */ | |
7260 int API dw_menu_delete_item(HMENUI menux, unsigned long itemid) | |
7261 { | |
7262 id menu = menux; | |
7263 NSMenuItem *menuitem = (NSMenuItem *)[menu itemWithTag:itemid]; | |
7264 | |
7265 if(menuitem != nil) | |
7266 { | |
7267 [menu removeItem:menuitem]; | |
7268 [menuitem release]; | |
7269 return DW_ERROR_NONE; | |
7270 } | |
7271 return DW_ERROR_UNKNOWN; | |
7272 } | |
7273 | |
7274 /* | |
7253 * Sets the state of a menu item. | 7275 * Sets the state of a menu item. |
7254 * Parameters: | 7276 * Parameters: |
7255 * menu: The handle to the existing menu. | 7277 * menu: The handle to the existing menu. |
7256 * id: Menuitem id. | 7278 * id: Menuitem id. |
7257 * flags: DW_MIS_ENABLED/DW_MIS_DISABLED | 7279 * flags: DW_MIS_ENABLED/DW_MIS_DISABLED |
7986 { | 8008 { |
7987 int _locked_by_me = FALSE; | 8009 int _locked_by_me = FALSE; |
7988 DW_MUTEX_LOCK; | 8010 DW_MUTEX_LOCK; |
7989 id object = handle; | 8011 id object = handle; |
7990 | 8012 |
7991 /* Handle destroying a top-levle window */ | 8013 /* Handle destroying a top-level window */ |
7992 if([ object isKindOfClass:[ NSWindow class ] ]) | 8014 if([ object isKindOfClass:[ NSWindow class ] ]) |
7993 { | 8015 { |
7994 DWWindow *window = handle; | 8016 DWWindow *window = handle; |
7995 [window close]; | 8017 [window close]; |
8018 } | |
8019 /* Handle removing menu items from menus */ | |
8020 else if([ object isKindOfClass:[NSMenuItem class]]) | |
8021 { | |
8022 NSMenu *menu = [object menu]; | |
8023 | |
8024 if(menu) | |
8025 { | |
8026 [menu removeItem:object]; | |
8027 [object release]; | |
8028 } | |
7996 } | 8029 } |
7997 /* Handle destroying a control or box */ | 8030 /* Handle destroying a control or box */ |
7998 else if([object isKindOfClass:[DWBox class]] || [object isKindOfClass:[DWGroupBox class]] || [object isKindOfClass:[NSControl class]]) | 8031 else if([object isKindOfClass:[DWBox class]] || [object isKindOfClass:[DWGroupBox class]] || [object isKindOfClass:[NSControl class]]) |
7999 { | 8032 { |
8000 DWBox *parent = (DWBox *)[object superview]; | 8033 DWBox *parent = (DWBox *)[object superview]; |