// 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
/////////////////////////////////////////////////////////////////////////////
// =============================================================================
#include "wx/layout.h"
-#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxIndividualLayoutConstraint, wxObject)
IMPLEMENT_DYNAMIC_CLASS(wxLayoutConstraints, wxObject)
-#endif
wxIndividualLayoutConstraint::wxIndividualLayoutConstraint()
void wxIndividualLayoutConstraint::Set(wxRelationship rel, wxWindowBase *otherW, wxEdge otherE, int val, int marg)
{
- relationship = rel;
- otherWin = otherW;
- otherEdge = otherE;
- value = val;
- margin = 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;
+
+ if ( rel == wxPercentOf )
+ {
+ percent = val;
+ }
+ else
+ {
+ value = val;
+ }
+
+ margin = marg;
}
void wxIndividualLayoutConstraint::LeftOf(wxWindowBase *sibling, int marg)
// 'Same edge' alignment
//
void wxIndividualLayoutConstraint::SameAs(wxWindowBase *otherW, wxEdge edge, int marg)
-{
- Set(wxPercentOf, otherW, edge, 0, marg);
- percent = 100;
+{
+ 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)
-{
- otherWin = otherW;
- relationship = wxPercentOf;
- percent = per;
-
- otherEdge = wh;
+{
+ Set(wxPercentOf, otherW, wh, per);
}
//
//
void wxIndividualLayoutConstraint::Absolute(int val)
{
- value = val; relationship = wxAbsolute;
+ value = val;
+ relationship = wxAbsolute;
}
// Reset constraint if it mentions otherWin
otherWin = (wxWindowBase *) NULL;
return TRUE;
}
- else
- return FALSE;
+
+ return FALSE;
}
// Try to satisfy constraint
// 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)
{
Set each calculated position and size
*/
-
+
#if WXWIN_COMPATIBILITY
bool wxOldDoLayout(wxWindowBase *win)
{