1999-10-11 06:05:36 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: spinctrl.h
|
|
|
|
// Purpose: wxSpinCtrl class
|
|
|
|
// Author: Robert Roebling
|
|
|
|
// Modified by:
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Robert Roebling
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-10-11 06:05:36 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2006-08-30 01:55:56 -04:00
|
|
|
#ifndef _WX_GTK_SPINCTRL_H_
|
|
|
|
#define _WX_GTK_SPINCTRL_H_
|
1999-11-27 11:43:47 -05:00
|
|
|
|
1999-10-11 06:05:36 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
2008-03-18 10:04:19 -04:00
|
|
|
// wxSpinCtrlGTKBase - Base class for GTK versions of the wxSpinCtrl[Double]
|
|
|
|
//
|
|
|
|
// This class manages a double valued GTK spinctrl through the DoGet/SetXXX
|
|
|
|
// functions that are made public as Get/SetXXX functions for int or double
|
|
|
|
// for the wxSpinCtrl and wxSpinCtrlDouble classes respectively to avoid
|
|
|
|
// function ambiguity.
|
1999-10-11 06:05:36 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
2008-03-18 10:04:19 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxSpinCtrlGTKBase : public wxSpinCtrlBase
|
1999-10-11 06:05:36 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
bool Create(wxWindow *parent,
|
2009-11-08 18:50:46 -05:00
|
|
|
wxWindowID id,
|
|
|
|
const wxString& value,
|
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
long style,
|
|
|
|
double min, double max, double initial,
|
|
|
|
double inc,
|
|
|
|
const wxString& name);
|
1999-10-11 06:05:36 -04:00
|
|
|
|
2008-03-18 10:04:19 -04:00
|
|
|
// wxSpinCtrl(Double) methods call DoXXX functions of the same name
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
// T GetValue() const
|
|
|
|
// T GetMin() const
|
|
|
|
// T GetMax() const
|
|
|
|
// T GetIncrement() const
|
|
|
|
virtual bool GetSnapToTicks() const;
|
1999-10-28 09:04:45 -04:00
|
|
|
|
2008-03-18 10:04:19 -04:00
|
|
|
// operations
|
|
|
|
virtual void SetValue(const wxString& value);
|
|
|
|
// void SetValue(T val)
|
|
|
|
// void SetRange(T minVal, T maxVal)
|
|
|
|
// void SetIncrement(T inc)
|
|
|
|
void SetSnapToTicks( bool snap_to_ticks );
|
|
|
|
|
|
|
|
// Select text in the textctrl
|
|
|
|
void SetSelection(long from, long to);
|
1999-10-11 06:05:36 -04:00
|
|
|
|
2004-05-06 13:26:25 -04:00
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
2008-03-18 10:04:19 -04:00
|
|
|
|
1999-10-28 09:04:45 -04:00
|
|
|
// implementation
|
1999-10-29 13:20:44 -04:00
|
|
|
void OnChar( wxKeyEvent &event );
|
2008-03-18 10:04:19 -04:00
|
|
|
|
1999-12-29 14:18:01 -05:00
|
|
|
protected:
|
2008-03-18 10:04:19 -04:00
|
|
|
double DoGetValue() const;
|
|
|
|
double DoGetMin() const;
|
|
|
|
double DoGetMax() const;
|
|
|
|
double DoGetIncrement() const;
|
|
|
|
|
|
|
|
void DoSetValue(double val);
|
|
|
|
void DoSetValue(const wxString& strValue);
|
|
|
|
void DoSetRange(double min_val, double max_val);
|
|
|
|
void DoSetIncrement(double inc);
|
|
|
|
|
2007-07-10 07:50:14 -04:00
|
|
|
void GtkDisableEvents() const;
|
|
|
|
void GtkEnableEvents() const;
|
|
|
|
|
1999-12-29 14:18:01 -05:00
|
|
|
virtual wxSize DoGetBestSize() const;
|
2006-08-25 08:59:28 -04:00
|
|
|
virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
|
1999-12-29 14:18:01 -05:00
|
|
|
|
2004-05-06 13:26:25 -04:00
|
|
|
// Widgets that use the style->base colour for the BG colour should
|
|
|
|
// override this and return true.
|
|
|
|
virtual bool UseGTKStyleBase() const { return true; }
|
|
|
|
|
2008-03-18 10:04:19 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxSpinCtrlGTKBase)
|
1999-10-29 13:20:44 -04:00
|
|
|
DECLARE_EVENT_TABLE()
|
1999-10-11 06:05:36 -04:00
|
|
|
};
|
|
|
|
|
2008-03-18 10:04:19 -04:00
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxSpinCtrl - An integer valued spin control
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinCtrlGTKBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxSpinCtrl() {}
|
|
|
|
wxSpinCtrl(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2009-03-22 07:18:15 -04:00
|
|
|
long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
|
2008-03-18 10:04:19 -04:00
|
|
|
int min = 0, int max = 100, int initial = 0,
|
2009-11-08 18:50:46 -05:00
|
|
|
const wxString& name = wxS("wxSpinCtrl"))
|
2008-03-18 10:04:19 -04:00
|
|
|
{
|
|
|
|
Create(parent, id, value, pos, size, style, min, max, initial, name);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2009-03-22 07:18:15 -04:00
|
|
|
long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
|
2008-03-18 10:04:19 -04:00
|
|
|
int min = 0, int max = 100, int initial = 0,
|
2009-11-08 18:50:46 -05:00
|
|
|
const wxString& name = wxS("wxSpinCtrl"))
|
2008-03-18 10:04:19 -04:00
|
|
|
{
|
2009-03-22 07:18:15 -04:00
|
|
|
return wxSpinCtrlGTKBase::Create(parent, id, value, pos, size,
|
|
|
|
style, min, max, initial, 1, name);
|
2008-03-18 10:04:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// accessors
|
2009-01-08 09:36:18 -05:00
|
|
|
int GetValue() const { return wxRound( DoGetValue() ); }
|
|
|
|
int GetMin() const { return wxRound( DoGetMin() ); }
|
|
|
|
int GetMax() const { return wxRound( DoGetMax() ); }
|
|
|
|
int GetIncrement() const { return wxRound( DoGetIncrement() ); }
|
2008-03-18 10:04:19 -04:00
|
|
|
|
|
|
|
// operations
|
|
|
|
void SetValue(const wxString& value) { wxSpinCtrlGTKBase::SetValue(value); } // visibility problem w/ gcc
|
|
|
|
void SetValue( int value ) { DoSetValue(value); }
|
|
|
|
void SetRange( int minVal, int maxVal ) { DoSetRange(minVal, maxVal); }
|
|
|
|
void SetIncrement( double inc ) { DoSetIncrement(inc); }
|
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
|
|
|
|
};
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// wxSpinCtrlDouble - a double valued spin control
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class WXDLLIMPEXP_CORE wxSpinCtrlDouble : public wxSpinCtrlGTKBase
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxSpinCtrlDouble() {}
|
|
|
|
wxSpinCtrlDouble(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2009-03-22 07:18:15 -04:00
|
|
|
long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
|
|
|
|
double min = 0, double max = 100, double initial = 0,
|
|
|
|
double inc = 1,
|
2009-11-08 18:50:46 -05:00
|
|
|
const wxString& name = wxS("wxSpinCtrlDouble"))
|
2008-03-18 10:04:19 -04:00
|
|
|
{
|
2009-03-22 07:18:15 -04:00
|
|
|
Create(parent, id, value, pos, size, style,
|
|
|
|
min, max, initial, inc, name);
|
2008-03-18 10:04:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent,
|
|
|
|
wxWindowID id = wxID_ANY,
|
|
|
|
const wxString& value = wxEmptyString,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2009-03-22 07:18:15 -04:00
|
|
|
long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
|
|
|
|
double min = 0, double max = 100, double initial = 0,
|
|
|
|
double inc = 1,
|
2009-11-08 18:50:46 -05:00
|
|
|
const wxString& name = wxS("wxSpinCtrlDouble"))
|
2008-03-18 10:04:19 -04:00
|
|
|
{
|
2009-03-22 07:18:15 -04:00
|
|
|
return wxSpinCtrlGTKBase::Create(parent, id, value, pos, size,
|
|
|
|
style, min, max, initial, inc, name);
|
2008-03-18 10:04:19 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// accessors
|
|
|
|
double GetValue() const { return DoGetValue(); }
|
|
|
|
double GetMin() const { return DoGetMin(); }
|
|
|
|
double GetMax() const { return DoGetMax(); }
|
|
|
|
double GetIncrement() const { return DoGetIncrement(); }
|
|
|
|
unsigned GetDigits() const;
|
|
|
|
|
|
|
|
// operations
|
|
|
|
void SetValue(const wxString& value) { wxSpinCtrlGTKBase::SetValue(value); } // visibility problem w/ gcc
|
|
|
|
void SetValue(double value) { DoSetValue(value); }
|
|
|
|
void SetRange(double minVal, double maxVal) { DoSetRange(minVal, maxVal); }
|
|
|
|
void SetIncrement(double inc) { DoSetIncrement(inc); }
|
|
|
|
void SetDigits(unsigned digits);
|
|
|
|
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxSpinCtrlDouble)
|
|
|
|
};
|
|
|
|
|
2006-08-30 01:55:56 -04:00
|
|
|
#endif // _WX_GTK_SPINCTRL_H_
|