int DockWindow::GetQuad(Point p, Rect r) /* Finds the quadrant in the rectangle for point p: ------- |\0|1/| |7\|/2| |-----| |6/|\3| |/5|4\| ------- */ { Point cp = r.CenterPoint(); p -= cp; cp -= r.TopLeft(); if (p.x <= 0) { // Left if (p.y <= 0) // Top-Left return ((p.y * cp.x)/cp.y > p.x) ? 7 : 0; else {// Bottom-Left p.x = -p.x; return ((p.y * cp.x)/cp.y > p.x) ? 5 : 6; } } else { // Right if (p.y <= 0) { // Top-Right p.x = -p.x; return ((p.y * cp.x)/cp.y > p.x) ? 2 : 1; } else // Bottom-Right return ((p.y * cp.x)/cp.y > p.x) ? 4 : 3; } }
void PopUpDockWindow::ShowOuterPopUps(DockCont &dc) { Rect wrect = GetScreenRect(); Point cp = wrect.CenterPoint(); Size psz(style->outersize, style->outersize); Rect prect = Rect(psz); psz /= 2; wrect.Deflate(12, 12); if (dc.IsDockAllowed(DOCK_LEFT)) ShowPopUp(outer[DOCK_LEFT], prect.Offseted(wrect.left + POPUP_SPACING, cp.y - psz.cy)); if (dc.IsDockAllowed(DOCK_TOP)) ShowPopUp(outer[DOCK_TOP], prect.Offseted(cp.x - psz.cx, wrect.top + POPUP_SPACING)); if (dc.IsDockAllowed(DOCK_RIGHT)) ShowPopUp(outer[DOCK_RIGHT], prect.Offseted(wrect.right - POPUP_SPACING - psz.cx*2, cp.y - psz.cy)); if (dc.IsDockAllowed(DOCK_BOTTOM)) ShowPopUp(outer[DOCK_BOTTOM], prect.Offseted(cp.x - psz.cx, wrect.bottom - POPUP_SPACING - psz.cy*2)); }
void FormView::DrawSprings(Draw& w, const Rect& r, dword align, dword valign, bool drawLeft, bool drawTop, bool drawRight, bool drawBottom, bool centered) { if (!IsLayout()) return; int x = r.CenterPoint().x; int y = r.CenterPoint().y; if (drawLeft) { if (!centered) y = YToGrid(r.top + r.Height() / 3); if (align == Ctrl::LEFT || align == Ctrl::SIZE) w.DrawLine(2, y, r.left, y, 1, LtRed()); else for (int i = 5; i <= r.left; i += 5) w.DrawLine(i, YToGrid(y - 5, !centered), i, YToGrid(y + 5, !centered), 1, LtRed()); } if (drawRight) { if (!centered) y = YToGrid(r.top + r.Height() * 2 / 3); if (align == Ctrl::RIGHT || align == Ctrl::SIZE) w.DrawLine(r.right, y, GetRect().Width() - 2, y, 1, LtRed()); else for (int i = r.right; i < GetRect().Width() + 5; i += 5) w.DrawLine(i, YToGrid(y - 5, !centered), i, YToGrid(y + 5, !centered), 1, LtRed()); } if (drawTop) { if (!centered) x = XToGrid(r.left + r.Width() / 3); if (valign == Ctrl::TOP || valign == Ctrl::SIZE) w.DrawLine(x, 2, x, r.top, 1, LtRed()); else for (int i = 5; i <= r.top; i += 5) w.DrawLine(XToGrid(x - 5, !centered), i, XToGrid(x + 5, !centered), i, 1, LtRed()); } if (drawBottom) { if (!centered) x = XToGrid(r.left + r.Width() * 2 / 3); if (valign == Ctrl::BOTTOM || valign == Ctrl::SIZE) w.DrawLine(x, r.bottom, x, GetRect().Height() - 2, 1, LtRed()); else for (int i = r.bottom; i < GetRect().Height() + 5; i += 5) w.DrawLine(XToGrid(x - 5, !centered), i, XToGrid(x + 5, !centered), i, 1, LtRed()); } }