Beispiel #1
0
        /// <summary>
        /// Returns a rectangle based on the given IDisplayPointer
        /// </summary>
        /// <param name="element">The element that contains the display pointer</param>
        /// <param name="displayPointer"></param>
        /// <returns></returns>
        protected Rectangle GetLineRect(IHTMLElement element, IDisplayPointerRaw displayPointer)
        {
            ILineInfo lineInfo;

            displayPointer.GetLineInfo(out lineInfo);

            Rectangle elementRect = HTMLElementHelper.GetClientRectangle(element);

            //determine the rectangle based on the baseline and text height.
            //Note: baseline is relative to the parent element, and the text
            //height includes the textDescent, which is below the baseline
            int lineBottom = elementRect.Y + lineInfo.baseLine + lineInfo.textDescent;
            int lineTop    = lineBottom - lineInfo.textHeight;
            int lineLeft   = elementRect.X;
            int lineWidth  = elementRect.Width;

            //Calculate the height of line.  Since the bottom pixel line is shared by the next line,
            //we subtract 1 from the height. This height exactly matches height of the caret.
            //Note: this height adjustment fixes a bug that can occur with some text styles where a
            //caret placed on the next line is detected as being within this rectangle.
            int lineHeight = lineInfo.textHeight - 1;

            //create a rectangle that exactly fits the caret for this line
            //Note: this can be verified by painting a rectangle over the line using this rectangle
            return(new Rectangle(lineLeft, lineTop, lineWidth, lineHeight));
        }
Beispiel #2
0
 /// <summary>
 /// Returns the bounds of the element in client-based coordinatates.
 /// Note: These bounds seem to map to the outer edge of the element's border region.
 /// </summary>
 /// <returns></returns>
 protected Rectangle GetClientRectangle()
 {
     return(HTMLElementHelper.GetClientRectangle(HTMLElement));
 }