]> git.saurik.com Git - wxWidgets.git/blob - include/wx/spinbutt.h
Committing in .
[wxWidgets.git] / include / wx / spinbutt.h
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
12 #ifndef _WX_SPINBUTT_H_BASE_
13 #define _WX_SPINBUTT_H_BASE_
14
15 #ifdef __GNUG__
16 #if !defined(__WXMOTIF__) && !defined(__WXMAC__) // because there is no matching .cpp
17 #pragma interface "spinbutbase.h"
18 #endif
19 #endif
20
21 // ----------------------------------------------------------------------------
22 // headers
23 // ----------------------------------------------------------------------------
24
25 #include "wx/defs.h"
26
27 #if wxUSE_SPINBTN
28
29 #include "wx/control.h"
30 #include "wx/event.h"
31
32 #define wxSPIN_BUTTON_NAME _T("wxSpinButton")
33
34 // ----------------------------------------------------------------------------
35 // The wxSpinButton is like a small scrollbar than is often placed next
36 // to a text control.
37 //
38 // Styles:
39 // wxSP_HORIZONTAL: horizontal spin button
40 // wxSP_VERTICAL: vertical spin button (the default)
41 // wxSP_ARROW_KEYS: arrow keys increment/decrement value
42 // wxSP_WRAP: value wraps at either end
43 // ----------------------------------------------------------------------------
44
45 class WXDLLEXPORT wxSpinButtonBase : public wxControl
46 {
47 public:
48 wxSpinButtonBase() { InitBase(); }
49
50 // accessors
51 virtual int GetValue() const = 0;
52 virtual int GetMin() const { return m_min; }
53 virtual int GetMax() const { return m_max; }
54
55 // operations
56 virtual void SetValue(int val) = 0;
57 virtual void SetRange(int minVal, int maxVal)
58 {
59 m_min = minVal;
60 m_max = maxVal;
61 }
62
63 // is this spin button vertically oriented?
64 bool IsVertical() const { return (m_windowStyle & wxSP_VERTICAL) != 0; }
65
66 protected:
67 // init the base part of the control
68 void InitBase()
69 {
70 m_min = 0;
71 m_max = 100;
72 }
73
74 // the range value
75 int m_min;
76 int m_max;
77 };
78
79 // ----------------------------------------------------------------------------
80 // include the declaration of the real class
81 // ----------------------------------------------------------------------------
82
83 #if defined(__WXUNIVERSAL__)
84 #include "wx/univ/spinbutt.h"
85 #elif defined(__WXMSW__)
86 #include "wx/msw/spinbutt.h"
87 #elif defined(__WXMOTIF__)
88 #include "wx/motif/spinbutt.h"
89 #elif defined(__WXGTK__)
90 #include "wx/gtk/spinbutt.h"
91 #elif defined(__WXQT__)
92 #include "wx/qt/spinbutt.h"
93 #elif defined(__WXMAC__)
94 #include "wx/mac/spinbutt.h"
95 #elif defined(__WXPM__)
96 #include "wx/os2/spinbutt.h"
97 #elif defined(__WXSTUBS__)
98 #include "wx/stubs/spinbutt.h"
99 #endif
100
101 // ----------------------------------------------------------------------------
102 // the wxSpinButton event
103 // ----------------------------------------------------------------------------
104
105 class WXDLLEXPORT wxSpinEvent : public wxNotifyEvent
106 {
107 public:
108 wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
109 : wxNotifyEvent(commandType, id)
110 {
111 }
112
113 // get the current value of the control
114 int GetPosition() const { return m_commandInt; }
115 void SetPosition(int pos) { m_commandInt = pos; }
116
117 private:
118 DECLARE_DYNAMIC_CLASS(wxSpinEvent)
119 };
120
121 typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
122
123 // macros for handling spin events
124 #define EVT_SPIN_UP(id, func) \
125 DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
126 #define EVT_SPIN_DOWN(id, func) \
127 DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
128 #define EVT_SPIN(id, func) \
129 DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
130
131 #endif // wxUSE_SPINBTN
132
133 #endif
134 // _WX_SPINBUTT_H_BASE_