Add wxSpinCtrl::GetTextValue()

This allows to retrieve the current contents of the text entry part of
wxSpinCtrl.

For now provide a stub in the base class, will be made pure virtual
later.

Co-Authored-By: Vadim Zeitlin <vadim@wxwidgets.org>
This commit is contained in:
Dummy
2021-04-18 01:27:37 +01:00
committed by Vadim Zeitlin
parent c6d6ec9295
commit b6f8a8cf5b
8 changed files with 35 additions and 0 deletions

View File

@@ -60,6 +60,7 @@ public:
virtual ~wxSpinCtrlGenericBase(); virtual ~wxSpinCtrlGenericBase();
// accessors // accessors
virtual wxString GetTextValue() const wxOVERRIDE;
// T GetValue() const // T GetValue() const
// T GetMin() const // T GetMin() const
// T GetMax() const // T GetMax() const

View File

@@ -35,6 +35,7 @@ public:
// wxSpinCtrl(Double) methods call DoXXX functions of the same name // wxSpinCtrl(Double) methods call DoXXX functions of the same name
// accessors // accessors
virtual wxString GetTextValue() const wxOVERRIDE;
// T GetValue() const // T GetValue() const
// T GetMin() const // T GetMin() const
// T GetMax() const // T GetMax() const

View File

@@ -62,6 +62,7 @@ public:
void SetSelection(long from, long to); void SetSelection(long from, long to);
// wxSpinCtrlBase methods // wxSpinCtrlBase methods
virtual wxString GetTextValue() const;
virtual int GetBase() const; virtual int GetBase() const;
virtual bool SetBase(int base); virtual bool SetBase(int base);

View File

@@ -35,6 +35,7 @@ public:
wxSpinCtrlBase() {} wxSpinCtrlBase() {}
// accessor functions that derived classes are expected to have // accessor functions that derived classes are expected to have
virtual wxString GetTextValue() const { return wxString(); }
// T GetValue() const // T GetValue() const
// T GetMin() const // T GetMin() const
// T GetMax() const // T GetMax() const

View File

@@ -133,6 +133,13 @@ public:
*/ */
int GetMin() const; int GetMin() const;
/**
Returns the text in the text entry part of the control.
@since 3.1.6
*/
wxString GetTextValue() const;
/** /**
Gets the value of the spin control. Gets the value of the spin control.
*/ */
@@ -315,6 +322,13 @@ public:
*/ */
double GetMin() const; double GetMin() const;
/**
Returns the text in the text entry part of the control.
@since 3.1.6
*/
wxString GetTextValue() const;
/** /**
Gets the value of the spin control. Gets the value of the spin control.
*/ */

View File

@@ -506,6 +506,11 @@ bool wxSpinCtrlGenericBase::SyncSpinToText(SendEvent sendEvent)
// changing value and range // changing value and range
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxString wxSpinCtrlGenericBase::GetTextValue() const
{
return m_textCtrl ? m_textCtrl->GetValue() : wxString();
}
void wxSpinCtrlGenericBase::SetValue(const wxString& text) void wxSpinCtrlGenericBase::SetValue(const wxString& text)
{ {
wxCHECK_RET( m_textCtrl, wxT("invalid call to wxSpinCtrl::SetValue") ); wxCHECK_RET( m_textCtrl, wxT("invalid call to wxSpinCtrl::SetValue") );

View File

@@ -214,6 +214,13 @@ double wxSpinCtrlGTKBase::DoGetIncrement() const
return inc; return inc;
} }
wxString wxSpinCtrlGTKBase::GetTextValue() const
{
wxCHECK_MSG(m_widget, wxEmptyString, "invalid spin button");
return gtk_entry_get_text( GTK_ENTRY(m_widget) );
}
bool wxSpinCtrlGTKBase::GetSnapToTicks() const bool wxSpinCtrlGTKBase::GetSnapToTicks() const
{ {
wxCHECK_MSG(m_widget, false, "invalid spin button"); wxCHECK_MSG(m_widget, false, "invalid spin button");

View File

@@ -442,6 +442,11 @@ bool wxSpinCtrl::SetBase(int base)
// wxTextCtrl-like methods // wxTextCtrl-like methods
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
wxString wxSpinCtrl::GetTextValue() const
{
return wxGetWindowText(m_hwndBuddy);
}
void wxSpinCtrl::SetValue(const wxString& text) void wxSpinCtrl::SetValue(const wxString& text)
{ {
if ( !::SetWindowText(GetBuddyHwnd(), text.c_str()) ) if ( !::SetWindowText(GetBuddyHwnd(), text.c_str()) )