X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bd044e27b3c7f9b6d56e75b9e1b789be3545cd5e..06e56e62b9ab3a4ee66d7013c978128e5021f4e2:/src/osx/carbon/toolbar.cpp?ds=sidebyside diff --git a/src/osx/carbon/toolbar.cpp b/src/osx/carbon/toolbar.cpp index 35b9bd4ff8..093c703000 100644 --- a/src/osx/carbon/toolbar.cpp +++ b/src/osx/carbon/toolbar.cpp @@ -932,6 +932,15 @@ wxToolBar::~wxToolBar() if ( !m_macToolbar ) return; + // it might already have been uninstalled due to a previous call to Destroy, but in case + // wasn't, do so now, otherwise redraw events may occur for deleted objects + bool ownToolbarInstalled = false; + MacTopLevelHasNativeToolbar( &ownToolbarInstalled ); + if (ownToolbarInstalled) + { + MacUninstallNativeToolbar(); + } + CFIndex count = CFGetRetainCount( m_macToolbar ) ; // Leopard seems to have one refcount more, so we cannot check reliably at the moment if ( UMAGetSystemVersion() < 0x1050 ) @@ -1111,16 +1120,16 @@ bool wxToolBar::MacInstallNativeToolbar(bool usesNative) // which we don't want in this case wxSize sz = GetParent()->GetSize(); ShowHideWindowToolbar( tlw, true, false ); - // Restore the orginal size + // Restore the original size GetParent()->SetSize( sz ); ChangeWindowAttributes( tlw, kWindowToolbarButtonAttribute, 0 ); SetAutomaticControlDragTrackingEnabledForWindow( tlw, true ); - m_peer->Move(0,0,0,0 ); + GetPeer()->Move(0,0,0,0 ); SetSize( wxSIZE_AUTO_WIDTH, 0 ); - m_peer->SetVisibility( false ); + GetPeer()->SetVisibility( false ); wxToolBarBase::Show( false ); } } @@ -1135,7 +1144,7 @@ bool wxToolBar::MacInstallNativeToolbar(bool usesNative) ChangeWindowAttributes( tlw, 0, kWindowToolbarButtonAttribute ); MacUninstallNativeToolbar(); - m_peer->SetVisibility( true ); + GetPeer()->SetVisibility( true ); } } @@ -1150,7 +1159,7 @@ void wxToolBar::MacUninstallNativeToolbar() { if (!m_macToolbar) return; - + WindowRef tlw = MAC_WXHWND(MacGetTopLevelWindowRef()); if (tlw) SetWindowToolbar( tlw, NULL ); @@ -1424,6 +1433,18 @@ bool wxToolBar::Realize() return true; } +void wxToolBar::DoLayout() +{ + // TODO port back osx_cocoa layout solution +} + +void wxToolBar::DoSetSize(int x, int y, int width, int height, int sizeFlags) +{ + wxToolBarBase::DoSetSize(x, y, width, height, sizeFlags); + + DoLayout(); +} + void wxToolBar::SetToolBitmapSize(const wxSize& size) { m_defaultWidth = size.x + kwxMacToolBorder;