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