X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/22a35096a0a9c3fe4d3d32b8d68a361126ef9677..ce457f1245754243f17b4efde9ec773a8b3c3067:/src/common/toplvcmn.cpp?ds=inline diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp index aa07d2f096..2b20827bc1 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 */ @@ -347,21 +358,7 @@ void wxTopLevelWindowBase::DoLayout() int clientW, clientH; DoGetClientSize(&clientW, &clientH); - // for whatever reasons, wxGTK wants to have a small offset - it - // probably looks better with it? -#ifdef __WXGTK__ - const int ofs = 1; - clientW -= 2 * ofs; - clientH -= 2 * ofs; - if (clientW < 0) - clientW = 0; - if (clientH < 0) - clientH = 0; -#else - const int ofs = 0; -#endif - - child->SetSize(ofs, ofs, clientW, clientH); + child->SetSize(0, 0, clientW, clientH); } } }