// function ambiguity.
// ----------------------------------------------------------------------------
-class WXDLLEXPORT wxSpinCtrlGenericBase : public wxSpinCtrlBase
+class WXDLLIMPEXP_CORE wxSpinCtrlGenericBase : public wxSpinCtrlBase
{
public:
wxSpinCtrlGenericBase() { Init(); }
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,
+ long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
+ double min = 0, double max = 100, double initial = 0,
+ double inc = 1,
const wxString& name = _T("wxSpinCtrl"));
virtual ~wxSpinCtrlGenericBase();
// forward these functions to all subcontrols
virtual bool Enable(bool enable = true);
virtual bool Show(bool show = true);
- virtual bool Reparent(wxWindow *newParent);
+ virtual bool Reparent(wxWindowBase *newParent);
// get the subcontrols
wxTextCtrl *GetText() const { return m_textCtrl; }
// Send the correct event type
virtual void DoSendEvent() = 0;
+ // check if the value is in range
bool InRange(double n) const { return (n >= m_min) && (n <= m_max); }
+ // ensure that the value is in range wrapping it round if necessary
+ double AdjustToFitInRange(double value) const;
+
+
double m_value;
double m_min;
double m_max;
#include "wx/textctrl.h"
-class WXDLLEXPORT wxSpinCtrlGenericBase : public wxTextCtrl
+class WXDLLIMPEXP_CORE wxSpinCtrlGenericBase : public wxTextCtrl
{
public:
wxSpinCtrlGenericBase() : m_value(0), m_min(0), m_max(100),
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,
+ long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
+ double min = 0, double max = 100, double initial = 0,
+ double inc = 1,
const wxString& name = _T("wxSpinCtrl"))
{
m_min = min;
// void SetValue(T val)
// void SetRange(T minVal, T maxVal)
// void SetIncrement(T inc)
- virtual void SetSnapToTicks(bool snap_to_ticks) { m_snap_to_ticks = snap_to_ticks; }
+ virtual void SetSnapToTicks(bool snap_to_ticks)
+ { m_snap_to_ticks = snap_to_ticks; }
// void SetDigits(unsigned digits) - wxSpinCtrlDouble only
// Select text in the textctrl
return n;
}
- bool DoSetValue(double val) { wxTextCtrl::SetValue(wxString::Format(m_format.c_str(), val)); return true; }
- void DoSetRange(double min_val, double max_val) { m_min = min_val; m_max = max_val; }
+ bool DoSetValue(double val)
+ {
+ wxTextCtrl::SetValue(wxString::Format(m_format.c_str(), val));
+ return true;
+ }
+ void DoSetRange(double min_val, double max_val)
+ {
+ m_min = min_val;
+ m_max = max_val;
+ }
void DoSetIncrement(double inc) { m_increment = inc; } // Note: unused
double m_value;
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
int min = 0, int max = 100, int initial = 0,
const wxString& name = _T("wxSpinCtrl"))
{
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
- long style = wxSP_ARROW_KEYS,
+ long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
int min = 0, int max = 100, int initial = 0,
const wxString& name = _T("wxSpinCtrl"))
{
- return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size, style, min, max, initial, 1, name);
+ return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size,
+ style, min, max, initial, 1, name);
}
// accessors
- int GetValue(wxSPINCTRL_GETVALUE_FIX) const { return int(DoGetValue() + 0.5); }
- int GetMin() const { return int(m_min + 0.5); }
- int GetMax() const { return int(m_max + 0.5); }
- int GetIncrement() const { return int(m_increment + 0.5); }
+ int GetValue(wxSPINCTRL_GETVALUE_FIX) const
+ { return wxRound( DoGetValue() ); }
+ int GetMin() const { return wxRound( m_min ); }
+ int GetMax() const { return wxRound( m_max ); }
+ int GetIncrement() const { return wxRound( m_increment ); }
// operations
- void SetValue(const wxString& value) { wxSpinCtrlGenericBase::SetValue(value); } // visibility problem w/ gcc
+ void SetValue(const wxString& value)
+ { wxSpinCtrlGenericBase::SetValue(value); }
void SetValue( int value ) { DoSetValue(value); }
void SetRange( int minVal, int maxVal ) { DoSetRange(minVal, maxVal); }
void SetIncrement( double inc ) { DoSetIncrement(inc); }
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,
+ long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
+ double min = 0, double max = 100, double initial = 0,
+ double inc = 1,
const wxString& name = _T("wxSpinCtrlDouble"))
{
m_digits = 0;
- Create(parent, id, value, pos, size, style, min, max, initial, inc, name);
+ Create(parent, id, value, pos, size, style,
+ min, max, initial, inc, name);
}
bool Create(wxWindow *parent,
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,
+ long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
+ double min = 0, double max = 100, double initial = 0,
+ double inc = 1,
const wxString& name = _T("wxSpinCtrlDouble"))
{
- return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size, style, min, max, initial, inc, name);
+ return wxSpinCtrlGenericBase::Create(parent, id, value, pos, size,
+ style, min, max, initial,
+ inc, name);
}
// accessors
unsigned GetDigits() const { return m_digits; }
// operations
- void SetValue(const wxString& value) { wxSpinCtrlGenericBase::SetValue(value); } // visibility problem w/ gcc
+ void SetValue(const wxString& value)
+ { wxSpinCtrlGenericBase::SetValue(value); }
void SetValue(double value) { DoSetValue(value); }
void SetRange(double minVal, double maxVal) { DoSetRange(minVal, maxVal); }
void SetIncrement(double inc) { DoSetIncrement(inc); }