- if (relationship == wxAbsolute)
- {
- done = TRUE;
- return TRUE;
- }
-
- switch (myEdge)
- {
- case wxLeft:
- {
- switch (relationship)
- {
- case wxLeftOf:
- {
- // We can know this edge if: otherWin is win's parent,
- // or otherWin has a satisfied constraint, or
- // otherWin has no constraint.
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos - margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxRightOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos + margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxPercentOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01) + margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxUnconstrained:
- {
- // We know the left-hand edge position if we know
- // the right-hand edge and we know the width; OR if we know the centre and the width.
- if (constraints->right.GetDone() && constraints->width.GetDone())
- {
- value = (constraints->right.GetValue() - constraints->width.GetValue() + margin);
- 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;
- }
- else
- return FALSE;
- }
- case wxAsIs:
- {
- int y;
- win->GetPosition(&value, &y);
- done = TRUE;
- return TRUE;
- }
- default:
- break;
- }
- break;
- }
- case wxRight:
- {
- switch (relationship)
- {
- case wxLeftOf:
- {
- // We can know this edge if: otherWin is win's parent,
- // or otherWin has a satisfied constraint, or
- // otherWin has no constraint.
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos - margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxRightOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos + margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxPercentOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01) - margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxUnconstrained:
- {
- // We know the right-hand edge position if we know
- // the left-hand edge and we know the width, OR if we know the
- // centre edge and the width.
- if (constraints->left.GetDone() && constraints->width.GetDone())
- {
- value = (constraints->left.GetValue() + constraints->width.GetValue() - margin);
- 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;
- }
- else
- return FALSE;
- }
- case wxAsIs:
- {
- int x, y;
- int w, h;
- win->GetSize(&w, &h);
- win->GetPosition(&x, &y);
- value = x + w;
- done = TRUE;
- return TRUE;
- }
- default:
- break;
- }
- break;
- }
- case wxTop:
- {
- switch (relationship)
- {
- case wxAbove:
- {
- // We can know this edge if: otherWin is win's parent,
- // or otherWin has a satisfied constraint, or
- // otherWin has no constraint.
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos - margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxBelow:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos + margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxPercentOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01) + margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxUnconstrained:
- {
- // We know the top edge position if we know
- // the bottom edge and we know the height; OR if we know the centre
- // edge and the height.
- if (constraints->bottom.GetDone() && constraints->height.GetDone())
- {
- value = (constraints->bottom.GetValue() - constraints->height.GetValue() + margin);
- 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;
- }
- else
- return FALSE;
- }
- case wxAsIs:
- {
- int x;
- win->GetPosition(&x, &value);
- done = TRUE;
- return TRUE;
- }
- default:
- break;
- }
- break;
- }
- case wxBottom:
- {
- switch (relationship)
- {
- case wxAbove:
- {
- // We can know this edge if: otherWin is win's parent,
- // or otherWin has a satisfied constraint, or
- // otherWin has no constraint.
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos + margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxBelow:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos - margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxPercentOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01) - margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxUnconstrained:
- {
- // We know the bottom edge position if we know
- // the top edge and we know the height; OR if we know the
- // centre edge and the height.
- if (constraints->top.GetDone() && constraints->height.GetDone())
- {
- value = (constraints->top.GetValue() + constraints->height.GetValue() - margin);
- 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;
- }
- else
- return FALSE;
- }
- case wxAsIs:
- {
- int x, y;
- int w, h;
- win->GetSize(&w, &h);
- win->GetPosition(&x, &y);
- value = h + y;
- done = TRUE;
- return TRUE;
- }
- default:
- break;
- }
- break;
- }
- case wxCentreX:
- {
- switch (relationship)
- {
- case wxLeftOf:
- {
- // We can know this edge if: otherWin is win's parent,
- // or otherWin has a satisfied constraint, or
- // otherWin has no constraint.
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos - margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxRightOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos + margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxPercentOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01) + margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxUnconstrained:
- {
- // We know the centre position if we know
- // the left-hand edge and we know the width, OR
- // the right-hand edge and the width
- if (constraints->left.GetDone() && constraints->width.GetDone())
- {
- value = (int)(constraints->left.GetValue() + (constraints->width.GetValue()/2) + margin);
- 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;
- }
- else
- return FALSE;
- }
- default:
- break;
- }
- break;
- }
- case wxCentreY:
- {
- switch (relationship)
- {
- case wxAbove:
- {
- // We can know this edge if: otherWin is win's parent,
- // or otherWin has a satisfied constraint, or
- // otherWin has no constraint.
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos - margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxBelow:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = edgePos + margin;
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxPercentOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01) + margin);
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxUnconstrained:
- {
- // We know the centre position if we know
- // the top edge and we know the height, OR
- // the bottom edge and the height.
- if (constraints->bottom.GetDone() && constraints->height.GetDone())
- {
- value = (int)(constraints->bottom.GetValue() - (constraints->height.GetValue()/2) + margin);
- 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;
- }
- else
- return FALSE;
- }
- default:
- break;
- }
- break;
- }
- case wxWidth:
- {
- switch (relationship)
- {
- case wxPercentOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01));
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxAsIs:
- {
- if (win)
- {
- int h;
- win->GetSize(&value, &h);
- done = TRUE;
- return TRUE;
- }
- else return FALSE;
- }
- case wxUnconstrained:
- {
- // We know the width if we know the left edge and the right edge, OR
- // if we know the left edge and the centre, OR
- // if we know the right edge and the centre
- if (constraints->left.GetDone() && constraints->right.GetDone())
- {
- value = constraints->right.GetValue() - constraints->left.GetValue();
- 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;
- }
- else if (constraints->centreX.GetDone() && constraints->right.GetDone())
- {
- value = (int)(2*(constraints->right.GetValue() - constraints->centreX.GetValue()));
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- default:
- break;
- }
- break;
- }
- case wxHeight:
- {
- switch (relationship)
- {
- case wxPercentOf:
- {
- int edgePos = GetEdge(otherEdge, win, otherWin);
- if (edgePos != -1)
- {
- value = (int)(edgePos*(((float)percent)*0.01));
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- case wxAsIs:
- {
- if (win)
- {
- int w;
- win->GetSize(&w, &value);
- done = TRUE;
- return TRUE;
- }
- else return FALSE;
- }
- case wxUnconstrained:
- {
- // We know the height if we know the top edge and the bottom edge, OR
- // if we know the top edge and the centre, OR
- // if we know the bottom edge and the centre
- if (constraints->top.GetDone() && constraints->bottom.GetDone())
- {
- value = constraints->bottom.GetValue() - constraints->top.GetValue();
- 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;
- }
- else if (constraints->bottom.GetDone() && constraints->centreY.GetDone())
- {
- value = (int)(2*(constraints->bottom.GetValue() - constraints->centreY.GetValue()));
- done = TRUE;
- return TRUE;
- }
- else
- return FALSE;
- }
- default:
- break;
- }
- break;
- }
- default:
- break;
- }
- return FALSE;
-}