bool wxWindowBase::Layout()
{
- int w, h;
- GetClientSize(&w, &h);
-
// If there is a sizer, use it instead of the constraints
if ( GetSizer() )
{
+ int w, h;
+ GetClientSize(&w, &h);
+
GetSizer()->SetDimension( 0, 0, w, h );
- return TRUE;
}
-
- if ( GetConstraints() )
+ else
{
- GetConstraints()->width.SetValue(w);
- GetConstraints()->height.SetValue(h);
+ wxLayoutConstraints *constr = GetConstraints();
+ bool wasOk = constr && constr->AreSatisfied();
+
+ ResetConstraints(); // Mark all constraints as unevaluated
+
+ // if we're a top level panel (i.e. our parent is frame/dialog), our
+ // own constraints will never be satisfied any more unless we do it
+ // here
+ if ( wasOk )
+ {
+ int noChanges = 1;
+ while ( noChanges > 0 )
+ {
+ constr->SatisfyConstraints(this, &noChanges);
+ }
+ }
+
+ DoPhase(1); // Layout children
+ DoPhase(2); // Layout grand children
+ SetConstraintSizes(); // Recursively set the real window sizes
}
-
- // Evaluate child constraints
- ResetConstraints(); // Mark all constraints as unevaluated
- DoPhase(1); // Just one phase need if no sizers involved
- DoPhase(2);
- SetConstraintSizes(); // Recursively set the real window sizes
return TRUE;
}
constr->centreX.SetDone(FALSE);
constr->centreY.SetDone(FALSE);
}
+
wxWindowList::Node *node = GetChildren().GetFirst();
while (node)
{
void wxWindowBase::SetConstraintSizes(bool recurse)
{
wxLayoutConstraints *constr = GetConstraints();
- if ( constr && constr->left.GetDone() && constr->right.GetDone( ) &&
- constr->width.GetDone() && constr->height.GetDone())
+ if ( constr && constr->AreSatisfied() )
{
int x = constr->left.GetValue();
int y = constr->top.GetValue();
}
else if ( constr )
{
- wxChar *windowClass = GetClassInfo()->GetClassName();
-
- wxString winName;
- if ( GetName() == wxT("") )
- winName = wxT("unnamed");
- else
- winName = GetName();
- wxLogDebug( wxT("Constraint(s) not satisfied for window of type %s, name %s:\n"),
- (const wxChar *)windowClass,
- (const wxChar *)winName);
- if ( !constr->left.GetDone()) wxLogDebug( wxT(" unsatisfied 'left' constraint.\n") );
- if ( !constr->right.GetDone()) wxLogDebug( wxT(" unsatisfied 'right' constraint.\n") );
- if ( !constr->width.GetDone()) wxLogDebug( wxT(" unsatisfied 'width' constraint.\n") );
- if ( !constr->height.GetDone()) wxLogDebug( wxT(" unsatisfied 'height' constraint.\n") );
- wxLogDebug( wxT("Please check constraints: try adding AsIs() constraints.\n") );
+ wxLogDebug(wxT("Constraints not satisfied for %s named '%s'."),
+ GetClassInfo()->GetClassName(),
+ GetName().c_str());
}
if ( recurse )