ToPaintY() public method

Convert a position relative to the box for which this is the transform to one in paint coordinates. Todo: tests and implementation of differing DPI and non-zero ScrollOffset.
public ToPaintY ( int ys ) : int
ys int
return int
Example #1
0
        /// <summary>
        /// Answer true if the box is entirely below 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 exceptionally
        /// high stacked diacritics extend above the top 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.ToPaintY(box.Top) > bottom);
        }
Example #2
0
        /// <summary>
        /// Answer the first box whose bottom comes below the top 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 exceptionally
        /// long descenders or stacked diacritics extend below the bottom 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.ToPaintY(box.Bottom) > top)
                {
                    return(box);
                }
            }
            return(null);
        }
Example #3
0
        /// <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);
            }
        }
Example #4
0
		/// <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);
		}
Example #5
0
		/// <summary>
		/// Answer true if the box is entirely below 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 exceptionally
		/// high stacked diacritics extend above the top 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.ToPaintY(box.Top) > bottom;
		}
Example #6
0
		/// <summary>
		/// Answer the first box whose bottom comes below the top 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 exceptionally
		/// long descenders or stacked diacritics extend below the bottom 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.ToPaintY(box.Bottom) > top)
					return box;
			return null;
		}