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