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