]> git.saurik.com Git - wxWidgets.git/blame - src/osx/carbon/slider.cpp
Update version to 2.9.4 in version.bkl too and rebake everything.
[wxWidgets.git] / src / osx / carbon / slider.cpp
CommitLineData
489468fe 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/osx/carbon/slider.cpp
489468fe
SC
3// Purpose: wxSlider
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#if wxUSE_SLIDER
15
16#include "wx/slider.h"
524c47aa
SC
17#include "wx/osx/private.h"
18
bbca44f1
SC
19class wxMacSliderCarbonControl : public wxMacControl
20{
21public :
22 wxMacSliderCarbonControl( wxWindowMac* peer ) : wxMacControl( peer )
23 {
24 }
25
26 // work around an OSX bug : if the control is having the keyboard focus it cannot
27 // be set to the full max/min values by dragging
28 virtual bool CanFocus() const
29 {
30 return false;
31 }
32};
33
34
03647350
VZ
35wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer,
36 wxWindowMac* parent,
37 wxWindowID WXUNUSED(id),
524c47aa
SC
38 wxInt32 value,
39 wxInt32 minimum,
40 wxInt32 maximum,
03647350 41 const wxPoint& pos,
524c47aa 42 const wxSize& size,
03647350 43 long style,
a4fec5b4 44 long WXUNUSED(extraStyle))
524c47aa
SC
45{
46 Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size );
489468fe
SC
47 int tickMarks = 0;
48 if ( style & wxSL_AUTOTICKS )
524c47aa 49 tickMarks = (maximum - minimum) + 1; // +1 for the 0 value
489468fe
SC
50
51 // keep the number of tickmarks from becoming unwieldly, therefore below it is ok to cast
52 // it to a UInt16
53 while (tickMarks > 20)
54 tickMarks /= 5;
55
524c47aa 56
bbca44f1 57 wxMacControl* peer = new wxMacSliderCarbonControl( wxpeer );
489468fe
SC
58 OSStatus err = CreateSliderControl(
59 MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds,
524c47aa 60 value, minimum, maximum,
489468fe
SC
61 kControlSliderPointsDownOrRight,
62 (UInt16) tickMarks, true /* liveTracking */,
63 GetwxMacLiveScrollbarActionProc(),
524c47aa 64 peer->GetControlRefAddr() );
489468fe
SC
65 verify_noerr( err );
66
524c47aa 67 return peer;
489468fe
SC
68}
69
70#endif // wxUSE_SLIDER