Beispiel #1
0
 /**
  * Sets the contents of the receiver to the given string. If the receiver has style SINGLE and the
  * argument contains multiple lines of text, the result of this operation is undefined and may
  * vary from platform to platform.
  *
  * @param string the new text
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the string is null
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setText(String string) {
   checkWidget();
   TextUtils.setText(variant, topHandle, string, textLimit, this);
   if (isDisposed()) return;
   if (variant == TextUtils.TEXT_EDIT) {
     OS.QScrollBar_setValue(OS.QAbstractScrollArea_verticalScrollBar(scrollAreaHandle), 0);
   }
 }
Beispiel #2
0
 /**
  * Sets the editable state.
  *
  * @param editable the new editable state
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setEditable(boolean editable) {
   checkWidget();
   style &= ~SWT.READ_ONLY;
   if (!editable) {
     style |= SWT.READ_ONLY;
   }
   TextUtils.setReadOnly(variant, topHandle, !editable);
 }
Beispiel #3
0
  boolean qt_event_keypress_pp(
      int widgetHandle, int key, int modifier, int character, int nativeScanCode) {
    // In QTextEdit key events normally come with QTextEdit handle (=scrollAreaHandle).
    // KeyPress events may come with viewport widget handle (=handle) when Display.post()
    // is used to generate the event. In this case just let the event through so that it is
    // passed to QTextEdit in native side.
    if (variant == TextUtils.TEXT_EDIT && widgetHandle != scrollAreaHandle) {
      return false;
    }

    if (super.qt_event_keypress_pp(widgetHandle, key, modifier, character, nativeScanCode)) {
      return true;
    }

    if (!(hooks(SWT.Verify) || filters(SWT.Verify)) && textLimit <= 0) {
      return false;
    }

    Event keyEv = makeKeyEvent(key, modifier, character, nativeScanCode);
    return TextUtils.handle_keypress(
        variant, widgetHandle, key, modifier, character, keyEv, textLimit, this);
  }
Beispiel #4
0
 /**
  * Pastes text from clipboard.
  *
  * <p>The selected text is deleted from the widget and new text inserted from the clipboard.
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void paste() {
   TextUtils.paste(variant, topHandle, textLimit, this);
 }
Beispiel #5
0
 /**
  * Inserts a string.
  *
  * <p>The old selection is replaced with the new text.
  *
  * @param string the string
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the string is <code>null</code>
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void insert(String string) {
   checkWidget();
   TextUtils.insert(variant, topHandle, string, textLimit, this);
 }
Beispiel #6
0
 /**
  * Returns the widget text.
  *
  * <p>The text for a text widget is the characters in the widget, or an empty string if this has
  * never been set.
  *
  * @return the widget text
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public String getText() {
   checkWidget();
   return TextUtils.getText(variant, topHandle);
 }
Beispiel #7
0
 /**
  * Returns a <code>Point</code> whose x coordinate is the character position representing the
  * start of the selected text, and whose y coordinate is the character position representing the
  * end of the selection. An "empty" selection is indicated by the x and y coordinates having the
  * same value.
  *
  * <p>Indexing is zero based. The range of a selection is from 0..N where N is the number of
  * characters in the widget.
  *
  * @return a point representing the selection start and end
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public Point getSelection() {
   checkWidget();
   return TextUtils.getSelection(variant, topHandle);
 }
Beispiel #8
0
 /**
  * Returns the editable state.
  *
  * @return whether or not the receiver is editable
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public boolean getEditable() {
   checkWidget();
   return !TextUtils.getReadOnly(variant, topHandle);
 }
Beispiel #9
0
 /**
  * Returns the number of characters.
  *
  * @return number of characters in the widget
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public int getCharCount() {
   checkWidget();
   return TextUtils.getCharCount(variant, topHandle);
 }
Beispiel #10
0
 /**
  * Returns the character position of the caret.
  *
  * <p>Indexing is zero based.
  *
  * @return the position of the caret
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public int getCaretPosition() {
   checkWidget();
   return TextUtils.getCaretPosition(variant, topHandle);
 }
Beispiel #11
0
 /**
  * Cuts the selected text.
  *
  * <p>The current selection is first copied to the clipboard and then deleted from the widget.
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void cut() {
   checkWidget();
   TextUtils.cut(variant, topHandle, this);
 }
Beispiel #12
0
 /**
  * Copies the selected text.
  *
  * <p>The current selection is copied to the clipboard.
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void copy() {
   checkWidget();
   TextUtils.copy(variant, topHandle);
 }
Beispiel #13
0
 /**
  * Clears the selection.
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void clearSelection() {
   checkWidget();
   TextUtils.clearSelection(variant, topHandle);
 }
Beispiel #14
0
 /**
  * Appends a string.
  *
  * <p>The new text is appended to the text at the end of the widget.
  *
  * @param string the string to be appended
  * @exception IllegalArgumentException
  *     <ul>
  *       <li>ERROR_NULL_ARGUMENT - if the string is null
  *     </ul>
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void append(String string) {
   checkWidget();
   TextUtils.append(variant, topHandle, string, textLimit, this);
 }
Beispiel #15
0
 /**
  * Sets the selection to the range specified by the given start and end indices.
  *
  * <p>Indexing is zero based. The range of a selection is from 0..N where N is the number of
  * characters in the widget.
  *
  * <p>Text selections are specified in terms of caret positions. In a text widget that contains N
  * characters, there are N+1 caret positions, ranging from 0..N. This differs from other functions
  * that address character position such as getText () that use the usual array indexing rules.
  *
  * @param start the start of the range
  * @param end the end of the range
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void setSelection(int start, int end) {
   checkWidget();
   TextUtils.setSelection(variant, topHandle, start, end);
 }
Beispiel #16
0
 /**
  * Selects all the text in the receiver.
  *
  * @exception SWTException
  *     <ul>
  *       <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  *       <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  *     </ul>
  */
 public void selectAll() {
   checkWidget();
   TextUtils.selectAll(variant, topHandle);
 }