]> git.saurik.com Git - wxWidgets.git/blame - include/wx/spinctrl.h
temporary fix the linking problem due to making GSocket::Detected_Read/Write() non...
[wxWidgets.git] / include / wx / spinctrl.h
CommitLineData
b782f2e0
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: spinctrl.h
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
VZ
20
21// ----------------------------------------------------------------------------
8cd6a9ad
VZ
22// A spin ctrl is a text control with a spin button which is usually used to
23// prompt the user for a numeric input.
24// There are two kinds for number types T=integer or T=double.
b782f2e0
VZ
25// ----------------------------------------------------------------------------
26
53a2db12 27class WXDLLIMPEXP_CORE wxSpinCtrlBase : public wxControl
b782f2e0
VZ
28{
29public:
8cd6a9ad 30 wxSpinCtrlBase() {}
b782f2e0 31
8cd6a9ad
VZ
32 // accessor functions that derived classes are expected to have
33 // T GetValue() const
34 // T GetMin() const
35 // T GetMax() const
36 // T GetIncrement() const
37 virtual bool GetSnapToTicks() const = 0;
38 // unsigned GetDigits() const - wxSpinCtrlDouble only
b782f2e0 39
8cd6a9ad 40 // operation functions that derived classes are expected to have
36f210c8 41 virtual void SetValue(const wxString& value) = 0;
8cd6a9ad
VZ
42 // void SetValue(T val)
43 // void SetRange(T minVal, T maxVal)
44 // void SetIncrement(T inc)
45 virtual void SetSnapToTicks(bool snap_to_ticks) = 0;
46 // void SetDigits(unsigned digits) - wxSpinCtrlDouble only
b782f2e0 47
8cd6a9ad 48 // Select text in the textctrl
14bc59a2
VZ
49 virtual void SetSelection(long from, long to) = 0;
50
8cd6a9ad
VZ
51private:
52 DECLARE_NO_COPY_CLASS(wxSpinCtrlBase)
53};
54
55// ----------------------------------------------------------------------------
56// wxSpinDoubleEvent - a wxSpinEvent for double valued controls
57// ----------------------------------------------------------------------------
58
53a2db12 59class WXDLLIMPEXP_CORE wxSpinDoubleEvent : public wxNotifyEvent
8cd6a9ad
VZ
60{
61public:
62 wxSpinDoubleEvent(wxEventType commandType = wxEVT_NULL, int winid = 0,
63 double value = 0)
64 : wxNotifyEvent(commandType, winid), m_value(value)
65 {
66 }
67
68 wxSpinDoubleEvent(const wxSpinDoubleEvent& event)
69 : wxNotifyEvent(event), m_value(event.GetValue())
70 {
71 }
72
73 double GetValue() const { return m_value; }
74 void SetValue(double value) { m_value = value; }
75
76 virtual wxEvent *Clone() const { return new wxSpinDoubleEvent(*this); }
77
b782f2e0 78protected:
8cd6a9ad 79 double m_value;
b782f2e0 80
8cd6a9ad
VZ
81private:
82 DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSpinDoubleEvent)
b782f2e0 83};
8cd6a9ad
VZ
84
85// ----------------------------------------------------------------------------
86// wxSpinDoubleEvent event type, see also wxSpinEvent in wx/spinbutt.h
87// ----------------------------------------------------------------------------
88
89typedef void (wxEvtHandler::*wxSpinDoubleEventFunction)(wxSpinDoubleEvent&);
90
91#define wxSpinDoubleEventHandler(func) \
92 (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxSpinDoubleEventFunction, &func)
93
94// macros for handling spinctrl events
95
96#define EVT_SPINCTRL(id, fn) \
97 wx__DECLARE_EVT1(wxEVT_COMMAND_SPINCTRL_UPDATED, id, wxSpinEventHandler(fn))
98
99#define EVT_SPINCTRLDOUBLE(id, fn) \
100 wx__DECLARE_EVT1(wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, id, wxSpinDoubleEventHandler(fn))
b782f2e0
VZ
101
102// ----------------------------------------------------------------------------
103// include the platform-dependent class implementation
104// ----------------------------------------------------------------------------
105
8cd6a9ad
VZ
106// we may have a native wxSpinCtrl implementation, native wxSpinCtrl and
107// wxSpinCtrlDouble implementations or neither, define the appropriate symbols
108// and include the generic version if necessary to provide the missing class(es)
109
110#if defined(__WXUNIVERSAL__) || \
111 defined(__WXMOTIF__) || \
112 defined(__WXCOCOA__)
113 // nothing, use generic controls
3a5bcc4d 114#elif defined(__WXMSW__)
8cd6a9ad 115 #define wxHAS_NATIVE_SPINCTRL
b782f2e0 116 #include "wx/msw/spinctrl.h"
04701dd9 117#elif defined(__WXPM__)
8cd6a9ad 118 #define wxHAS_NATIVE_SPINCTRL
04701dd9 119 #include "wx/os2/spinctrl.h"
1be7a35c 120#elif defined(__WXGTK20__)
8cd6a9ad
VZ
121 #define wxHAS_NATIVE_SPINCTRL
122 #define wxHAS_NATIVE_SPINCTRLDOUBLE
738f9e5a 123 #include "wx/gtk/spinctrl.h"
1be7a35c 124#elif defined(__WXGTK__)
8cd6a9ad 125 #define wxHAS_NATIVE_SPINCTRL
1be7a35c 126 #include "wx/gtk1/spinctrl.h"
1e5e1c40 127#elif defined(__WXMAC__)
8cd6a9ad 128 #define wxHAS_NATIVE_SPINCTRL
ef0e9220 129 #include "wx/osx/spinctrl.h"
b782f2e0
VZ
130#endif // platform
131
8cd6a9ad
VZ
132#if !defined(wxHAS_NATIVE_SPINCTRL) || !defined(wxHAS_NATIVE_SPINCTRLDOUBLE)
133 #include "wx/generic/spinctlg.h"
134#endif
5dd26b08 135
2ecf902b 136#endif // wxUSE_SPINCTRL
b782f2e0 137
2ecf902b 138#endif // _WX_SPINCTRL_H_