1999-10-10 19:28:07 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
2011-03-19 20:14:35 -04:00
|
|
|
// Name: wx/spinctrl.h
|
1999-10-10 19:28:07 -04:00
|
|
|
// Purpose: wxSpinCtrlBase class
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 22.07.99
|
|
|
|
// Copyright: (c) Vadim Zeitlin
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-10-10 19:28:07 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_SPINCTRL_H_
|
|
|
|
#define _WX_SPINCTRL_H_
|
|
|
|
|
2005-03-16 11:18:31 -05:00
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#if wxUSE_SPINCTRL
|
|
|
|
|
1999-12-29 14:18:01 -05:00
|
|
|
#include "wx/spinbutt.h" // should make wxSpinEvent visible to the app
|
1999-10-10 19:28:07 -04:00
|
|
|
|
2009-01-12 09:26:13 -05:00
|
|
|
// Events
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxSpinDoubleEvent;
|
|
|
|
|
2013-04-25 06:11:03 -04:00
|
|
|
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SPINCTRL, wxSpinEvent);
|
|
|
|
wxDECLARE_EXPORTED_EVENT(WXDLLIMPEXP_CORE, wxEVT_SPINCTRLDOUBLE, wxSpinDoubleEvent);
|
2009-01-12 09:26:13 -05:00
|
|
|
|
1999-10-10 19:28:07 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
2008-03-18 10:04:19 -04:00
|
|
|
// A spin ctrl is a text control with a spin button which is usually used to
|
|
|
|
// prompt the user for a numeric input.
|
|
|
|
// There are two kinds for number types T=integer or T=double.
|
1999-10-10 19:28:07 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxSpinCtrlBase : public wxControl
|
1999-10-10 19:28:07 -04:00
|
|
|
{
|
|
|
|
public:
|
2008-03-18 10:04:19 -04:00
|
|
|
wxSpinCtrlBase() {}
|
1999-10-10 19:28:07 -04:00
|
|
|
|
2008-03-18 10:04:19 -04:00
|
|
|
// accessor functions that derived classes are expected to have
|
|
|
|
// T GetValue() const
|
|
|
|
// T GetMin() const
|
|
|
|
// T GetMax() const
|
|
|
|
// T GetIncrement() const
|
|
|
|
virtual bool GetSnapToTicks() const = 0;
|
|
|
|
// unsigned GetDigits() const - wxSpinCtrlDouble only
|
1999-10-10 19:28:07 -04:00
|
|
|
|
2008-03-18 10:04:19 -04:00
|
|
|
// operation functions that derived classes are expected to have
|
1999-10-29 13:54:13 -04:00
|
|
|
virtual void SetValue(const wxString& value) = 0;
|
2008-03-18 10:04:19 -04:00
|
|
|
// void SetValue(T val)
|
|
|
|
// void SetRange(T minVal, T maxVal)
|
|
|
|
// void SetIncrement(T inc)
|
|
|
|
virtual void SetSnapToTicks(bool snap_to_ticks) = 0;
|
|
|
|
// void SetDigits(unsigned digits) - wxSpinCtrlDouble only
|
1999-10-10 19:28:07 -04:00
|
|
|
|
2012-08-30 16:24:38 -04:00
|
|
|
// The base for numbers display, e.g. 10 or 16.
|
|
|
|
virtual int GetBase() const = 0;
|
|
|
|
virtual bool SetBase(int base) = 0;
|
|
|
|
|
2008-03-18 10:04:19 -04:00
|
|
|
// Select text in the textctrl
|
2002-09-01 16:24:25 -04:00
|
|
|
virtual void SetSelection(long from, long to) = 0;
|
|
|
|
|
2008-03-18 10:04:19 -04:00
|
|
|
private:
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxSpinCtrlBase);
|
2008-03-18 10:04:19 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxSpinDoubleEvent - a wxSpinEvent for double valued controls
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxSpinDoubleEvent : public wxNotifyEvent
|
2008-03-18 10:04:19 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxSpinDoubleEvent(wxEventType commandType = wxEVT_NULL, int winid = 0,
|
|
|
|
double value = 0)
|
|
|
|
: wxNotifyEvent(commandType, winid), m_value(value)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
wxSpinDoubleEvent(const wxSpinDoubleEvent& event)
|
|
|
|
: wxNotifyEvent(event), m_value(event.GetValue())
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
double GetValue() const { return m_value; }
|
|
|
|
void SetValue(double value) { m_value = value; }
|
|
|
|
|
|
|
|
virtual wxEvent *Clone() const { return new wxSpinDoubleEvent(*this); }
|
|
|
|
|
1999-10-10 19:28:07 -04:00
|
|
|
protected:
|
2008-03-18 10:04:19 -04:00
|
|
|
double m_value;
|
1999-10-10 19:28:07 -04:00
|
|
|
|
2008-03-18 10:04:19 -04:00
|
|
|
private:
|
|
|
|
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSpinDoubleEvent)
|
1999-10-10 19:28:07 -04:00
|
|
|
};
|
2008-03-18 10:04:19 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// wxSpinDoubleEvent event type, see also wxSpinEvent in wx/spinbutt.h
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
typedef void (wxEvtHandler::*wxSpinDoubleEventFunction)(wxSpinDoubleEvent&);
|
|
|
|
|
|
|
|
#define wxSpinDoubleEventHandler(func) \
|
2009-01-12 09:26:13 -05:00
|
|
|
wxEVENT_HANDLER_CAST(wxSpinDoubleEventFunction, func)
|
2008-03-18 10:04:19 -04:00
|
|
|
|
|
|
|
// macros for handling spinctrl events
|
|
|
|
|
|
|
|
#define EVT_SPINCTRL(id, fn) \
|
2013-04-25 06:11:03 -04:00
|
|
|
wx__DECLARE_EVT1(wxEVT_SPINCTRL, id, wxSpinEventHandler(fn))
|
2008-03-18 10:04:19 -04:00
|
|
|
|
|
|
|
#define EVT_SPINCTRLDOUBLE(id, fn) \
|
2013-04-25 06:11:03 -04:00
|
|
|
wx__DECLARE_EVT1(wxEVT_SPINCTRLDOUBLE, id, wxSpinDoubleEventHandler(fn))
|
1999-10-10 19:28:07 -04:00
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// include the platform-dependent class implementation
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-18 10:04:19 -04:00
|
|
|
// we may have a native wxSpinCtrl implementation, native wxSpinCtrl and
|
|
|
|
// wxSpinCtrlDouble implementations or neither, define the appropriate symbols
|
|
|
|
// and include the generic version if necessary to provide the missing class(es)
|
|
|
|
|
2012-08-30 16:24:12 -04:00
|
|
|
#if defined(__WXUNIVERSAL__)
|
2008-03-18 10:04:19 -04:00
|
|
|
// nothing, use generic controls
|
2004-03-28 08:10:14 -05:00
|
|
|
#elif defined(__WXMSW__)
|
2008-03-18 10:04:19 -04:00
|
|
|
#define wxHAS_NATIVE_SPINCTRL
|
1999-10-10 19:28:07 -04:00
|
|
|
#include "wx/msw/spinctrl.h"
|
1999-10-17 13:23:27 -04:00
|
|
|
#elif defined(__WXPM__)
|
2008-03-18 10:04:19 -04:00
|
|
|
#define wxHAS_NATIVE_SPINCTRL
|
1999-10-17 13:23:27 -04:00
|
|
|
#include "wx/os2/spinctrl.h"
|
2006-01-22 22:27:34 -05:00
|
|
|
#elif defined(__WXGTK20__)
|
2008-03-18 10:04:19 -04:00
|
|
|
#define wxHAS_NATIVE_SPINCTRL
|
|
|
|
#define wxHAS_NATIVE_SPINCTRLDOUBLE
|
1999-10-11 06:05:36 -04:00
|
|
|
#include "wx/gtk/spinctrl.h"
|
2006-01-22 22:27:34 -05:00
|
|
|
#elif defined(__WXGTK__)
|
2008-03-18 10:04:19 -04:00
|
|
|
#define wxHAS_NATIVE_SPINCTRL
|
2006-01-22 22:27:34 -05:00
|
|
|
#include "wx/gtk1/spinctrl.h"
|
1999-10-10 19:28:07 -04:00
|
|
|
#endif // platform
|
|
|
|
|
2008-03-18 10:04:19 -04:00
|
|
|
#if !defined(wxHAS_NATIVE_SPINCTRL) || !defined(wxHAS_NATIVE_SPINCTRLDOUBLE)
|
|
|
|
#include "wx/generic/spinctlg.h"
|
|
|
|
#endif
|
2000-01-15 05:20:46 -05:00
|
|
|
|
2012-08-30 16:24:38 -04:00
|
|
|
namespace wxPrivate
|
|
|
|
{
|
|
|
|
|
|
|
|
// This is an internal helper function currently used by all ports: return the
|
|
|
|
// string containing hexadecimal representation of the given number.
|
|
|
|
extern wxString wxSpinCtrlFormatAsHex(long val, long maxVal);
|
|
|
|
|
|
|
|
} // namespace wxPrivate
|
|
|
|
|
2013-04-25 06:11:03 -04:00
|
|
|
// old wxEVT_COMMAND_* constants
|
|
|
|
#define wxEVT_COMMAND_SPINCTRL_UPDATED wxEVT_SPINCTRL
|
|
|
|
#define wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED wxEVT_SPINCTRLDOUBLE
|
|
|
|
|
2005-03-16 11:18:31 -05:00
|
|
|
#endif // wxUSE_SPINCTRL
|
1999-10-10 19:28:07 -04:00
|
|
|
|
2005-03-16 11:18:31 -05:00
|
|
|
#endif // _WX_SPINCTRL_H_
|