X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9a7247f0e941c83cba9e620ca8541c60ec135a0b..76e7cfab8fdb0c7862fd07e427af54181717fc62:/src/cocoa/NSMenu.mm?ds=sidebyside diff --git a/src/cocoa/NSMenu.mm b/src/cocoa/NSMenu.mm index ef19045c45..fae4e995a2 100644 --- a/src/cocoa/NSMenu.mm +++ b/src/cocoa/NSMenu.mm @@ -1,12 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: cocoa/NSMenu.mm +// Name: src/cocoa/NSMenu.mm // Purpose: wxCocoaNSMenu implementation // Author: David Elliott // Modified by: // Created: 2002/12/09 -// RCS-ID: $Id$ // Copyright: (c) 2002 David Elliott -// Licence: wxWidgets licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" @@ -15,25 +14,17 @@ #include "wx/log.h" #endif // WX_PRECOMP +#include "wx/cocoa/ObjcRef.h" #include "wx/cocoa/NSMenu.h" -#include "wx/cocoa/ObjcPose.h" #import -#import +#include "wx/cocoa/objc/NSMenu.h" // ============================================================================ -// @class wxPoserNSMenu +// @class WXNSMenu // ============================================================================ -@interface wxPoserNSMenu : NSMenu -{ -} - -- (void)dealloc; -@end // wxPoserNSMenu - -WX_IMPLEMENT_POSER(wxPoserNSMenu); -@implementation wxPoserNSMenu : NSMenu +@implementation WXNSMenu : NSMenu - (void)dealloc { @@ -43,7 +34,8 @@ WX_IMPLEMENT_POSER(wxPoserNSMenu); [super dealloc]; } -@end // wxPoserNSMenu +@end // WXNSMenu +WX_IMPLEMENT_GET_OBJC_CLASS(WXNSMenu,NSMenu) // ============================================================================ // @class wxNSMenuNotificationObserver @@ -52,14 +44,13 @@ WX_IMPLEMENT_POSER(wxPoserNSMenu); { } -struct objc_object *wxCocoaNSMenu::sm_cocoaObserver = [[wxNSMenuNotificationObserver alloc] init]; - - (void)menuDidAddItem: (NSNotification *)notification; - (void)menuDidChangeItem: (NSNotification *)notification; - (void)menuDidRemoveItem: (NSNotification *)notification; - (void)menuDidSendAction: (NSNotification *)notification; - (void)menuWillSendAction: (NSNotification *)notification; @end // interface wxNSMenuNotificationObserver +WX_DECLARE_GET_OBJC_CLASS(wxNSMenuNotificationObserver,NSObject) @implementation wxNSMenuNotificationObserver : NSObject @@ -99,12 +90,18 @@ struct objc_object *wxCocoaNSMenu::sm_cocoaObserver = [[wxNSMenuNotificationObse } @end // implementation wxNSMenuNotificationObserver +WX_IMPLEMENT_GET_OBJC_CLASS(wxNSMenuNotificationObserver,NSObject) // ======================================================================== // wxCocoaNSMenu // ======================================================================== WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSMenu) +// New CF-retained observer (this should have been using wxObjcAutoRefFromAlloc to begin with) +static wxObjcAutoRefFromAlloc s_cocoaNSMenuObserver([[WX_GET_OBJC_CLASS(wxNSMenuNotificationObserver) alloc] init]); +// For compatibility with old code +struct objc_object *wxCocoaNSMenu::sm_cocoaObserver = s_cocoaNSMenuObserver; + void wxCocoaNSMenu::AssociateNSMenu(WX_NSMenu cocoaNSMenu, unsigned int flags) { if(cocoaNSMenu)