コード例 #1
0
		protected internal override bool right(android.widget.TextView widget, android.text.Spannable
			 buffer)
		{
			android.text.Layout layout = widget.getLayout();
			if (isSelecting(buffer))
			{
				return android.text.Selection.extendRight(buffer, layout);
			}
			else
			{
				return android.text.Selection.moveRight(buffer, layout);
			}
		}
コード例 #2
0
		public override void onTakeFocus(android.widget.TextView view, android.text.Spannable
			 text, int dir)
		{
			if ((dir & (android.view.View.FOCUS_FORWARD | android.view.View.FOCUS_DOWN)) != 0)
			{
				if (view.getLayout() == null)
				{
					// This shouldn't be null, but do something sensible if it is.
					android.text.Selection.setSelection(text, text.Length);
				}
			}
			else
			{
				android.text.Selection.setSelection(text, text.Length);
			}
		}
コード例 #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;
		}
コード例 #4
0
		protected internal override bool pageDown(android.widget.TextView widget, android.text.Spannable
			 buffer)
		{
			android.text.Layout layout = widget.getLayout();
			bool selecting = isSelecting(buffer);
			int targetY = getCurrentLineTop(buffer, layout) + getPageHeight(widget);
			bool handled = false;
			for (; ; )
			{
				int previousSelectionEnd = android.text.Selection.getSelectionEnd(buffer);
				if (selecting)
				{
					android.text.Selection.extendDown(buffer, layout);
				}
				else
				{
					android.text.Selection.moveDown(buffer, layout);
				}
				if (android.text.Selection.getSelectionEnd(buffer) == previousSelectionEnd)
				{
					break;
				}
				handled = true;
				if (getCurrentLineTop(buffer, layout) >= targetY)
				{
					break;
				}
			}
			return handled;
		}
コード例 #5
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;
		}
コード例 #6
0
		/// <summary>Performs a scroll to top action.</summary>
		/// <remarks>
		/// Performs a scroll to top action.
		/// Scrolls to the top 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 scrollTop(android.widget.TextView widget, android.text.Spannable
			 buffer)
		{
			android.text.Layout layout = widget.getLayout();
			if (getTopLine(widget) >= 0)
			{
				android.text.method.Touch.scrollTo(widget, layout, widget.getScrollX(), layout.getLineTop
					(0));
				return true;
			}
			return false;
		}
コード例 #7
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;
		}
コード例 #8
0
		/// <summary>Performs a scroll page up action.</summary>
		/// <remarks>
		/// Performs a scroll page up action.
		/// Scrolls up 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 scrollPageUp(android.widget.TextView widget, android.text.Spannable
			 buffer)
		{
			android.text.Layout layout = widget.getLayout();
			int top_1 = widget.getScrollY() - getInnerHeight(widget);
			int topLine = layout.getLineForVertical(top_1);
			if (topLine >= 0)
			{
				android.text.method.Touch.scrollTo(widget, layout, widget.getScrollX(), layout.getLineTop
					(topLine));
				return true;
			}
			return false;
		}
コード例 #9
0
		/// <summary>Performs a scroll up action.</summary>
		/// <remarks>
		/// Performs a scroll up action.
		/// Scrolls up 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 scrollUp(android.widget.TextView widget, android.text.Spannable
			 buffer, int amount)
		{
			android.text.Layout layout = widget.getLayout();
			int top_1 = widget.getScrollY();
			int topLine = layout.getLineForVertical(top_1);
			if (layout.getLineTop(topLine) == top_1)
			{
				// If the top line is partially visible, bring it all the way
				// into view; otherwise, bring the previous line into view.
				topLine -= 1;
			}
			if (topLine >= 0)
			{
				topLine = System.Math.Max(topLine - amount + 1, 0);
				android.text.method.Touch.scrollTo(widget, layout, widget.getScrollX(), layout.getLineTop
					(topLine));
				return true;
			}
			return false;
		}
コード例 #10
0
		private int getScrollBoundsRight(android.widget.TextView widget)
		{
			android.text.Layout layout = widget.getLayout();
			int topLine = getTopLine(widget);
			int bottomLine = getBottomLine(widget);
			if (topLine > bottomLine)
			{
				return 0;
			}
			int right_1 = int.MinValue;
			{
				for (int line = topLine; line <= bottomLine; line++)
				{
					int lineRight = (int)System.Math.Ceiling(layout.getLineRight(line));
					if (lineRight > right_1)
					{
						right_1 = lineRight;
					}
				}
			}
			return right_1;
		}
コード例 #11
0
		private int getScrollBoundsLeft(android.widget.TextView widget)
		{
			android.text.Layout layout = widget.getLayout();
			int topLine = getTopLine(widget);
			int bottomLine = getBottomLine(widget);
			if (topLine > bottomLine)
			{
				return 0;
			}
			int left_1 = int.MaxValue;
			{
				for (int line = topLine; line <= bottomLine; line++)
				{
					int lineLeft = (int)Sharpen.Util.Floor(layout.getLineLeft(line));
					if (lineLeft < left_1)
					{
						left_1 = lineLeft;
					}
				}
			}
			return left_1;
		}
コード例 #12
0
		private int getBottomLine(android.widget.TextView widget)
		{
			return widget.getLayout().getLineForVertical(widget.getScrollY() + getInnerHeight
				(widget));
		}
コード例 #13
0
		private int getTopLine(android.widget.TextView widget)
		{
			return widget.getLayout().getLineForVertical(widget.getScrollY());
		}