]>
Commit | Line | Data |
---|---|---|
0f9b48d1 SC |
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 | { | |
4850cc8b | 21 | wxWidgetCocoaImpl* impl; |
0f9b48d1 SC |
22 | } |
23 | ||
4850cc8b SC |
24 | - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation; |
25 | - (wxWidgetCocoaImpl*) implementation; | |
0f9b48d1 SC |
26 | - (BOOL) isFlipped; |
27 | - (void) clickedAction: (id) sender; | |
28 | ||
29 | @end | |
30 | ||
31 | @implementation wxNSStepper | |
32 | ||
33 | - (id)initWithFrame:(NSRect)frame | |
34 | { | |
35 | [super initWithFrame:frame]; | |
36 | impl = NULL; | |
37 | [self setTarget: self]; | |
38 | [self setAction: @selector(clickedAction:)]; | |
39 | return self; | |
40 | } | |
41 | ||
42 | - (void) clickedAction: (id) sender | |
43 | { | |
44 | if ( impl ) | |
45 | { | |
46 | wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer(); | |
47 | if ( wxpeer ) | |
48 | wxpeer->HandleClicked(0); | |
49 | } | |
50 | } | |
51 | ||
4850cc8b | 52 | - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation |
0f9b48d1 SC |
53 | { |
54 | impl = theImplementation; | |
55 | } | |
56 | ||
4850cc8b | 57 | - (wxWidgetCocoaImpl*) implementation |
0f9b48d1 SC |
58 | { |
59 | return impl; | |
60 | } | |
61 | ||
62 | - (BOOL) isFlipped | |
63 | { | |
64 | return YES; | |
65 | } | |
66 | ||
67 | @end | |
68 | ||
69 | wxWidgetImplType* wxWidgetImpl::CreateSpinButton( wxWindowMac* wxpeer, | |
70 | wxWindowMac* parent, | |
71 | wxWindowID id, | |
72 | wxInt32 value, | |
73 | wxInt32 minimum, | |
74 | wxInt32 maximum, | |
75 | const wxPoint& pos, | |
76 | const wxSize& size, | |
77 | long style, | |
78 | long extraStyle) | |
79 | { | |
0f9b48d1 SC |
80 | NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; |
81 | wxNSStepper* v = [[wxNSStepper alloc] initWithFrame:r]; | |
82 | ||
83 | [v setMinValue: minimum]; | |
84 | [v setMaxValue: maximum]; | |
85 | [v setIntValue: value]; | |
86 | ||
87 | if ( style & wxSP_WRAP ) | |
88 | [v setValueWraps:YES]; | |
89 | ||
0f9b48d1 SC |
90 | wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v ); |
91 | [v setImplementation:c]; | |
92 | return c; | |
93 | } | |
94 | ||
95 | #endif // wxUSE_SPINBTN |