Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.FontMetrics


    portControl.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    label = new Label(portControl, SWT.NONE);
    label.setText("Port:");
    label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
    requestPort = new Text(portControl, SWT.BORDER | SWT.SINGLE);
    final FontMetrics requestPortFm = new GC(requestPort).getFontMetrics();
    GridData requestPortGd = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    requestPortGd.widthHint = requestPortFm.getAverageCharWidth() * 7;
    requestPort.setLayoutData(requestPortGd);
    requestPort.addListener(SWT.Verify, new Listener() {
        public void handleEvent(Event e) {
            String string = e.text;
            char[] chars = new char[string.length()];
View Full Code Here


   * @param fg the foreground color
   */
  private void draw(GC gc, int offset, String s, Color fg) {
    // Compute baseline delta (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=165640)
    int baseline= fTextWidget.getBaseline(offset);
    FontMetrics fontMetrics= gc.getFontMetrics();
    int fontBaseline= fontMetrics.getAscent() + fontMetrics.getLeading();
    int baslineDelta= baseline - fontBaseline;

    Point pos= fTextWidget.getLocationAtOffset(offset);
    gc.setForeground(fg);
    gc.drawString(s, pos.x, pos.y + baslineDelta, true);
View Full Code Here

   
    final Label label = new Label(rootControl, SWT.NONE);
    label.setText("Description:");

    tagDescText = new Text(rootControl, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    final FontMetrics tagDescTextFm = new GC(tagDescText).getFontMetrics();
    GridData tagDescTextGd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    tagDescTextGd.heightHint = tagDescTextFm.getHeight() * 5;
    tagDescText.setLayoutData(tagDescTextGd);
    tagDescText.setEditable(false);

    return rootControl;
  }
View Full Code Here

            Point p= textWidget.getLocationAtOffset(lineEnd);

            Color c= gc.getForeground();
            gc.setForeground(color);

            FontMetrics metrics= gc.getFontMetrics();

            // baseline: where the dots are drawn
            int baseline= textWidget.getBaseline(offset);
            // descent: number of pixels that the box extends over baseline
            int descent= Math.min(2, textWidget.getLineHeight(offset) - baseline);
            // ascent: so much does the box stand up from baseline
            int ascent= metrics.getAscent();
            // leading: free space from line top to box upper line
            int leading= baseline - ascent;
            // height: height of the box
            int height= ascent + descent;

            int width= metrics.getAverageCharWidth();
            gc.drawRectangle(p.x, p.y + leading, width, height);
            int third= width/3;
            int dotsVertical= p.y + baseline - 1;
            gc.drawPoint(p.x + third, dotsVertical);
            gc.drawPoint(p.x + width - third, dotsVertical);
View Full Code Here

  }

  public static Point computeWrapSize(GC gc, String text, int wHint) {
    BreakIterator wb = BreakIterator.getWordInstance();
    wb.setText(text);
    FontMetrics fm = gc.getFontMetrics();
    int lineHeight = fm.getHeight();

    int saved = 0;
    int last = 0;
    int height = lineHeight;
    int maxWidth = 0;
View Full Code Here

  public static void paintWrapText(GC gc, String text, Rectangle bounds,
      boolean underline) {
    BreakIterator wb = BreakIterator.getWordInstance();
    wb.setText(text);
    FontMetrics fm = gc.getFontMetrics();
    int lineHeight = fm.getHeight();
    int descent = fm.getDescent();

    int saved = 0;
    int last = 0;
    int y = bounds.y;
    int width = bounds.width;
View Full Code Here

      Paragraph[] paragraphs = model.getParagraphs();
      GC gc = new GC(FormText.this);
      gc.setFont(getFont());
      Locator loc = new Locator();
      int width = wHint != SWT.DEFAULT ? wHint : 0;
      FontMetrics fm = gc.getFontMetrics();
      int lineHeight = fm.getHeight();
      boolean selectableInTheLastRow = false;
      for (int i = 0; i < paragraphs.length; i++) {
        Paragraph p = paragraphs[i];
        if (i > 0 && getParagraphsSeparated()
            && p.getAddVerticalSpace())
View Full Code Here

      Locator loc = new Locator();
      loc.marginWidth = marginWidth;
      loc.marginHeight = marginHeight;
      loc.y = marginHeight;
      FontMetrics fm = gc.getFontMetrics();
      int lineHeight = fm.getHeight();

      Paragraph[] paragraphs = model.getParagraphs();
      IHyperlinkSegment selectedLink = getSelectedLink();
      for (int i = 0; i < paragraphs.length; i++) {
        Paragraph p = paragraphs[i];
View Full Code Here

   
    final Label label = new Label(rootControl, SWT.NONE);
    label.setText("Description:");

    tagDescText = new Text(rootControl, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
    final FontMetrics tagDescTextFm = new GC(tagDescText).getFontMetrics();
    GridData tagDescTextGd = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
    tagDescTextGd.heightHint = tagDescTextFm.getHeight() * 5;
    tagDescText.setLayoutData(tagDescTextGd);
    tagDescText.addModifyListener(new ModifyListener() {
      @Override
      public void modifyText(ModifyEvent e) {
        tagModified = true;
View Full Code Here

        }
      }
      if (toggle != null) {
        GC gc = new GC(ExpandableComposite.this);
        gc.setFont(getFont());
        FontMetrics fm = gc.getFontMetrics();
        int textHeight = fm.getHeight();
        gc.dispose();
        if (textClient != null
            && (expansionStyle & LEFT_TEXT_CLIENT_ALIGNMENT) != 0) {
          textHeight = Math.max(textHeight, tcsize.y);
        }
View Full Code Here

TOP

Related Classes of org.eclipse.swt.graphics.FontMetrics

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.