- // 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()->Member(thisWin))
- {
- switch (which)
- {
- case wxLeft:
- {
- return wxSizerMarginX(other);
- }
- case wxTop:
- {
- return wxSizerMarginY(other);
- }
- case wxRight:
- {
- int w, h;
- other->GetClientSizeConstraint(&w, &h);
- return w - wxSizerMarginX(other);
- }
- case wxBottom:
- {
- int w, h;
- other->GetClientSizeConstraint(&w, &h);
- return h - wxSizerMarginY(other);
- }
- case wxWidth:
- {
- int w, h;
- other->GetClientSizeConstraint(&w, &h);
- return w - 2*wxSizerMarginX(other);
- }
- case wxHeight:
- {
- int w, h;
- other->GetClientSizeConstraint(&w, &h);
- return h - 2*wxSizerMarginY(other);
- }
- case wxCentreX:
- case wxCentreY:
- {
- int w, h;
- other->GetClientSizeConstraint(&w, &h);
- if (which == wxCentreX)
- return (int)(w/2);
- else
- return (int)(h/2);
- }
- default:
- return -1;
- }
- }
- switch (which)
- {
- case wxLeft:
- {
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->left.GetDone())
- return constr->left.GetValue();
- else
- return -1;
- }
- else
- {
- int x, y;
- other->GetPosition(&x, &y);
- return x;
- }
- }
- case wxTop:
- {
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->top.GetDone())
- return constr->top.GetValue();
- else
- return -1;
- }
- else
- {
- int x, y;
- other->GetPosition(&x, &y);
- return y;
- }
- }
- case wxRight:
- {
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->right.GetDone())
- return constr->right.GetValue();
- else
- return -1;
- }
- else
- {
- int x, y, w, h;
- other->GetPosition(&x, &y);
- other->GetSize(&w, &h);
- return (int)(x + w);
- }
- }
- case wxBottom:
- {
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->bottom.GetDone())
- return constr->bottom.GetValue();
- else
- return -1;
- }
- else
- {
- int x, y, w, h;
- other->GetPosition(&x, &y);
- other->GetSize(&w, &h);
- return (int)(y + h);
- }
- }
- case wxWidth:
- {
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->width.GetDone())
- return constr->width.GetValue();
- else
- return -1;
- }
- else
- {
- int w, h;
- other->GetSize(&w, &h);
- return w;
- }
- }
- case wxHeight:
- {
- wxLayoutConstraints *constr = other->GetConstraints();
- // If no constraints, it means the window is not dependent
- // on anything, and therefore we know its value immediately
- if (constr)
- {
- if (constr->height.GetDone())
- return constr->height.GetValue();
- else
- return -1;
- }
- else
- {
- int w, h;
- other->GetSize(&w, &h);
- return h;
- }
- }
- case wxCentreX: