/// <summary> /// Answer true if the box is entirely to the right of the clip rectangle. /// Enhance JohnT: Could refine this to skip a box if only its margin is visible. /// Enhance JohnT: if we do separate page drawing, as in print preview, we may need /// a more precise way to eliminate boxes not on the page. /// Enhance JohnT: may need to include a box that is just out of sight, in case one extends beyond the left of the box? /// </summary> internal override bool IsAfterVisibleBoxes(Box box, IVwGraphics vg, PaintTransform ptrans) { int left, top, right, bottom; vg.GetClipRect(out left, out top, out right, out bottom); return(ptrans.ToPaintX(box.Left) > right); }
/// <summary> /// Answer the first box whose bottom comes to the right of the left of the clip rectangle. /// Enhance JohnT: Could refine this to skip a box if only its margin is visible. /// Enhance JohnT: if we do separate page drawing, as in print preview, we may need /// a more precise way to eliminate boxes not on the page. /// Enhance JohnT: may need to include a box that is just out of sight, in case one extends beyond the right of the box? /// </summary> internal override Box FirstVisibleBox(IVwGraphics vg, PaintTransform ptrans) { int left, top, right, bottom; vg.GetClipRect(out left, out top, out right, out bottom); for (Box box = FirstBox; box != null; box = box.Next) { if (ptrans.ToPaintX(box.Right) > left) { return(box); } } return(null); }
/// <summary> /// Any box knows how to paint its background. Some subclasses may override. /// </summary> public virtual void PaintBackground(IVwGraphics vg, PaintTransform ptrans) { if (BorderTop == 0 && BorderBottom == 0 && BorderLeading == 0 && BorderTrailing == 0 && Style.BackColor.ToArgb() == Color.Transparent.ToArgb()) { return; } // Margin thicknesses int dxsMLeft = ptrans.MpToPixelsX(Style.Margins.LeadingMp); int dysMTop = ptrans.MpToPixelsY(Style.Margins.TopMp); int dxsMRight = ptrans.MpToPixelsX(Style.Margins.TrailingMp); int dysMBottom = ptrans.MpToPixelsY(Style.Margins.BottomMp); SwapIfRightToLeft(ref dxsMLeft, ref dxsMRight); // outside of border rectangle int xdLeftBord = ptrans.ToPaintX(dxsMLeft + Left); int ydTopBord = ptrans.ToPaintY(dysMTop + Top); int xdRightBord = ptrans.ToPaintX(Right - dxsMRight); int ydBottomBord = ptrans.ToPaintY(Bottom - dysMBottom); // Border thickness in pixels. int dxdLeftBord = ptrans.MpToBorderPixelsX(BorderLeading); int dydTopBord = ptrans.MpToBorderPixelsY(BorderTop); int dxdRightBord = ptrans.MpToBorderPixelsX(BorderTrailing); int dydBottomBord = ptrans.MpToBorderPixelsY(BorderBottom); SwapIfRightToLeft(ref dxdLeftBord, ref dxdRightBord); // inside of border rectangle, outside of pad rectangle int xdLeftPad = xdLeftBord + dxdLeftBord; int ydTopPad = ydTopBord + dydTopBord; int xdRightPad = xdRightBord - dxdRightBord; int ydBottomPad = ydBottomBord - dydBottomBord; // Wanted this in the old Views version, not sure if it may become relevant here. //// no pad, border, or margin to left of extension box. //if (IsBoxFromTsString()) // xdLeftPad = xdLeftBord = rcSrc.MapXTo(m_xsLeft, rcDst); //// no pad, border, or margin to right of box followed by //// extension //if (m_pboxNext && m_pboxNext->IsBoxFromTsString()) // xdRightPad = xdRightBord = rcSrc.MapXTo(m_xsLeft + m_dxsWidth, rcDst); // Draw background if (Style.BackColor.ToArgb() != Color.Transparent.ToArgb()) { vg.BackColor = (int)ColorUtil.ConvertColorToBGR(Style.BackColor); vg.DrawRectangle(xdLeftPad, ydTopPad, xdRightPad, ydBottomPad); } // Draw border lines. We initially set the background color because we draw the // borders using rectangles, and DrawRectangle uses the background color vg.BackColor = (int)ColorUtil.ConvertColorToBGR(Style.BorderColor); if (xdLeftPad != xdLeftBord) { vg.DrawRectangle(xdLeftBord, ydTopBord, xdLeftPad, ydBottomBord); } if (ydTopBord != ydTopPad) { vg.DrawRectangle(xdLeftBord, ydTopBord, xdRightBord, ydTopPad); } if (xdRightPad != xdRightBord) { vg.DrawRectangle(xdRightPad, ydTopBord, xdRightBord, ydBottomBord); } if (ydBottomPad != ydBottomBord) { vg.DrawRectangle(xdLeftBord, ydBottomPad, xdRightBord, ydBottomBord); } }
/// <summary> /// Any box knows how to paint its background. Some subclasses may override. /// </summary> public virtual void PaintBackground(IVwGraphics vg, PaintTransform ptrans) { if (BorderTop == 0 && BorderBottom == 0 && BorderLeading == 0 && BorderTrailing == 0 && Style.BackColor.ToArgb() == Color.Transparent.ToArgb()) return; // Margin thicknesses int dxsMLeft = ptrans.MpToPixelsX(Style.Margins.LeadingMp); int dysMTop = ptrans.MpToPixelsY(Style.Margins.TopMp); int dxsMRight = ptrans.MpToPixelsX(Style.Margins.TrailingMp); int dysMBottom = ptrans.MpToPixelsY(Style.Margins.BottomMp); SwapIfRightToLeft(ref dxsMLeft, ref dxsMRight); // outside of border rectangle int xdLeftBord = ptrans.ToPaintX(dxsMLeft + Left); int ydTopBord = ptrans.ToPaintY(dysMTop + Top); int xdRightBord = ptrans.ToPaintX(Right - dxsMRight); int ydBottomBord = ptrans.ToPaintY(Bottom - dysMBottom); // Border thickness in pixels. int dxdLeftBord = ptrans.MpToBorderPixelsX(BorderLeading); int dydTopBord = ptrans.MpToBorderPixelsY(BorderTop); int dxdRightBord = ptrans.MpToBorderPixelsX(BorderTrailing); int dydBottomBord = ptrans.MpToBorderPixelsY(BorderBottom); SwapIfRightToLeft(ref dxdLeftBord, ref dxdRightBord); // inside of border rectangle, outside of pad rectangle int xdLeftPad = xdLeftBord + dxdLeftBord; int ydTopPad = ydTopBord + dydTopBord; int xdRightPad = xdRightBord - dxdRightBord; int ydBottomPad = ydBottomBord - dydBottomBord; // Wanted this in the old Views version, not sure if it may become relevant here. //// no pad, border, or margin to left of extension box. //if (IsBoxFromTsString()) // xdLeftPad = xdLeftBord = rcSrc.MapXTo(m_xsLeft, rcDst); //// no pad, border, or margin to right of box followed by //// extension //if (m_pboxNext && m_pboxNext->IsBoxFromTsString()) // xdRightPad = xdRightBord = rcSrc.MapXTo(m_xsLeft + m_dxsWidth, rcDst); // Draw background if (Style.BackColor.ToArgb() != Color.Transparent.ToArgb()) { vg.BackColor = (int) ColorUtil.ConvertColorToBGR(Style.BackColor); vg.DrawRectangle(xdLeftPad, ydTopPad, xdRightPad, ydBottomPad); } // Draw border lines. We initially set the background color because we draw the // borders using rectangles, and DrawRectangle uses the background color vg.BackColor = (int) ColorUtil.ConvertColorToBGR(Style.BorderColor); if (xdLeftPad != xdLeftBord) vg.DrawRectangle(xdLeftBord, ydTopBord, xdLeftPad, ydBottomBord); if (ydTopBord != ydTopPad) vg.DrawRectangle(xdLeftBord, ydTopBord, xdRightBord, ydTopPad); if (xdRightPad != xdRightBord) vg.DrawRectangle(xdRightPad, ydTopBord, xdRightBord, ydBottomBord); if (ydBottomPad != ydBottomBord) vg.DrawRectangle(xdLeftBord, ydBottomPad, xdRightBord, ydBottomBord); }
/// <summary> /// Answer the first box whose bottom comes to the right of the left of the clip rectangle. /// Enhance JohnT: Could refine this to skip a box if only its margin is visible. /// Enhance JohnT: if we do separate page drawing, as in print preview, we may need /// a more precise way to eliminate boxes not on the page. /// Enhance JohnT: may need to include a box that is just out of sight, in case one extends beyond the right of the box? /// </summary> internal override Box FirstVisibleBox(IVwGraphics vg, PaintTransform ptrans) { int left, top, right, bottom; vg.GetClipRect(out left, out top, out right, out bottom); for (Box box = FirstBox; box != null; box = box.Next) if (ptrans.ToPaintX(box.Right) > left) return box; return null; }
/// <summary> /// Answer true if the box is entirely to the right of the clip rectangle. /// Enhance JohnT: Could refine this to skip a box if only its margin is visible. /// Enhance JohnT: if we do separate page drawing, as in print preview, we may need /// a more precise way to eliminate boxes not on the page. /// Enhance JohnT: may need to include a box that is just out of sight, in case one extends beyond the left of the box? /// </summary> internal override bool IsAfterVisibleBoxes(Box box, IVwGraphics vg, PaintTransform ptrans) { int left, top, right, bottom; vg.GetClipRect(out left, out top, out right, out bottom); return ptrans.ToPaintX(box.Left) > right; }