]>
Commit | Line | Data |
---|---|---|
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 | |
489468fe SC |
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" | |
524c47aa SC |
16 | #include "wx/osx/private.h" |
17 | ||
bbca44f1 SC |
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 | ||
03647350 VZ |
34 | wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer, |
35 | wxWindowMac* parent, | |
36 | wxWindowID WXUNUSED(id), | |
524c47aa SC |
37 | wxInt32 value, |
38 | wxInt32 minimum, | |
39 | wxInt32 maximum, | |
03647350 | 40 | const wxPoint& pos, |
524c47aa | 41 | const wxSize& size, |
03647350 | 42 | long style, |
a4fec5b4 | 43 | long WXUNUSED(extraStyle)) |
524c47aa SC |
44 | { |
45 | Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size ); | |
489468fe SC |
46 | int tickMarks = 0; |
47 | if ( style & wxSL_AUTOTICKS ) | |
524c47aa | 48 | tickMarks = (maximum - minimum) + 1; // +1 for the 0 value |
489468fe | 49 | |
3d167787 | 50 | // keep the number of tickmarks from becoming unwieldy, therefore below it is ok to cast |
489468fe SC |
51 | // it to a UInt16 |
52 | while (tickMarks > 20) | |
53 | tickMarks /= 5; | |
54 | ||
524c47aa | 55 | |
bbca44f1 | 56 | wxMacControl* peer = new wxMacSliderCarbonControl( wxpeer ); |
489468fe SC |
57 | OSStatus err = CreateSliderControl( |
58 | MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds, | |
524c47aa | 59 | value, minimum, maximum, |
489468fe SC |
60 | kControlSliderPointsDownOrRight, |
61 | (UInt16) tickMarks, true /* liveTracking */, | |
62 | GetwxMacLiveScrollbarActionProc(), | |
524c47aa | 63 | peer->GetControlRefAddr() ); |
489468fe SC |
64 | verify_noerr( err ); |
65 | ||
524c47aa | 66 | return peer; |
489468fe SC |
67 | } |
68 | ||
69 | #endif // wxUSE_SLIDER |