diff --git a/src/univ/radiobut.cpp b/src/univ/radiobut.cpp index ec2ccd9994..bae966edb5 100644 --- a/src/univ/radiobut.cpp +++ b/src/univ/radiobut.cpp @@ -65,43 +65,17 @@ bool wxRadioButton::Create(wxWindow *parent, void wxRadioButton::OnCheck() { - // clear all others radio buttons in our group: for this we need to - // find the radio button which is the first in the group, i.e. the one - // with wxRB_GROUP style - const wxWindowList& siblings = GetParent()->GetChildren(); - wxWindowList::compatibility_iterator nodeStart = siblings.Find(this); - while ( nodeStart ) + // clear all the other radio buttons in our group + wxRadioButton* const last = GetLastInGroup(); + for ( wxRadioButton* radio = GetFirstInGroup(); + radio; + radio = radio->GetNextInGroup() ) { - // stop if we found a radio button with wxRB_GROUP style or it we - // are at the first control - if ( !nodeStart->GetPrevious() || - (nodeStart->GetData()->GetWindowStyle() & wxRB_GROUP) ) + if ( radio != this ) + radio->ClearValue(); + + if ( radio == last ) break; - - nodeStart = nodeStart->GetPrevious(); - } - - // now clear all radio buttons from the starting one until the next - // one with wxRB_GROUP style - while ( nodeStart ) - { - wxWindow *win = nodeStart->GetData(); - if ( win != this ) - { - wxRadioButton *btn = wxDynamicCast(win, wxRadioButton); - if ( btn ) - { - btn->ClearValue(); - } - } - - nodeStart = nodeStart->GetNext(); - if ( !nodeStart || - (nodeStart->GetData()->GetWindowStyle() & wxRB_GROUP) ) - { - // we reached the next group - break; - } } }