]> git.saurik.com Git - wxWidgets.git/commitdiff
Fix from Jed Burgess that correctly untoggles radio toolbar items when
authorRobin Dunn <robin@alldunn.com>
Thu, 23 Sep 2004 22:39:24 +0000 (22:39 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 23 Sep 2004 22:39:24 +0000 (22:39 +0000)
another one in the same group is selected.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29296 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/common/tbarbase.cpp
src/mac/carbon/toolbar.cpp

index e3b306923cf3f71559441da1725ee18a923c41b1..69f106b9ee85172b1b780cd3d94e2efd34316caf 100644 (file)
@@ -385,7 +385,10 @@ void wxToolBarBase::UnToggleRadioGroup(wxToolBarToolBase *tool)
         if ( !tool->IsButton() || tool->GetKind() != wxITEM_RADIO )
             break;
 
-        tool->Toggle(false);
+        if ( tool->Toggle(false) )
+        {
+            DoToggleTool(tool, false);
+        }
 
         nodeNext = nodeNext->GetNext();
     }
@@ -398,7 +401,10 @@ void wxToolBarBase::UnToggleRadioGroup(wxToolBarToolBase *tool)
         if ( !tool->IsButton() || tool->GetKind() != wxITEM_RADIO )
             break;
 
-        tool->Toggle(false);
+        if ( tool->Toggle(false) )
+        {
+            DoToggleTool(tool, false);
+        }
 
         nodePrev = nodePrev->GetPrevious();
     }
index 0ae7bed16ee73de01b88d0a755b169988d6dedb7..9a6f08cd1f1f900e27e920bdd566aa1536be44e1 100644 (file)
@@ -123,10 +123,9 @@ static pascal OSStatus wxMacToolBarToolControlEventHandler( EventHandlerCallRef
                 wxToolBarTool* tbartool = (wxToolBarTool*)data ;
                 if ( tbartool->CanBeToggled() )
                 {
-                    tbartool->Toggle( GetControl32BitValue( (ControlRef) tbartool->GetControlHandle() ) ) ;
+                    ((wxToolBar*)tbartool->GetToolBar())->ToggleTool(tbartool->GetId(), GetControl32BitValue((ControlRef)tbartool->GetControlHandle()));
                 }
                 ((wxToolBar*)tbartool->GetToolBar())->OnLeftClick( tbartool->GetId() , tbartool -> IsToggled() ) ;
-
                 result = noErr; 
             }
             break ;
@@ -349,12 +348,32 @@ bool wxToolBar::Realize()
         node = node->GetNext();
     }
 
+    bool lastWasRadio = FALSE;
     node = m_tools.GetFirst();
     while (node)
     {
         wxToolBarTool *tool = (wxToolBarTool *)node->GetData();
         wxSize cursize = tool->GetSize() ;
         
+        bool isRadio = FALSE;
+
+        if ( tool->IsButton() && tool->GetKind() == wxITEM_RADIO )
+        {
+            if ( !lastWasRadio )
+            {
+                if (tool->Toggle(true))
+                {
+                    DoToggleTool(tool, true);
+                }
+            }
+            isRadio = TRUE;
+        }
+        else
+        {
+            isRadio = FALSE;
+        }
+        lastWasRadio = isRadio;
+
         // for the moment we just do a single row/column alignement
         if ( x + cursize.x > maxWidth )
             maxWidth = x + cursize.x ;