]> git.saurik.com Git - wxWidgets.git/blame - include/wx/spinbutt.h
Added project files for wxUniv under MSW
[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__
5fde6fcc 16 #if !defined(__WXMOTIF__) && !defined(__WXMAC__) // because there is no matching .cpp
88e243b2 17 #pragma interface "spinbutbase.h"
5fde6fcc 18 #endif
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
1e6feb95
VZ
32#define wxSPIN_BUTTON_NAME _T("wxSpinButton")
33
31528cd3
VZ
34// ----------------------------------------------------------------------------
35// The wxSpinButton is like a small scrollbar than is often placed next
36// to a text control.
37//
38// Styles:
39// wxSP_HORIZONTAL: horizontal spin button
40// wxSP_VERTICAL: vertical spin button (the default)
41// wxSP_ARROW_KEYS: arrow keys increment/decrement value
42// wxSP_WRAP: value wraps at either end
43// ----------------------------------------------------------------------------
44
45class WXDLLEXPORT wxSpinButtonBase : public wxControl
46{
47public:
48 wxSpinButtonBase() { InitBase(); }
49
50 // accessors
51 virtual int GetValue() const = 0;
52 virtual int GetMin() const { return m_min; }
53 virtual int GetMax() const { return m_max; }
54
55 // operations
56 virtual void SetValue(int val) = 0;
57 virtual void SetRange(int minVal, int maxVal)
58 {
59 m_min = minVal;
60 m_max = maxVal;
61 }
62
1e6feb95
VZ
63 // is this spin button vertically oriented?
64 bool IsVertical() const { return (m_windowStyle & wxSP_VERTICAL) != 0; }
65
31528cd3
VZ
66protected:
67 // init the base part of the control
68 void InitBase()
69 {
70 m_min = 0;
71 m_max = 100;
72 }
73
74 // the range value
75 int m_min;
76 int m_max;
77};
78
79// ----------------------------------------------------------------------------
80// include the declaration of the real class
81// ----------------------------------------------------------------------------
82
1e6feb95
VZ
83#if defined(__WXUNIVERSAL__)
84 #include "wx/univ/spinbutt.h"
85#elif defined(__WXMSW__)
31528cd3 86 #include "wx/msw/spinbutt.h"
2049ba38 87#elif defined(__WXMOTIF__)
31528cd3 88 #include "wx/motif/spinbutt.h"
2049ba38 89#elif defined(__WXGTK__)
31528cd3 90 #include "wx/gtk/spinbutt.h"
b4e76e0d 91#elif defined(__WXQT__)
31528cd3 92 #include "wx/qt/spinbutt.h"
34138703 93#elif defined(__WXMAC__)
31528cd3 94 #include "wx/mac/spinbutt.h"
1777b9bb
DW
95#elif defined(__WXPM__)
96 #include "wx/os2/spinbutt.h"
34138703 97#elif defined(__WXSTUBS__)
31528cd3 98 #include "wx/stubs/spinbutt.h"
c801d85f
KB
99#endif
100
31528cd3
VZ
101// ----------------------------------------------------------------------------
102// the wxSpinButton event
103// ----------------------------------------------------------------------------
104
0655ad29 105class WXDLLEXPORT wxSpinEvent : public wxNotifyEvent
31528cd3 106{
31528cd3
VZ
107public:
108 wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
0655ad29 109 : wxNotifyEvent(commandType, id)
31528cd3
VZ
110 {
111 }
0655ad29
VZ
112
113 // get the current value of the control
114 int GetPosition() const { return m_commandInt; }
115 void SetPosition(int pos) { m_commandInt = pos; }
1e6feb95
VZ
116
117private:
118 DECLARE_DYNAMIC_CLASS(wxSpinEvent)
31528cd3
VZ
119};
120
121typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
122
123// macros for handling spin events
82a5f02c 124#define EVT_SPIN_UP(id, func) \
2e4df4bf 125 DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
82a5f02c 126#define EVT_SPIN_DOWN(id, func) \
2e4df4bf 127 DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
82a5f02c 128#define EVT_SPIN(id, func) \
2e4df4bf 129 DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
31528cd3
VZ
130
131#endif // wxUSE_SPINBTN
132
c801d85f 133#endif
34138703 134 // _WX_SPINBUTT_H_BASE_