- 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;