Exemplo n.º 1
0
        /// <summary>
        /// Move the selection end to the buffer offset physically below
        /// the current selection end.
        /// </summary>
        /// <remarks>
        /// Move the selection end to the buffer offset physically below
        /// the current selection end.
        /// </remarks>
        public static bool extendDown(android.text.Spannable text, android.text.Layout layout
                                      )
        {
            int end  = getSelectionEnd(text);
            int line = layout.getLineForOffset(end);

            if (line < layout.getLineCount() - 1)
            {
                int move;
                if (layout.getParagraphDirection(line) == layout.getParagraphDirection(line + 1))
                {
                    float h = layout.getPrimaryHorizontal(end);
                    move = layout.getOffsetForHorizontal(line + 1, h);
                }
                else
                {
                    move = layout.getLineStart(line + 1);
                }
                extendSelection(text, move);
                return(true);
            }
            else
            {
                if (end != text.Length)
                {
                    extendSelection(text, text.Length);
                    return(true);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
 protected internal override void onMeasure(int widthMeasureSpec, int heightMeasureSpec
                                            )
 {
     base.onMeasure(widthMeasureSpec, heightMeasureSpec);
     android.text.Layout layout_1 = getLayout();
     if (layout_1 != null)
     {
         int lineCount = layout_1.getLineCount();
         if (lineCount > 0)
         {
             int ellipsisCount = layout_1.getEllipsisCount(lineCount - 1);
             if (ellipsisCount > 0)
             {
                 setSingleLine(false);
                 setMaxLines(2);
                 android.content.res.TypedArray a = mContext.obtainStyledAttributes(null, android.R
                                                                                    .styleable.TextAppearance, android.R.attr.textAppearanceMedium, android.R.style.
                                                                                    TextAppearance_Medium);
                 int textSize = a.getDimensionPixelSize(android.R.styleable.TextAppearance_textSize
                                                        , 0);
                 if (textSize != 0)
                 {
                     // textSize is already expressed in pixels
                     setTextSize(android.util.TypedValue.COMPLEX_UNIT_PX, textSize);
                 }
                 a.recycle();
                 base.onMeasure(widthMeasureSpec, heightMeasureSpec);
             }
         }
     }
 }
Exemplo n.º 3
0
		/// <summary>Performs a scroll to bottom action.</summary>
		/// <remarks>
		/// Performs a scroll to bottom action.
		/// Scrolls to the bottom of the document.
		/// </remarks>
		/// <param name="widget">The text view.</param>
		/// <param name="buffer">The text buffer.</param>
		/// <returns>True if the event was handled.</returns>
		/// <hide></hide>
		protected internal virtual bool scrollBottom(android.widget.TextView widget, android.text.Spannable
			 buffer)
		{
			android.text.Layout layout = widget.getLayout();
			int lineCount = layout.getLineCount();
			if (getBottomLine(widget) <= lineCount - 1)
			{
				android.text.method.Touch.scrollTo(widget, layout, widget.getScrollX(), layout.getLineTop
					(lineCount) - getInnerHeight(widget));
				return true;
			}
			return false;
		}
Exemplo n.º 4
0
		/// <summary>Performs a scroll page up action.</summary>
		/// <remarks>
		/// Performs a scroll page up action.
		/// Scrolls down by one page.
		/// </remarks>
		/// <param name="widget">The text view.</param>
		/// <param name="buffer">The text buffer.</param>
		/// <returns>True if the event was handled.</returns>
		/// <hide></hide>
		protected internal virtual bool scrollPageDown(android.widget.TextView widget, android.text.Spannable
			 buffer)
		{
			android.text.Layout layout = widget.getLayout();
			int innerHeight = getInnerHeight(widget);
			int bottom_1 = widget.getScrollY() + innerHeight + innerHeight;
			int bottomLine = layout.getLineForVertical(bottom_1);
			if (bottomLine <= layout.getLineCount() - 1)
			{
				android.text.method.Touch.scrollTo(widget, layout, widget.getScrollX(), layout.getLineTop
					(bottomLine + 1) - innerHeight);
				return true;
			}
			return false;
		}
Exemplo n.º 5
0
        /// <summary>
        /// Move the cursor to the buffer offset physically below the current
        /// offset, or return false if the cursor is already on the bottom line.
        /// </summary>
        /// <remarks>
        /// Move the cursor to the buffer offset physically below the current
        /// offset, or return false if the cursor is already on the bottom line.
        /// </remarks>
        public static bool moveDown(android.text.Spannable text, android.text.Layout layout
                                    )
        {
            int start = getSelectionStart(text);
            int end   = getSelectionEnd(text);

            if (start != end)
            {
                int min = System.Math.Min(start, end);
                int max = System.Math.Max(start, end);
                setSelection(text, max);
                if (min == 0 && max == text.Length)
                {
                    return(false);
                }
                return(true);
            }
            else
            {
                int line = layout.getLineForOffset(end);
                if (line < layout.getLineCount() - 1)
                {
                    int move;
                    if (layout.getParagraphDirection(line) == layout.getParagraphDirection(line + 1))
                    {
                        float h = layout.getPrimaryHorizontal(end);
                        move = layout.getOffsetForHorizontal(line + 1, h);
                    }
                    else
                    {
                        move = layout.getLineStart(line + 1);
                    }
                    setSelection(text, move);
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 6
0
		/// <summary>Performs a scroll down action.</summary>
		/// <remarks>
		/// Performs a scroll down action.
		/// Scrolls down by the specified number of lines.
		/// </remarks>
		/// <param name="widget">The text view.</param>
		/// <param name="buffer">The text buffer.</param>
		/// <param name="amount">The number of lines to scroll by.  Must be at least 1.</param>
		/// <returns>True if the event was handled.</returns>
		/// <hide></hide>
		protected internal virtual bool scrollDown(android.widget.TextView widget, android.text.Spannable
			 buffer, int amount)
		{
			android.text.Layout layout = widget.getLayout();
			int innerHeight = getInnerHeight(widget);
			int bottom_1 = widget.getScrollY() + innerHeight;
			int bottomLine = layout.getLineForVertical(bottom_1);
			if (layout.getLineTop(bottomLine + 1) < bottom_1 + 1)
			{
				// Less than a pixel of this line is out of view,
				// so we must have tried to make it entirely in view
				// and now want the next line to be in view instead.
				bottomLine += 1;
			}
			int limit = layout.getLineCount() - 1;
			if (bottomLine <= limit)
			{
				bottomLine = System.Math.Min(bottomLine + amount - 1, limit);
				android.text.method.Touch.scrollTo(widget, layout, widget.getScrollX(), layout.getLineTop
					(bottomLine + 1) - innerHeight);
				return true;
			}
			return false;
		}
Exemplo n.º 7
0
        private static int findEdge(android.text.Spannable text, android.text.Layout layout
                                    , int dir)
        {
            int pt   = getSelectionEnd(text);
            int line = layout.getLineForOffset(pt);
            int pdir = layout.getParagraphDirection(line);

            if (dir * pdir < 0)
            {
                return(layout.getLineStart(line));
            }
            else
            {
                int end = layout.getLineEnd(line);
                if (line == layout.getLineCount() - 1)
                {
                    return(end);
                }
                else
                {
                    return(end - 1);
                }
            }
        }