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