📄 constrnt.cpp
字号:
spacingY = m_ySpacing; startY = (double)(y - ((totalObjectHeight + (n+1)*spacingY)/2.0)); } // Now position the objects bool changed = false; node = m_constrainedObjects.GetFirst(); while (node) { wxShape *constrainedObject = (wxShape *)node->GetData(); double width2, height2; constrainedObject->GetBoundingBoxMax(&width2, &height2); startX += (double)(spacingX + (width2/2.0)); startY += (double)(spacingY + (height2/2.0)); if ((!Equals(startX, constrainedObject->GetX())) || (!Equals(startY, constrainedObject->GetY()))) { constrainedObject->Move(dc, startX, startY, false); changed = true; } startX += (double)(width2/2.0); startY += (double)(height2/2.0); node = node->GetNext(); } return changed; } case gyCONSTRAINT_LEFT_OF: { bool changed = false; wxNode *node = m_constrainedObjects.GetFirst(); while (node) { wxShape *constrainedObject = (wxShape *)node->GetData(); double width2, height2; constrainedObject->GetBoundingBoxMax(&width2, &height2); double x3 = (double)(x - (minWidth/2.0) - (width2/2.0) - m_xSpacing); if (!Equals(x3, constrainedObject->GetX())) { changed = true; constrainedObject->Move(dc, x3, constrainedObject->GetY(), false); } node = node->GetNext(); } return changed; } case gyCONSTRAINT_RIGHT_OF: { bool changed = false; wxNode *node = m_constrainedObjects.GetFirst(); while (node) { wxShape *constrainedObject = (wxShape *)node->GetData(); double width2, height2; constrainedObject->GetBoundingBoxMax(&width2, &height2); double x3 = (double)(x + (minWidth/2.0) + (width2/2.0) + m_xSpacing); if (!Equals(x3, constrainedObject->GetX())) { changed = true; constrainedObject->Move(dc, x3, constrainedObject->GetY(), false); } node = node->GetNext(); } return changed; } case gyCONSTRAINT_ABOVE: { bool changed = false; wxNode *node = m_constrainedObjects.GetFirst(); while (node) { wxShape *constrainedObject = (wxShape *)node->GetData(); double width2, height2; constrainedObject->GetBoundingBoxMax(&width2, &height2); double y3 = (double)(y - (minHeight/2.0) - (height2/2.0) - m_ySpacing); if (!Equals(y3, constrainedObject->GetY())) { changed = true; constrainedObject->Move(dc, constrainedObject->GetX(), y3, false); } node = node->GetNext(); } return changed; } case gyCONSTRAINT_BELOW: { bool changed = false; wxNode *node = m_constrainedObjects.GetFirst(); while (node) { wxShape *constrainedObject = (wxShape *)node->GetData(); double width2, height2; constrainedObject->GetBoundingBoxMax(&width2, &height2); double y3 = (double)(y + (minHeight/2.0) + (height2/2.0) + m_ySpacing); if (!Equals(y3, constrainedObject->GetY())) { changed = true; constrainedObject->Move(dc, constrainedObject->GetX(), y3, false); } node = node->GetNext(); } return changed; } case gyCONSTRAINT_ALIGNED_LEFT: { bool changed = false; wxNode *node = m_constrainedObjects.GetFirst(); while (node) { wxShape *constrainedObject = (wxShape *)node->GetData(); double width2, height2; constrainedObject->GetBoundingBoxMax(&width2, &height2); double x3 = (double)(x - (minWidth/2.0) + (width2/2.0) + m_xSpacing); if (!Equals(x3, constrainedObject->GetX())) { changed = true; constrainedObject->Move(dc, x3, constrainedObject->GetY(), false); } node = node->GetNext(); } return changed; } case gyCONSTRAINT_ALIGNED_RIGHT: { bool changed = false; wxNode *node = m_constrainedObjects.GetFirst(); while (node) { wxShape *constrainedObject = (wxShape *)node->GetData(); double width2, height2; constrainedObject->GetBoundingBoxMax(&width2, &height2); double x3 = (double)(x + (minWidth/2.0) - (width2/2.0) - m_xSpacing); if (!Equals(x3, constrainedObject->GetX())) { changed = true; constrainedObject->Move(dc, x3, constrainedObject->GetY(), false); } node = node->GetNext(); } return changed; #if 0 // two returned values ? return false; #endif } case gyCONSTRAINT_ALIGNED_TOP: { bool changed = false; wxNode *node = m_constrainedObjects.GetFirst(); while (node) { wxShape *constrainedObject = (wxShape *)node->GetData(); double width2, height2; constrainedObject->GetBoundingBoxMax(&width2, &height2); double y3 = (double)(y - (minHeight/2.0) + (height2/2.0) + m_ySpacing); if (!Equals(y3, constrainedObject->GetY())) { changed = true; constrainedObject->Move(dc, constrainedObject->GetX(), y3, false); } node = node->GetNext(); } return changed; } case gyCONSTRAINT_ALIGNED_BOTTOM: { bool changed = false; wxNode *node = m_constrainedObjects.GetFirst(); while (node) { wxShape *constrainedObject = (wxShape *)node->GetData(); double width2, height2; constrainedObject->GetBoundingBoxMax(&width2, &height2); double y3 = (double)(y + (minHeight/2.0) - (height2/2.0) - m_ySpacing); if (!Equals(y3, constrainedObject->GetY())) { changed = true; constrainedObject->Move(dc, constrainedObject->GetX(), y3, false); } node = node->GetNext(); } return changed; } case gyCONSTRAINT_MIDALIGNED_LEFT: { bool changed = false; wxNode *node = m_constrainedObjects.GetFirst(); while (node) { wxShape *constrainedObject = (wxShape *)node->GetData(); double x3 = (double)(x - (minWidth/2.0)); if (!Equals(x3, constrainedObject->GetX())) { changed = true; constrainedObject->Move(dc, x3, constrainedObject->GetY(), false); } node = node->GetNext(); } return changed; } case gyCONSTRAINT_MIDALIGNED_RIGHT: { bool changed = false; wxNode *node = m_constrainedObjects.GetFirst(); while (node) { wxShape *constrainedObject = (wxShape *)node->GetData(); double x3 = (double)(x + (minWidth/2.0)); if (!Equals(x3, constrainedObject->GetX())) { changed = true; constrainedObject->Move(dc, x3, constrainedObject->GetY(), false); } node = node->GetNext(); } return changed; #if 0 // two returned values ? return false; #endif } case gyCONSTRAINT_MIDALIGNED_TOP: { bool changed = false; wxNode *node = m_constrainedObjects.GetFirst(); while (node) { wxShape *constrainedObject = (wxShape *)node->GetData(); double y3 = (double)(y - (minHeight/2.0)); if (!Equals(y3, constrainedObject->GetY())) { changed = true; constrainedObject->Move(dc, constrainedObject->GetX(), y3, false); } node = node->GetNext(); } return changed; } case gyCONSTRAINT_MIDALIGNED_BOTTOM: { bool changed = false; wxNode *node = m_constrainedObjects.GetFirst(); while (node) { wxShape *constrainedObject = (wxShape *)node->GetData(); double y3 = (double)(y + (minHeight/2.0)); if (!Equals(y3, constrainedObject->GetY())) { changed = true; constrainedObject->Move(dc, constrainedObject->GetX(), y3, false); } node = node->GetNext(); } return changed; } #if 0 // default value handled in main function body default: return false; #endif } return false;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -