From 0c089c08261235630426ccedb29d7049f1cef1bd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Apr 2004 17:26:56 +0000 Subject: [PATCH] added wxTLWBase::GetDefaultSize() to avoid creating windows with default size unsuitable for the current display size git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26615 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/toplevel.h | 7 ++++--- src/common/toplvcmn.cpp | 24 ++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/include/wx/toplevel.h b/include/wx/toplevel.h index e4ea49abb1..612b1353bd 100644 --- a/include/wx/toplevel.h +++ b/include/wx/toplevel.h @@ -152,9 +152,10 @@ protected: // Get the default size for the new window if no explicit size given. If // there are better default sizes then these can be changed, just as long - // as they are not too small for TLWs. - static int WidthDefault(int w) { return w == -1 ? 400 : w; } - static int HeightDefault(int h) { return h == -1 ? 250 : h; } + // as they are not too small for TLWs (and not larger than screen). + static wxSize GetDefaultSize(); + static int WidthDefault(int w) { return w == -1 ? GetDefaultSize().x : w; } + static int HeightDefault(int h) { return h == -1 ? GetDefaultSize().y : h; } // the frame icon wxIconBundle m_icons; diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp index 6ff702eff3..3abc4cb2da 100644 --- a/src/common/toplvcmn.cpp +++ b/src/common/toplvcmn.cpp @@ -125,6 +125,30 @@ wxSize wxTopLevelWindowBase::GetMaxSize() const return size; } +/* static */ +wxSize wxTopLevelWindowBase::GetDefaultSize() +{ + wxSize size = wxGetClientDisplayRect().GetSize(); + + // create proportionally bigger windows on small screens + if ( size.x >= 1024 ) + size.x = 400; + else if ( size.x >= 800 ) + size.x = 300; + else if ( size.x >= 320 ) + size.x = 240; + + if ( size.y >= 768 ) + size.y = 250; + else if ( size.y > 200 ) + { + size.y *= 2; + size.y /= 3; + } + + return size; +} + // ---------------------------------------------------------------------------- // wxTopLevelWindow size management: we exclude the areas taken by // menu/status/toolbars from the client area, so the client area is what's -- 2.45.2