Added original works and stubs to CVS repository
[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 David Elliott
9 // Licence:     wxWindows license
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 wxPoserNSButton
35 // ============================================================================
36 @interface wxPoserNSButton : NSButton
37 {
38 }
39
40 - (void)wxNSButtonAction: (id)sender;
41 @end // wxPoserNSButton
42
43 WX_IMPLEMENT_POSER(wxPoserNSButton);
44
45 @implementation wxPoserNSButton :  NSButton
46 - (void)wxNSButtonAction: (id)sender
47 {
48     wxASSERT_MSG(self==sender,"Received wxNSButtonAction from another object");
49     wxCocoaNSButton *button = wxCocoaNSButton::GetFromCocoa(self);
50     wxCHECK_RET(button,"wxNSButtonAction received without associated wx object");
51     button->Cocoa_wxNSButtonAction();
52 }
53
54 @end // implementation wxPoserNSButton
55
56 void wxCocoaNSButton::AssociateNSButton(WX_NSButton cocoaNSButton)
57 {
58     sm_cocoaHash.insert(wxCocoaNSButtonHash::value_type(cocoaNSButton,this));
59     [cocoaNSButton setTarget: cocoaNSButton];
60     [cocoaNSButton setAction: @selector(wxNSButtonAction:)];
61 }
62