]> git.saurik.com Git - wxWidgets.git/blame - include/wx/spinbutt.h
Applied #15226 with modifications: wxRichTextCtrl: Implement setting properties with...
[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
31528cd3 7// Copyright: (c) Julian Smart
65571936 8// Licence: wxWindows licence
31528cd3
VZ
9/////////////////////////////////////////////////////////////////////////////
10
34138703
JS
11#ifndef _WX_SPINBUTT_H_BASE_
12#define _WX_SPINBUTT_H_BASE_
c801d85f 13
31528cd3
VZ
14// ----------------------------------------------------------------------------
15// headers
16// ----------------------------------------------------------------------------
17
18#include "wx/defs.h"
19
2fa7c206 20#if wxUSE_SPINBTN
31528cd3
VZ
21
22#include "wx/control.h"
23#include "wx/event.h"
4e3762c9 24#include "wx/range.h"
31528cd3 25
9a83f860 26#define wxSPIN_BUTTON_NAME wxT("wxSpinButton")
1e6feb95 27
31528cd3
VZ
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
53a2db12 39class WXDLLIMPEXP_CORE wxSpinButtonBase : public wxControl
31528cd3
VZ
40{
41public:
3103e8a9 42 // ctor initializes the range with the default (0..100) values
72795335 43 wxSpinButtonBase() { m_min = 0; m_max = 100; }
31528cd3
VZ
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; }
4e3762c9 49 wxRange GetRange() const { return wxRange( GetMin(), GetMax() );}
31528cd3
VZ
50
51 // operations
52 virtual void SetValue(int val) = 0;
fae7d158
SC
53 virtual void SetMin(int minVal) { SetRange ( minVal , m_max ) ; }
54 virtual void SetMax(int maxVal) { SetRange ( m_min , maxVal ) ; }
31528cd3
VZ
55 virtual void SetRange(int minVal, int maxVal)
56 {
57 m_min = minVal;
58 m_max = maxVal;
59 }
4e3762c9 60 void SetRange( const wxRange& range) { SetRange( range.GetMin(), range.GetMax()); }
31528cd3 61
1e6feb95
VZ
62 // is this spin button vertically oriented?
63 bool IsVertical() const { return (m_windowStyle & wxSP_VERTICAL) != 0; }
64
31528cd3 65protected:
31528cd3
VZ
66 // the range value
67 int m_min;
68 int m_max;
fc7a2a60 69
c0c133e1 70 wxDECLARE_NO_COPY_CLASS(wxSpinButtonBase);
31528cd3
VZ
71};
72
73// ----------------------------------------------------------------------------
74// include the declaration of the real class
75// ----------------------------------------------------------------------------
76
1e6feb95
VZ
77#if defined(__WXUNIVERSAL__)
78 #include "wx/univ/spinbutt.h"
1ed64378 79#elif defined(__WXMSW__)
31528cd3 80 #include "wx/msw/spinbutt.h"
2049ba38 81#elif defined(__WXMOTIF__)
31528cd3 82 #include "wx/motif/spinbutt.h"
1be7a35c 83#elif defined(__WXGTK20__)
31528cd3 84 #include "wx/gtk/spinbutt.h"
1be7a35c
MR
85#elif defined(__WXGTK__)
86 #include "wx/gtk1/spinbutt.h"
34138703 87#elif defined(__WXMAC__)
ef0e9220 88 #include "wx/osx/spinbutt.h"
768d9ec8
DE
89#elif defined(__WXCOCOA__)
90 #include "wx/cocoa/spinbutt.h"
1777b9bb
DW
91#elif defined(__WXPM__)
92 #include "wx/os2/spinbutt.h"
c801d85f
KB
93#endif
94
31528cd3
VZ
95// ----------------------------------------------------------------------------
96// the wxSpinButton event
97// ----------------------------------------------------------------------------
98
53a2db12 99class WXDLLIMPEXP_CORE wxSpinEvent : public wxNotifyEvent
31528cd3 100{
31528cd3 101public:
f07c5701
DE
102 wxSpinEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
103 : wxNotifyEvent(commandType, winid)
31528cd3
VZ
104 {
105 }
0655ad29 106
8cd6a9ad
VZ
107 wxSpinEvent(const wxSpinEvent& event) : wxNotifyEvent(event) {}
108
0655ad29 109 // get the current value of the control
8cd6a9ad
VZ
110 int GetValue() const { return m_commandInt; }
111 void SetValue(int value) { m_commandInt = value; }
112
0655ad29
VZ
113 int GetPosition() const { return m_commandInt; }
114 void SetPosition(int pos) { m_commandInt = pos; }
1e6feb95 115
8cd6a9ad
VZ
116 virtual wxEvent *Clone() const { return new wxSpinEvent(*this); }
117
1e6feb95 118private:
8cd6a9ad 119 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSpinEvent)
31528cd3
VZ
120};
121
122typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
123
7fa03f04 124#define wxSpinEventHandler(func) \
3c778901 125 wxEVENT_HANDLER_CAST(wxSpinEventFunction, func)
7fa03f04 126
02221dcb
VZ
127// macros for handling spin events: notice that we must use the real values of
128// the event type constants and not their references (wxEVT_SPIN[_UP/DOWN])
129// here as otherwise the event tables could end up with non-initialized
130// (because of undefined initialization order of the globals defined in
131// different translation units) references in them
f07c5701 132#define EVT_SPIN_UP(winid, func) \
dca94103 133 wx__DECLARE_EVT1(wxEVT_SPIN_UP, winid, wxSpinEventHandler(func))
f07c5701 134#define EVT_SPIN_DOWN(winid, func) \
dca94103 135 wx__DECLARE_EVT1(wxEVT_SPIN_DOWN, winid, wxSpinEventHandler(func))
f07c5701 136#define EVT_SPIN(winid, func) \
dca94103 137 wx__DECLARE_EVT1(wxEVT_SPIN, winid, wxSpinEventHandler(func))
31528cd3
VZ
138
139#endif // wxUSE_SPINBTN
140
c801d85f 141#endif
34138703 142 // _WX_SPINBUTT_H_BASE_