X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/693460233749fec3bf79720268d3cd8dfc55c78d..e319bb30f7e88242f56144fcc279b57047566a6b:/src/common/toplvcmn.cpp diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp index 101f64677f..45ad2fc6fb 100644 --- a/src/common/toplvcmn.cpp +++ b/src/common/toplvcmn.cpp @@ -140,26 +140,37 @@ bool wxTopLevelWindowBase::IsLastBeforeExit() const // wxTopLevelWindow geometry // ---------------------------------------------------------------------------- -void wxTopLevelWindowBase::GetRectForTopLevelChildren(int *x, int *y, int *w, int *h) +void wxTopLevelWindowBase::SetMinSize(const wxSize& minSize) { - GetPosition(x,y); - GetSize(w,h); + SetSizeHints( minSize.x, minSize.y, GetMaxWidth(), GetMaxHeight() ); } -wxSize wxTopLevelWindowBase::GetMaxSize() const +void wxTopLevelWindowBase::SetMaxSize(const wxSize& maxSize) { - wxSize size( GetMaxWidth(), GetMaxHeight() ); - int w, h; - - wxClientDisplayRect( 0, 0, &w, &h ); - - if( size.GetWidth() == wxDefaultCoord ) - size.SetWidth( w ); + SetSizeHints( GetMinWidth(), GetMinHeight(), maxSize.x, maxSize.y ); +} - if( size.GetHeight() == wxDefaultCoord ) - size.SetHeight( h ); +// set the min/max size of the window +void wxTopLevelWindowBase::DoSetSizeHints(int minW, int minH, + int maxW, int maxH, + int WXUNUSED(incW), int WXUNUSED(incH)) +{ + // setting min width greater than max width leads to infinite loops under + // X11 and generally doesn't make any sense, so don't allow it + wxCHECK_RET( (minW == wxDefaultCoord || maxW == wxDefaultCoord || minW <= maxW) && + (minH == wxDefaultCoord || maxH == wxDefaultCoord || minH <= maxH), + _T("min width/height must be less than max width/height!") ); + + m_minWidth = minW; + m_maxWidth = maxW; + m_minHeight = minH; + m_maxHeight = maxH; +} - return size; +void wxTopLevelWindowBase::GetRectForTopLevelChildren(int *x, int *y, int *w, int *h) +{ + GetPosition(x,y); + GetSize(w,h); } /* static */ @@ -210,8 +221,8 @@ void wxTopLevelWindowBase::DoCentre(int dir) // parent frame under Mac but could happen elsewhere too if the frame // was hidden/moved away for some reason), don't use it as otherwise // this window wouldn't be visible at all - if ( !rectDisplay.Inside(rectParent.GetTopLeft()) && - !rectParent.Inside(rectParent.GetBottomRight()) ) + if ( !rectDisplay.Contains(rectParent.GetTopLeft()) && + !rectParent.Contains(rectParent.GetBottomRight()) ) { // this is enough to make IsEmpty() test below pass rectParent.width = 0; @@ -235,9 +246,9 @@ void wxTopLevelWindowBase::DoCentre(int dir) // we don't want to place the window off screen if Centre() is called as // this is (almost?) never wanted and it would be very difficult to prevent // it from happening from the user code if we didn't check for it here - if ( rectDisplay.Inside(rect.GetTopLeft()) ) + if ( rectDisplay.Contains(rect.GetTopLeft()) ) { - if ( !rectDisplay.Inside(rect.GetBottomRight()) ) + if ( !rectDisplay.Contains(rect.GetBottomRight()) ) { // check if we can move the window so that the bottom right corner // is visible without hiding the top left one