1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/NSControl.mm
3 // Purpose: wxCocoaNSControl
4 // Author: David Elliott
7 // Copyright: (c) 2003 David Elliott
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 #include "wx/wxprec.h"
24 #include "wx/cocoa/objc/objc_uniquifying.h"
25 #include "wx/cocoa/ObjcRef.h"
26 #include "wx/cocoa/NSControl.h"
28 #import <Foundation/NSObject.h>
30 // ============================================================================
31 // @class wxNSControlTarget
32 // ============================================================================
33 @interface wxNSControlTarget : NSObject
37 - (void)wxNSControlAction: (id)sender;
38 @end //interface wxNSControlTarget
39 WX_DECLARE_GET_OBJC_CLASS(wxNSControlTarget,NSObject)
41 @implementation wxNSControlTarget : NSObject
43 - (void)wxNSControlAction: (id)sender
45 wxLogTrace(wxTRACE_COCOA,wxT("wxNSControlAction"));
46 wxCocoaNSControl *wxcontrol = wxCocoaNSControl::GetFromCocoa(sender);
47 wxCHECK_RET(wxcontrol,wxT("wxNSControlAction received but no wxCocoaNSControl exists!"));
48 wxcontrol->CocoaTarget_action();
51 @end //implementation wxNSControlTarget
52 WX_IMPLEMENT_GET_OBJC_CLASS(wxNSControlTarget,NSObject)
54 // ============================================================================
56 // ============================================================================
57 WX_IMPLEMENT_OBJC_INTERFACE(NSControl)
59 // New CF-retained observer (this should have been using wxObjcAutoRefFromAlloc to begin with)
60 wxObjcAutoRefFromAlloc<wxNSControlTarget*> s_cocoaNSControlTarget = [[WX_GET_OBJC_CLASS(wxNSControlTarget) alloc] init];
61 // For compatibility with old code
62 struct objc_object *wxCocoaNSControl::sm_cocoaTarget = s_cocoaNSControlTarget;