]> git.saurik.com Git - wxWidgets.git/blame - include/wx/spinbutt.h
event handling seems to work again, new sample (event) added and documented
[wxWidgets.git] / include / wx / spinbutt.h
CommitLineData
31528cd3
VZ
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
34138703
JS
12#ifndef _WX_SPINBUTT_H_BASE_
13#define _WX_SPINBUTT_H_BASE_
c801d85f 14
d422d01e 15#ifdef __GNUG__
88e243b2
VZ
16 #ifndef __WXMOTIF__ // because there is no matching .cpp for Motif
17 #pragma interface "spinbutbase.h"
18 #endif // Motif
d422d01e
RR
19#endif
20
31528cd3
VZ
21// ----------------------------------------------------------------------------
22// headers
23// ----------------------------------------------------------------------------
24
25#include "wx/defs.h"
26
2fa7c206 27#if wxUSE_SPINBTN
31528cd3
VZ
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
43class WXDLLEXPORT wxSpinButtonBase : public wxControl
44{
45public:
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
61protected:
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
2049ba38 78#if defined(__WXMSW__)
31528cd3 79 #include "wx/msw/spinbutt.h"
2049ba38 80#elif defined(__WXMOTIF__)
31528cd3 81 #include "wx/motif/spinbutt.h"
2049ba38 82#elif defined(__WXGTK__)
31528cd3 83 #include "wx/gtk/spinbutt.h"
b4e76e0d 84#elif defined(__WXQT__)
31528cd3 85 #include "wx/qt/spinbutt.h"
34138703 86#elif defined(__WXMAC__)
31528cd3 87 #include "wx/mac/spinbutt.h"
1777b9bb
DW
88#elif defined(__WXPM__)
89 #include "wx/os2/spinbutt.h"
34138703 90#elif defined(__WXSTUBS__)
31528cd3 91 #include "wx/stubs/spinbutt.h"
c801d85f
KB
92#endif
93
31528cd3
VZ
94// ----------------------------------------------------------------------------
95// the wxSpinButton event
96// ----------------------------------------------------------------------------
97
0655ad29 98class WXDLLEXPORT wxSpinEvent : public wxNotifyEvent
31528cd3
VZ
99{
100 DECLARE_DYNAMIC_CLASS(wxSpinEvent)
101
102public:
103 wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
0655ad29 104 : wxNotifyEvent(commandType, id)
31528cd3
VZ
105 {
106 }
0655ad29
VZ
107
108 // get the current value of the control
109 int GetPosition() const { return m_commandInt; }
110 void SetPosition(int pos) { m_commandInt = pos; }
31528cd3
VZ
111};
112
113typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
114
115// macros for handling spin events
82a5f02c 116#define EVT_SPIN_UP(id, func) \
b7245f12 117 wxEventTableEntry( wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
82a5f02c 118#define EVT_SPIN_DOWN(id, func) \
b7245f12 119 wxEventTableEntry( wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
82a5f02c 120#define EVT_SPIN(id, func) \
b7245f12 121 wxEventTableEntry( wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
31528cd3
VZ
122
123#endif // wxUSE_SPINBTN
124
c801d85f 125#endif
34138703 126 // _WX_SPINBUTT_H_BASE_