]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/toolbar.cpp
Worked around problem with kill focus event being sent as soon as
[wxWidgets.git] / src / mac / carbon / toolbar.cpp
index 1f5403adb325e52f006e96659575a19f39cd4b37..2f4ac0c6a30a49fbdfa63011a7f882241dff1b5c 100644 (file)
 #include "wx/tabctrl.h"
 #include "wx/bitmap.h"
 
-#if !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxControl)
 
 BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase)
     EVT_PAINT( wxToolBar::OnPaint ) 
 END_EVENT_TABLE()
-#endif
 
 #include "wx/mac/uma.h"
 #include "wx/geometry.h"
@@ -170,7 +168,7 @@ static pascal OSStatus wxMacToolBarToolControlEventHandler( EventHandlerCallRef
                 
                 ControlPartCode pc = kControlNoPart ;
                 if ( CGRectContainsPoint( rect , pt ) )
-                    pc = kControlButtonPart ;
+                    pc = kControlIconPart ;
                 cEvent.SetParameter( kEventParamControlPart , typeControlPartCode, pc ) ;
                 result = noErr ;
             }
@@ -182,7 +180,7 @@ static pascal OSStatus wxMacToolBarToolControlEventHandler( EventHandlerCallRef
     return result ;
 }
 
-pascal OSStatus wxMacToolBarToolEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
+static pascal OSStatus wxMacToolBarToolEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
 {
     OSStatus result = eventNotHandledErr ;
 
@@ -436,6 +434,21 @@ bool wxToolBar::Realize()
                     DoToggleTool(tool, true);
                 }
             }
+            else if (tool->IsToggled())
+            {
+                wxToolBarToolsList::compatibility_iterator nodePrev = node->GetPrevious();
+                while ( nodePrev )
+                {
+                    wxToolBarToolBase *tool = nodePrev->GetData();
+                    if ( !tool->IsButton() || (tool->GetKind() != wxITEM_RADIO) )
+                        break;
+                    if ( tool->Toggle(false) )
+                    {
+                        DoToggleTool(tool, false);
+                    }
+                    nodePrev = nodePrev->GetPrevious();
+                }
+            }
             isRadio = TRUE;
         }
         else
@@ -617,7 +630,7 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos),
                 CreateIconControl( window , &toolrect , &info , false , &controlHandle ) ;
         #else        
                 SInt16 behaviour = kControlBehaviorOffsetContents ;
-                if ( CanBeToggled() )
+                if ( tool->CanBeToggled() )
                     behaviour += kControlBehaviorToggles ;
                 CreateBevelButtonControl( window , &toolrect , CFSTR("") , kControlBevelButtonNormalBevel , behaviour , &info , 
                     0 , 0 , 0 , &controlHandle ) ;