Merge branch 'qt-radio-groups'

Fix radio button grouping in Qt.

See https://github.com/wxWidgets/wxWidgets/pull/1212
This commit is contained in:
Vadim Zeitlin
2019-02-05 03:03:10 +01:00
3 changed files with 92 additions and 16 deletions

View File

@@ -17,6 +17,7 @@
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/radiobut.h"
#include "wx/stattext.h"
#endif // WX_PRECOMP
#include "wx/uiaction.h"
@@ -105,22 +106,25 @@ void RadioButtonTestCase::Value()
void RadioButtonTestCase::Group()
{
//Add another button to the first group and create another of two buttons
wxRadioButton* g1radio0 = new wxRadioButton(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton",
wxDefaultPosition,
wxDefaultSize, wxRB_GROUP);
wxWindow* const parent = wxTheApp->GetTopWindow();
wxRadioButton* g1radio1 = new wxRadioButton(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton");
// Create two different radio groups.
wxRadioButton* g1radio0 = new wxRadioButton(parent, wxID_ANY, "radio 1.0",
wxDefaultPosition, wxDefaultSize,
wxRB_GROUP);
wxRadioButton* g2radio0 = new wxRadioButton(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton",
wxDefaultPosition,
wxDefaultSize, wxRB_GROUP);
wxRadioButton* g1radio1 = new wxRadioButton(parent, wxID_ANY, "radio 1.1");
wxRadioButton* g2radio1 = new wxRadioButton(wxTheApp->GetTopWindow(),
wxID_ANY, "wxRadioButton");
wxRadioButton* g2radio0 = new wxRadioButton(parent, wxID_ANY, "radio 2.0",
wxDefaultPosition, wxDefaultSize,
wxRB_GROUP);
wxRadioButton* g2radio1 = new wxRadioButton(parent, wxID_ANY, "radio 2.1");
// Check that having another control between radio buttons doesn't break
// grouping.
wxStaticText* text = new wxStaticText(parent, wxID_ANY, "Label");
wxRadioButton* g2radio2 = new wxRadioButton(parent, wxID_ANY, "radio 2.1");
g1radio0->SetValue(true);
g2radio0->SetValue(true);
@@ -138,6 +142,11 @@ void RadioButtonTestCase::Group()
CPPUNIT_ASSERT(!g2radio0->GetValue());
CPPUNIT_ASSERT(g2radio1->GetValue());
g2radio2->SetValue(true);
CPPUNIT_ASSERT(!g2radio0->GetValue());
CPPUNIT_ASSERT(!g2radio1->GetValue());
CPPUNIT_ASSERT(g2radio2->GetValue());
g1radio0->SetValue(true);
g2radio0->SetValue(true);
@@ -150,6 +159,8 @@ void RadioButtonTestCase::Group()
wxDELETE(g1radio1);
wxDELETE(g2radio0);
wxDELETE(g2radio1);
wxDELETE(g2radio2);
wxDELETE(text);
}
void RadioButtonTestCase::Single()