1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/slider.mm
4 // Author: Stefan Csomor
7 // RCS-ID: $Id: slider.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/slider.h"
17 #include "wx/osx/private.h"
19 @interface wxNSSlider : NSSlider
21 wxWidgetCocoaImpl* impl;
24 - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation;
25 - (wxWidgetCocoaImpl*) implementation;
27 - (void) clickedAction: (id) sender;
31 @implementation wxNSSlider
33 - (id)initWithFrame:(NSRect)frame
35 [super initWithFrame:frame];
37 [self setTarget: self];
38 [self setAction: @selector(clickedAction:)];
42 - (void) clickedAction: (id) sender
46 wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
48 wxpeer->HandleClicked(0);
52 - (void)setImplementation: (wxWidgetCocoaImpl *) theImplementation
54 impl = theImplementation;
57 - (wxWidgetCocoaImpl*) implementation
69 wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer,
80 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
81 wxNSSlider* v = [[wxNSSlider alloc] initWithFrame:r];
84 if ( style & wxSL_AUTOTICKS )
86 tickMarks = (maximum - minimum) + 1; // +1 for the 0 value
88 // keep the number of tickmarks from becoming unwieldly, therefore below it is ok to cast
90 while (tickMarks > 20)
93 [v setNumberOfTickMarks:tickMarks];
94 [v setTickMarkPosition:NSTickMarkBelow];
97 [v setMinValue: minimum];
98 [v setMaxValue: maximum];
99 [v setFloatValue: (double) value];
100 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
101 [v setImplementation:c];
105 #endif // wxUSE_SLIDER