]> git.saurik.com Git - wxWidgets.git/blob - src/osx/cocoa/spinbutt.mm
872bef97a8fb7d0584c234e8ec6afa620f094b70
[wxWidgets.git] / src / osx / cocoa / spinbutt.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: spinbutt.cpp
3 // Purpose: wxSpinButton
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // RCS-ID: $Id: spinbutt.cpp 54129 2008-06-11 19:30:52Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13
14 #if wxUSE_SPINBTN
15
16 #include "wx/spinbutt.h"
17 #include "wx/osx/private.h"
18
19 @interface wxNSStepper : NSStepper
20 {
21 WXCOCOAIMPL_COMMON_MEMBERS
22 }
23
24 WXCOCOAIMPL_COMMON_INTERFACE
25
26 - (void) clickedAction: (id) sender;
27
28 @end
29
30 @implementation wxNSStepper
31
32 - (id)initWithFrame:(NSRect)frame
33 {
34 [super initWithFrame:frame];
35 impl = NULL;
36 [self setTarget: self];
37 [self setAction: @selector(clickedAction:)];
38 return self;
39 }
40
41 - (void) clickedAction: (id) sender
42 {
43 if ( impl )
44 {
45 wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
46 if ( wxpeer )
47 wxpeer->HandleClicked(0);
48 }
49 }
50
51 WXCOCOAIMPL_COMMON_IMPLEMENTATION
52
53 @end
54
55 wxWidgetImplType* wxWidgetImpl::CreateSpinButton( wxWindowMac* wxpeer,
56 wxWindowMac* parent,
57 wxWindowID id,
58 wxInt32 value,
59 wxInt32 minimum,
60 wxInt32 maximum,
61 const wxPoint& pos,
62 const wxSize& size,
63 long style,
64 long extraStyle)
65 {
66 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
67 wxNSStepper* v = [[wxNSStepper alloc] initWithFrame:r];
68
69 [v setMinValue: minimum];
70 [v setMaxValue: maximum];
71 [v setIntValue: value];
72
73 if ( style & wxSP_WRAP )
74 [v setValueWraps:YES];
75
76 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
77 [v setImplementation:c];
78 return c;
79 }
80
81 #endif // wxUSE_SPINBTN