Package org.eclipse.swt.widgets

Examples of org.eclipse.swt.widgets.Caret


    updateCaret();
    reveal();
  }

  private void setCaretVisible(boolean visible) {
    Caret caret = _viewer.getCaret();
    if (caret == null)
      return;
    if (caret.isDisposed()) {
      return;
    }
    caret.setVisible(visible);
  }
View Full Code Here


  public void updateCaret() {
    if (_trackFigure != null) {
      _trackFigure.removeFigureListener(this);
      _trackFigure = null;
    }
    Caret caret = _viewer.getCaret();
    if (caret == null) {
      return;
    }
    if (caret.isDisposed()) {
      return;
    }

    Rectangle rect = null;

    // try get the caret bounds.
    if (_viewer.isInRangeMode()) {
      DesignRange range = _viewer.getRangeSelection();
      if (range != null) {
        DesignPosition endPosition = range.getEndPosition();
        if (endPosition != null && endPosition.isValid()) {
          rect = EditPartPositionHelper
              .convertToAbsoluteCaretRect(endPosition);
          _trackFigure = ((GraphicalEditPart) endPosition
              .getContainerPart()).getFigure();
          _trackFigure.addFigureListener(this);
        }
      }
    }

    // set visible effect
    if (rect == null) {
      caret.setVisible(false);
    } else {
      caret.setVisible(false); // make sure it get removed from the
      // screen.
      // the caret width doesn't need to be calculated, the x pos should
      // be adjusted more acurately.
      caret.setBounds(rect.x, rect.y, CARET_WIDTH, rect.height);
      caret.setVisible(true);
    }
  }
View Full Code Here

  public void figureMoved(IFigure source) {
    updateCaret();
  }

  private void reveal() {
    Caret caret = _viewer.getCaret();
    if (caret != null && !caret.isDisposed() && _viewer.isInRangeMode()) {
      org.eclipse.swt.graphics.Rectangle rect = caret.getBounds();
      ExposeHelper helper = new ExposeHelper(_viewer);
      helper.exposeArea(new Rectangle(rect.x, rect.y, rect.width,
          rect.height));
    }
  }
View Full Code Here

      toggleOverwriteMode();
    fIsOverwriteModeEnabled= enable;
  }

  private Caret createOverwriteCaret(StyledText styledText) {
    Caret caret= new Caret(styledText, SWT.NULL);
    GC gc= new GC(styledText);
    // XXX: this overwrite box is not proportional-font aware
    // take 'a' as a medium sized character
    Point charSize= gc.stringExtent("a"); //$NON-NLS-1$

    // XXX: Filed request to get a caret with auto-height: https://bugs.eclipse.org/bugs/show_bug.cgi?id=118612
    caret.setSize(charSize.x, styledText.getLineHeight());
    caret.setFont(styledText.getFont());

    gc.dispose();

    return caret;
  }
View Full Code Here

    return caret;
  }

  private Caret createInsertCaret(StyledText styledText) {
    Caret caret= new Caret(styledText, SWT.NULL);

    // XXX: Filed request to get a caret with auto-height: https://bugs.eclipse.org/bugs/show_bug.cgi?id=118612
    caret.setSize(getCaretWidthPreference(), styledText.getLineHeight());
    caret.setFont(styledText.getFont());

    return caret;
  }
View Full Code Here

  private Caret createRawInsertModeCaret(StyledText styledText) {
    // don't draw special raw caret if no smart mode is enabled
    if (!getLegalInsertModes().contains(SMART_INSERT))
      return createInsertCaret(styledText);

    Caret caret= new Caret(styledText, SWT.NULL);
    Image image= createRawInsertModeCaretImage(styledText);
    if (image != null)
      caret.setImage(image);
    else {
      // XXX: Filed request to get a caret with auto-height: https://bugs.eclipse.org/bugs/show_bug.cgi?id=118612
      caret.setSize(getCaretWidthPreference(), styledText.getLineHeight());
    }

    caret.setFont(styledText.getFont());

    return caret;
  }
View Full Code Here

      return item.getParent();
    } else if (widget instanceof TreeItem) {
      TreeItem item = (TreeItem) widget;
      return item.getParent();
    } else if (widget instanceof Caret) {
      Caret item = (Caret) widget;
      return item.getParent();
    }
    return null;
  }
View Full Code Here

  /**
   * Sets or clears the caret in the "Example" widget.
   */
  void setCaret() {
    Caret oldCaret = canvas.getCaret();
    if (caretButton.getSelection()) {
      Caret newCaret = new Caret(canvas, SWT.NONE);
      Font font = canvas.getFont();
      newCaret.setFont(font);
      GC gc = new GC(canvas);
      gc.setFont(font);
      newCaret.setBounds(1, 1, 1, gc.getFontMetrics().getHeight());
      gc.dispose();
      canvas.setCaret(newCaret);
      canvas.setFocus();
    } else
      canvas.setCaret(null);
View Full Code Here

TOP

Related Classes of org.eclipse.swt.widgets.Caret

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.