X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/98dd4ee512e6dda9ccf6f862161be41bd3105c4b..61ecf6d34ffb087e4a02d1c4e29e1f155875eba0:/include/wx/window.h diff --git a/include/wx/window.h b/include/wx/window.h index 2352b90c17..1b12bc2884 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -12,7 +12,7 @@ #ifndef _WX_WINDOW_H_BASE_ #define _WX_WINDOW_H_BASE_ -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(__APPLE__) #pragma interface "windowbase.h" #endif @@ -271,7 +271,18 @@ public: *h = s.y; } - // the generic centre function - centers the window on parent by + // There are times (and windows) where 'Best' size and 'Min' size + // are vastly out of sync. This should be remedied somehow, but in + // the meantime, this method will return the larger of BestSize + // (the window's smallest legible size), and any user specified + // MinSize hint. + wxSize GetAdjustedBestSize() const + { + wxSize s( DoGetBestSize() ); + return wxSize( wxMax( s.x, GetMinWidth() ), wxMax( s.y, GetMinHeight() ) ); + } + + // the generic centre function - centers the window on parent by` // default or on screen if it doesn't have parent or // wxCENTER_ON_SCREEN flag is given void Centre( int direction = wxBOTH ); @@ -288,6 +299,9 @@ public: // set window size to wrap around its children virtual void Fit(); + // set virtual size to satisfy children + virtual void FitInside(); + // set min/max size of the window virtual void SetSizeHints( int minW, int minH, int maxW = -1, int maxH = -1, @@ -331,6 +345,17 @@ public: virtual void DoSetVirtualSize( int x, int y ); virtual wxSize DoGetVirtualSize() const; // { return m_virtualSize; } + // Return the largest of ClientSize and BestSize (as determined + // by a sizer, interior children, or other means) + + virtual wxSize GetBestVirtualSize() const + { + wxSize client( GetClientSize() ); + wxSize best( GetBestSize() ); + + return wxSize( wxMax( client.x, best.x ), wxMax( client.y, best.y ) ); + } + // window state // ------------ @@ -951,15 +976,23 @@ protected: virtual wxBorder GetDefaultBorder() const; // get the default size for the new window if no explicit size given - // FIXME why 40 and not 20, 10 or ...? GTK can crash with 40. RR. - static int WidthDefault(int w) { return w == -1 ? 40 : w; } - static int HeightDefault(int h) { return h == -1 ? 40 : h; } + // FIXME why 20 and not 30, 10 or ...? + static int WidthDefault(int w) { return w == -1 ? 20 : w; } + static int HeightDefault(int h) { return h == -1 ? 20 : h; } // set the best size for the control if the default size was given: // replaces the fields of size == -1 with the best values for them and // calls SetSize() if needed + // + // This function is rather unfortunately named.. it's really just a + // smarter SetSize / convenience function for expanding wxDefaultSize. + // Note that it does not influence the value returned by GetBestSize + // at all. void SetBestSize(const wxSize& size) { + // the size only needs to be changed if the current size is incomplete, + // i.e. one of the components was specified as default -- so if both + // were given, simply don't do anything if ( size.x == -1 || size.y == -1 ) { wxSize sizeBest = DoGetBestSize();