X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1832043f93af07af3f4891d9a95c4d4e1f70eec5..d632789924e1ef1427c5321476215bd473dfe4d6:/src/common/toplvcmn.cpp diff --git a/src/common/toplvcmn.cpp b/src/common/toplvcmn.cpp index a6c9133dbd..97821d0d69 100644 --- a/src/common/toplvcmn.cpp +++ b/src/common/toplvcmn.cpp @@ -55,6 +55,8 @@ wxTopLevelWindowBase::wxTopLevelWindowBase() { // Unlike windows, top level windows are created hidden by default. m_isShown = false; + m_winDefault = NULL; + m_winTmpDefault = NULL; } wxTopLevelWindowBase::~wxTopLevelWindowBase() @@ -138,6 +140,33 @@ bool wxTopLevelWindowBase::IsLastBeforeExit() const // wxTopLevelWindow geometry // ---------------------------------------------------------------------------- +void wxTopLevelWindowBase::SetMinSize(const wxSize& minSize) +{ + SetSizeHints( minSize.x, minSize.y, GetMaxWidth(), GetMaxHeight() ); +} + +void wxTopLevelWindowBase::SetMaxSize(const wxSize& maxSize) +{ + SetSizeHints( GetMinWidth(), GetMinHeight(), maxSize.x, maxSize.y ); +} + +// 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; +} + void wxTopLevelWindowBase::GetRectForTopLevelChildren(int *x, int *y, int *w, int *h) { GetPosition(x,y); @@ -146,16 +175,16 @@ void wxTopLevelWindowBase::GetRectForTopLevelChildren(int *x, int *y, int *w, in wxSize wxTopLevelWindowBase::GetMaxSize() const { - wxSize size( GetMaxWidth(), GetMaxHeight() ); - int w, h; + wxSize size = wxWindow::GetMaxSize(); - wxClientDisplayRect( 0, 0, &w, &h ); + int w, h; + wxClientDisplayRect(NULL, NULL, &w, &h ); - if( size.GetWidth() == wxDefaultCoord ) - size.SetWidth( w ); + if ( size.GetWidth() == wxDefaultCoord ) + size.SetWidth(w); - if( size.GetHeight() == wxDefaultCoord ) - size.SetHeight( h ); + if ( size.GetHeight() == wxDefaultCoord ) + size.SetHeight(h); return size; } @@ -208,8 +237,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; @@ -233,9 +262,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 @@ -348,12 +377,18 @@ void wxTopLevelWindowBase::DoLayout() // for whatever reasons, wxGTK wants to have a small offset - it // probably looks better with it? #ifdef __WXGTK__ - static const int ofs = 1; + const int ofs = 1; + clientW -= 2 * ofs; + clientH -= 2 * ofs; + if (clientW < 0) + clientW = 0; + if (clientH < 0) + clientH = 0; #else - static const int ofs = 0; + const int ofs = 0; #endif - child->SetSize(ofs, ofs, clientW - 2*ofs, clientH - 2*ofs); + child->SetSize(ofs, ofs, clientW, clientH); } } } @@ -393,3 +428,14 @@ void wxTopLevelWindowBase::RequestUserAttention(int WXUNUSED(flags)) // it's probably better than do nothing, isn't it? Raise(); } + +void wxTopLevelWindowBase::RemoveChild(wxWindowBase *child) +{ + if ( child == m_winDefault ) + m_winDefault = NULL; + + if ( child == m_winTmpDefault ) + m_winTmpDefault = NULL; + + wxWindow::RemoveChild(child); +}