diff --git a/include/wx/qt/radiobox.h b/include/wx/qt/radiobox.h index f858a576f6..2c84083aa3 100644 --- a/include/wx/qt/radiobox.h +++ b/include/wx/qt/radiobox.h @@ -65,10 +65,11 @@ public: using wxWindowBase::Enable; using wxRadioBoxBase::GetDefaultBorder; - virtual bool Enable(unsigned int n, bool enable = true); - virtual bool Show(unsigned int n, bool show = true); - virtual bool IsItemEnabled(unsigned int n) const; - virtual bool IsItemShown(unsigned int n) const; + virtual bool Enable(unsigned int n, bool enable = true) wxOVERRIDE; + virtual bool Enable(bool enable = true) wxOVERRIDE; + virtual bool Show(unsigned int n, bool show = true) wxOVERRIDE; + virtual bool IsItemEnabled(unsigned int n) const wxOVERRIDE; + virtual bool IsItemShown(unsigned int n) const wxOVERRIDE; virtual unsigned int GetCount() const; virtual wxString GetString(unsigned int n) const; diff --git a/src/qt/radiobox.cpp b/src/qt/radiobox.cpp index 693e673170..beede99053 100644 --- a/src/qt/radiobox.cpp +++ b/src/qt/radiobox.cpp @@ -168,10 +168,42 @@ static QAbstractButton *GetButtonAt( const QButtonGroup *group, unsigned int n ) bool wxRadioBox::Enable(unsigned int n, bool enable) { - QAbstractButton *qtButton = GetButtonAt( m_qtButtonGroup, n ); - CHECK_BUTTON( qtButton, false ); + if ( enable && !m_qtGroupBox->isEnabled() ) + { + 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; }