]> git.saurik.com Git - wxWidgets.git/commitdiff
Handle wxDefaultSize correctly in wxNonOwnedWindow under wxOSX.
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 11 Aug 2010 16:04:00 +0000 (16:04 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 11 Aug 2010 16:04:00 +0000 (16:04 +0000)
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
src/osx/toplevel_osx.cpp

index 638af1d7ac52c1e5f5717eb744fa92061297452e..5ed8b5993fc4f30ab834ac02a5790b28d1a3328e 100644 (file)
@@ -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);
 
index 3c1c8ae4d339d92bafc64f4d2ec1fb6241f05cc4..b96d3a0eccf4ae6a6ba3a610a88163e29276df30 100644 (file)
@@ -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 ) ;