]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: wx/slider.h | |
3 | // Purpose: wxSlider interface | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 09.02.01 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1996-2001 Vadim Zeitlin | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_SLIDER_H_BASE_ | |
13 | #define _WX_SLIDER_H_BASE_ | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | #include "wx/defs.h" | |
20 | ||
21 | #if wxUSE_SLIDER | |
22 | ||
23 | #include "wx/control.h" | |
24 | ||
25 | // ---------------------------------------------------------------------------- | |
26 | // wxSlider flags | |
27 | // ---------------------------------------------------------------------------- | |
28 | ||
29 | #define wxSL_HORIZONTAL wxHORIZONTAL /* 0x0004 */ | |
30 | #define wxSL_VERTICAL wxVERTICAL /* 0x0008 */ | |
31 | ||
32 | #define wxSL_TICKS 0x0010 | |
33 | #define wxSL_AUTOTICKS wxSL_TICKS // we don't support manual ticks | |
34 | #define wxSL_LABELS 0x0020 | |
35 | #define wxSL_LEFT 0x0040 | |
36 | #define wxSL_TOP 0x0080 | |
37 | #define wxSL_RIGHT 0x0100 | |
38 | #define wxSL_BOTTOM 0x0200 | |
39 | #define wxSL_BOTH 0x0400 | |
40 | #define wxSL_SELRANGE 0x0800 | |
41 | #define wxSL_INVERSE 0x1000 | |
42 | ||
43 | // obsolete | |
44 | #define wxSL_NOTIFY_DRAG 0x0000 | |
45 | ||
46 | ||
47 | extern WXDLLEXPORT_DATA(const wxChar*) wxSliderNameStr; | |
48 | ||
49 | // ---------------------------------------------------------------------------- | |
50 | // wxSliderBase: define wxSlider interface | |
51 | // ---------------------------------------------------------------------------- | |
52 | ||
53 | class WXDLLEXPORT wxSliderBase : public wxControl | |
54 | { | |
55 | public: | |
56 | /* the ctor of the derived class should have the following form: | |
57 | ||
58 | wxSlider(wxWindow *parent, | |
59 | wxWindowID id, | |
60 | int value, int minValue, int maxValue, | |
61 | const wxPoint& pos = wxDefaultPosition, | |
62 | const wxSize& size = wxDefaultSize, | |
63 | long style = wxSL_HORIZONTAL, | |
64 | const wxValidator& validator = wxDefaultValidator, | |
65 | const wxString& name = wxSliderNameStr); | |
66 | */ | |
67 | wxSliderBase() { } | |
68 | ||
69 | // get/set the current slider value (should be in range) | |
70 | virtual int GetValue() const = 0; | |
71 | virtual void SetValue(int value) = 0; | |
72 | ||
73 | // retrieve/change the range | |
74 | virtual void SetRange(int minValue, int maxValue) = 0; | |
75 | virtual int GetMin() const = 0; | |
76 | virtual int GetMax() const = 0; | |
77 | void SetMin( int minValue ) { SetRange( minValue , GetMax() ) ; } | |
78 | void SetMax( int maxValue ) { SetRange( GetMin() , maxValue ) ; } | |
79 | ||
80 | // the line/page size is the increment by which the slider moves when | |
81 | // cursor arrow key/page up or down are pressed (clicking the mouse is like | |
82 | // pressing PageUp/Down) and are by default set to 1 and 1/10 of the range | |
83 | virtual void SetLineSize(int lineSize) = 0; | |
84 | virtual void SetPageSize(int pageSize) = 0; | |
85 | virtual int GetLineSize() const = 0; | |
86 | virtual int GetPageSize() const = 0; | |
87 | ||
88 | // these methods get/set the length of the slider pointer in pixels | |
89 | virtual void SetThumbLength(int lenPixels) = 0; | |
90 | virtual int GetThumbLength() const = 0; | |
91 | ||
92 | // warning: most of subsequent methods are currently only implemented in | |
93 | // wxMSW under Win95 and are silently ignored on other platforms | |
94 | ||
95 | virtual void SetTickFreq(int WXUNUSED(n), int WXUNUSED(pos)) { } | |
96 | virtual int GetTickFreq() const { return 0; } | |
97 | virtual void ClearTicks() { } | |
98 | virtual void SetTick(int WXUNUSED(tickPos)) { } | |
99 | ||
100 | virtual void ClearSel() { } | |
101 | virtual int GetSelEnd() const { return GetMin(); } | |
102 | virtual int GetSelStart() const { return GetMax(); } | |
103 | virtual void SetSelection(int WXUNUSED(min), int WXUNUSED(max)) { } | |
104 | ||
105 | protected: | |
106 | ||
107 | // adjust value according to wxSL_INVERSE style | |
108 | virtual int ValueInvertOrNot(int value) const | |
109 | { | |
110 | if (HasFlag(wxSL_INVERSE)) | |
111 | return (GetMax() + GetMin()) - value; | |
112 | else | |
113 | return value; | |
114 | } | |
115 | ||
116 | private: | |
117 | DECLARE_NO_COPY_CLASS(wxSliderBase) | |
118 | }; | |
119 | ||
120 | // ---------------------------------------------------------------------------- | |
121 | // include the real class declaration | |
122 | // ---------------------------------------------------------------------------- | |
123 | ||
124 | #if defined(__WXUNIVERSAL__) | |
125 | #include "wx/univ/slider.h" | |
126 | #elif defined(__WXMSW__) | |
127 | #include "wx/msw/slider95.h" | |
128 | #if WXWIN_COMPATIBILITY_2_4 | |
129 | #define wxSlider95 wxSlider | |
130 | #endif | |
131 | #elif defined(__WXMOTIF__) | |
132 | #include "wx/motif/slider.h" | |
133 | #elif defined(__WXGTK__) | |
134 | #include "wx/gtk/slider.h" | |
135 | #elif defined(__WXMAC__) | |
136 | #include "wx/mac/slider.h" | |
137 | #elif defined(__WXCOCOA__) | |
138 | #include "wx/cocoa/slider.h" | |
139 | #elif defined(__WXPM__) | |
140 | #include "wx/os2/slider.h" | |
141 | #elif defined(__WXPALMOS__) | |
142 | #include "wx/palmos/slider.h" | |
143 | #endif | |
144 | ||
145 | #endif // wxUSE_SLIDER | |
146 | ||
147 | #endif | |
148 | // _WX_SLIDER_H_BASE_ |