Example #1
0
        public override void GetCaretPosition(IGraphics gr, int x, int y, SelectionPoint sp, ref CaretPositionInfo cpi)
        {
            startTag.GetCaretPosition(gr, x, y, sp, ref cpi);
            if (cpi.IsFinal)
            {
                return;
            }

            int pos = x + startTag.Width;

            foreach (TableCell cell in cells)
            {
                cell.GetCaretPosition(gr, pos, y, sp, ref cpi);
                if (cpi.IsFinal)
                {
                    return;
                }

                int cellWidth = ParentTable[cell.ElementNode].Column.Width;
                pos += cellWidth;
            }

            endTag.GetCaretPosition(gr, pos, y, sp, ref cpi);
            if (cpi.IsFinal)
            {
                return;
            }
        }
Example #2
0
        public override void GetCaretPosition(IGraphics gr, int x, int y, SelectionPoint sp, ref CaretPositionInfo cpi)
        {
            // TODO: M: this is very innefficient since it is called for all text nodes during search
            if ( !ContainsSelectionPoint(sp) )
            {
                cpi.UpdateLocation(x+Width, y, Height, CaretSetting.Fallback);
                return;
            }

            TextSelectionPoint tsp=(TextSelectionPoint) sp;

            CaretSetting mode=CaretSetting.Absolute;

            gr.PushFont(gr.GetFontHandle(style.FontDesc));
            try
            {
                int n=tsp.Index-start;
                if ( n < 0 )
                {
                    // position is not in visible part of the string, it's
                    // in whitespace that has been trimmed.
                    cpi.UseSecondary=true;
                    return;
                } else if ( tsp.Index == 0 )
                {
                    // caret can be put somewhere else if necessary
                    // TODO: L: this is a bit simplistic - will be wrong if text nodes are
                    //			split and first node ends with space and ends a line (!)
                    mode=CaretSetting.Accurate;
                }

                string text=Text;

                if ( n > text.Length )
                    // TODO: L: not sure exactly when this happens
                    n=text.Length;

                text=ProcessText(text.Substring(0, n));

                int w=gr.MeasureText(text).Width;
                cpi.UpdateLocation(x+w, y, Height, mode);
            }
            finally
            {
                gr.PopFont();
            }
        }
Example #3
0
        public Rectangle GetCaretPosition(IGraphics gr, SelectionPoint sp, CaretDirection d)
        {
            if ( rootBlock == null )
                return Rectangle.Empty;

            CaretPositionInfo cpi=new CaretPositionInfo();
            rootBlock.GetCaretPosition(gr, 0, 0, sp, ref cpi);
            if ( d == CaretDirection.LTR )
                cpi.UseSecondary=true;

            return cpi.ToRectangle();
        }
Example #4
0
 public override void GetCaretPosition(IGraphics gr, int x, int y, SelectionPoint sp, ref CaretPositionInfo cpi)
 {
     if ( ContainsSelectionPoint(sp) )
         cpi.UpdateLocation(x, y, Height, CaretSetting.Accurate);
     else
         cpi.UpdateLocation(x+Width, y, Height, CaretSetting.Fallback);
 }