Implement support for value range in wxQt wxSpinButton
Closes https://github.com/wxWidgets/wxWidgets/pull/1237
This commit is contained in:
		
				
					committed by
					
						
						Vadim Zeitlin
					
				
			
			
				
	
			
			
			
						parent
						
							e9813688ad
						
					
				
				
					commit
					0e3784c46e
				
			@@ -31,6 +31,7 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    virtual int GetValue() const;
 | 
					    virtual int GetValue() const;
 | 
				
			||||||
    virtual void SetValue(int val);
 | 
					    virtual void SetValue(int val);
 | 
				
			||||||
 | 
					    virtual void SetRange(int min, int max) wxOVERRIDE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    virtual QWidget *GetHandle() const;
 | 
					    virtual QWidget *GetHandle() const;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -84,6 +84,8 @@ bool wxSpinButton::Create(wxWindow *parent,
 | 
				
			|||||||
{
 | 
					{
 | 
				
			||||||
    m_qtSpinBox = new wxQtSpinButton( parent, this );
 | 
					    m_qtSpinBox = new wxQtSpinButton( parent, this );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    m_qtSpinBox->setRange(wxSpinButtonBase::GetMin(), wxSpinButtonBase::GetMax());
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Modify the size so that the text field is not visible.
 | 
					    // 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).
 | 
					    // TODO: Find out the width of the buttons i.e. take the style into account (QStyleOptionSpinBox).
 | 
				
			||||||
    wxSize newSize( size );
 | 
					    wxSize newSize( size );
 | 
				
			||||||
@@ -92,6 +94,16 @@ bool wxSpinButton::Create(wxWindow *parent,
 | 
				
			|||||||
    return QtCreateControl( parent, id, pos, newSize, style, wxDefaultValidator, name );
 | 
					    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
 | 
					int wxSpinButton::GetValue() const
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return m_qtSpinBox->value();
 | 
					    return m_qtSpinBox->value();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user