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
|
|
|
|
// Licence: wxWindows licence
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
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-08-06 10:10:10 +00:00
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface "spinbutbase.h"
|
|
|
|
#pragma implementation "spinbutbase.h"
|
|
|
|
#endif
|
|
|
|
|
1999-07-23 21:03:02 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// headers
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#include "wx/defs.h"
|
|
|
|
|
|
|
|
#ifdef wxUSE_SPINBTN
|
|
|
|
|
|
|
|
#include "wx/control.h"
|
|
|
|
#include "wx/event.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
};
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// include the declaration of the real class
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1998-07-10 14:15:17 +00:00
|
|
|
#if 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"
|
1998-07-10 14:15:17 +00:00
|
|
|
#elif defined(__WXGTK__)
|
1999-07-23 21:03:02 +00:00
|
|
|
#include "wx/gtk/spinbutt.h"
|
1998-08-07 20:23:17 +00:00
|
|
|
#elif defined(__WXQT__)
|
1999-07-23 21:03:02 +00:00
|
|
|
#include "wx/qt/spinbutt.h"
|
1998-08-15 00:23:28 +00:00
|
|
|
#elif defined(__WXMAC__)
|
1999-07-23 21:03:02 +00:00
|
|
|
#include "wx/mac/spinbutt.h"
|
1999-07-28 03:38:12 +00:00
|
|
|
#elif defined(__WXPM__)
|
|
|
|
#include "wx/os2/spinbutt.h"
|
1998-08-15 00:23:28 +00:00
|
|
|
#elif defined(__WXSTUBS__)
|
1999-07-23 21:03:02 +00:00
|
|
|
#include "wx/stubs/spinbutt.h"
|
1998-05-20 14:01:55 +00:00
|
|
|
#endif
|
|
|
|
|
1999-07-23 21:03:02 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// the wxSpinButton event
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
1999-07-28 21:01:04 +00:00
|
|
|
class WXDLLEXPORT wxSpinEvent : public wxNotifyEvent
|
1999-07-23 21:03:02 +00:00
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxSpinEvent)
|
|
|
|
|
|
|
|
public:
|
|
|
|
wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
|
1999-07-28 21:01:04 +00:00
|
|
|
: wxNotifyEvent(commandType, id)
|
1999-07-23 21:03:02 +00:00
|
|
|
{
|
|
|
|
}
|
1999-07-28 21:01:04 +00:00
|
|
|
|
|
|
|
// get the current value of the control
|
|
|
|
int GetPosition() const { return m_commandInt; }
|
|
|
|
void SetPosition(int pos) { m_commandInt = pos; }
|
1999-07-23 21:03:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
|
|
|
|
|
|
|
|
// macros for handling spin events
|
1999-07-30 21:47:13 +00:00
|
|
|
#ifndef EVT_SPIN_UP
|
1999-07-28 21:01:04 +00:00
|
|
|
#define EVT_SPIN_UP(id, func) { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
|
1999-07-30 21:47:13 +00:00
|
|
|
#endif
|
|
|
|
#ifndef EVT_SPIN_DOWN
|
1999-07-28 21:01:04 +00:00
|
|
|
#define EVT_SPIN_DOWN(id, func) { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
|
1999-07-30 21:47:13 +00:00
|
|
|
#endif
|
|
|
|
#ifndef EVT_SPIN
|
1999-07-28 21:01:04 +00:00
|
|
|
#define EVT_SPIN(id, func) { wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
|
1999-07-30 21:47:13 +00:00
|
|
|
#endif
|
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_
|