]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/NSButton.mm
Include wx/log.h according to precompiled headers of wx/wx.h (with other minor cleaning).
[wxWidgets.git] / src / cocoa / NSButton.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/NSButton.cpp
3 // Purpose: wxCocoaNSButton
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/01/31
7 // RCS-ID: $Id$
8 // Copyright: (c) 2003-2004 David Elliott
9 // Licence: wxWidgets licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // ============================================================================
13 // declarations
14 // ============================================================================
15
16 // ----------------------------------------------------------------------------
17 // headers
18 // ----------------------------------------------------------------------------
19
20 #include "wx/wxprec.h"
21 #ifndef WX_PRECOMP
22 #include "wx/log.h"
23 #endif // WX_PRECOMP
24
25 #include "wx/cocoa/NSButton.h"
26 #import <AppKit/NSButton.h>
27
28 // ----------------------------------------------------------------------------
29 // globals
30 // ----------------------------------------------------------------------------
31 WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSButton)
32
33 // ============================================================================
34 // @class wxNSButtonTarget
35 // ============================================================================
36 @interface wxNSButtonTarget : NSObject
37 {
38 }
39
40 - (void)wxNSButtonAction: (id)sender;
41 @end // wxNSButtonTarget
42
43 @implementation wxNSButtonTarget : NSObject
44 - (void)wxNSButtonAction: (id)sender
45 {
46 wxCocoaNSButton *button = wxCocoaNSButton::GetFromCocoa(sender);
47 wxCHECK_RET(button,wxT("wxNSButtonAction received without associated wx object"));
48 button->Cocoa_wxNSButtonAction();
49 }
50
51 @end // implementation wxNSButtonTarget
52
53 // ============================================================================
54 // class wxCocoaNSButton
55 // ============================================================================
56 const wxObjcAutoRefFromAlloc<struct objc_object*> wxCocoaNSButton::sm_cocoaTarget = [[wxNSButtonTarget alloc] init];
57
58 void wxCocoaNSButton::AssociateNSButton(WX_NSButton cocoaNSButton)
59 {
60 if(cocoaNSButton)
61 {
62 sm_cocoaHash.insert(wxCocoaNSButtonHash::value_type(cocoaNSButton,this));
63 [cocoaNSButton setTarget: sm_cocoaTarget];
64 [cocoaNSButton setAction: @selector(wxNSButtonAction:)];
65 }
66 }
67