added wxSpinCtrlDouble (slightly modified patch 1835864)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52612 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -12,52 +12,67 @@
|
||||
#define _WX_GTK_SPINCTRL_H_
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxSpinCtrl
|
||||
// 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.
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLIMPEXP_CORE wxSpinCtrl : public wxControl
|
||||
class WXDLLIMPEXP_CORE wxSpinCtrlGTKBase : public wxSpinCtrlBase
|
||||
{
|
||||
public:
|
||||
wxSpinCtrl();
|
||||
wxSpinCtrl(wxWindow *parent,
|
||||
wxWindowID id = -1,
|
||||
const wxString& value = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxSP_ARROW_KEYS,
|
||||
int min = 0, int max = 100, int initial = 0,
|
||||
const wxString& name = _T("wxSpinCtrl"))
|
||||
{
|
||||
Create(parent, id, value, pos, size, style, min, max, initial, name);
|
||||
}
|
||||
wxSpinCtrlGTKBase() : m_value(0) {}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id = -1,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxString& value = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxSP_ARROW_KEYS,
|
||||
int min = 0, int max = 100, int initial = 0,
|
||||
const wxString& name = _T("wxSpinCtrl"));
|
||||
double min = 0, double max = 100, double initial = 0, double inc = 1,
|
||||
const wxString& name = _T("wxSpinCtrlGTKBase"));
|
||||
|
||||
void SetValue(const wxString& text);
|
||||
// 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;
|
||||
|
||||
// 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);
|
||||
|
||||
virtual int GetValue() const;
|
||||
virtual void SetValue( int value );
|
||||
virtual void SetRange( int minVal, int maxVal );
|
||||
virtual int GetMin() const;
|
||||
virtual int GetMax() const;
|
||||
|
||||
static wxVisualAttributes
|
||||
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
|
||||
|
||||
|
||||
// implementation
|
||||
void OnChar( wxKeyEvent &event );
|
||||
|
||||
int m_pos;
|
||||
|
||||
double m_value; // public for GTK callback function
|
||||
|
||||
protected:
|
||||
|
||||
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);
|
||||
|
||||
void GtkDisableEvents() const;
|
||||
void GtkEnableEvents() const;
|
||||
|
||||
@@ -69,8 +84,106 @@ protected:
|
||||
virtual bool UseGTKStyleBase() const { return true; }
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
|
||||
DECLARE_DYNAMIC_CLASS(wxSpinCtrlGTKBase)
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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,
|
||||
long style = wxSP_ARROW_KEYS,
|
||||
int min = 0, int max = 100, int initial = 0,
|
||||
const wxString& name = _T("wxSpinCtrl"))
|
||||
{
|
||||
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,
|
||||
long style = wxSP_ARROW_KEYS,
|
||||
int min = 0, int max = 100, int initial = 0,
|
||||
const wxString& name = _T("wxSpinCtrl"))
|
||||
{
|
||||
return wxSpinCtrlGTKBase::Create(parent, id, value, pos, size, style, min, max, initial, 1, name);
|
||||
}
|
||||
|
||||
// accessors
|
||||
int GetValue() const { return int(DoGetValue() + 0.5); }
|
||||
int GetMin() const { return int(DoGetMin() + 0.5); }
|
||||
int GetMax() const { return int(DoGetMax() + 0.5); }
|
||||
int GetIncrement() const { return int(DoGetIncrement() + 0.5); }
|
||||
|
||||
// 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); }
|
||||
|
||||
private:
|
||||
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,
|
||||
long style = wxSP_ARROW_KEYS,
|
||||
double min = 0, double max = 100, double initial = 0, double inc = 1,
|
||||
const wxString& name = _T("wxSpinCtrlDouble"))
|
||||
{
|
||||
Create(parent, id, value, pos, size, style, min, max, initial, inc, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const wxString& value = wxEmptyString,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = wxSP_ARROW_KEYS,
|
||||
double min = 0, double max = 100, double initial = 0, double inc = 1,
|
||||
const wxString& name = _T("wxSpinCtrlDouble"))
|
||||
{
|
||||
return wxSpinCtrlGTKBase::Create(parent, id, value, pos, size, style, min, max, initial, inc, name);
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxSpinCtrlDouble)
|
||||
};
|
||||
|
||||
#endif // _WX_GTK_SPINCTRL_H_
|
||||
|
Reference in New Issue
Block a user