]> git.saurik.com Git - wxWidgets.git/blame - include/wx/spinctrl.h
Fix wrong tab order in wxAuiNotebook after dragging.
[wxWidgets.git] / include / wx / spinctrl.h
CommitLineData
b782f2e0 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/spinctrl.h
b782f2e0
VZ
3// Purpose: wxSpinCtrlBase class
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 22.07.99
7// RCS-ID: $Id$
8// Copyright: (c) Vadim Zeitlin
65571936 9// Licence: wxWindows licence
b782f2e0
VZ
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_SPINCTRL_H_
13#define _WX_SPINCTRL_H_
14
2ecf902b
WS
15#include "wx/defs.h"
16
17#if wxUSE_SPINCTRL
18
9d9b7755 19#include "wx/spinbutt.h" // should make wxSpinEvent visible to the app
b782f2e0 20
3c778901
VZ
21// Events
22class WXDLLIMPEXP_FWD_CORE wxSpinDoubleEvent;
23
9b11752c
VZ
24wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SPINCTRL_UPDATED, wxSpinEvent);
25wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, wxSpinDoubleEvent);
3c778901 26
b782f2e0 27// ----------------------------------------------------------------------------
8cd6a9ad
VZ
28// A spin ctrl is a text control with a spin button which is usually used to
29// prompt the user for a numeric input.
30// There are two kinds for number types T=integer or T=double.
b782f2e0
VZ
31// ----------------------------------------------------------------------------
32
53a2db12 33class WXDLLIMPEXP_CORE wxSpinCtrlBase : public wxControl
b782f2e0
VZ
34{
35public:
8cd6a9ad 36 wxSpinCtrlBase() {}
b782f2e0 37
8cd6a9ad
VZ
38 // accessor functions that derived classes are expected to have
39 // T GetValue() const
40 // T GetMin() const
41 // T GetMax() const
42 // T GetIncrement() const
43 virtual bool GetSnapToTicks() const = 0;
44 // unsigned GetDigits() const - wxSpinCtrlDouble only
b782f2e0 45
8cd6a9ad 46 // operation functions that derived classes are expected to have
36f210c8 47 virtual void SetValue(const wxString& value) = 0;
8cd6a9ad
VZ
48 // void SetValue(T val)
49 // void SetRange(T minVal, T maxVal)
50 // void SetIncrement(T inc)
51 virtual void SetSnapToTicks(bool snap_to_ticks) = 0;
52 // void SetDigits(unsigned digits) - wxSpinCtrlDouble only
b782f2e0 53
9e565667
VZ
54 // The base for numbers display, e.g. 10 or 16.
55 virtual int GetBase() const = 0;
56 virtual bool SetBase(int base) = 0;
57
8cd6a9ad 58 // Select text in the textctrl
14bc59a2
VZ
59 virtual void SetSelection(long from, long to) = 0;
60
8cd6a9ad 61private:
c0c133e1 62 wxDECLARE_NO_COPY_CLASS(wxSpinCtrlBase);
8cd6a9ad
VZ
63};
64
65// ----------------------------------------------------------------------------
66// wxSpinDoubleEvent - a wxSpinEvent for double valued controls
67// ----------------------------------------------------------------------------
68
53a2db12 69class WXDLLIMPEXP_CORE wxSpinDoubleEvent : public wxNotifyEvent
8cd6a9ad
VZ
70{
71public:
72 wxSpinDoubleEvent(wxEventType commandType = wxEVT_NULL, int winid = 0,
73 double value = 0)
74 : wxNotifyEvent(commandType, winid), m_value(value)
75 {
76 }
77
78 wxSpinDoubleEvent(const wxSpinDoubleEvent& event)
79 : wxNotifyEvent(event), m_value(event.GetValue())
80 {
81 }
82
83 double GetValue() const { return m_value; }
84 void SetValue(double value) { m_value = value; }
85
86 virtual wxEvent *Clone() const { return new wxSpinDoubleEvent(*this); }
87
b782f2e0 88protected:
8cd6a9ad 89 double m_value;
b782f2e0 90
8cd6a9ad
VZ
91private:
92 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSpinDoubleEvent)
b782f2e0 93};
8cd6a9ad
VZ
94
95// ----------------------------------------------------------------------------
96// wxSpinDoubleEvent event type, see also wxSpinEvent in wx/spinbutt.h
97// ----------------------------------------------------------------------------
98
99typedef void (wxEvtHandler::*wxSpinDoubleEventFunction)(wxSpinDoubleEvent&);
100
101#define wxSpinDoubleEventHandler(func) \
3c778901 102 wxEVENT_HANDLER_CAST(wxSpinDoubleEventFunction, func)
8cd6a9ad
VZ
103
104// macros for handling spinctrl events
105
106#define EVT_SPINCTRL(id, fn) \
107 wx__DECLARE_EVT1(wxEVT_COMMAND_SPINCTRL_UPDATED, id, wxSpinEventHandler(fn))
108
109#define EVT_SPINCTRLDOUBLE(id, fn) \
110 wx__DECLARE_EVT1(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, id, wxSpinDoubleEventHandler(fn))
b782f2e0
VZ
111
112// ----------------------------------------------------------------------------
113// include the platform-dependent class implementation
114// ----------------------------------------------------------------------------
115
8cd6a9ad
VZ
116// we may have a native wxSpinCtrl implementation, native wxSpinCtrl and
117// wxSpinCtrlDouble implementations or neither, define the appropriate symbols
118// and include the generic version if necessary to provide the missing class(es)
119
36090ae5 120#if defined(__WXUNIVERSAL__)
8cd6a9ad 121 // nothing, use generic controls
3a5bcc4d 122#elif defined(__WXMSW__)
8cd6a9ad 123 #define wxHAS_NATIVE_SPINCTRL
b782f2e0 124 #include "wx/msw/spinctrl.h"
04701dd9 125#elif defined(__WXPM__)
8cd6a9ad 126 #define wxHAS_NATIVE_SPINCTRL
04701dd9 127 #include "wx/os2/spinctrl.h"
1be7a35c 128#elif defined(__WXGTK20__)
8cd6a9ad
VZ
129 #define wxHAS_NATIVE_SPINCTRL
130 #define wxHAS_NATIVE_SPINCTRLDOUBLE
738f9e5a 131 #include "wx/gtk/spinctrl.h"
1be7a35c 132#elif defined(__WXGTK__)
8cd6a9ad 133 #define wxHAS_NATIVE_SPINCTRL
1be7a35c 134 #include "wx/gtk1/spinctrl.h"
b782f2e0
VZ
135#endif // platform
136
8cd6a9ad
VZ
137#if !defined(wxHAS_NATIVE_SPINCTRL) || !defined(wxHAS_NATIVE_SPINCTRLDOUBLE)
138 #include "wx/generic/spinctlg.h"
139#endif
5dd26b08 140
9e565667
VZ
141namespace wxPrivate
142{
143
144// This is an internal helper function currently used by all ports: return the
145// string containing hexadecimal representation of the given number.
146extern wxString wxSpinCtrlFormatAsHex(long val, long maxVal);
147
148} // namespace wxPrivate
149
2ecf902b 150#endif // wxUSE_SPINCTRL
b782f2e0 151
2ecf902b 152#endif // _WX_SPINCTRL_H_