PaintTransformOffsetBy() public method

Answer a layout transform (actually a PaintTransform) suitable for a child box whose left and top are dx and dy.
public PaintTransformOffsetBy ( int dx, int dy ) : PaintTransform
dx int
dy int
return PaintTransform
Example #1
0
        public override void PaintBackground(IVwGraphics vg, PaintTransform ptrans)
        {
            base.PaintBackground(vg, ptrans);
            PaintTransform childTrans = ptrans.PaintTransformOffsetBy(Left, Top);

            for (Box box = FirstVisibleBox(vg, ptrans); box != null && !IsAfterVisibleBoxes(box, vg, ptrans); box = box.Next)
            {
                box.PaintBackground(vg, childTrans);
            }
        }
Example #2
0
        public override void PaintForeground(IVwGraphics vg, PaintTransform ptrans)
        {
            base.PaintForeground(vg, ptrans);
            PaintTransform childTrans = ptrans.PaintTransformOffsetBy(Left, Top);

            for (Box box = FirstVisibleBox(vg, ptrans); box != null && !IsAfterVisibleBoxes(box, vg, ptrans); box = box.Next)
            {
                //vg.PushClipRect(new Rect(box.Left, box.Top, box.Right, box.Bottom));
                box.PaintForeground(vg, childTrans);
            }
        }
Example #3
0
        /// <summary>
        /// If there is a leaf box at the specified position, return it. Also return the paint transform that should be
        /// passed to operations on that box.
        /// Enhance JohnT: should probably always return something, if box contains any leaf?
        /// Where is in drawing coords.
        /// </summary>
        public override LeafBox FindBoxAt(Point where, PaintTransform ptrans, out PaintTransform leafBoxTransform)
        {
            var childTransform = ptrans.PaintTransformOffsetBy(Left, Top);
            var hit            = childTransform.ToLayout(where);
            Box best           = null;   // if we don't find a box containing the point, this is the closest on the same line.
            int bestDistance   = int.MaxValue;

            for (Box current = FirstBox; current != null; current = current.Next)
            {
                // If we're not even on the current line, keep trying.
                if (hit.Y > current.Bottom)
                {
                    continue;
                }
                if (hit.Y < current.Top)
                {
                    continue;
                }
                // If it's within the borders of this box, return it unconditionally.
                if (hit.X <= current.Right && hit.X >= current.Left)
                {
                    return(current.FindBoxAt(where, childTransform, out leafBoxTransform));
                }
                // If we're on the right line, we'll return this if we don't find a better.
                int distance = hit.X - current.Right;
                if (hit.X < current.Left)
                {
                    distance = current.Left - hit.X;
                }
                if (distance < bestDistance)
                {
                    bestDistance = distance;
                    best         = current;
                }
            }
            if (best != null)
            {
                return(best.FindBoxAt(where, childTransform, out leafBoxTransform));
            }
            leafBoxTransform = ptrans;             // arbitrary.
            return(null);
        }
Example #4
0
		public override void PaintBackground(IVwGraphics vg, PaintTransform ptrans)
		{
			base.PaintBackground(vg, ptrans);
			PaintTransform childTrans = ptrans.PaintTransformOffsetBy(Left, Top);
			for (Box box = FirstVisibleBox(vg, ptrans); box != null && !IsAfterVisibleBoxes(box, vg, ptrans); box = box.Next)
				box.PaintBackground(vg, childTrans);
		}
Example #5
0
		public override void PaintForeground(IVwGraphics vg, PaintTransform ptrans)
		{
			base.PaintForeground(vg, ptrans);
			PaintTransform childTrans = ptrans.PaintTransformOffsetBy(Left, Top);
			for (Box box = FirstVisibleBox(vg, ptrans); box != null && !IsAfterVisibleBoxes(box, vg, ptrans); box = box.Next)
			{
				//vg.PushClipRect(new Rect(box.Left, box.Top, box.Right, box.Bottom));
				box.PaintForeground(vg, childTrans);
			}
		}
Example #6
0
		/// <summary>
		/// If there is a leaf box at the specified position, return it. Also return the paint transform that should be
		/// passed to operations on that box.
		/// Enhance JohnT: should probably always return something, if box contains any leaf?
		/// Where is in drawing coords.
		/// </summary>
		public override LeafBox FindBoxAt(Point where, PaintTransform ptrans, out PaintTransform leafBoxTransform)
		{
			var childTransform = ptrans.PaintTransformOffsetBy(Left, Top);
			var hit = childTransform.ToLayout(where);
			Box best = null; // if we don't find a box containing the point, this is the closest on the same line.
			int bestDistance = int.MaxValue;
			for (Box current = FirstBox; current != null; current = current.Next)
			{
				// If we're not even on the current line, keep trying.
				if (hit.Y > current.Bottom)
					continue;
				if (hit.Y < current.Top)
					continue;
				// If it's within the borders of this box, return it unconditionally.
				if (hit.X <= current.Right && hit.X >= current.Left)
					return current.FindBoxAt(where, childTransform, out leafBoxTransform);
				// If we're on the right line, we'll return this if we don't find a better.
				int distance = hit.X - current.Right;
				if (hit.X < current.Left)
					distance = current.Left - hit.X;
				if (distance < bestDistance)
				{
					bestDistance = distance;
					best = current;
				}
			}
			if (best != null)
				return best.FindBoxAt(where, childTransform, out leafBoxTransform);
			leafBoxTransform = ptrans; // arbitrary.
			return null;
		}