Fix enabling radiobox buttons in wxQt
If a QGroupBox is disabled, then you cannot set any of its items to be enabled without first enabling it. Enabling/disabling it will set that value (true/false) on all of its items, although setting the QGroupBox to an enabled state which it already has does not result in this behaviour. Fix wxQt to match the expected wxRadioBox behaviour and allow the unit test to pass. Closes https://github.com/wxWidgets/wxWidgets/pull/1064
This commit is contained in:
committed by
Vadim Zeitlin
parent
91a87e765b
commit
2a64b65149
@@ -65,10 +65,11 @@ public:
|
|||||||
using wxWindowBase::Enable;
|
using wxWindowBase::Enable;
|
||||||
using wxRadioBoxBase::GetDefaultBorder;
|
using wxRadioBoxBase::GetDefaultBorder;
|
||||||
|
|
||||||
virtual bool Enable(unsigned int n, bool enable = true);
|
virtual bool Enable(unsigned int n, bool enable = true) wxOVERRIDE;
|
||||||
virtual bool Show(unsigned int n, bool show = true);
|
virtual bool Enable(bool enable = true) wxOVERRIDE;
|
||||||
virtual bool IsItemEnabled(unsigned int n) const;
|
virtual bool Show(unsigned int n, bool show = true) wxOVERRIDE;
|
||||||
virtual bool IsItemShown(unsigned int n) const;
|
virtual bool IsItemEnabled(unsigned int n) const wxOVERRIDE;
|
||||||
|
virtual bool IsItemShown(unsigned int n) const wxOVERRIDE;
|
||||||
|
|
||||||
virtual unsigned int GetCount() const;
|
virtual unsigned int GetCount() const;
|
||||||
virtual wxString GetString(unsigned int n) const;
|
virtual wxString GetString(unsigned int n) const;
|
||||||
|
@@ -168,10 +168,42 @@ static QAbstractButton *GetButtonAt( const QButtonGroup *group, unsigned int n )
|
|||||||
|
|
||||||
bool wxRadioBox::Enable(unsigned int n, bool enable)
|
bool wxRadioBox::Enable(unsigned int n, bool enable)
|
||||||
{
|
{
|
||||||
QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, n );
|
if ( enable && !m_qtGroupBox->isEnabled() )
|
||||||
CHECK_BUTTON( qtButton, false );
|
{
|
||||||
|
m_qtGroupBox->setEnabled( true );
|
||||||
|
|
||||||
|
for ( unsigned int i = 0; i < GetCount(); ++i )
|
||||||
|
{
|
||||||
|
QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, i );
|
||||||
|
CHECK_BUTTON( qtButton, false );
|
||||||
|
|
||||||
|
qtButton->setEnabled( i == n );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, n );
|
||||||
|
CHECK_BUTTON( qtButton, false );
|
||||||
|
qtButton->setEnabled(enable);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxRadioBox::Enable( bool enable )
|
||||||
|
{
|
||||||
|
if ( m_qtGroupBox->isEnabled() == enable )
|
||||||
|
{
|
||||||
|
for ( unsigned int i = 0; i < GetCount(); ++i )
|
||||||
|
{
|
||||||
|
QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, i );
|
||||||
|
CHECK_BUTTON( qtButton, false );
|
||||||
|
qtButton->setEnabled( enable );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_qtGroupBox->setEnabled( enable );
|
||||||
|
|
||||||
qtButton->setEnabled( enable );
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user