]>
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 | ||
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 | // ============================================================================ | |
feb82768 | 34 | // @class wxNSButtonTarget |
fb896a32 | 35 | // ============================================================================ |
feb82768 | 36 | @interface wxNSButtonTarget : NSObject |
fb896a32 DE |
37 | { |
38 | } | |
39 | ||
40 | - (void)wxNSButtonAction: (id)sender; | |
feb82768 | 41 | @end // wxNSButtonTarget |
fb896a32 | 42 | |
feb82768 | 43 | @implementation wxNSButtonTarget : NSObject |
fb896a32 DE |
44 | - (void)wxNSButtonAction: (id)sender |
45 | { | |
feb82768 | 46 | wxCocoaNSButton *button = wxCocoaNSButton::GetFromCocoa(sender); |
2b030203 | 47 | wxCHECK_RET(button,wxT("wxNSButtonAction received without associated wx object")); |
fb896a32 DE |
48 | button->Cocoa_wxNSButtonAction(); |
49 | } | |
50 | ||
feb82768 DE |
51 | @end // implementation wxNSButtonTarget |
52 | ||
53 | // ============================================================================ | |
54 | // class wxCocoaNSButton | |
55 | // ============================================================================ | |
56 | const wxObjcAutoRefFromAlloc<struct objc_object*> wxCocoaNSButton::sm_cocoaTarget = [[wxNSButtonTarget alloc] init]; | |
fb896a32 DE |
57 | |
58 | void wxCocoaNSButton::AssociateNSButton(WX_NSButton cocoaNSButton) | |
59 | { | |
bac6f234 DE |
60 | if(cocoaNSButton) |
61 | { | |
62 | sm_cocoaHash.insert(wxCocoaNSButtonHash::value_type(cocoaNSButton,this)); | |
feb82768 | 63 | [cocoaNSButton setTarget: sm_cocoaTarget]; |
bac6f234 DE |
64 | [cocoaNSButton setAction: @selector(wxNSButtonAction:)]; |
65 | } | |
fb896a32 DE |
66 | } |
67 |