Implement support for value range in wxQt wxSpinButton

Closes https://github.com/wxWidgets/wxWidgets/pull/1237
This commit is contained in:
Cătălin Răceanu 2019-02-22 18:18:17 +02:00 committed by Vadim Zeitlin
parent e9813688ad
commit 0e3784c46e
2 changed files with 13 additions and 0 deletions

View File

@ -31,6 +31,7 @@ public:
virtual int GetValue() const;
virtual void SetValue(int val);
virtual void SetRange(int min, int max) wxOVERRIDE;
virtual QWidget *GetHandle() const;

View File

@ -84,6 +84,8 @@ bool wxSpinButton::Create(wxWindow *parent,
{
m_qtSpinBox = new wxQtSpinButton( parent, this );
m_qtSpinBox->setRange(wxSpinButtonBase::GetMin(), wxSpinButtonBase::GetMax());
// Modify the size so that the text field is not visible.
// TODO: Find out the width of the buttons i.e. take the style into account (QStyleOptionSpinBox).
wxSize newSize( size );
@ -92,6 +94,16 @@ bool wxSpinButton::Create(wxWindow *parent,
return QtCreateControl( parent, id, pos, newSize, style, wxDefaultValidator, name );
}
void wxSpinButton::SetRange(int min, int max)
{
wxSpinButtonBase::SetRange(min, max); // cache the values
if ( m_qtSpinBox )
{
m_qtSpinBox->setRange(min, max);
}
}
int wxSpinButton::GetValue() const
{
return m_qtSpinBox->value();