1999-07-23 17:03:02 -04: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
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
1998-08-14 20:23:28 -04:00
|
|
|
#ifndef _WX_SPINBUTT_H_BASE_
|
|
|
|
#define _WX_SPINBUTT_H_BASE_
|
1998-05-20 10:01:55 -04:00
|
|
|
|
1999-07-23 17:03:02 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
|
2000-02-16 06:53:16 -05:00
|
|
|
#if wxUSE_SPINBTN
|
1999-07-23 17:03:02 -04:00
|
|
|
|
|
|
|
#include "wx/control.h"
|
|
|
|
#include "wx/event.h"
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#define wxSPIN_BUTTON_NAME _T("wxSpinButton")
|
|
|
|
|
1999-07-23 17:03:02 -04: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
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLEXPORT wxSpinButtonBase : public wxControl
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxSpinButtonBase() { InitBase(); }
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
virtual void SetRange(int minVal, int maxVal)
|
|
|
|
{
|
|
|
|
m_min = minVal;
|
|
|
|
m_max = maxVal;
|
|
|
|
}
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
// is this spin button vertically oriented?
|
|
|
|
bool IsVertical() const { return (m_windowStyle & wxSP_VERTICAL) != 0; }
|
|
|
|
|
1999-07-23 17:03:02 -04:00
|
|
|
protected:
|
|
|
|
// init the base part of the control
|
|
|
|
void InitBase()
|
|
|
|
{
|
|
|
|
m_min = 0;
|
|
|
|
m_max = 100;
|
|
|
|
}
|
|
|
|
|
|
|
|
// the range value
|
|
|
|
int m_min;
|
|
|
|
int m_max;
|
2003-07-21 20:24:07 -04:00
|
|
|
|
|
|
|
DECLARE_NO_COPY_CLASS(wxSpinButtonBase)
|
1999-07-23 17:03:02 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// include the declaration of the real class
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2001-06-26 16:59:19 -04:00
|
|
|
#if defined(__WXUNIVERSAL__)
|
|
|
|
#include "wx/univ/spinbutt.h"
|
2001-07-20 07:59:46 -04:00
|
|
|
#elif defined(__WXMSW__) && defined(__WIN95__)
|
1999-07-23 17:03:02 -04:00
|
|
|
#include "wx/msw/spinbutt.h"
|
1998-07-10 10:15:17 -04:00
|
|
|
#elif defined(__WXMOTIF__)
|
1999-07-23 17:03:02 -04:00
|
|
|
#include "wx/motif/spinbutt.h"
|
1998-07-10 10:15:17 -04:00
|
|
|
#elif defined(__WXGTK__)
|
1999-07-23 17:03:02 -04:00
|
|
|
#include "wx/gtk/spinbutt.h"
|
1998-08-14 20:23:28 -04:00
|
|
|
#elif defined(__WXMAC__)
|
1999-07-23 17:03:02 -04:00
|
|
|
#include "wx/mac/spinbutt.h"
|
2003-07-14 13:33:36 -04:00
|
|
|
#elif defined(__WXCOCOA__)
|
|
|
|
#include "wx/cocoa/spinbutt.h"
|
1999-07-27 23:38:12 -04:00
|
|
|
#elif defined(__WXPM__)
|
|
|
|
#include "wx/os2/spinbutt.h"
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
|
|
|
|
1999-07-23 17:03:02 -04:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// the wxSpinButton event
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1999-07-28 17:01:04 -04:00
|
|
|
class WXDLLEXPORT wxSpinEvent : public wxNotifyEvent
|
1999-07-23 17:03:02 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
|
1999-07-28 17:01:04 -04:00
|
|
|
: wxNotifyEvent(commandType, id)
|
1999-07-23 17:03:02 -04:00
|
|
|
{
|
|
|
|
}
|
1999-07-28 17:01:04 -04:00
|
|
|
|
|
|
|
// get the current value of the control
|
|
|
|
int GetPosition() const { return m_commandInt; }
|
|
|
|
void SetPosition(int pos) { m_commandInt = pos; }
|
2001-06-26 16:59:19 -04:00
|
|
|
|
|
|
|
private:
|
2003-07-21 20:24:07 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxSpinEvent)
|
1999-07-23 17:03:02 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
|
|
|
|
|
|
|
|
// macros for handling spin events
|
2001-01-26 12:35:36 -05:00
|
|
|
#define EVT_SPIN_UP(id, func) \
|
2001-01-31 12:16:40 -05:00
|
|
|
DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
|
2001-01-26 12:35:36 -05:00
|
|
|
#define EVT_SPIN_DOWN(id, func) \
|
2001-01-31 12:16:40 -05:00
|
|
|
DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
|
2001-01-26 12:35:36 -05:00
|
|
|
#define EVT_SPIN(id, func) \
|
2001-01-31 12:16:40 -05:00
|
|
|
DECLARE_EVENT_TABLE_ENTRY( wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func, NULL ),
|
1999-07-23 17:03:02 -04:00
|
|
|
|
|
|
|
#endif // wxUSE_SPINBTN
|
|
|
|
|
1998-05-20 10:01:55 -04:00
|
|
|
#endif
|
1998-08-14 20:23:28 -04:00
|
|
|
// _WX_SPINBUTT_H_BASE_
|