X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1665389a9ab7359c164069a31f231f121e4afd8e..71a09c3579dd5cb4cd8fa7fdc143561cbff74e12:/src/osx/carbon/toolbar.cpp?ds=inline diff --git a/src/osx/carbon/toolbar.cpp b/src/osx/carbon/toolbar.cpp index 58cc4af000..a44e23bbda 100644 --- a/src/osx/carbon/toolbar.cpp +++ b/src/osx/carbon/toolbar.cpp @@ -4,7 +4,6 @@ // Author: Stefan Csomor // Modified by: // Created: 04/01/98 -// RCS-ID: $Id$ // Copyright: (c) Stefan Csomor // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -926,6 +925,21 @@ bool wxToolBar::Create( wxToolBar::~wxToolBar() { +#if wxOSX_USE_NATIVE_TOOLBAR + // We could be not using a native tool bar at all, this happens when we're + // created with something other than the frame as parent for example. + 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 ) @@ -937,6 +951,7 @@ wxToolBar::~wxToolBar() } CFRelease( (HIToolbarRef)m_macToolbar ); m_macToolbar = NULL; +#endif // wxOSX_USE_NATIVE_TOOLBAR } bool wxToolBar::Show( bool show ) @@ -1104,16 +1119,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 ); } } @@ -1128,7 +1143,7 @@ bool wxToolBar::MacInstallNativeToolbar(bool usesNative) ChangeWindowAttributes( tlw, 0, kWindowToolbarButtonAttribute ); MacUninstallNativeToolbar(); - m_peer->SetVisibility( true ); + GetPeer()->SetVisibility( true ); } } @@ -1143,7 +1158,7 @@ void wxToolBar::MacUninstallNativeToolbar() { if (!m_macToolbar) return; - + WindowRef tlw = MAC_WXHWND(MacGetTopLevelWindowRef()); if (tlw) SetWindowToolbar( tlw, NULL ); @@ -1315,6 +1330,10 @@ bool wxToolBar::Realize() wxFAIL_MSG("Reference count of native tool was illegal before removal"); } wxASSERT( IsValidControlHandle(tool->GetControl()->GetPeer()->GetControlRef() )) ; + + wxString label = tool->GetLabel(); + if ( !label.empty() ) + HIToolbarItemSetLabel( hiItemRef, wxCFStringRef(label, GetFont().GetEncoding()) ); } } @@ -1413,6 +1432,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;