1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/NSControl.cpp
3 // Purpose: wxCocoaNSControl
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 #include "wx/wxprec.h"
25 #include "wx/cocoa/objc/objc_uniquifying.h"
26 #include "wx/cocoa/ObjcRef.h"
27 #include "wx/cocoa/NSControl.h"
29 #import <Foundation/NSObject.h>
31 // ============================================================================
32 // @class wxNSControlTarget
33 // ============================================================================
34 @interface wxNSControlTarget : NSObject
38 - (void)wxNSControlAction: (id)sender;
39 @end //interface wxNSControlTarget
40 WX_DECLARE_GET_OBJC_CLASS(wxNSControlTarget,NSObject)
42 @implementation wxNSControlTarget : NSObject
44 - (void)wxNSControlAction: (id)sender
46 wxLogTrace(wxTRACE_COCOA,wxT("wxNSControlAction"));
47 wxCocoaNSControl *wxcontrol = wxCocoaNSControl::GetFromCocoa(sender);
48 wxCHECK_RET(wxcontrol,wxT("wxNSControlAction received but no wxCocoaNSControl exists!"));
49 wxcontrol->CocoaTarget_action();
52 @end //implementation wxNSControlTarget
53 WX_IMPLEMENT_GET_OBJC_CLASS(wxNSControlTarget,NSObject)
55 // ============================================================================
57 // ============================================================================
58 WX_IMPLEMENT_OBJC_INTERFACE(NSControl)
60 // New CF-retained observer (this should have been using wxObjcAutoRefFromAlloc to begin with)
61 wxObjcAutoRefFromAlloc<wxNSControlTarget*> s_cocoaNSControlTarget = [[WX_GET_OBJC_CLASS(wxNSControlTarget) alloc] init];
62 // For compatibility with old code
63 struct objc_object *wxCocoaNSControl::sm_cocoaTarget = s_cocoaNSControlTarget;