]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/slider.h
build fix for wxGTK/Univ build (#9706)
[wxWidgets.git] / include / wx / univ / slider.h
CommitLineData
1e6feb95
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/univ/slider.h
3// Purpose: wxSlider control for wxUniversal
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 09.02.01
7// RCS-ID: $Id$
442b35b5 8// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
65571936 9// Licence: wxWindows licence
1e6feb95
VZ
10///////////////////////////////////////////////////////////////////////////////
11
1e6feb95
VZ
12#ifndef _WX_UNIV_SLIDER_H_
13#define _WX_UNIV_SLIDER_H_
14
15#include "wx/univ/scrthumb.h"
16
17// ----------------------------------------------------------------------------
18// the actions supported by this control
19// ----------------------------------------------------------------------------
20
21// our actions are the same as scrollbars
22
23#define wxACTION_SLIDER_START _T("start") // to the beginning
24#define wxACTION_SLIDER_END _T("end") // to the end
25#define wxACTION_SLIDER_LINE_UP _T("lineup") // one line up/left
26#define wxACTION_SLIDER_PAGE_UP _T("pageup") // one page up/left
27#define wxACTION_SLIDER_LINE_DOWN _T("linedown") // one line down/right
28#define wxACTION_SLIDER_PAGE_DOWN _T("pagedown") // one page down/right
29#define wxACTION_SLIDER_PAGE_CHANGE _T("pagechange")// change page by numArg
30
31#define wxACTION_SLIDER_THUMB_DRAG _T("thumbdrag")
32#define wxACTION_SLIDER_THUMB_MOVE _T("thumbmove")
33#define wxACTION_SLIDER_THUMB_RELEASE _T("thumbrelease")
34
35// ----------------------------------------------------------------------------
36// wxSlider
37// ----------------------------------------------------------------------------
38
53a2db12 39class WXDLLIMPEXP_CORE wxSlider : public wxSliderBase,
1e6feb95
VZ
40 public wxControlWithThumb
41{
42public:
43 // ctors and such
44 wxSlider();
45
46 wxSlider(wxWindow *parent,
47 wxWindowID id,
48 int value, int minValue, int maxValue,
49 const wxPoint& pos = wxDefaultPosition,
50 const wxSize& size = wxDefaultSize,
51 long style = wxSL_HORIZONTAL,
52 const wxValidator& validator = wxDefaultValidator,
53 const wxString& name = wxSliderNameStr);
54
55 bool Create(wxWindow *parent,
56 wxWindowID id,
57 int value, int minValue, int maxValue,
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize,
60 long style = wxSL_HORIZONTAL,
61 const wxValidator& validator = wxDefaultValidator,
62 const wxString& name = wxSliderNameStr);
63
64 // implement base class pure virtuals
65 virtual int GetValue() const;
66 virtual void SetValue(int value);
67
68 virtual void SetRange(int minValue, int maxValue);
69 virtual int GetMin() const;
70 virtual int GetMax() const;
71
72 virtual void SetLineSize(int lineSize);
73 virtual void SetPageSize(int pageSize);
74 virtual int GetLineSize() const;
75 virtual int GetPageSize() const;
76
77 virtual void SetThumbLength(int lenPixels);
78 virtual int GetThumbLength() const;
79
80 virtual void SetTickFreq(int n, int WXUNUSED(dummy) = 0);
81 virtual int GetTickFreq() const { return m_tickFreq; }
82
83 // wxUniv-specific methods
84 // -----------------------
85
86 // is this a vertical slider?
87 bool IsVert() const { return (GetWindowStyle() & wxSL_VERTICAL) != 0; }
88
89 // get the slider orientation
90 wxOrientation GetOrientation() const
91 { return IsVert() ? wxVERTICAL : wxHORIZONTAL; }
92
93 // do we have labels?
88d2e567
WS
94 bool HasLabels() const
95 { return ((GetWindowStyle() & wxSL_LABELS) != 0) &&
6766e5d1 96 ((GetWindowStyle() & (wxSL_TOP|wxSL_BOTTOM|wxSL_LEFT|wxSL_RIGHT)) != 0); }
1e6feb95
VZ
97
98 // do we have ticks?
88d2e567
WS
99 bool HasTicks() const
100 { return ((GetWindowStyle() & wxSL_TICKS) != 0) &&
6766e5d1 101 ((GetWindowStyle() & (wxSL_TOP|wxSL_BOTTOM|wxSL_LEFT|wxSL_RIGHT|wxSL_BOTH)) != 0); }
1e6feb95
VZ
102
103 // implement wxControlWithThumb interface
104 virtual wxWindow *GetWindow() { return this; }
105 virtual bool IsVertical() const { return IsVert(); }
106
107 virtual wxScrollThumb::Shaft HitTest(const wxPoint& pt) const;
108 virtual wxCoord ThumbPosToPixel() const;
109 virtual int PixelToThumbPos(wxCoord x) const;
110
111 virtual void SetShaftPartState(wxScrollThumb::Shaft shaftPart,
112 int flag,
a290fa5a 113 bool set = true);
1e6feb95
VZ
114
115 virtual void OnThumbDragStart(int pos);
116 virtual void OnThumbDrag(int pos);
117 virtual void OnThumbDragEnd(int pos);
118 virtual void OnPageScrollStart();
119 virtual bool OnPageScroll(int pageInc);
120
9467bdb7 121 // for wxStdSliderInputHandler
1e6feb95
VZ
122 wxScrollThumb& GetThumb() { return m_thumb; }
123
6f02a879
VZ
124 virtual bool PerformAction(const wxControlAction& action,
125 long numArg = 0,
126 const wxString& strArg = wxEmptyString);
127
9467bdb7
VZ
128 static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
129 virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
130 {
131 return GetStdInputHandler(handlerDef);
132 }
133
1e6feb95
VZ
134protected:
135 enum
136 {
137 INVALID_THUMB_VALUE = -0xffff
138 };
139
140 // overridden base class virtuals
141 virtual wxSize DoGetBestClientSize() const;
142 virtual void DoDraw(wxControlRenderer *renderer);
143 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
144
1e6feb95
VZ
145 // event handlers
146 void OnSize(wxSizeEvent& event);
147
148 // common part of all ctors
149 void Init();
150
151 // normalize the value to fit in the range
152 int NormalizeValue(int value) const;
153
a290fa5a 154 // change the value by the given increment, return true if really changed
1e6feb95
VZ
155 bool ChangeValueBy(int inc);
156
157 // change the value to the given one
158 bool ChangeValueTo(int value);
159
160 // is the value inside the range?
161 bool IsInRange(int value) { return (value >= m_min) && (value <= m_max); }
162
163 // format the value for printing as label
164 virtual wxString FormatValue(int value) const;
165
166 // calculate max label size
167 wxSize CalcLabelSize() const;
168
169 // calculate m_rectLabel/Slider
170 void CalcGeometry();
171
172 // get the thumb size
173 wxSize GetThumbSize() const;
174
175 // get the shaft rect (uses m_rectSlider which is supposed to be calculated)
176 wxRect GetShaftRect() const;
177
178 // calc the current thumb position using the shaft rect (if the pointer is
179 // NULL, we calculate it here too)
180 void CalcThumbRect(const wxRect *rectShaft,
181 wxRect *rectThumbOut,
182 wxRect *rectLabelOut,
183 int value = INVALID_THUMB_VALUE) const;
184
185 // return the slider rect calculating it if needed
186 const wxRect& GetSliderRect() const;
187
188 // refresh the current thumb position
189 void RefreshThumb();
190
191private:
192 // get the default thumb size (without using m_thumbSize)
193 wxSize GetDefaultThumbSize() const;
194
195 // the object which manages our thumb
196 wxScrollThumb m_thumb;
197
198 // the slider range and value
199 int m_min,
200 m_max,
201 m_value;
202
203 // the tick frequence (default is 1)
204 int m_tickFreq;
205
206 // the line and page increments (logical units)
207 int m_lineSize,
208 m_pageSize;
209
210 // the size of the thumb (in pixels)
211 int m_thumbSize;
212
213 // the part of the client area reserved for the label, the ticks and the
214 // part for the slider itself
215 wxRect m_rectLabel,
216 m_rectTicks,
217 m_rectSlider;
218
219 // the state of the thumb (wxCONTROL_XXX constants sum)
220 int m_thumbFlags;
221
222 DECLARE_EVENT_TABLE()
223 DECLARE_DYNAMIC_CLASS(wxSlider)
224};
225
1e6feb95 226#endif // _WX_UNIV_SLIDER_H_