X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b030203c5926bd6af8bc310469c911f2143f7e1..643e9cf9f61fdbe517b15477f9247ca8ac0b3578:/src/cocoa/NSMenu.mm diff --git a/src/cocoa/NSMenu.mm b/src/cocoa/NSMenu.mm index 60792740f4..4060f544a5 100644 --- a/src/cocoa/NSMenu.mm +++ b/src/cocoa/NSMenu.mm @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: cocoa/NSMenu.mm +// Name: src/cocoa/NSMenu.mm // Purpose: wxCocoaNSMenu implementation // Author: David Elliott // Modified by: @@ -15,27 +15,28 @@ #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" -#if 0 // There is no reason to pose for NSMenu at this time. // ============================================================================ -// @class wxPoserNSMenu +// @class WXNSMenu // ============================================================================ -@interface wxPoserNSMenu : NSMenu -{ -} -@end // wxPoserNSMenu +@implementation WXNSMenu : NSMenu -WX_IMPLEMENT_POSER(wxPoserNSMenu); -@implementation wxPoserNSMenu : NSMenu +- (void)dealloc +{ + wxCocoaNSMenu *menu = wxCocoaNSMenu::GetFromCocoa(self); + if(menu) + menu->Cocoa_dealloc(); + [super dealloc]; +} -@end // wxPoserNSMenu -#endif // 0 +@end // WXNSMenu +WX_IMPLEMENT_GET_OBJC_CLASS(WXNSMenu,NSMenu) // ============================================================================ // @class wxNSMenuNotificationObserver @@ -44,14 +45,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 @@ -91,12 +91,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)