]> git.saurik.com Git - wxWidgets.git/blob - include/wx/msw/slider.h
abd4ec4985fa0a771e084afea13044d699906f37
[wxWidgets.git] / include / wx / msw / slider.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/msw/slider.h
3 // Purpose: wxSlider class implementation using trackbar control
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_SLIDER_H_
13 #define _WX_SLIDER_H_
14
15 class WXDLLIMPEXP_FWD_CORE wxSubwindows;
16
17 // Slider
18 class WXDLLIMPEXP_CORE wxSlider : public wxSliderBase
19 {
20 public:
21 wxSlider() { Init(); }
22
23 wxSlider(wxWindow *parent,
24 wxWindowID id,
25 int value,
26 int minValue,
27 int maxValue,
28 const wxPoint& pos = wxDefaultPosition,
29 const wxSize& size = wxDefaultSize,
30 long style = wxSL_HORIZONTAL,
31 const wxValidator& validator = wxDefaultValidator,
32 const wxString& name = wxSliderNameStr)
33 {
34 Init();
35
36 (void)Create(parent, id, value, minValue, maxValue,
37 pos, size, style, validator, name);
38 }
39
40 bool Create(wxWindow *parent,
41 wxWindowID id,
42 int value,
43 int minValue, int maxValue,
44 const wxPoint& pos = wxDefaultPosition,
45 const wxSize& size = wxDefaultSize,
46 long style = wxSL_HORIZONTAL,
47 const wxValidator& validator = wxDefaultValidator,
48 const wxString& name = wxSliderNameStr);
49
50 virtual ~wxSlider();
51
52 // slider methods
53 virtual int GetValue() const;
54 virtual void SetValue(int);
55
56 void SetRange(int minValue, int maxValue);
57
58 int GetMin() const { return m_rangeMin; }
59 int GetMax() const { return m_rangeMax; }
60
61 // Win32-specific slider methods
62 int GetTickFreq() const { return m_tickFreq; }
63 void SetPageSize(int pageSize);
64 int GetPageSize() const;
65 void ClearSel();
66 void ClearTicks();
67 void SetLineSize(int lineSize);
68 int GetLineSize() const;
69 int GetSelEnd() const;
70 int GetSelStart() const;
71 void SetSelection(int minPos, int maxPos);
72 void SetThumbLength(int len);
73 int GetThumbLength() const;
74 void SetTick(int tickPos);
75
76 // implementation only from now on
77 WXHWND GetStaticMin() const;
78 WXHWND GetStaticMax() const;
79 WXHWND GetEditValue() const;
80 virtual bool ContainsHWND(WXHWND hWnd) const;
81
82 // we should let background show through the slider (and its labels)
83 virtual bool HasTransparentBackground() { return true; }
84
85 // returns true if the platform should explicitly apply a theme border
86 virtual bool CanApplyThemeBorder() const { return false; }
87
88 void Command(wxCommandEvent& event);
89 virtual bool MSWOnScroll(int orientation, WXWORD wParam,
90 WXWORD pos, WXHWND control);
91
92 virtual bool Show(bool show = true);
93 virtual bool Enable(bool show = true);
94 virtual bool SetFont(const wxFont& font);
95
96 virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
97
98 protected:
99 // common part of all ctors
100 void Init();
101
102 // format an integer value as string
103 static wxString Format(int n) { return wxString::Format(wxT("%d"), n); }
104
105 // get the boundig box for the slider and possible labels
106 wxRect GetBoundingBox() const;
107
108 // Get the height and, if the pointers are non NULL, widths of both labels.
109 int GetLabelsSize(int *widthMin = NULL, int *widthMax = NULL) const;
110
111
112 // overridden base class virtuals
113 virtual void DoGetPosition(int *x, int *y) const;
114 virtual void DoGetSize(int *width, int *height) const;
115 virtual void DoMoveWindow(int x, int y, int width, int height);
116 virtual wxSize DoGetBestSize() const;
117
118 // the labels windows, if any
119 wxSubwindows *m_labels;
120
121 int m_rangeMin;
122 int m_rangeMax;
123 int m_pageSize;
124 int m_lineSize;
125 int m_tickFreq;
126 int m_minLabelWidth;
127 int m_maxLabelWidth;
128
129 // flag needed to detect whether we're getting THUMBRELEASE event because
130 // of dragging the thumb or scrolling the mouse wheel
131 bool m_isDragging;
132
133 // Platform-specific implementation of SetTickFreq
134 virtual void DoSetTickFreq(int freq);
135
136 DECLARE_DYNAMIC_CLASS_NO_COPY(wxSlider)
137 };
138
139 #endif // _WX_SLIDER_H_
140