+ wxToolBarTool *tool = (wxToolBarTool *)node->Data();
+ wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->GetBitmap1().GetRefData()) ;
+
+ if( !tool->IsSeparator() )
+ {
+ Rect toolrect = { toolbarrect.top + y + m_yMargin + kwxMacToolBarTopMargin,
+ toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin , 0 , 0 } ;
+ toolrect.right = toolrect.left + toolSize.x ;
+ toolrect.bottom = toolrect.top + toolSize.y ;
+
+ ControlButtonContentInfo info ;
+ if ( bmap )
+ {
+ if ( bmap->m_bitmapType == kMacBitmapTypePict )
+ {
+ info.contentType = kControlContentPictHandle ;
+ info.u.picture = MAC_WXHMETAFILE(bmap->m_hPict) ;
+ }
+ else if ( bmap->m_bitmapType == kMacBitmapTypeGrafWorld )
+ {
+ if ( tool->GetBitmap1().GetMask() )
+ {
+ info.contentType = kControlContentCIconHandle ;
+ info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , MAC_WXHBITMAP(tool->GetBitmap1().GetMask()->GetMaskBitmap()) ,
+ 8 , 16 ) ;
+ }
+ else
+ {
+ info.contentType = kControlContentCIconHandle ;
+ info.u.cIconHandle = wxMacCreateCIcon( MAC_WXHBITMAP(bmap->m_hBitmap) , NULL ,
+ 8 , 16 ) ;
+ }
+ }
+ }
+
+ ControlHandle m_macToolHandle ;
+
+ SInt16 behaviour = kControlBehaviorOffsetContents ;
+ if ( tool->CanBeToggled() )
+ behaviour += kControlBehaviorToggles ;
+
+ if ( info.u.cIconHandle ) // since it is a handle we can use one of them
+ {
+ m_macToolHandle = ::NewControl( window , &toolrect , "\p" , false , 0 ,
+ behaviour + info.contentType , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
+
+ ::SetControlData( m_macToolHandle , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
+ }
+ else
+ {
+ m_macToolHandle = ::NewControl( window , &toolrect , "\p" , false , 0 ,
+ behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
+ }
+ UMAShowControl( m_macToolHandle ) ;
+ m_macToolHandles.Add( m_macToolHandle ) ;
+ tool->m_index = m_macToolHandles.Count() -1 ;
+ if ( !tool->IsEnabled() )
+ {
+ UMADeactivateControl( m_macToolHandle ) ;
+ }
+ if ( tool->CanBeToggled() && tool->IsToggled() )
+ {
+ ::SetControlValue( m_macToolHandle , 1 ) ;
+ }
+ else
+ {
+ ::SetControlValue( m_macToolHandle , 0 ) ;
+ }
+ /*
+ ::SetControlFontStyle( m_macToolHandle , &controlstyle ) ;
+ */
+ ControlHandle container = (ControlHandle) GetParent()->MacGetContainerForEmbedding() ;
+ wxASSERT_MSG( container != NULL , "No valid mac container control" ) ;
+ ::EmbedControl( m_macToolHandle , container ) ;
+
+ if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
+ {
+ x += (int)toolSize.x;
+ }
+ else
+ {
+ y += (int)toolSize.y;
+ }
+ noButtons ++;
+ }
+ else
+ {
+ m_macToolHandles.Add( NULL ) ;
+ if ( GetWindowStyleFlag() & wxTB_HORIZONTAL )
+ {
+ x += (int)toolSize.x / 4;
+ }
+ else
+ {
+ y += (int)toolSize.y / 4;
+ }
+ }
+ if ( toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin - m_x - localOrigin.h > maxWidth) {
+ maxWidth = toolbarrect.left + x + m_xMargin + kwxMacToolBarLeftMargin - m_x - localOrigin.h;
+ }
+ if (toolbarrect.top + y + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v > maxHeight) {
+ maxHeight = toolbarrect.top + y + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v ;
+ }
+ node = node->Next();