public override HitTestInfo GetHitTestInfo(IGraphics gr, int x, int y, Point pt) { ElementSelectionPoint esp = new ElementSelectionPoint(Node, TagType.EndTag); Line l = (Line)Parent; Rectangle rcCaret = Rectangle.Empty; LineItemContext ili = new LineItemContext(l.Height, l.Baseline, this, new Point(x, y)); return(new HitTestInfo(esp, ili, false, rcCaret)); }
public override HitTestInfo GetHitTestInfo(IGraphics gr, int x, int y, Point pt) { // caller will have tested if point is within bounding rect // taking into account additional ascent/descent on the line Debug.Assert(style != null, "No class attached to TextFragment!!"); string text = ProcessText(Text); gr.PushFont(gr.GetFontHandle(style.FontDesc)); try { BinaryChopper bc = new BinaryChopper(text); int w = 0; while (bc.CanMove) { // TODO: L: this could be optimised by calculating the shift // left and right in pixels rather than measuring from zero w = gr.MeasureText(bc.Text).Width; if (pt.X < x + w) { bc.TooLong(); } else { bc.TooShort(); } } int cw = gr.MeasureText(text[bc.Position].ToString()).Width; bool after = (float)1.0 * x + w - cw / 2 < pt.X; Debug.Assert(start + bc.Position < Node.Value.Length, "Invalid TextSelectionPoint!"); SelectionPoint sp = new TextSelectionPoint(Node, start + bc.Position); Line l = (Line)Parent; LineItemContext ili = new LineItemContext(l.Height, l.Baseline, this, new Point(x, y)); HitTestInfo ht = new HitTestInfo(sp, ili, after); return(ht); } finally { gr.PopFont(); } }
public override HitTestInfo GetHitTestInfo(IGraphics gr, int x, int y, Point pt) { // caller will have tested if point is within bounding rect // taking into account additional ascent/descent on the line Debug.Assert(style != null, "No class attached to TextFragment!!"); string text=ProcessText(Text); gr.PushFont(gr.GetFontHandle(style.FontDesc)); try { BinaryChopper bc=new BinaryChopper(text); int w=0; while ( bc.CanMove ) { // TODO: L: this could be optimised by calculating the shift // left and right in pixels rather than measuring from zero w=gr.MeasureText(bc.Text).Width; if ( pt.X < x+w ) bc.TooLong(); else bc.TooShort(); } int cw=gr.MeasureText(text[bc.Position].ToString()).Width; bool after=(float) 1.0 * x + w - cw / 2 < pt.X; Debug.Assert(start+bc.Position < Node.Value.Length, "Invalid TextSelectionPoint!"); SelectionPoint sp=new TextSelectionPoint(Node, start+bc.Position); Line l=(Line) Parent; LineItemContext ili=new LineItemContext(l.Height, l.Baseline, this, new Point(x,y)); HitTestInfo ht=new HitTestInfo(sp, ili, after); return ht; } finally { gr.PopFont(); } }
public override HitTestInfo GetHitTestInfo(IGraphics gr, int x, int y, Point pt) { ElementSelectionPoint esp=new ElementSelectionPoint(Node, TagType.EndTag); Line l=(Line) Parent; Rectangle rcCaret=Rectangle.Empty; LineItemContext ili=new LineItemContext(l.Height, l.Baseline, this, new Point(x,y)); return new HitTestInfo(esp, ili, false, rcCaret); }