X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/f644b28c1154d638270d0d1abbc41f760be6abbd..a4ea083bbdf710d3234dcbd2eafb5d0e078f8348:/src/common/layout.cpp diff --git a/src/common/layout.cpp b/src/common/layout.cpp index adadfe0be5..9d23b46116 100644 --- a/src/common/layout.cpp +++ b/src/common/layout.cpp @@ -1,12 +1,11 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: layout.cpp +// Name: src/common/layout.cpp // Purpose: Constraint layout system classes // Author: Julian Smart // Modified by: // Created: 04/01/98 -// RCS-ID: $Id$ // Copyright: (c) Julian Smart -// Licence: wxWindows licence +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================= @@ -17,35 +16,53 @@ // headers // ---------------------------------------------------------------------------- -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) - #pragma implementation "layout.h" -#endif - // For compilers that support precompilation, includes "wx.h". #include "wx/wxprec.h" #ifdef __BORLANDC__ - #pragma hdrstop + #pragma hdrstop #endif +#if wxUSE_CONSTRAINTS + +#include "wx/layout.h" + #ifndef WX_PRECOMP - #include "wx/defs.h" + #include "wx/window.h" + #include "wx/utils.h" + #include "wx/dialog.h" + #include "wx/msgdlg.h" + #include "wx/intl.h" #endif -#if wxUSE_CONSTRAINTS -#ifndef WX_PRECOMP - #include "wx/window.h" - #include "wx/utils.h" - #include "wx/dialog.h" - #include "wx/msgdlg.h" - #include "wx/intl.h" +IMPLEMENT_DYNAMIC_CLASS(wxIndividualLayoutConstraint, wxObject) +IMPLEMENT_DYNAMIC_CLASS(wxLayoutConstraints, wxObject) + + +inline void wxGetAsIs(wxWindowBase* win, int* w, int* h) +{ +#if 1 + // The old way. Works for me. + win->GetSize(w, h); #endif -#include "wx/layout.h" +#if 0 + // Vadim's change. Breaks wxPython's LayoutAnchors + win->GetBestSize(w, h); +#endif - IMPLEMENT_DYNAMIC_CLASS(wxIndividualLayoutConstraint, wxObject) - IMPLEMENT_DYNAMIC_CLASS(wxLayoutConstraints, wxObject) +#if 0 + // Proposed compromise. Doesn't work. + int sw, sh, bw, bh; + win->GetSize(&sw, &sh); + win->GetBestSize(&bw, &bh); + if (w) + *w = wxMax(sw, bw); + if (h) + *h = wxMax(sh, bh); +#endif +} wxIndividualLayoutConstraint::wxIndividualLayoutConstraint() @@ -57,11 +74,7 @@ wxIndividualLayoutConstraint::wxIndividualLayoutConstraint() percent = 0; otherEdge = wxTop; done = false; - otherWin = (wxWindowBase *) NULL; -} - -wxIndividualLayoutConstraint::~wxIndividualLayoutConstraint() -{ + otherWin = NULL; } void wxIndividualLayoutConstraint::Set(wxRelationship rel, wxWindowBase *otherW, wxEdge otherE, int val, int marg) @@ -144,7 +157,7 @@ bool wxIndividualLayoutConstraint::ResetIfWin(wxWindowBase *otherW) value = 0; percent = 0; otherEdge = wxTop; - otherWin = (wxWindowBase *) NULL; + otherWin = NULL; return true; } @@ -304,7 +317,7 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr { int x, y; int w, h; - win->GetSize(&w, &h); + wxGetAsIs(win, &w, &h); win->GetPosition(&x, &y); value = x + w; done = true; @@ -457,7 +470,7 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr { int x, y; int w, h; - win->GetSize(&w, &h); + wxGetAsIs(win, &w, &h); win->GetPosition(&x, &y); value = h + y; done = true; @@ -625,7 +638,7 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr if (win) { int h; - win->GetSize(&value, &h); + wxGetAsIs(win, &value, &h); done = true; return true; } @@ -683,7 +696,7 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr if (win) { int w; - win->GetSize(&w, &value); + wxGetAsIs(win, &w, &value); done = true; return true; } @@ -960,10 +973,6 @@ wxLayoutConstraints::wxLayoutConstraints() height.SetEdge(wxHeight); } -wxLayoutConstraints::~wxLayoutConstraints() -{ -} - bool wxLayoutConstraints::SatisfyConstraints(wxWindowBase *win, int *nChanges) { int noChanges = 0;