]> git.saurik.com Git - wxWidgets.git/blame - include/wx/spinbutt.h
Fix build with Sun CC under Linux.
[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"
4e3762c9 25#include "wx/range.h"
31528cd3 26
9a83f860 27#define wxSPIN_BUTTON_NAME wxT("wxSpinButton")
1e6feb95 28
31528cd3
VZ
29// ----------------------------------------------------------------------------
30// The wxSpinButton is like a small scrollbar than is often placed next
31// to a text control.
32//
33// Styles:
34// wxSP_HORIZONTAL: horizontal spin button
35// wxSP_VERTICAL: vertical spin button (the default)
36// wxSP_ARROW_KEYS: arrow keys increment/decrement value
37// wxSP_WRAP: value wraps at either end
38// ----------------------------------------------------------------------------
39
53a2db12 40class WXDLLIMPEXP_CORE wxSpinButtonBase : public wxControl
31528cd3
VZ
41{
42public:
3103e8a9 43 // ctor initializes the range with the default (0..100) values
72795335 44 wxSpinButtonBase() { m_min = 0; m_max = 100; }
31528cd3
VZ
45
46 // accessors
47 virtual int GetValue() const = 0;
48 virtual int GetMin() const { return m_min; }
49 virtual int GetMax() const { return m_max; }
4e3762c9 50 wxRange GetRange() const { return wxRange( GetMin(), GetMax() );}
31528cd3
VZ
51
52 // operations
53 virtual void SetValue(int val) = 0;
fae7d158
SC
54 virtual void SetMin(int minVal) { SetRange ( minVal , m_max ) ; }
55 virtual void SetMax(int maxVal) { SetRange ( m_min , maxVal ) ; }
31528cd3
VZ
56 virtual void SetRange(int minVal, int maxVal)
57 {
58 m_min = minVal;
59 m_max = maxVal;
60 }
4e3762c9 61 void SetRange( const wxRange& range) { SetRange( range.GetMin(), range.GetMax()); }
31528cd3 62
1e6feb95
VZ
63 // is this spin button vertically oriented?
64 bool IsVertical() const { return (m_windowStyle & wxSP_VERTICAL) != 0; }
65
31528cd3 66protected:
31528cd3
VZ
67 // the range value
68 int m_min;
69 int m_max;
fc7a2a60 70
c0c133e1 71 wxDECLARE_NO_COPY_CLASS(wxSpinButtonBase);
31528cd3
VZ
72};
73
74// ----------------------------------------------------------------------------
75// include the declaration of the real class
76// ----------------------------------------------------------------------------
77
1e6feb95
VZ
78#if defined(__WXUNIVERSAL__)
79 #include "wx/univ/spinbutt.h"
1ed64378 80#elif defined(__WXMSW__)
31528cd3 81 #include "wx/msw/spinbutt.h"
2049ba38 82#elif defined(__WXMOTIF__)
31528cd3 83 #include "wx/motif/spinbutt.h"
1be7a35c 84#elif defined(__WXGTK20__)
31528cd3 85 #include "wx/gtk/spinbutt.h"
1be7a35c
MR
86#elif defined(__WXGTK__)
87 #include "wx/gtk1/spinbutt.h"
34138703 88#elif defined(__WXMAC__)
ef0e9220 89 #include "wx/osx/spinbutt.h"
768d9ec8
DE
90#elif defined(__WXCOCOA__)
91 #include "wx/cocoa/spinbutt.h"
1777b9bb
DW
92#elif defined(__WXPM__)
93 #include "wx/os2/spinbutt.h"
c801d85f
KB
94#endif
95
31528cd3
VZ
96// ----------------------------------------------------------------------------
97// the wxSpinButton event
98// ----------------------------------------------------------------------------
99
53a2db12 100class WXDLLIMPEXP_CORE wxSpinEvent : public wxNotifyEvent
31528cd3 101{
31528cd3 102public:
f07c5701
DE
103 wxSpinEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
104 : wxNotifyEvent(commandType, winid)
31528cd3
VZ
105 {
106 }
0655ad29 107
8cd6a9ad
VZ
108 wxSpinEvent(const wxSpinEvent& event) : wxNotifyEvent(event) {}
109
0655ad29 110 // get the current value of the control
8cd6a9ad
VZ
111 int GetValue() const { return m_commandInt; }
112 void SetValue(int value) { m_commandInt = value; }
113
0655ad29
VZ
114 int GetPosition() const { return m_commandInt; }
115 void SetPosition(int pos) { m_commandInt = pos; }
1e6feb95 116
8cd6a9ad
VZ
117 virtual wxEvent *Clone() const { return new wxSpinEvent(*this); }
118
1e6feb95 119private:
8cd6a9ad 120 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSpinEvent)
31528cd3
VZ
121};
122
123typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
124
7fa03f04 125#define wxSpinEventHandler(func) \
3c778901 126 wxEVENT_HANDLER_CAST(wxSpinEventFunction, func)
7fa03f04 127
02221dcb
VZ
128// macros for handling spin events: notice that we must use the real values of
129// the event type constants and not their references (wxEVT_SPIN[_UP/DOWN])
130// here as otherwise the event tables could end up with non-initialized
131// (because of undefined initialization order of the globals defined in
132// different translation units) references in them
f07c5701 133#define EVT_SPIN_UP(winid, func) \
dca94103 134 wx__DECLARE_EVT1(wxEVT_SPIN_UP, winid, wxSpinEventHandler(func))
f07c5701 135#define EVT_SPIN_DOWN(winid, func) \
dca94103 136 wx__DECLARE_EVT1(wxEVT_SPIN_DOWN, winid, wxSpinEventHandler(func))
f07c5701 137#define EVT_SPIN(winid, func) \
dca94103 138 wx__DECLARE_EVT1(wxEVT_SPIN, winid, wxSpinEventHandler(func))
31528cd3
VZ
139
140#endif // wxUSE_SPINBTN
141
c801d85f 142#endif
34138703 143 // _WX_SPINBUTT_H_BASE_