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