+ switch (tool->GetStyle())
+ {
+ case wxTOOL_STYLE_SEPARATOR :
+ {
+ wxASSERT( tool->GetControlHandle() == NULL );
+ toolSize.x /= 4;
+ toolSize.y /= 4;
+ if ( GetWindowStyleFlag() & wxTB_VERTICAL )
+ toolrect.bottom = toolSize.y;
+ else
+ toolrect.right = toolSize.x;
+
+ #ifdef __WXMAC_OSX__
+ // in flat style we need a visual separator
+ #if wxMAC_USE_NATIVE_TOOLBAR
+ HIToolbarItemRef item;
+ err = HIToolbarItemCreate( kHIToolbarSeparatorIdentifier, kHIToolbarItemCantBeRemoved | kHIToolbarItemIsSeparator | kHIToolbarItemAllowDuplicates, &item );
+ if (err == noErr)
+ tool->SetToolbarItemRef( item );
+ #endif
+ CreateSeparatorControl( window, &toolrect, &controlHandle );
+ tool->SetControlHandle( controlHandle );
+ #endif
+ }
+ break;
+
+ case wxTOOL_STYLE_BUTTON :
+ {
+ wxASSERT( tool->GetControlHandle() == NULL ) ;
+ ControlButtonContentInfo info ;
+ wxMacCreateBitmapButton( &info , tool->GetNormalBitmap() , kControlContentIconRef ) ;
+
+ if ( UMAGetSystemVersion() >= 0x1000)
+ CreateIconControl( window , &toolrect , &info , false , &controlHandle ) ;
+ else
+ {
+ SInt16 behaviour = kControlBehaviorOffsetContents ;
+ if ( tool->CanBeToggled() )
+ behaviour += kControlBehaviorToggles ;
+ CreateBevelButtonControl( window , &toolrect , CFSTR("") , kControlBevelButtonNormalBevel , behaviour , &info ,
+ 0 , 0 , 0 , &controlHandle ) ;
+ }
+
+#if wxMAC_USE_NATIVE_TOOLBAR
+ HIToolbarItemRef item ;
+ wxString labelStr;
+ labelStr.Format(wxT("%xd"), (int)tool);
+ err = HIToolbarItemCreate(
+ wxMacCFStringHolder(labelStr, wxFont::GetDefaultEncoding()),
+ kHIToolbarItemCantBeRemoved | kHIToolbarItemAnchoredLeft | kHIToolbarItemAllowDuplicates, &item );
+ if (err == noErr)
+ {
+ HIToolbarItemSetLabel( item, wxMacCFStringHolder(tool->GetLabel(), m_font.GetEncoding()) );
+ HIToolbarItemSetIconRef( item, info.u.iconRef );
+ HIToolbarItemSetCommandID( item, tool->GetId() );
+ tool->SetToolbarItemRef( item );
+ }
+#endif
+
+ wxMacReleaseBitmapButton( &info ) ;
+ /*
+ SetBevelButtonTextPlacement( m_controlHandle , kControlBevelButtonPlaceBelowGraphic ) ;
+ UMASetControlTitle( m_controlHandle , label , wxFont::GetDefaultEncoding() ) ;
+ */
+
+ InstallControlEventHandler( (ControlRef) controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
+ GetEventTypeCount(eventList), eventList, tool, NULL );
+
+ tool->SetControlHandle( controlHandle );
+ }
+ break;
+
+ case wxTOOL_STYLE_CONTROL :
+ wxASSERT( tool->GetControl() != NULL );
+#if 0 // wxMAC_USE_NATIVE_TOOLBAR
+ // FIXME: doesn't work yet...
+ {
+ HIToolbarItemRef item;
+ wxString labelStr;
+ labelStr.Format( wxT("%xd"), (int) tool );
+ result = HIToolbarItemCreate( wxMacCFStringHolder(labelStr, wxFont::GetDefaultEncoding()),
+ kHIToolbarItemCantBeRemoved | kHIToolbarItemAnchoredLeft | kHIToolbarItemAllowDuplicates,
+ &item );
+ if ( result == 0 )
+ {
+ HIToolbarItemSetLabel( item, wxMacCFStringHolder(tool->GetLabel(), m_font.GetEncoding()) );
+ HIToolbarItemSetCommandID( item, tool->GetId() );
+ tool->SetToolbarItemRef( item );
+
+ controlHandle = ( ControlRef ) tool->GetControlHandle();
+ wxASSERT_MSG( controlHandle != NULL, wxT("NULL tool control") );
+
+ // FIXME: is this necessary ??
+ ::GetControlBounds( controlHandle, &toolrect );
+ UMAMoveControl( controlHandle, -toolrect.left, -toolrect.top );
+
+ // FIXME: is this necessary ??
+ InstallControlEventHandler( controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
+ GetEventTypeCount(eventList), eventList, tool, NULL );
+ }
+ }
+
+#else
+ // FIXME: right now there's nothing to do here
+#endif
+ break;
+
+ default :
+ break;
+ }
+
+ if ( err == 0 )
+ {
+ if ( controlHandle )
+ {
+ ControlRef container = (ControlRef) GetHandle();
+ wxASSERT_MSG( container != NULL, wxT("No valid mac container control") );
+
+ UMAShowControl( controlHandle );
+ ::EmbedControl( controlHandle, container );
+ }
+
+ if ( tool->CanBeToggled() && tool->IsToggled() )
+ tool->UpdateToggleImage( true );
+
+ // nothing special to do here - we relayout in Realize() later
+ tool->Attach(this);
+ InvalidateBestSize();
+ }
+ else
+ {
+ wxString errMsg;
+ errMsg.Format( wxT("wxToolBar::DoInsertTool - failure [%ld]"), (long) err );
+ wxASSERT_MSG( false, errMsg.c_str() );
+ }
+
+ return( err == 0 );