1999-07-23 21:03:02 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: wx/spinbutt.h
|
|
|
|
// Purpose: wxSpinButtonBase class
|
|
|
|
// Author: Julian Smart, Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 23.07.99
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Julian Smart
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1999-07-23 21:03:02 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-15 00:23:28 +00:00
|
|
|
#ifndef _WX_SPINBUTT_H_BASE_
|
|
|
|
#define _WX_SPINBUTT_H_BASE_
|
1998-05-20 14:01:55 +00:00
|
|
|
|
1999-07-23 21:03:02 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
|
2000-02-16 11:53:16 +00:00
|
|
|
#if wxUSE_SPINBTN
|
1999-07-23 21:03:02 +00:00
|
|
|
|
|
|
|
#include "wx/control.h"
|
|
|
|
#include "wx/event.h"
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#define wxSPIN_BUTTON_NAME _T("wxSpinButton")
|
|
|
|
|
2009-01-12 14:26:13 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxSpinEvent;
|
|
|
|
wxDECLARE_EXPORTED_EVENT_REFERENCE( WXDLLIMPEXP_CORE, wxEVT_SPIN_UP, wxSpinEvent )
|
|
|
|
wxDECLARE_EXPORTED_EVENT_REFERENCE( WXDLLIMPEXP_CORE, wxEVT_SPIN_DOWN, wxSpinEvent )
|
|
|
|
wxDECLARE_EXPORTED_EVENT_REFERENCE( WXDLLIMPEXP_CORE, wxEVT_SPIN, wxSpinEvent )
|
|
|
|
|
1999-07-23 21:03:02 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// The wxSpinButton is like a small scrollbar than is often placed next
|
|
|
|
// to a text control.
|
|
|
|
//
|
|
|
|
// Styles:
|
|
|
|
// wxSP_HORIZONTAL: horizontal spin button
|
|
|
|
// wxSP_VERTICAL: vertical spin button (the default)
|
|
|
|
// wxSP_ARROW_KEYS: arrow keys increment/decrement value
|
|
|
|
// wxSP_WRAP: value wraps at either end
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxSpinButtonBase : public wxControl
|
1999-07-23 21:03:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2005-05-31 09:20:43 +00:00
|
|
|
// ctor initializes the range with the default (0..100) values
|
2003-10-30 23:08:39 +00:00
|
|
|
wxSpinButtonBase() { m_min = 0; m_max = 100; }
|
1999-07-23 21:03:02 +00:00
|
|
|
|
|
|
|
// accessors
|
|
|
|
virtual int GetValue() const = 0;
|
|
|
|
virtual int GetMin() const { return m_min; }
|
|
|
|
virtual int GetMax() const { return m_max; }
|
|
|
|
|
|
|
|
// operations
|
|
|
|
virtual void SetValue(int val) = 0;
|
2003-08-14 17:59:34 +00:00
|
|
|
virtual void SetMin(int minVal) { SetRange ( minVal , m_max ) ; }
|
|
|
|
virtual void SetMax(int maxVal) { SetRange ( m_min , maxVal ) ; }
|
1999-07-23 21:03:02 +00:00
|
|
|
virtual void SetRange(int minVal, int maxVal)
|
|
|
|
{
|
|
|
|
m_min = minVal;
|
|
|
|
m_max = maxVal;
|
|
|
|
}
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
// is this spin button vertically oriented?
|
|
|
|
bool IsVertical() const { return (m_windowStyle & wxSP_VERTICAL) != 0; }
|
|
|
|
|
1999-07-23 21:03:02 +00:00
|
|
|
protected:
|
|
|
|
// the range value
|
|
|
|
int m_min;
|
|
|
|
int m_max;
|
2003-07-22 00:24:07 +00:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxSpinButtonBase)
|
1999-07-23 21:03:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// include the declaration of the real class
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
#if defined(__WXUNIVERSAL__)
|
|
|
|
#include "wx/univ/spinbutt.h"
|
2005-12-19 10:55:11 +00:00
|
|
|
#elif defined(__WXMSW__)
|
1999-07-23 21:03:02 +00:00
|
|
|
#include "wx/msw/spinbutt.h"
|
1998-07-10 14:15:17 +00:00
|
|
|
#elif defined(__WXMOTIF__)
|
1999-07-23 21:03:02 +00:00
|
|
|
#include "wx/motif/spinbutt.h"
|
2006-01-23 03:27:34 +00:00
|
|
|
#elif defined(__WXGTK20__)
|
1999-07-23 21:03:02 +00:00
|
|
|
#include "wx/gtk/spinbutt.h"
|
2006-01-23 03:27:34 +00:00
|
|
|
#elif defined(__WXGTK__)
|
|
|
|
#include "wx/gtk1/spinbutt.h"
|
1998-08-15 00:23:28 +00:00
|
|
|
#elif defined(__WXMAC__)
|
2008-06-11 19:17:41 +00:00
|
|
|
#include "wx/osx/spinbutt.h"
|
2003-07-14 17:33:36 +00:00
|
|
|
#elif defined(__WXCOCOA__)
|
|
|
|
#include "wx/cocoa/spinbutt.h"
|
1999-07-28 03:38:12 +00:00
|
|
|
#elif defined(__WXPM__)
|
|
|
|
#include "wx/os2/spinbutt.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
1999-07-23 21:03:02 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// the wxSpinButton event
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxSpinEvent : public wxNotifyEvent
|
1999-07-23 21:03:02 +00:00
|
|
|
{
|
|
|
|
public:
|
2003-08-11 15:14:37 +00:00
|
|
|
wxSpinEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
|
|
|
|
: wxNotifyEvent(commandType, winid)
|
1999-07-23 21:03:02 +00:00
|
|
|
{
|
|
|
|
}
|
1999-07-28 21:01:04 +00:00
|
|
|
|
2008-03-18 14:04:19 +00:00
|
|
|
wxSpinEvent(const wxSpinEvent& event) : wxNotifyEvent(event) {}
|
|
|
|
|
1999-07-28 21:01:04 +00:00
|
|
|
// get the current value of the control
|
2008-03-18 14:04:19 +00:00
|
|
|
int GetValue() const { return m_commandInt; }
|
|
|
|
void SetValue(int value) { m_commandInt = value; }
|
|
|
|
|
1999-07-28 21:01:04 +00:00
|
|
|
int GetPosition() const { return m_commandInt; }
|
|
|
|
void SetPosition(int pos) { m_commandInt = pos; }
|
2001-06-26 20:59:19 +00:00
|
|
|
|
2008-03-18 14:04:19 +00:00
|
|
|
virtual wxEvent *Clone() const { return new wxSpinEvent(*this); }
|
|
|
|
|
2001-06-26 20:59:19 +00:00
|
|
|
private:
|
2008-03-18 14:04:19 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_ASSIGN(wxSpinEvent)
|
1999-07-23 21:03:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
|
|
|
|
|
2005-02-14 23:53:48 +00:00
|
|
|
#define wxSpinEventHandler(func) \
|
2009-01-12 14:26:13 +00:00
|
|
|
wxEVENT_HANDLER_CAST(wxSpinEventFunction, func)
|
2005-02-14 23:53:48 +00:00
|
|
|
|
1999-07-23 21:03:02 +00:00
|
|
|
// macros for handling spin events
|
2003-08-11 15:14:37 +00:00
|
|
|
#define EVT_SPIN_UP(winid, func) \
|
2009-01-12 14:26:13 +00:00
|
|
|
wx__DECLARE_EVT1(wxEVT_SPIN_UP, winid, wxSpinEventHandler(func))
|
2003-08-11 15:14:37 +00:00
|
|
|
#define EVT_SPIN_DOWN(winid, func) \
|
2009-01-12 14:26:13 +00:00
|
|
|
wx__DECLARE_EVT1(wxEVT_SPIN_DOWN, winid, wxSpinEventHandler(func))
|
2003-08-11 15:14:37 +00:00
|
|
|
#define EVT_SPIN(winid, func) \
|
2009-01-12 14:26:13 +00:00
|
|
|
wx__DECLARE_EVT1(wxEVT_SPIN, winid, wxSpinEventHandler(func))
|
1999-07-23 21:03:02 +00:00
|
|
|
|
|
|
|
#endif // wxUSE_SPINBTN
|
|
|
|
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
1998-08-15 00:23:28 +00:00
|
|
|
// _WX_SPINBUTT_H_BASE_
|