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 WXCOCOAIMPL_COMMON_MEMBERS
24 WXCOCOAIMPL_COMMON_INTERFACE
26 - (void) clickedAction: (id) sender;
30 @implementation wxNSSlider
32 - (id)initWithFrame:(NSRect)frame
34 [super initWithFrame:frame];
36 [self setTarget: self];
37 [self setAction: @selector(clickedAction:)];
41 - (void) clickedAction: (id) sender
45 wxWindow* wxpeer = (wxWindow*) impl->GetWXPeer();
47 wxpeer->HandleClicked(0);
51 WXCOCOAIMPL_COMMON_IMPLEMENTATION
55 wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer,
66 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
67 wxNSSlider* v = [[wxNSSlider alloc] initWithFrame:r];
70 if ( style & wxSL_AUTOTICKS )
72 tickMarks = (maximum - minimum) + 1; // +1 for the 0 value
74 // keep the number of tickmarks from becoming unwieldly, therefore below it is ok to cast
76 while (tickMarks > 20)
79 [v setNumberOfTickMarks:tickMarks];
80 [v setTickMarkPosition:NSTickMarkBelow];
83 [v setMinValue: minimum];
84 [v setMaxValue: maximum];
85 [v setFloatValue: (double) value];
86 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
87 [v setImplementation:c];
91 #endif // wxUSE_SLIDER