]> git.saurik.com Git - wxWidgets.git/blame_incremental - 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
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/osx/carbon/slider.cpp
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"
17#include "wx/osx/private.h"
18
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
35wxWidgetImplType* wxWidgetImpl::CreateSlider( wxWindowMac* wxpeer,
36 wxWindowMac* parent,
37 wxWindowID WXUNUSED(id),
38 wxInt32 value,
39 wxInt32 minimum,
40 wxInt32 maximum,
41 const wxPoint& pos,
42 const wxSize& size,
43 long style,
44 long WXUNUSED(extraStyle))
45{
46 Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size );
47 int tickMarks = 0;
48 if ( style & wxSL_AUTOTICKS )
49 tickMarks = (maximum - minimum) + 1; // +1 for the 0 value
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
56
57 wxMacControl* peer = new wxMacSliderCarbonControl( wxpeer );
58 OSStatus err = CreateSliderControl(
59 MAC_WXHWND(parent->MacGetTopLevelWindowRef()), &bounds,
60 value, minimum, maximum,
61 kControlSliderPointsDownOrRight,
62 (UInt16) tickMarks, true /* liveTracking */,
63 GetwxMacLiveScrollbarActionProc(),
64 peer->GetControlRefAddr() );
65 verify_noerr( err );
66
67 return peer;
68}
69
70#endif // wxUSE_SLIDER