X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/facd6764872eede45605ba7c9dfa0e1d0c708fa2..23866d595f47f48356cc63890f80049fb0f1dd43:/src/mac/carbon/toolbar.cpp diff --git a/src/mac/carbon/toolbar.cpp b/src/mac/carbon/toolbar.cpp index 2dd8872464..b240fa221b 100644 --- a/src/mac/carbon/toolbar.cpp +++ b/src/mac/carbon/toolbar.cpp @@ -26,7 +26,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxToolBar, wxControl) BEGIN_EVENT_TABLE(wxToolBar, wxToolBarBase) - EVT_MOUSE_EVENTS( wxToolBar::OnMouse ) EVT_PAINT( wxToolBar::OnPaint ) END_EVENT_TABLE() #endif @@ -233,34 +232,21 @@ wxToolBarTool::wxToolBarTool(wxToolBar *tbar, 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 ) ; - } + CreateBevelButtonControl( window , &toolrect , CFSTR("") , kControlBevelButtonNormalBevel , behaviour , &info , + 0 , 0 , 0 , &m_controlHandle ) ; + InstallControlEventHandler( (ControlRef) m_controlHandle, GetwxMacToolBarToolEventHandlerUPP(), GetEventTypeCount(eventList), eventList, this,NULL); + UMAShowControl( m_controlHandle ) ; if ( !IsEnabled() ) - { - UMADeactivateControl( m_controlHandle ) ; - } + DisableControl( 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") ) ; @@ -327,7 +313,7 @@ bool wxToolBar::Realize() int maxToolHeight = 0; // Find the maximum tool width and height - wxToolBarToolsList::Node *node = m_tools.GetFirst(); + wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); while ( node ) { wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); @@ -391,6 +377,7 @@ bool wxToolBar::Realize() } SetSize( maxWidth, maxHeight ); + InvalidateBestSize(); return TRUE; } @@ -406,27 +393,6 @@ wxSize wxToolBar::GetToolSize() const return wxSize(m_defaultWidth + 4, m_defaultHeight + 4); } -void wxToolBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED( mouseStillDown ) ) -{ - wxToolBarToolsList::Node *node; - for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) - { - wxToolBarTool* tool = (wxToolBarTool*) node->GetData() ; - if ( tool->IsButton() ) - { - if( tool->GetControlHandle() == control ) - { - if ( tool->CanBeToggled() ) - { - tool->Toggle( GetControl32BitValue( (ControlRef) control ) ) ; - } - OnLeftClick( tool->GetId() , tool -> IsToggled() ) ; - break ; - } - } - } -} - void wxToolBar::SetRows(int nRows) { if ( nRows == m_maxRows ) @@ -446,7 +412,7 @@ void wxToolBar::MacSuperChangedPosition() wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const { - wxToolBarToolsList::Node *node = m_tools.GetFirst(); + wxToolBarToolsList::compatibility_iterator node = m_tools.GetFirst(); while (node) { wxToolBarTool *tool = (wxToolBarTool *)node->GetData() ; @@ -508,6 +474,7 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), { // nothing special to do here - we relayout in Realize() later tool->Attach(this); + InvalidateBestSize(); return TRUE; } @@ -519,7 +486,7 @@ void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(tog bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool) { - wxToolBarToolsList::Node *node; + wxToolBarToolsList::compatibility_iterator node; for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) { wxToolBarToolBase *tool2 = node->GetData(); @@ -554,6 +521,7 @@ bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool) tool2->SetPosition( pt ) ; } + InvalidateBestSize(); return TRUE ; } @@ -573,72 +541,8 @@ void wxToolBar::OnPaint(wxPaintEvent& event) toolbarrect.top = 0 ; */ UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; -/* - { - wxToolBarToolsList::Node *node; - for ( node = m_tools.GetFirst(); node; node = node->GetNext() ) - { - wxToolBarTool* tool = (wxToolBarTool*) node->GetData() ; - if ( tool->IsButton() ) - { - UMADrawControl( (ControlRef) tool->GetControlHandle() ) ; - } - } - } -*/ - event.Skip() ; -} -void wxToolBar::OnMouse( wxMouseEvent &event ) -{ - if (event.GetEventType() == wxEVT_LEFT_DOWN || event.GetEventType() == wxEVT_LEFT_DCLICK ) - { - - int x = event.m_x ; - int y = event.m_y ; - - MacClientToRootWindow( &x , &y ) ; - - ControlRef control ; - Point localwhere ; - SInt16 controlpart ; - WindowRef window = (WindowRef) MacGetTopLevelWindowRef() ; - - localwhere.h = x ; - localwhere.v = y ; - - short modifiers = 0; - - if ( !event.m_leftDown && !event.m_rightDown ) - modifiers |= btnState ; - - if ( event.m_shiftDown ) - modifiers |= shiftKey ; - - if ( event.m_controlDown ) - modifiers |= controlKey ; - - if ( event.m_altDown ) - modifiers |= optionKey ; - - if ( event.m_metaDown ) - modifiers |= cmdKey ; - - controlpart = ::FindControl( localwhere , window , &control ) ; - { - if ( control && ::IsControlActive( control ) ) - { - { - controlpart = ::HandleControlClick( control , localwhere , modifiers , (ControlActionUPP) -1 ) ; - wxTheApp->s_lastMouseDown = 0 ; - if ( control && controlpart != kControlNoPart ) // otherwise we will get the event twice - { - MacHandleControlClick((WXWidget) control , controlpart , false /* not down anymore */ ) ; - } - } - } - } - } + event.Skip() ; } #endif // wxUSE_TOOLBAR