]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/radiobut.cpp
extracted duplicated code from src/*/data.cpp in a common file
[wxWidgets.git] / src / msw / radiobut.cpp
index 9dd486599843233bbbb6ba6f10565ba10001a9bc..aee70d403494ef873eafc9e18d2772ab7fc13a04 100644 (file)
@@ -117,31 +117,35 @@ void wxRadioButton::SetValue(bool value)
         wxWindowList::Node *nodeThis = siblings.Find(this);
         wxCHECK_RET( nodeThis, _T("radio button not a child of its parent?") );
 
-        // turn off all radio buttons before this one
-        for ( wxWindowList::Node *nodeBefore = nodeThis->GetPrevious();
-              nodeBefore;
-              nodeBefore = nodeBefore->GetPrevious() )
+        // if it's not the first item of the group ...
+        if ( !HasFlag(wxRB_GROUP) )
         {
-            wxRadioButton *btn = wxDynamicCast(nodeBefore->GetData(),
-                                               wxRadioButton);
-            if ( !btn )
-            {
-                // the radio buttons in a group must be consecutive, so there
-                // are no more of them
-                break;
-            }
-
-            btn->SetValue(FALSE);
-
-            if ( btn->HasFlag(wxRB_GROUP) )
+            // ... turn off all radio buttons before it
+            for ( wxWindowList::Node *nodeBefore = nodeThis->GetPrevious();
+                  nodeBefore;
+                  nodeBefore = nodeBefore->GetPrevious() )
             {
-                // even if there are other radio buttons before this one,
-                // they're not in the same group with us
-                break;
+                wxRadioButton *btn = wxDynamicCast(nodeBefore->GetData(),
+                                                   wxRadioButton);
+                if ( !btn )
+                {
+                    // the radio buttons in a group must be consecutive, so
+                    // there are no more of them
+                    break;
+                }
+
+                btn->SetValue(FALSE);
+
+                if ( btn->HasFlag(wxRB_GROUP) )
+                {
+                    // even if there are other radio buttons before this one,
+                    // they're not in the same group with us
+                    break;
+                }
             }
         }
 
-        // ... and all after this one
+        // ... and also turn off all buttons after this one
         for ( wxWindowList::Node *nodeAfter = nodeThis->GetNext();
               nodeAfter;
               nodeAfter = nodeAfter->GetNext() )