]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/layout.cpp
use HandleWindowEvent() in Close() as it can be called from a GTK+ callback (#9565)
[wxWidgets.git] / src / common / layout.cpp
index 8dbb8ea8dc5e93601ff196e31f90c85df0b784d5..710ff2223e12cf68f66c5822d8e99b764ac520ed 100644 (file)
@@ -1,12 +1,12 @@
 /////////////////////////////////////////////////////////////////////////////
-// 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 and Markus Holzem
-// Licence:       wxWindows license
+// Copyright:   (c) Julian Smart
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // =============================================================================
 // headers
 // ----------------------------------------------------------------------------
 
-#ifdef __GNUG__
-    #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()
@@ -56,16 +74,20 @@ wxIndividualLayoutConstraint::wxIndividualLayoutConstraint()
     value = 0;
     percent = 0;
     otherEdge = wxTop;
-    done = FALSE;
+    done = false;
     otherWin = (wxWindowBase *) NULL;
 }
 
-wxIndividualLayoutConstraint::~wxIndividualLayoutConstraint()
-{
-}
-
 void wxIndividualLayoutConstraint::Set(wxRelationship rel, wxWindowBase *otherW, wxEdge otherE, int val, int marg)
 {
+    if (rel == wxSameAs)
+    {
+        // If Set is called by the user with wxSameAs then call SameAs to do
+        // it since it will actually use wxPercent instead.
+        SameAs(otherW, otherE, marg);
+        return;
+    }
+
     relationship = rel;
     otherWin = otherW;
     otherEdge = otherE;
@@ -106,13 +128,13 @@ void wxIndividualLayoutConstraint::Below(wxWindowBase *sibling, int marg)
 // 'Same edge' alignment
 //
 void wxIndividualLayoutConstraint::SameAs(wxWindowBase *otherW, wxEdge edge, int marg)
-{ 
+{
     Set(wxPercentOf, otherW, edge, 100, marg);
 }
 
 // The edge is a percentage of the other window's edge
 void wxIndividualLayoutConstraint::PercentOf(wxWindowBase *otherW, wxEdge wh, int per)
-{ 
+{
     Set(wxPercentOf, otherW, wh, per);
 }
 
@@ -137,10 +159,10 @@ bool wxIndividualLayoutConstraint::ResetIfWin(wxWindowBase *otherW)
         percent = 0;
         otherEdge = wxTop;
         otherWin = (wxWindowBase *) NULL;
-        return TRUE;
+        return true;
     }
 
-    return FALSE;
+    return false;
 }
 
 // Try to satisfy constraint
@@ -148,8 +170,8 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
 {
     if (relationship == wxAbsolute)
     {
-        done = TRUE;
-        return TRUE;
+        done = true;
+        return true;
     }
 
     switch (myEdge)
@@ -167,11 +189,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = edgePos - margin;
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxRightOf:
                 {
@@ -179,11 +201,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = edgePos + margin;
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxPercentOf:
                 {
@@ -191,11 +213,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = (int)(edgePos*(((float)percent)*0.01) + margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxUnconstrained:
                 {
@@ -205,24 +227,24 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (constraints->right.GetDone() && constraints->width.GetDone())
                     {
                         value = (constraints->right.GetValue() - constraints->width.GetValue() + margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else if (constraints->centreX.GetDone() && constraints->width.GetDone())
                     {
                         value = (int)(constraints->centreX.GetValue() - (constraints->width.GetValue()/2) + margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxAsIs:
                 {
                     int y;
                     win->GetPosition(&value, &y);
-                    done = TRUE;
-                    return TRUE;
+                    done = true;
+                    return true;
                 }
                 default:
                     break;
@@ -242,11 +264,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = edgePos - margin;
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxRightOf:
                 {
@@ -254,11 +276,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = edgePos + margin;
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxPercentOf:
                 {
@@ -266,11 +288,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = (int)(edgePos*(((float)percent)*0.01) - margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxUnconstrained:
                 {
@@ -280,27 +302,27 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (constraints->left.GetDone() && constraints->width.GetDone())
                     {
                         value = (constraints->left.GetValue() + constraints->width.GetValue() - margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else if (constraints->centreX.GetDone() && constraints->width.GetDone())
                     {
                         value = (int)(constraints->centreX.GetValue() + (constraints->width.GetValue()/2) - margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxAsIs:
                 {
                     int x, y;
                     int w, h;
-                    win->GetSize(&w, &h);
+                    wxGetAsIs(win, &w, &h);
                     win->GetPosition(&x, &y);
                     value = x + w;
-                    done = TRUE;
-                    return TRUE;
+                    done = true;
+                    return true;
                 }
                 default:
                     break;
@@ -320,11 +342,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = edgePos - margin;
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxBelow:
                 {
@@ -332,11 +354,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = edgePos + margin;
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxPercentOf:
                 {
@@ -344,11 +366,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = (int)(edgePos*(((float)percent)*0.01) + margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxUnconstrained:
                 {
@@ -358,24 +380,24 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (constraints->bottom.GetDone() && constraints->height.GetDone())
                     {
                         value = (constraints->bottom.GetValue() - constraints->height.GetValue() + margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else if (constraints->centreY.GetDone() && constraints->height.GetDone())
                     {
                         value = (constraints->centreY.GetValue() - (constraints->height.GetValue()/2) + margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxAsIs:
                 {
                     int x;
                     win->GetPosition(&x, &value);
-                    done = TRUE;
-                    return TRUE;
+                    done = true;
+                    return true;
                 }
                 default:
                     break;
@@ -395,11 +417,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = edgePos + margin;
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxBelow:
                 {
@@ -407,11 +429,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = edgePos - margin;
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxPercentOf:
                 {
@@ -419,11 +441,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = (int)(edgePos*(((float)percent)*0.01) - margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxUnconstrained:
                 {
@@ -433,27 +455,27 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (constraints->top.GetDone() && constraints->height.GetDone())
                     {
                         value = (constraints->top.GetValue() + constraints->height.GetValue() - margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else if (constraints->centreY.GetDone() && constraints->height.GetDone())
                     {
                         value = (constraints->centreY.GetValue() + (constraints->height.GetValue()/2) - margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxAsIs:
                 {
                     int x, y;
                     int w, h;
-                    win->GetSize(&w, &h);
+                    wxGetAsIs(win, &w, &h);
                     win->GetPosition(&x, &y);
                     value = h + y;
-                    done = TRUE;
-                    return TRUE;
+                    done = true;
+                    return true;
                 }
                 default:
                     break;
@@ -473,11 +495,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = edgePos - margin;
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxRightOf:
                 {
@@ -485,11 +507,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = edgePos + margin;
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxPercentOf:
                 {
@@ -497,11 +519,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = (int)(edgePos*(((float)percent)*0.01) + margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxUnconstrained:
                 {
@@ -511,17 +533,17 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (constraints->left.GetDone() && constraints->width.GetDone())
                     {
                         value = (int)(constraints->left.GetValue() + (constraints->width.GetValue()/2) + margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else if (constraints->right.GetDone() && constraints->width.GetDone())
                     {
                         value = (int)(constraints->left.GetValue() - (constraints->width.GetValue()/2) + margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 default:
                     break;
@@ -541,11 +563,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = edgePos - margin;
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxBelow:
                 {
@@ -553,11 +575,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = edgePos + margin;
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxPercentOf:
                 {
@@ -565,11 +587,11 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = (int)(edgePos*(((float)percent)*0.01) + margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxUnconstrained:
                 {
@@ -579,17 +601,17 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (constraints->bottom.GetDone() && constraints->height.GetDone())
                     {
                         value = (int)(constraints->bottom.GetValue() - (constraints->height.GetValue()/2) + margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else if (constraints->top.GetDone() && constraints->height.GetDone())
                     {
                         value = (int)(constraints->top.GetValue() + (constraints->height.GetValue()/2) + margin);
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 default:
                     break;
@@ -606,22 +628,22 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = (int)(edgePos*(((float)percent)*0.01));
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxAsIs:
                 {
                     if (win)
                     {
                         int h;
-                        win->GetSize(&value, &h);
-                        done = TRUE;
-                        return TRUE;
+                        wxGetAsIs(win, &value, &h);
+                        done = true;
+                        return true;
                     }
-                    else return FALSE;
+                    else return false;
                 }
                 case wxUnconstrained:
                 {
@@ -631,23 +653,23 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (constraints->left.GetDone() && constraints->right.GetDone())
                     {
                         value = constraints->right.GetValue() - constraints->left.GetValue();
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else if (constraints->centreX.GetDone() && constraints->left.GetDone())
                     {
                         value = (int)(2*(constraints->centreX.GetValue() - constraints->left.GetValue()));
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else if (constraints->centreX.GetDone() && constraints->right.GetDone())
                     {
                         value = (int)(2*(constraints->right.GetValue() - constraints->centreX.GetValue()));
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 default:
                     break;
@@ -664,22 +686,22 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (edgePos != -1)
                     {
                         value = (int)(edgePos*(((float)percent)*0.01));
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 case wxAsIs:
                 {
                     if (win)
                     {
                         int w;
-                        win->GetSize(&w, &value);
-                        done = TRUE;
-                        return TRUE;
+                        wxGetAsIs(win, &w, &value);
+                        done = true;
+                        return true;
                     }
-                    else return FALSE;
+                    else return false;
                 }
                 case wxUnconstrained:
                 {
@@ -689,23 +711,23 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
                     if (constraints->top.GetDone() && constraints->bottom.GetDone())
                     {
                         value = constraints->bottom.GetValue() - constraints->top.GetValue();
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else if (constraints->top.GetDone() && constraints->centreY.GetDone())
                     {
                         value = (int)(2*(constraints->centreY.GetValue() - constraints->top.GetValue()));
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else if (constraints->bottom.GetDone() && constraints->centreY.GetDone())
                     {
                         value = (int)(2*(constraints->bottom.GetValue() - constraints->centreY.GetValue()));
-                        done = TRUE;
-                        return TRUE;
+                        done = true;
+                        return true;
                     }
                     else
-                        return FALSE;
+                        return false;
                 }
                 default:
                     break;
@@ -715,7 +737,7 @@ bool wxIndividualLayoutConstraint::SatisfyConstraint(wxLayoutConstraints *constr
         default:
             break;
     }
-    return FALSE;
+    return false;
 }
 
 // Get the value of this edge or dimension, or if this is not determinable, -1.
@@ -726,7 +748,7 @@ int wxIndividualLayoutConstraint::GetEdge(wxEdge which,
     // If the edge or dimension belongs to the parent, then we know the
     // dimension is obtainable immediately. E.g. a wxExpandSizer may contain a
     // button (but the button's true parent is a panel, not the sizer)
-    if (other->GetChildren().Find(thisWin))
+    if (other->GetChildren().Find((wxWindow*)thisWin))
     {
         switch (which)
         {
@@ -952,51 +974,47 @@ wxLayoutConstraints::wxLayoutConstraints()
     height.SetEdge(wxHeight);
 }
 
-wxLayoutConstraints::~wxLayoutConstraints()
-{
-}
-
 bool wxLayoutConstraints::SatisfyConstraints(wxWindowBase *win, int *nChanges)
 {
     int noChanges = 0;
 
     bool done = width.GetDone();
-    bool newDone = (done ? TRUE : width.SatisfyConstraint(this, win));
+    bool newDone = (done ? true : width.SatisfyConstraint(this, win));
     if (newDone != done)
         noChanges ++;
 
     done = height.GetDone();
-    newDone = (done ? TRUE : height.SatisfyConstraint(this, win));
+    newDone = (done ? true : height.SatisfyConstraint(this, win));
     if (newDone != done)
         noChanges ++;
 
     done = left.GetDone();
-    newDone = (done ? TRUE : left.SatisfyConstraint(this, win));
+    newDone = (done ? true : left.SatisfyConstraint(this, win));
     if (newDone != done)
         noChanges ++;
 
     done = top.GetDone();
-    newDone = (done ? TRUE : top.SatisfyConstraint(this, win));
+    newDone = (done ? true : top.SatisfyConstraint(this, win));
     if (newDone != done)
         noChanges ++;
 
     done = right.GetDone();
-    newDone = (done ? TRUE : right.SatisfyConstraint(this, win));
+    newDone = (done ? true : right.SatisfyConstraint(this, win));
     if (newDone != done)
         noChanges ++;
 
     done = bottom.GetDone();
-    newDone = (done ? TRUE : bottom.SatisfyConstraint(this, win));
+    newDone = (done ? true : bottom.SatisfyConstraint(this, win));
     if (newDone != done)
         noChanges ++;
 
     done = centreX.GetDone();
-    newDone = (done ? TRUE : centreX.SatisfyConstraint(this, win));
+    newDone = (done ? true : centreX.SatisfyConstraint(this, win));
     if (newDone != done)
         noChanges ++;
 
     done = centreY.GetDone();
-    newDone = (done ? TRUE : centreY.SatisfyConstraint(this, win));
+    newDone = (done ? true : centreY.SatisfyConstraint(this, win));
     if (newDone != done)
         noChanges ++;
 
@@ -1005,134 +1023,4 @@ bool wxLayoutConstraints::SatisfyConstraints(wxWindowBase *win, int *nChanges)
     return AreSatisfied();
 }
 
-/*
- * Main constrained layout algorithm. Look at all the child
- * windows, and their constraints (if any).
- * The idea is to keep iterating through the constraints
- * until all left, right, bottom and top edges, and widths and heights,
- * are known (or no change occurs and we've failed to resolve all
- * constraints).
- *
- * If the user has not specified a dimension or edge, it will be
- * be calculated from the other known values. E.g. If we know
- * the right hand edge and the left hand edge, we now know the width.
- * The snag here is that this means we must specify absolute dimensions
- * twice (in constructor and in constraint), if we wish to use the
- * constraint notation to just set the position, for example.
- * Otherwise, if we only set ONE edge and no dimension, it would never
- * find the other edge.
- *
- * Algorithm:
-
-  Mark all constraints as not done.
-
-  iterations = 0;
-  until no change or iterations >= max iterations
-    For each child:
-    {
-      Calculate all constraints
-    }
-    iterations ++;
-
-  For each child
-    Set each calculated position and size
-
- */
-#if WXWIN_COMPATIBILITY
-bool wxOldDoLayout(wxWindowBase *win)
-{
-  // Make sure this isn't called recursively from below
-  static wxList doneSoFar;
-
-  if (doneSoFar.Member(win))
-    return TRUE;
-
-  doneSoFar.Append(win);
-
-  wxNode *node = win->GetChildren().First();
-  while (node)
-  {
-    wxWindowBase *child = (wxWindowBase *)node->Data();
-    wxLayoutConstraints *constr = child->GetConstraints();
-    if (constr)
-    {
-      constr->left.SetDone(FALSE);
-      constr->top.SetDone(FALSE);
-      constr->right.SetDone(FALSE);
-      constr->bottom.SetDone(FALSE);
-      constr->width.SetDone(FALSE);
-      constr->height.SetDone(FALSE);
-      constr->centreX.SetDone(FALSE);
-      constr->centreY.SetDone(FALSE);
-    }
-    node = node->Next();
-  }
-  int noIterations = 0;
-  int maxIterations = 500;
-  int noChanges = 1;
-
-  while ((noChanges > 0) && (noIterations < maxIterations))
-  {
-    noChanges = 0;
-    wxNode *node = win->GetChildren().First();
-    while (node)
-    {
-      wxWindowBase *child = (wxWindowBase *)node->Data();
-      wxLayoutConstraints *constr = child->GetConstraints();
-      if (constr)
-      {
-        int tempNoChanges = 0;
-        (void)constr->SatisfyConstraints(child, &tempNoChanges);
-        noChanges += tempNoChanges;
-      }
-      node = node->Next();
-    }
-    noIterations ++;
-  }
-/*
-  // Would be nice to have a test here to see _which_ constraint(s)
-  // failed, so we can print a specific diagnostic message.
-  if (noFailures > 0)
-  {
-    wxDebugMsg(_("wxWindowBase::Layout() failed.\n"));
-  }
-*/
-  // Now set the sizes and positions of the children, and
-  // recursively call Layout().
-  node = win->GetChildren().First();
-  while (node)
-  {
-    wxWindowBase *child = (wxWindowBase *)node->Data();
-    wxLayoutConstraints *constr = child->GetConstraints();
-    if (constr && constr->left.GetDone() && constr->right.GetDone() &&
-                  constr->width.GetDone() && constr->height.GetDone())
-    {
-      int x = constr->left.GetValue();
-      int y = constr->top.GetValue();
-      int w = constr->width.GetValue();
-      int h = constr->height.GetValue();
-
-      // If we don't want to resize this window, just move it...
-      if ((constr->width.GetRelationship() != wxAsIs) ||
-          (constr->height.GetRelationship() != wxAsIs))
-      {
-        // _Should_ call Layout() recursively.
-        child->SetSize(x, y, w, h);
-      }
-      else
-      {
-        child->Move(x, y);
-      }
-    }
-    else
-      child->Layout();
-    node = node->Next();
-  }
-  doneSoFar.DeleteObject(win);
-
-  return TRUE;
-}
-#endif // WXWIN_COMPATIBILITY
-
 #endif // wxUSE_CONSTRAINTS