Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.FontMetrics


   * @return the composite in which the controls exist.
   */
  public Control createControl(Composite parent) {
        GC gc = new GC(parent);
        gc.setFont(JFaceResources.getDialogFont());
        FontMetrics fontMetrics = gc.getFontMetrics();
        gc.dispose();
       
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(createGridLayoutWithoutMargins(1, fontMetrics));

View Full Code Here


        label = new CLabel(statusLine, SWT.SHADOW_NONE);

        if (widthHint < 0) {
            GC gc = new GC(statusLine);
            gc.setFont(statusLine.getFont());
            FontMetrics fm = gc.getFontMetrics();
            widthHint = fm.getAverageCharWidth() * charWidth;
            heightHint = fm.getHeight();
            gc.dispose();
        }

        StatusLineLayoutData data = new StatusLineLayoutData();
        data.widthHint = widthHint;
View Full Code Here

    group.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false));
    group.setLayout(new GridLayout());
   
    detailsText = new Text(group, SWT.BORDER | SWT.MULTI | SWT.READ_ONLY | SWT.V_SCROLL | SWT.WRAP);
    GC gc = new GC(detailsText);
    FontMetrics fm = gc.getFontMetrics();
    gc.dispose();
    int cols = 80;
    int rows = 3;
    int width = cols * fm.getAverageCharWidth();
    int height = rows * fm.getHeight();
    GridData gridData = new GridData(SWT.FILL, SWT.NONE, true, false);
    gridData.widthHint = width;
    gridData.heightHint = height;
    detailsText.setLayoutData(gridData);
   
View Full Code Here

    Color black = new Color(gc.getDevice(), 0, 0, 0);
    Color wh = new Color(gc.getDevice(), 0xFF, 0xFF, 0xFF);

    gc.setForeground(gray);

    FontMetrics metrics = gc.getFontMetrics();

    int lineHeight = metrics.getHeight();

    // 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);//SC
    int descent = 1;
    // 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.fillRectangle(pS.x, p.y, width * 100, lineHeight + 1);

    int pos = pS.x;

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 = 1;// Math.min(1, 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() * 2;
    gc.drawRectangle(p.x, p.y + leading, width, height);
    int third = width / 3;
    int dotsVertical = p.y + baseline - 2;
    gc.drawPoint(p.x + third, dotsVertical);
    gc.drawPoint(p.x + width - third, dotsVertical);
View Full Code Here

     * font metrics than the simple font used for the numbers.
     */
    int offset= fCachedTextWidget.getOffsetAtLine(widgetLine);
    int widgetBaseline= fCachedTextWidget.getBaseline(offset);
   
    FontMetrics fm= gc.getFontMetrics();
    int fontBaseline= fm.getAscent() + fm.getLeading();
    int baselineBias= widgetBaseline - fontBaseline;
    return Math.max(0, baselineBias);
  }
View Full Code Here

   * Returns a width hint for a button control.
   */
  private static int getButtonWidthHint(Button button) {
    GC gc = new GC(button);
    gc.setFont(button.getFont());
    FontMetrics fFontMetrics = gc.getFontMetrics();
    gc.dispose();
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fFontMetrics, IDialogConstants.BUTTON_WIDTH);
    return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
  }
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.x = marginWidth;
      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

  private InputData currentInput = null;

  private LiveEditDiffViewer(Composite parent, Configuration configuration) {
    colors = new Colors(parent.getDisplay());

    FontMetrics defaultFontMetrics = PluginUtil.getFontMetrics(parent, null);

    Composite composite = new Composite(parent, SWT.NONE);
    {
      composite.setLayoutData(new GridData(GridData.FILL_BOTH));
      GridLayout topLayout = new GridLayout();
      topLayout.numColumns = 1;
      composite.setLayout(topLayout);
    }

    Composite labelPairComposite = new Composite(composite, SWT.NONE);
    {
      labelPairComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
      FillLayout fillLayout = new FillLayout();
      fillLayout.type = SWT.HORIZONTAL;
      fillLayout.spacing = 5;
      labelPairComposite.setLayout(fillLayout);
    }
    Label labelLeft = new Label(labelPairComposite, SWT.NONE);
    Label labelRight = new Label(labelPairComposite, SWT.NONE);

    Composite fourCells = new Composite(composite, SWT.NONE);
    {
      GridData gd = new GridData(GridData.FILL_BOTH);
      gd.heightHint = defaultFontMetrics.getHeight() * 30;
      gd.widthHint = defaultFontMetrics.getAverageCharWidth() * 85;
      fourCells.setLayoutData(gd);
      FillLayout fillLayout = new FillLayout();
      fillLayout.type = SWT.VERTICAL;
      fillLayout.spacing = 5;
      fourCells.setLayout(fillLayout);
    }

    Composite treePairComposite = new Composite(fourCells, SWT.NONE);
    {
      FillLayout fillLayout = new FillLayout();
      fillLayout.type = SWT.HORIZONTAL;
      fillLayout.spacing = 5;
      treePairComposite.setLayout(fillLayout);
    }

    linkMonitor = new TreeLinkMonitor();

    TreeViewer treeViewerLeft = new TreeViewer(treePairComposite);
    TreeViewer treeViewerRight = new TreeViewer(treePairComposite);

    Composite sourcePairComposite = new Composite(fourCells, SWT.NONE);
    {
      FillLayout fillLayout = new FillLayout();
      fillLayout.type = SWT.HORIZONTAL;
      fillLayout.spacing = 5;
      sourcePairComposite.setLayout(fillLayout);
    }
    SourceViewer sourceViewerLeft =
        new SourceViewer(sourcePairComposite, null, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    sourceViewerLeft.getTextWidget().setEditable(false);
    SourceViewer sourceViewerRight =
        new SourceViewer(sourcePairComposite, null, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    sourceViewerRight.getTextWidget().setEditable(false);

    {
      functionStatusText = new Text(composite, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
      Display display = composite.getDisplay();
      functionStatusText.setBackground(display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));

      GridData gd = new GridData(GridData.FILL_BOTH);
      gd.minimumHeight = defaultFontMetrics.getHeight() * 3;
      gd.heightHint = gd.minimumHeight;
      gd.grabExcessHorizontalSpace = true;
      gd.horizontalAlignment = GridData.FILL;
      functionStatusText.setLayoutData(gd);
    }
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.