]> git.saurik.com Git - wxWidgets.git/blame - include/wx/spinbutt.h
Better support for unspecified property value in wxDateProperty and DatePickerCtrl...
[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
65571936 9// Licence: wxWindows licence
31528cd3
VZ
10/////////////////////////////////////////////////////////////////////////////
11
34138703
JS
12#ifndef _WX_SPINBUTT_H_BASE_
13#define _WX_SPINBUTT_H_BASE_
c801d85f 14
31528cd3
VZ
15// ----------------------------------------------------------------------------
16// headers
17// ----------------------------------------------------------------------------
18
19#include "wx/defs.h"
20
2fa7c206 21#if wxUSE_SPINBTN
31528cd3
VZ
22
23#include "wx/control.h"
24#include "wx/event.h"
25
1e6feb95
VZ
26#define wxSPIN_BUTTON_NAME _T("wxSpinButton")
27
3c778901
VZ
28class WXDLLIMPEXP_FWD_CORE wxSpinEvent;
29wxDECLARE_EXPORTED_EVENT_REFERENCE( WXDLLIMPEXP_CORE, wxEVT_SPIN_UP, wxSpinEvent )
30wxDECLARE_EXPORTED_EVENT_REFERENCE( WXDLLIMPEXP_CORE, wxEVT_SPIN_DOWN, wxSpinEvent )
31wxDECLARE_EXPORTED_EVENT_REFERENCE( WXDLLIMPEXP_CORE, wxEVT_SPIN, wxSpinEvent )
32
31528cd3
VZ
33// ----------------------------------------------------------------------------
34// The wxSpinButton is like a small scrollbar than is often placed next
35// to a text control.
36//
37// Styles:
38// wxSP_HORIZONTAL: horizontal spin button
39// wxSP_VERTICAL: vertical spin button (the default)
40// wxSP_ARROW_KEYS: arrow keys increment/decrement value
41// wxSP_WRAP: value wraps at either end
42// ----------------------------------------------------------------------------
43
53a2db12 44class WXDLLIMPEXP_CORE wxSpinButtonBase : public wxControl
31528cd3
VZ
45{
46public:
3103e8a9 47 // ctor initializes the range with the default (0..100) values
72795335 48 wxSpinButtonBase() { m_min = 0; m_max = 100; }
31528cd3
VZ
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;
fae7d158
SC
57 virtual void SetMin(int minVal) { SetRange ( minVal , m_max ) ; }
58 virtual void SetMax(int maxVal) { SetRange ( m_min , maxVal ) ; }
31528cd3
VZ
59 virtual void SetRange(int minVal, int maxVal)
60 {
61 m_min = minVal;
62 m_max = maxVal;
63 }
64
1e6feb95
VZ
65 // is this spin button vertically oriented?
66 bool IsVertical() const { return (m_windowStyle & wxSP_VERTICAL) != 0; }
67
31528cd3 68protected:
31528cd3
VZ
69 // the range value
70 int m_min;
71 int m_max;
fc7a2a60
VZ
72
73 DECLARE_NO_COPY_CLASS(wxSpinButtonBase)
31528cd3
VZ
74};
75
76// ----------------------------------------------------------------------------
77// include the declaration of the real class
78// ----------------------------------------------------------------------------
79
1e6feb95
VZ
80#if defined(__WXUNIVERSAL__)
81 #include "wx/univ/spinbutt.h"
1ed64378 82#elif defined(__WXMSW__)
31528cd3 83 #include "wx/msw/spinbutt.h"
2049ba38 84#elif defined(__WXMOTIF__)
31528cd3 85 #include "wx/motif/spinbutt.h"
1be7a35c 86#elif defined(__WXGTK20__)
31528cd3 87 #include "wx/gtk/spinbutt.h"
1be7a35c
MR
88#elif defined(__WXGTK__)
89 #include "wx/gtk1/spinbutt.h"
34138703 90#elif defined(__WXMAC__)
ef0e9220 91 #include "wx/osx/spinbutt.h"
768d9ec8
DE
92#elif defined(__WXCOCOA__)
93 #include "wx/cocoa/spinbutt.h"
1777b9bb
DW
94#elif defined(__WXPM__)
95 #include "wx/os2/spinbutt.h"
c801d85f
KB
96#endif
97
31528cd3
VZ
98// ----------------------------------------------------------------------------
99// the wxSpinButton event
100// ----------------------------------------------------------------------------
101
53a2db12 102class WXDLLIMPEXP_CORE wxSpinEvent : public wxNotifyEvent
31528cd3 103{
31528cd3 104public:
f07c5701
DE
105 wxSpinEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
106 : wxNotifyEvent(commandType, winid)
31528cd3
VZ
107 {
108 }
0655ad29 109
8cd6a9ad
VZ
110 wxSpinEvent(const wxSpinEvent& event) : wxNotifyEvent(event) {}
111
0655ad29 112 // get the current value of the control
8cd6a9ad
VZ
113 int GetValue() const { return m_commandInt; }
114 void SetValue(int value) { m_commandInt = value; }
115
0655ad29
VZ
116 int GetPosition() const { return m_commandInt; }
117 void SetPosition(int pos) { m_commandInt = pos; }
1e6feb95 118
8cd6a9ad
VZ
119 virtual wxEvent *Clone() const { return new wxSpinEvent(*this); }
120
1e6feb95 121private:
8cd6a9ad 122 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSpinEvent)
31528cd3
VZ
123};
124
125typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
126
7fa03f04 127#define wxSpinEventHandler(func) \
3c778901 128 wxEVENT_HANDLER_CAST(wxSpinEventFunction, func)
7fa03f04 129
31528cd3 130// macros for handling spin events
f07c5701 131#define EVT_SPIN_UP(winid, func) \
3c778901 132 wx__DECLARE_EVT1(wxEVT_SPIN_UP, winid, wxSpinEventHandler(func))
f07c5701 133#define EVT_SPIN_DOWN(winid, func) \
3c778901 134 wx__DECLARE_EVT1(wxEVT_SPIN_DOWN, winid, wxSpinEventHandler(func))
f07c5701 135#define EVT_SPIN(winid, func) \
3c778901 136 wx__DECLARE_EVT1(wxEVT_SPIN, winid, wxSpinEventHandler(func))
31528cd3
VZ
137
138#endif // wxUSE_SPINBTN
139
c801d85f 140#endif
34138703 141 // _WX_SPINBUTT_H_BASE_