Ejemplo n.º 1
0
        /// <summary>
        /// Constructs an <code>InputMethodEvent</code> with the specified
        /// source component, type, time, text, caret, and visiblePosition.
        /// <para>
        /// The offsets of caret and visiblePosition are relative to the current
        /// composed text; that is, the composed text within <code>text</code>
        /// if this is an <code>INPUT_METHOD_TEXT_CHANGED</code> event,
        /// the composed text within the <code>text</code> of the
        /// preceding <code>INPUT_METHOD_TEXT_CHANGED</code> event otherwise.
        /// </para>
        /// <para>Note that passing in an invalid <code>id</code> results in
        /// unspecified behavior. This method throws an
        /// <code>IllegalArgumentException</code> if <code>source</code>
        /// is <code>null</code>.
        ///
        /// </para>
        /// </summary>
        /// <param name="source"> the object where the event originated </param>
        /// <param name="id"> the event type </param>
        /// <param name="when"> a long integer that specifies the time the event occurred </param>
        /// <param name="text"> the combined committed and composed text,
        ///      committed text first; must be <code>null</code>
        ///      when the event type is <code>CARET_POSITION_CHANGED</code>;
        ///      may be <code>null</code> for
        ///      <code>INPUT_METHOD_TEXT_CHANGED</code> if there's no
        ///      committed or composed text </param>
        /// <param name="committedCharacterCount"> the number of committed
        ///      characters in the text </param>
        /// <param name="caret"> the caret (a.k.a. insertion point);
        ///      <code>null</code> if there's no caret within current
        ///      composed text </param>
        /// <param name="visiblePosition"> the position that's most important
        ///      to be visible; <code>null</code> if there's no
        ///      recommendation for a visible position within current
        ///      composed text </param>
        /// <exception cref="IllegalArgumentException"> if <code>id</code> is not
        ///      in the range
        ///      <code>INPUT_METHOD_FIRST</code>..<code>INPUT_METHOD_LAST</code>;
        ///      or if id is <code>CARET_POSITION_CHANGED</code> and
        ///      <code>text</code> is not <code>null</code>;
        ///      or if <code>committedCharacterCount</code> is not in the range
        ///      <code>0</code>..<code>(text.getEndIndex() - text.getBeginIndex())</code> </exception>
        /// <exception cref="IllegalArgumentException"> if <code>source</code> is null
        ///
        /// @since 1.4 </exception>
        public InputMethodEvent(Component source, int id, long when, AttributedCharacterIterator text, int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition) : base(source, id)
        {
            if (id < INPUT_METHOD_FIRST || id > INPUT_METHOD_LAST)
            {
                throw new IllegalArgumentException("id outside of valid range");
            }

            if (id == CARET_POSITION_CHANGED && text != null)
            {
                throw new IllegalArgumentException("text must be null for CARET_POSITION_CHANGED");
            }

            this.When_Renamed = when;
            this.Text_Renamed = text;
            int textLength = 0;

            if (text != null)
            {
                textLength = text.EndIndex - text.BeginIndex;
            }

            if (committedCharacterCount < 0 || committedCharacterCount > textLength)
            {
                throw new IllegalArgumentException("committedCharacterCount outside of valid range");
            }
            this.CommittedCharacterCount_Renamed = committedCharacterCount;

            this.Caret_Renamed           = caret;
            this.VisiblePosition_Renamed = visiblePosition;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructs an <code>InputMethodEvent</code> with the
 /// specified source component, type, caret, and visiblePosition.
 /// The text is set to <code>null</code>,
 /// <code>committedCharacterCount</code> to 0.
 /// <para>
 /// The offsets of <code>caret</code> and <code>visiblePosition</code>
 /// are relative to the current composed text; that is,
 /// the composed text within the <code>text</code> of the
 /// preceding <code>INPUT_METHOD_TEXT_CHANGED</code> event if the
 /// event being constructed as a <code>CARET_POSITION_CHANGED</code> event.
 /// For an <code>INPUT_METHOD_TEXT_CHANGED</code> event without text,
 /// <code>caret</code> and <code>visiblePosition</code> must be
 /// <code>null</code>.
 /// The time stamp for this event is initialized by invoking
 /// <seealso cref="java.awt.EventQueue#getMostRecentEventTime()"/>.
 /// </para>
 /// <para>Note that passing in an invalid <code>id</code> results in
 /// unspecified behavior. This method throws an
 /// <code>IllegalArgumentException</code> if <code>source</code>
 /// is <code>null</code>.
 ///
 /// </para>
 /// </summary>
 /// <param name="source"> the object where the event originated </param>
 /// <param name="id"> the event type </param>
 /// <param name="caret"> the caret (a.k.a. insertion point);
 ///      <code>null</code> if there's no caret within current
 ///      composed text </param>
 /// <param name="visiblePosition"> the position that's most important
 ///      to be visible; <code>null</code> if there's no
 ///      recommendation for a visible position within current
 ///      composed text </param>
 /// <exception cref="IllegalArgumentException"> if <code>id</code> is not
 ///      in the range
 ///      <code>INPUT_METHOD_FIRST</code>..<code>INPUT_METHOD_LAST</code> </exception>
 /// <exception cref="IllegalArgumentException"> if <code>source</code> is null </exception>
 public InputMethodEvent(Component source, int id, TextHitInfo caret, TextHitInfo visiblePosition) : this(source, id, GetMostRecentEventTimeForSource(source), null, 0, caret, visiblePosition)
 {
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructs an <code>InputMethodEvent</code> with the specified
 /// source component, type, text, caret, and visiblePosition.
 /// <para>
 /// The offsets of caret and visiblePosition are relative to the current
 /// composed text; that is, the composed text within <code>text</code>
 /// if this is an <code>INPUT_METHOD_TEXT_CHANGED</code> event,
 /// the composed text within the <code>text</code> of the
 /// preceding <code>INPUT_METHOD_TEXT_CHANGED</code> event otherwise.
 /// The time stamp for this event is initialized by invoking
 /// <seealso cref="java.awt.EventQueue#getMostRecentEventTime()"/>.
 /// </para>
 /// <para>Note that passing in an invalid <code>id</code> results in
 /// unspecified behavior. This method throws an
 /// <code>IllegalArgumentException</code> if <code>source</code>
 /// is <code>null</code>.
 ///
 /// </para>
 /// </summary>
 /// <param name="source"> the object where the event originated </param>
 /// <param name="id"> the event type </param>
 /// <param name="text"> the combined committed and composed text,
 ///      committed text first; must be <code>null</code>
 ///      when the event type is <code>CARET_POSITION_CHANGED</code>;
 ///      may be <code>null</code> for
 ///      <code>INPUT_METHOD_TEXT_CHANGED</code> if there's no
 ///      committed or composed text </param>
 /// <param name="committedCharacterCount"> the number of committed
 ///      characters in the text </param>
 /// <param name="caret"> the caret (a.k.a. insertion point);
 ///      <code>null</code> if there's no caret within current
 ///      composed text </param>
 /// <param name="visiblePosition"> the position that's most important
 ///      to be visible; <code>null</code> if there's no
 ///      recommendation for a visible position within current
 ///      composed text </param>
 /// <exception cref="IllegalArgumentException"> if <code>id</code> is not
 ///      in the range
 ///      <code>INPUT_METHOD_FIRST</code>..<code>INPUT_METHOD_LAST</code>;
 ///      or if id is <code>CARET_POSITION_CHANGED</code> and
 ///      <code>text</code> is not <code>null</code>;
 ///      or if <code>committedCharacterCount</code> is not in the range
 ///      <code>0</code>..<code>(text.getEndIndex() - text.getBeginIndex())</code> </exception>
 /// <exception cref="IllegalArgumentException"> if <code>source</code> is null </exception>
 public InputMethodEvent(Component source, int id, AttributedCharacterIterator text, int committedCharacterCount, TextHitInfo caret, TextHitInfo visiblePosition) : this(source, id, GetMostRecentEventTimeForSource(source), text, committedCharacterCount, caret, visiblePosition)
 {
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Returns <code>true</code> if the specified <code>TextHitInfo</code>
 /// has the same <code>charIndex</code> and <code>isLeadingEdge</code>
 /// as this <code>TextHitInfo</code>.  This is not the same as having
 /// the same insertion offset. </summary>
 /// <param name="hitInfo"> a specified <code>TextHitInfo</code> </param>
 /// <returns> <code>true</code> if the specified <code>TextHitInfo</code>
 /// has the same <code>charIndex</code> and <code>isLeadingEdge</code>
 /// as this <code>TextHitInfo</code>. </returns>
 public bool Equals(TextHitInfo hitInfo)
 {
     return(hitInfo != null && CharIndex_Renamed == hitInfo.CharIndex_Renamed && IsLeadingEdge == hitInfo.IsLeadingEdge);
 }
 /// <summary>
 /// Constructs an <code>InputMethodEvent</code> with the
 /// specified source component, type, caret, and visiblePosition.
 /// </summary>
 public InputMethodEvent(Component @source, int @id, TextHitInfo @caret, TextHitInfo @visiblePosition)
 {
 }
 /// <summary>
 /// Constructs an <code>InputMethodEvent</code> with the specified
 /// source component, type, time, text, caret, and visiblePosition.
 /// </summary>
 public InputMethodEvent(Component @source, int @id, long @when, AttributedCharacterIterator @text, int @committedCharacterCount, TextHitInfo @caret, TextHitInfo @visiblePosition)
 {
 }