Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.FontMetrics


     */
    public static int getButtonWidth( Control control )
    {
        GC gc = new GC( control );
        gc.setFont( JFaceResources.getDialogFont() );
        FontMetrics fontMetrics = gc.getFontMetrics();
        gc.dispose();

        int width = Dialog.convertHorizontalDLUsToPixels( fontMetrics, IDialogConstants.BUTTON_WIDTH );
        return width;
    }
View Full Code Here


     */
    public static Button createButton( Composite parent, String text, int span )
    {
        GC gc = new GC( parent );
        gc.setFont( JFaceResources.getDialogFont() );
        FontMetrics fontMetrics = gc.getFontMetrics();
        gc.dispose();

        Button button = new Button( parent, SWT.PUSH );
        GridData gd = new GridData();
        gd.widthHint = Dialog.convertHorizontalDLUsToPixels( fontMetrics, IDialogConstants.BUTTON_WIDTH );
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

     * 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

        RowData data = new RowData();
        data.width = 40;
        //check to see if width is not enough space
        GC gc = new GC(parent.getParent());
        gc.setFont(parent.getParent().getFont());
        FontMetrics fontMetrics = gc.getFontMetrics();
        gc.dispose();
        int labelWidth = Dialog.convertWidthInCharsToPixels(fontMetrics, labell.getText().length()+1);
        if (labelWidth > data.width) {
          data.width = labelWidth;
        }
View Full Code Here

     * @param numberOfColumns
     * @param numberOfRows
     */
    protected void setPreferredTextSize( int numberOfColumns, int numberOfRows ){
        GC gc = new GC (text);
        FontMetrics fm = gc.getFontMetrics ();
        int width = 30 * fm.getAverageCharWidth ();
        int height = fm.getHeight ();
        gc.dispose();
        text.setSize (text.computeSize (width, height));
    }
View Full Code Here

        e.gc.drawLine(bounds.width - 1, 1, bounds.width - 1,
            bounds.height + 1);
      }

      int textIndent = INDENT;
      FontMetrics fm = e.gc.getFontMetrics();
      int height = fm.getHeight();
      int textMiddle = (bounds.height - height) / 2;

      if (selected && tab.getImage() != null
        && !tab.getImage().isDisposed()) {
        /* draw the icon for the selected tab */
 
View Full Code Here

          bounds.height - 1);
      } else {
        e.gc.setBackground(listBackground);
        e.gc.fillRectangle(0, 0, bounds.width, bounds.height);
        int textIndent = INDENT;
        FontMetrics fm = e.gc.getFontMetrics();
        int height = fm.getHeight();
        int textMiddle = (bounds.height - height) / 2;
        e.gc.setForeground(widgetForeground);
        String properties_not_available = "Attributes are not available";
        e.gc.drawText(properties_not_available, textIndent, textMiddle);
      }
View Full Code Here

      heightHint = preferredSize.y;
    } else if (widthHint < 0) {
      // Compute the size base on 'charWidth' average char widths
      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

        int widthHint = 0;
        int heightHint = 0;
        {
            GC gc = new GC(parent);
            gc.setFont(parent.getFont());
            FontMetrics fm = gc.getFontMetrics();
            Point extent = gc.textExtent("1");
            if(widthHint > 0)
                widthHint = fm.getAverageCharWidth() * widthHint;
            else
                widthHint = extent.x;
            heightHint = fm.getHeight();
            gc.dispose();
        }

        Label sep = new Label(parent, SWT.SEPARATOR);
        // {
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.