From e08b4823e8209dc683d0373bf4b0c24e3343ddf9 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 11 Aug 2010 16:04:00 +0000 Subject: [PATCH] Handle wxDefaultSize correctly in wxNonOwnedWindow under wxOSX. Creating a wxNonOwnedWindow with default size created tiny, practically invisible windows because the default size was only taken care of at wxTopLevelWindow level but not in wxNonOwnedWindow itself. In particular, this broke creation of wxMDIChildFrames with the default size as this class only derived from wxNonOwnedWindow and not from wxTopLevelWindow under OS X. It also probably wasn't intentional as the code did use {Width,Height}Default() functions but they were wxWindow methods and not the wxTopLevelWindow (confusingly and error-pronely) named the same. Fix this, remove the now redundant checks for the default size in wxTopLevelWindow itself and also rationalize and condense the checks for the default position and size components in wxNonOwnedWindow::Create(). git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65261 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/nonownedwnd_osx.cpp | 33 +++++++++++++++++---------------- src/osx/toplevel_osx.cpp | 5 +---- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp index 638af1d7ac..5ed8b5993f 100644 --- a/src/osx/nonownedwnd_osx.cpp +++ b/src/osx/nonownedwnd_osx.cpp @@ -101,8 +101,8 @@ void wxNonOwnedWindow::Init() bool wxNonOwnedWindow::Create(wxWindow *parent, wxWindowID id, - const wxPoint& pos, - const wxSize& size, + const wxPoint& posOrig, + const wxSize& sizeOrig, long style, const wxString& name) { @@ -114,22 +114,23 @@ bool wxNonOwnedWindow::Create(wxWindow *parent, m_windowStyle = style; m_isShown = false; - // create frame. - int x = (int)pos.x; - int y = (int)pos.y; - - wxRect display = wxGetClientDisplayRect() ; - - if ( x == wxDefaultPosition.x ) - x = display.x ; + // use the appropriate defaults for the position and size if necessary + wxPoint pos(posOrig); + if ( !pos.IsFullySpecified() ) + pos.SetDefaults(wxGetClientDisplayRect().GetPosition()); - if ( y == wxDefaultPosition.y ) - y = display.y ; + wxSize size(sizeOrig); + if ( !size.IsFullySpecified() ) + size.SetDefaults(wxTopLevelWindow::GetDefaultSize()); - int w = WidthDefault(size.x); - int h = HeightDefault(size.y); - - m_nowpeer = wxNonOwnedWindowImpl::CreateNonOwnedWindow(this, parent, wxPoint(x,y) , wxSize(w,h) , style , GetExtraStyle(), name ); + // create frame. + m_nowpeer = wxNonOwnedWindowImpl::CreateNonOwnedWindow + ( + this, parent, + pos , size, + style, GetExtraStyle(), + name + ); wxNonOwnedWindowImpl::Associate( m_nowpeer->GetWXWindow() , m_nowpeer ) ; m_peer = wxWidgetImpl::CreateContentView(this); diff --git a/src/osx/toplevel_osx.cpp b/src/osx/toplevel_osx.cpp index 3c1c8ae4d3..b96d3a0ecc 100644 --- a/src/osx/toplevel_osx.cpp +++ b/src/osx/toplevel_osx.cpp @@ -73,10 +73,7 @@ bool wxTopLevelWindowMac::Create(wxWindow *parent, long style, const wxString& name) { - int w = WidthDefault(size.x); - int h = HeightDefault(size.y); - - if ( !wxNonOwnedWindow::Create(parent, id, pos, wxSize(w,h), style, name) ) + if ( !wxNonOwnedWindow::Create(parent, id, pos, size, style, name) ) return false; wxWindow::SetLabel( title ) ; -- 2.45.2