X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1fd1922a49351a377bc6ef8f7e00f150112ee096..bf60426831535738b1b784629f08e9dd00bf9ecc:/src/mac/toolbar.cpp?ds=sidebyside diff --git a/src/mac/toolbar.cpp b/src/mac/toolbar.cpp index 7c6fa528d5..aa01c95226 100644 --- a/src/mac/toolbar.cpp +++ b/src/mac/toolbar.cpp @@ -159,13 +159,20 @@ bool wxToolBar::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, cons wxToolBar::~wxToolBar() { + size_t index = 0 ; + for ( index = 0 ; index < m_macToolHandles.Count() ; ++index ) + { + // Delete the control as we get ghosts otherwise + ::DisposeControl( (ControlHandle) m_macToolHandles[index] ); + } + // we must refresh the frame size when the toolbar is deleted but the frame // is not - otherwise toolbar leaves a hole in the place it used to occupy } bool wxToolBar::Realize() { - if (m_tools.Number() == 0) + if (m_tools.GetCount() == 0) return FALSE; Point localOrigin ; @@ -188,7 +195,7 @@ bool wxToolBar::Realize() controlstyle.flags = kControlUseFontMask ; controlstyle.font = kControlFontSmallSystemFont ; - wxNode *node = m_tools.First(); + wxToolBarToolsList::Node *node = m_tools.GetFirst(); int noButtons = 0; int x = 0 ; int y = 0 ; @@ -201,8 +208,7 @@ bool wxToolBar::Realize() while (node) { - wxToolBarTool *tool = (wxToolBarTool *)node->Data(); - wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->GetNormalBitmap().GetRefData()) ; + wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); if( !tool->IsSeparator() ) { @@ -240,11 +246,11 @@ bool wxToolBar::Realize() } if ( tool->CanBeToggled() && tool->IsToggled() ) { - ::SetControlValue( m_macToolHandle , 1 ) ; + ::SetControl32BitValue( m_macToolHandle , 1 ) ; } else { - ::SetControlValue( m_macToolHandle , 0 ) ; + ::SetControl32BitValue( m_macToolHandle , 0 ) ; } /* ::SetControlFontStyle( m_macToolHandle , &controlstyle ) ; @@ -282,7 +288,7 @@ bool wxToolBar::Realize() 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(); + node = node->GetNext(); } if ( GetWindowStyleFlag() & wxTB_HORIZONTAL ) @@ -328,15 +334,15 @@ wxSize wxToolBar::GetToolSize() const void wxToolBar::MacHandleControlClick( WXWidget control , wxInt16 controlpart ) { - int index = 0 ; + size_t index = 0 ; for ( index = 0 ; index < m_macToolHandles.Count() ; ++index ) { if ( m_macToolHandles[index] == (void*) control ) { - wxToolBarTool *tool = (wxToolBarTool *)m_tools.Nth( index )->Data(); + wxToolBarTool *tool = (wxToolBarTool *)m_tools.Item( index )->GetData(); if ( tool->CanBeToggled() ) { - tool->Toggle( GetControlValue( (ControlHandle) control ) ) ; + tool->Toggle( GetControl32BitValue( (ControlHandle) control ) ) ; } OnLeftClick( tool->GetId() , tool -> IsToggled() ) ; break ; @@ -357,7 +363,7 @@ void wxToolBar::SetRows(int nRows) void wxToolBar::MacSuperChangedPosition() { - if (m_tools.Number() > 0) + if (m_tools.GetCount() > 0) { Point localOrigin ; @@ -379,7 +385,7 @@ void wxToolBar::MacSuperChangedPosition() controlstyle.flags = kControlUseFontMask ; controlstyle.font = kControlFontSmallSystemFont ; - wxNode *node = m_tools.First(); + wxToolBarToolsList::Node *node = m_tools.GetFirst(); int noButtons = 0; int x = 0 ; wxSize toolSize = GetToolSize() ; @@ -393,8 +399,7 @@ void wxToolBar::MacSuperChangedPosition() WindowRef rootwindow = (WindowRef) MacGetRootWindow() ; while (node) { - wxToolBarTool *tool = (wxToolBarTool *)node->Data(); - wxBitmapRefData * bmap = (wxBitmapRefData*) ( tool->GetNormalBitmap().GetRefData()) ; + wxToolBarTool *tool = (wxToolBarTool *)node->GetData(); if( !tool->IsSeparator() ) { @@ -439,7 +444,7 @@ void wxToolBar::MacSuperChangedPosition() if (toolbarrect.top + m_yMargin + kwxMacToolBarTopMargin - m_y - localOrigin.v > maxHeight) maxHeight = toolbarrect.top + kwxMacToolBarTopMargin + m_yMargin - m_y - localOrigin.v ; - node = node->Next(); + node = node->GetNext(); } } @@ -479,7 +484,7 @@ wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const MacClientToRootWindow( &x , &y ) ; Point pt = { y ,x } ; - int index = 0 ; + size_t index = 0 ; for ( index = 0 ; index < m_macToolHandles.Count() ; ++index ) { if ( m_macToolHandles[index] ) @@ -488,7 +493,7 @@ wxToolBarToolBase *wxToolBar::FindToolForPosition(wxCoord x, wxCoord y) const GetControlBounds((ControlHandle) m_macToolHandles[index], &bounds ) ; if ( PtInRect( pt , &bounds ) ) { - return (wxToolBarTool*) (m_tools.Nth( index )->Data() ) ; + return (wxToolBarTool*) (m_tools.Item( index )->GetData() ) ; } } } @@ -533,7 +538,7 @@ void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle) return ; ControlHandle control = (ControlHandle) m_macToolHandles[ tool->m_index ] ; - ::SetControlValue( control , toggle ) ; + ::SetControl32BitValue( control , toggle ) ; } bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), @@ -546,15 +551,15 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), return TRUE; } -void wxToolBar::DoSetToggle(wxToolBarToolBase *t, bool toggle) +void wxToolBar::DoSetToggle(wxToolBarToolBase *WXUNUSED(tool), bool WXUNUSED(toggle)) { - wxToolBarTool *tool = (wxToolBarTool *)t; - // TODO: set toggle state + wxFAIL_MSG( _T("not implemented") ); } -bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool) +bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *WXUNUSED(tool)) { - return TRUE ; + wxFAIL_MSG( _T("not implemented") ); + return TRUE ; } void wxToolBar::OnPaint(wxPaintEvent& event) @@ -566,7 +571,7 @@ void wxToolBar::OnPaint(wxPaintEvent& event) dc.YLOG2DEVMAC(m_height) , dc.XLOG2DEVMAC(m_width) } ; UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; { - int index = 0 ; + size_t index = 0 ; for ( index = 0 ; index < m_macToolHandles.Count() ; ++index ) { if ( m_macToolHandles[index] )