]>
Commit | Line | Data |
---|---|---|
0dbd6262 SC |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: spinbutt.h | |
3 | // Purpose: wxSpinButton class | |
4 | // Author: AUTHOR | |
5 | // Modified by: | |
6 | // Created: ??/??/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_SPINBUTT_H_ | |
13 | #define _WX_SPINBUTT_H_ | |
14 | ||
15 | #ifdef __GNUG__ | |
16 | #pragma interface "spinbutt.h" | |
17 | #endif | |
18 | ||
19 | #include "wx/control.h" | |
20 | #include "wx/event.h" | |
21 | ||
22 | /* | |
23 | The wxSpinButton is like a small scrollbar than is often placed next | |
24 | to a text control. | |
25 | ||
26 | wxSP_HORIZONTAL: horizontal spin button | |
27 | wxSP_VERTICAL: vertical spin button (the default) | |
28 | wxSP_ARROW_KEYS: arrow keys increment/decrement value | |
29 | wxSP_WRAP: value wraps at either end | |
30 | */ | |
31 | ||
32 | class WXDLLEXPORT wxSpinButton: public wxControl | |
33 | { | |
34 | DECLARE_DYNAMIC_CLASS(wxSpinButton) | |
35 | public: | |
36 | /* | |
37 | * Public interface | |
38 | */ | |
39 | ||
40 | wxSpinButton(); | |
41 | ||
42 | inline wxSpinButton(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
43 | long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton") | |
44 | { | |
45 | Create(parent, id, pos, size, style, name); | |
46 | } | |
47 | ~wxSpinButton(); | |
48 | ||
49 | bool Create(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, | |
50 | long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton"); | |
51 | ||
52 | ||
53 | // Attributes | |
54 | //////////////////////////////////////////////////////////////////////////// | |
55 | ||
56 | int GetValue() const ; | |
57 | void SetValue(int val) ; | |
58 | void SetRange(int minVal, int maxVal) ; | |
59 | inline int GetMin() const { return m_min; } | |
60 | inline int GetMax() const { return m_max; } | |
61 | ||
62 | // Operations | |
63 | //////////////////////////////////////////////////////////////////////////// | |
64 | ||
65 | void Command(wxCommandEvent& event) { ProcessCommand(event); }; | |
519cb848 | 66 | virtual void MacHandleControlClick( ControlHandle control , SInt16 controlpart ) ; |
0dbd6262 SC |
67 | |
68 | protected: | |
69 | int m_min; | |
70 | int m_max; | |
519cb848 | 71 | int m_value ; |
0dbd6262 SC |
72 | }; |
73 | ||
74 | class WXDLLEXPORT wxSpinEvent: public wxScrollEvent | |
75 | { | |
76 | DECLARE_DYNAMIC_CLASS(wxSpinEvent) | |
77 | ||
78 | public: | |
79 | wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0); | |
80 | }; | |
81 | ||
82 | typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&); | |
83 | ||
84 | // Spin events | |
85 | ||
86 | #define EVT_SPIN_UP(id, func) { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func } | |
87 | #define EVT_SPIN_DOWN(id, func) { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func } | |
88 | ||
89 | #define EVT_SPIN(id, func) \ | |
90 | { wxEVT_SCROLL_TOP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\ | |
91 | { wxEVT_SCROLL_BOTTOM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\ | |
92 | { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\ | |
93 | { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\ | |
94 | { wxEVT_SCROLL_PAGEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\ | |
95 | { wxEVT_SCROLL_PAGEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\ | |
96 | { wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }, | |
97 | ||
98 | #endif | |
99 | // _WX_SPINBUTT_H_ |