1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxSpinButton
4 // Author: Stefan Csomor
7 // RCS-ID: $Id: spinbutt.cpp 54129 2008-06-11 19:30:52Z SC $
8 // Copyright: (c) Stefan Csomor
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
16 #include "wx/spinbutt.h"
17 #include "wx/osx/private.h"
19 @interface wxNSStepper : NSStepper
21 WXCOCOAIMPL_COMMON_MEMBERS
25 WXCOCOAIMPL_COMMON_INTERFACE
27 - (void) clickedAction: (id) sender;
31 @implementation wxNSStepper
33 - (id)initWithFrame:(NSRect)frame
35 [super initWithFrame:frame];
38 [self setTarget: self];
39 [self setAction: @selector(clickedAction:)];
43 - (void) clickedAction: (id) sender
47 wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
50 // because wx expects to be able to veto
51 // a change we must revert the value change
53 int currentValue = [self intValue];
54 [self setIntValue:formerValue];
55 int inc = currentValue-formerValue;
57 // adjust for wrap arounds
64 wxpeer->TriggerScrollEvent(wxEVT_SCROLL_LINEUP);
66 wxpeer->TriggerScrollEvent(wxEVT_SCROLL_LINEDOWN);
68 formerValue = [self intValue];
73 -(void)mouseDown:(NSEvent *)event
75 formerValue = [self intValue];
76 if ( !impl->DoHandleMouseEvent(event) )
77 [super mouseDown:event];
80 WXCOCOAIMPL_COMMON_IMPLEMENTATION_NO_MOUSEDOWN
84 wxWidgetImplType* wxWidgetImpl::CreateSpinButton( wxWindowMac* wxpeer,
95 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
96 wxNSStepper* v = [[wxNSStepper alloc] initWithFrame:r];
98 [v setMinValue: minimum];
99 [v setMaxValue: maximum];
100 [v setIntValue: value];
102 if ( style & wxSP_WRAP )
103 [v setValueWraps:YES];
105 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
106 [v setImplementation:c];
110 #endif // wxUSE_SPINBTN