]>
Commit | Line | Data |
---|---|---|
fb896a32 DE |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: cocoa/NSButton.cpp | |
3 | // Purpose: wxCocoaNSButton | |
4 | // Author: David Elliott | |
5 | // Modified by: | |
6 | // Created: 2003/01/31 | |
feb82768 DE |
7 | // RCS-ID: $Id$ |
8 | // Copyright: (c) 2003-2004 David Elliott | |
065e208e | 9 | // Licence: wxWidgets licence |
fb896a32 DE |
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 | ||
a24aa427 | 25 | #include "wx/cocoa/objc/objc_uniquifying.h" |
fb896a32 DE |
26 | #include "wx/cocoa/NSButton.h" |
27 | #import <AppKit/NSButton.h> | |
28 | ||
29 | // ---------------------------------------------------------------------------- | |
30 | // globals | |
31 | // ---------------------------------------------------------------------------- | |
32 | WX_IMPLEMENT_OBJC_INTERFACE_HASHMAP(NSButton) | |
33 | ||
34 | // ============================================================================ | |
feb82768 | 35 | // @class wxNSButtonTarget |
fb896a32 | 36 | // ============================================================================ |
feb82768 | 37 | @interface wxNSButtonTarget : NSObject |
fb896a32 DE |
38 | { |
39 | } | |
40 | ||
41 | - (void)wxNSButtonAction: (id)sender; | |
feb82768 | 42 | @end // wxNSButtonTarget |
a24aa427 | 43 | WX_DECLARE_GET_OBJC_CLASS(wxNSButtonTarget,NSObject) |
fb896a32 | 44 | |
feb82768 | 45 | @implementation wxNSButtonTarget : NSObject |
fb896a32 DE |
46 | - (void)wxNSButtonAction: (id)sender |
47 | { | |
feb82768 | 48 | wxCocoaNSButton *button = wxCocoaNSButton::GetFromCocoa(sender); |
2b030203 | 49 | wxCHECK_RET(button,wxT("wxNSButtonAction received without associated wx object")); |
fb896a32 DE |
50 | button->Cocoa_wxNSButtonAction(); |
51 | } | |
52 | ||
feb82768 | 53 | @end // implementation wxNSButtonTarget |
a24aa427 | 54 | WX_IMPLEMENT_GET_OBJC_CLASS(wxNSButtonTarget,NSObject) |
feb82768 DE |
55 | |
56 | // ============================================================================ | |
57 | // class wxCocoaNSButton | |
58 | // ============================================================================ | |
a24aa427 | 59 | const wxObjcAutoRefFromAlloc<struct objc_object*> wxCocoaNSButton::sm_cocoaTarget = [[WX_GET_OBJC_CLASS(wxNSButtonTarget) alloc] init]; |
fb896a32 DE |
60 | |
61 | void wxCocoaNSButton::AssociateNSButton(WX_NSButton cocoaNSButton) | |
62 | { | |
bac6f234 DE |
63 | if(cocoaNSButton) |
64 | { | |
65 | sm_cocoaHash.insert(wxCocoaNSButtonHash::value_type(cocoaNSButton,this)); | |
feb82768 | 66 | [cocoaNSButton setTarget: sm_cocoaTarget]; |
bac6f234 DE |
67 | [cocoaNSButton setAction: @selector(wxNSButtonAction:)]; |
68 | } | |
fb896a32 DE |
69 | } |
70 |