+void wxToolBarTool::SetSize(const wxSize& size)
+{
+ if ( IsControl() )
+ {
+ GetControl()->SetSize( size ) ;
+ }
+}
+
+void wxToolBarTool::SetPosition(const wxPoint& position)
+{
+ m_x = position.x;
+ m_y = position.y;
+
+ if ( IsButton() )
+ {
+ int x , y ;
+ x = y = 0 ;
+ int mac_x = position.x ;
+ int mac_y = position.y ;
+#if !TARGET_API_MAC_OSX
+ WindowRef rootwindow = (WindowRef) GetToolBar()->MacGetTopLevelWindowRef() ;
+ GetToolBar()->MacWindowToRootWindow( &x , &y ) ;
+ mac_x += x;
+ mac_y += y;
+#endif
+ Rect contrlRect ;
+ GetControlBounds( m_controlHandle , &contrlRect ) ;
+ int former_mac_x = contrlRect.left ;
+ int former_mac_y = contrlRect.top ;
+ wxSize sz = GetToolBar()->GetToolSize() ;
+
+ if ( mac_x != former_mac_x || mac_y != former_mac_y )
+ {
+ UMAMoveControl( m_controlHandle , mac_x , mac_y ) ;
+ }
+ }
+ else if ( IsControl() )
+ {
+ GetControl()->Move( position ) ;
+ }
+}
+
+const short kwxMacToolBarToolDefaultWidth = 24 ;
+const short kwxMacToolBarToolDefaultHeight = 22 ;
+const short kwxMacToolBarTopMargin = 2 ;
+const short kwxMacToolBarLeftMargin = 2 ;
+
+wxToolBarTool::wxToolBarTool(wxToolBar *tbar,
+ int id,
+ const wxString& label,
+ const wxBitmap& bmpNormal,
+ const wxBitmap& bmpDisabled,
+ wxItemKind kind,
+ wxObject *clientData,
+ const wxString& shortHelp,
+ const wxString& longHelp)
+ : wxToolBarToolBase(tbar, id, label, bmpNormal, bmpDisabled, kind,
+ clientData, shortHelp, longHelp)
+{
+ Init();
+
+ if (id == wxID_SEPARATOR) return;
+
+ WindowRef window = (WindowRef) tbar->MacGetTopLevelWindowRef() ;
+ wxSize toolSize = tbar->GetToolSize() ;
+ Rect toolrect = { 0, 0 , toolSize.y , toolSize.x } ;
+
+ ControlButtonContentInfo info ;
+ wxMacCreateBitmapButton( &info , GetNormalBitmap() ) ;
+
+ SInt16 behaviour = kControlBehaviorOffsetContents ;
+ if ( CanBeToggled() )
+ behaviour += kControlBehaviorToggles ;
+
+ if ( info.contentType != kControlNoContent )
+ {
+ m_controlHandle = ::NewControl( window , &toolrect , "\p" , true , 0 ,
+ behaviour + info.contentType , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
+
+ ::SetControlData( m_controlHandle , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
+ }
+ else
+ {
+ m_controlHandle = ::NewControl( window , &toolrect , "\p" , true , 0 ,
+ behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
+ }
+ InstallControlEventHandler( (ControlRef) m_controlHandle, GetwxMacToolBarToolEventHandlerUPP(),
+ GetEventTypeCount(eventList), eventList, this,NULL);
+ UMAShowControl( m_controlHandle ) ;
+ if ( !IsEnabled() )
+ {
+ UMADeactivateControl( m_controlHandle ) ;
+ }
+ if ( CanBeToggled() && IsToggled() )
+ {
+ ::SetControl32BitValue( m_controlHandle , 1 ) ;
+ }
+ else
+ {
+ ::SetControl32BitValue( m_controlHandle , 0 ) ;
+ }
+
+ ControlRef container = (ControlRef) tbar->GetHandle() ;
+ wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
+ ::EmbedControl( m_controlHandle , container ) ;
+}
+