]>
Commit | Line | Data |
---|---|---|
31528cd3 VZ |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: wx/spinbutt.h | |
3 | // Purpose: wxSpinButtonBase class | |
4 | // Author: Julian Smart, Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 23.07.99 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
34138703 JS |
12 | #ifndef _WX_SPINBUTT_H_BASE_ |
13 | #define _WX_SPINBUTT_H_BASE_ | |
c801d85f | 14 | |
31528cd3 VZ |
15 | // ---------------------------------------------------------------------------- |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | #include "wx/defs.h" | |
20 | ||
21 | #ifdef wxUSE_SPINBTN | |
22 | ||
23 | #include "wx/control.h" | |
24 | #include "wx/event.h" | |
25 | ||
26 | // ---------------------------------------------------------------------------- | |
27 | // The wxSpinButton is like a small scrollbar than is often placed next | |
28 | // to a text control. | |
29 | // | |
30 | // Styles: | |
31 | // wxSP_HORIZONTAL: horizontal spin button | |
32 | // wxSP_VERTICAL: vertical spin button (the default) | |
33 | // wxSP_ARROW_KEYS: arrow keys increment/decrement value | |
34 | // wxSP_WRAP: value wraps at either end | |
35 | // ---------------------------------------------------------------------------- | |
36 | ||
37 | class WXDLLEXPORT wxSpinButtonBase : public wxControl | |
38 | { | |
39 | public: | |
40 | wxSpinButtonBase() { InitBase(); } | |
41 | ||
42 | // accessors | |
43 | virtual int GetValue() const = 0; | |
44 | virtual int GetMin() const { return m_min; } | |
45 | virtual int GetMax() const { return m_max; } | |
46 | ||
47 | // operations | |
48 | virtual void SetValue(int val) = 0; | |
49 | virtual void SetRange(int minVal, int maxVal) | |
50 | { | |
51 | m_min = minVal; | |
52 | m_max = maxVal; | |
53 | } | |
54 | ||
55 | protected: | |
56 | // init the base part of the control | |
57 | void InitBase() | |
58 | { | |
59 | m_min = 0; | |
60 | m_max = 100; | |
61 | } | |
62 | ||
63 | // the range value | |
64 | int m_min; | |
65 | int m_max; | |
66 | }; | |
67 | ||
68 | // ---------------------------------------------------------------------------- | |
69 | // include the declaration of the real class | |
70 | // ---------------------------------------------------------------------------- | |
71 | ||
2049ba38 | 72 | #if defined(__WXMSW__) |
31528cd3 | 73 | #include "wx/msw/spinbutt.h" |
2049ba38 | 74 | #elif defined(__WXMOTIF__) |
31528cd3 | 75 | #include "wx/motif/spinbutt.h" |
2049ba38 | 76 | #elif defined(__WXGTK__) |
31528cd3 | 77 | #include "wx/gtk/spinbutt.h" |
b4e76e0d | 78 | #elif defined(__WXQT__) |
31528cd3 | 79 | #include "wx/qt/spinbutt.h" |
34138703 | 80 | #elif defined(__WXMAC__) |
31528cd3 | 81 | #include "wx/mac/spinbutt.h" |
1777b9bb DW |
82 | #elif defined(__WXPM__) |
83 | #include "wx/os2/spinbutt.h" | |
34138703 | 84 | #elif defined(__WXSTUBS__) |
31528cd3 | 85 | #include "wx/stubs/spinbutt.h" |
c801d85f KB |
86 | #endif |
87 | ||
31528cd3 VZ |
88 | // ---------------------------------------------------------------------------- |
89 | // the wxSpinButton event | |
90 | // ---------------------------------------------------------------------------- | |
91 | ||
0655ad29 | 92 | class WXDLLEXPORT wxSpinEvent : public wxNotifyEvent |
31528cd3 VZ |
93 | { |
94 | DECLARE_DYNAMIC_CLASS(wxSpinEvent) | |
95 | ||
96 | public: | |
97 | wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0) | |
0655ad29 | 98 | : wxNotifyEvent(commandType, id) |
31528cd3 VZ |
99 | { |
100 | } | |
0655ad29 VZ |
101 | |
102 | // get the current value of the control | |
103 | int GetPosition() const { return m_commandInt; } | |
104 | void SetPosition(int pos) { m_commandInt = pos; } | |
31528cd3 VZ |
105 | }; |
106 | ||
107 | typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&); | |
108 | ||
109 | // macros for handling spin events | |
0655ad29 VZ |
110 | #define EVT_SPIN_UP(id, func) { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }, |
111 | #define EVT_SPIN_DOWN(id, func) { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }, | |
112 | ||
113 | #define EVT_SPIN(id, func) { wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }, | |
31528cd3 VZ |
114 | |
115 | #endif // wxUSE_SPINBTN | |
116 | ||
c801d85f | 117 | #endif |
34138703 | 118 | // _WX_SPINBUTT_H_BASE_ |