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