+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 ;
+ WindowRef rootwindow = (WindowRef) GetToolBar()->MacGetRootWindow() ;
+ GetToolBar()->MacWindowToRootWindow( &x , &y ) ;
+ int mac_x = x + position.x ;
+ int mac_y = y + position.y ;
+
+
+ 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 )
+ {
+ {
+ Rect inval = { former_mac_y , former_mac_x , former_mac_y + sz.y , former_mac_x + sz.x } ;
+ InvalWindowRect( rootwindow , &inval ) ;
+ }
+ UMAMoveControl( m_controlHandle , mac_x , mac_y ) ;
+ {
+ Rect inval = { mac_y , mac_x , mac_y + sz.y , mac_x + sz.x } ;
+ InvalWindowRect( rootwindow , &inval ) ;
+ }
+ }
+ }
+ 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->MacGetRootWindow() ;
+ 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" , false , 0 ,
+ behaviour + info.contentType , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
+
+ ::SetControlData( m_controlHandle , kControlButtonPart , kControlBevelButtonContentTag , sizeof(info) , (char*) &info ) ;
+ }
+ else
+ {
+ m_controlHandle = ::NewControl( window , &toolrect , "\p" , false , 0 ,
+ behaviour , 0 , kControlBevelButtonNormalBevelProc , (long) this ) ;
+ }
+ UMAShowControl( m_controlHandle ) ;
+ if ( !IsEnabled() )
+ {
+ UMADeactivateControl( m_controlHandle ) ;
+ }
+ if ( CanBeToggled() && IsToggled() )
+ {
+ ::SetControl32BitValue( m_controlHandle , 1 ) ;
+ }
+ else
+ {
+ ::SetControl32BitValue( m_controlHandle , 0 ) ;
+ }
+
+ ControlHandle container = (ControlHandle) tbar->MacGetContainerForEmbedding() ;
+ wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
+ ::EmbedControl( m_controlHandle , container ) ;
+}
+