📄 layout.cpp
字号:
// 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;
wxGetAsIs(win, &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;
wxGetAsIs(win, &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)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -