From: Stefan Csomor Date: Fri, 9 Mar 2012 12:49:59 +0000 (+0000) Subject: reflect correct position for native toolbar, fixes #14049 X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/14919c70208688d2ab03fbc1f2a19d2ae0fb7f9c?ds=sidebyside reflect correct position for native toolbar, fixes #14049 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70851 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/osx/toolbar.h b/include/wx/osx/toolbar.h index f8d789ec35..5e20bc6768 100644 --- a/include/wx/osx/toolbar.h +++ b/include/wx/osx/toolbar.h @@ -86,8 +86,11 @@ protected: void DoSetSize(int x, int y, int width, int height, int sizeFlags); #ifndef __WXOSX_IPHONE__ - virtual void DoGetSize(int *width, int *height) const; + virtual void DoGetSize(int *width, int *height) const; virtual wxSize DoGetBestSize() const; +#endif +#ifdef __WXOSX_COCOA__ + virtual void DoGetPosition(int*x, int *y) const; #endif virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool); virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool); diff --git a/src/osx/cocoa/toolbar.mm b/src/osx/cocoa/toolbar.mm index d5d0256f45..20ad47d304 100644 --- a/src/osx/cocoa/toolbar.mm +++ b/src/osx/cocoa/toolbar.mm @@ -761,6 +761,41 @@ void wxToolBar::DoGetSize( int *width, int *height ) const #endif } +void wxToolBar::DoGetPosition(int*x, int *y) const +{ +#if wxOSX_USE_NATIVE_TOOLBAR + bool ownToolbarInstalled; + + MacTopLevelHasNativeToolbar( &ownToolbarInstalled ); + if ( ownToolbarInstalled ) + { + WXWindow tlw = MacGetTopLevelWindowRef(); + float toolbarHeight = 0.0; + NSRect windowFrame = NSMakeRect(0, 0, 0, 0); + + if(m_macToolbar && [(NSToolbar*)m_macToolbar isVisible]) + { + windowFrame = [NSWindow contentRectForFrameRect:[tlw frame] + styleMask:[tlw styleMask]]; + toolbarHeight = NSHeight(windowFrame) + - NSHeight([[tlw contentView] frame]); + } + + // it is extending to the north of the content area + + if ( x != NULL ) + *x = 0; + if ( y != NULL ) + *y = -toolbarHeight; + } + else + wxToolBarBase::DoGetPosition( x, y ); + +#else + wxToolBarBase::DoGetPosition( x, y ); +#endif +} + wxSize wxToolBar::DoGetBestSize() const { // was updated in Realize()