Package org.eclipse.swt.graphics

Examples of org.eclipse.swt.graphics.FontMetrics


   * @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= fWidget.getOffsetAtLine(widgetLine);
    int widgetBaseline= fWidget.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

    public Point getSizeHints() {

        Display display = canvas.getDisplay();

        GC gc = new GC(canvas);
        FontMetrics fm = gc.getFontMetrics();
        int charWidth = fm.getAverageCharWidth();
        int charHeight = fm.getHeight();
        int maxWidth = display.getBounds().width / 2;
        int maxHeight = display.getBounds().height / 6;
        int fontWidth = charWidth * maxCharacterWidth;
        int fontHeight = charHeight * numShowItems;
        if (maxWidth < fontWidth) {
View Full Code Here

        fFilterText = new Text(parent, SWT.NONE);

        GridData data = new GridData();
        GC gc = new GC(parent);
        gc.setFont(parent.getFont());
        FontMetrics fontMetrics = gc.getFontMetrics();
        gc.dispose();

        data.heightHint = org.eclipse.jface.dialogs.Dialog
                .convertHeightInCharsToPixels(fontMetrics, 1);
        data.horizontalAlignment = GridData.FILL;
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

     */
    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

     */
    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

        fLabel = new Label(this, SWT.LEFT);
        fLabel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, true, false, numColumns, 1));
   
        if (progressIndicatorHeight == SWT.DEFAULT) {
            GC gc = new GC(fLabel);
            FontMetrics fm = gc.getFontMetrics();
            gc.dispose();
            progressIndicatorHeight = fm.getHeight();
        }

        fProgressIndicator = new ProgressIndicator(this);
        GridData gd = new GridData();
        gd.horizontalAlignment = GridData.FILL;
View Full Code Here

  protected Control createTitleControl(Composite parent) {
    filterText = new Text(parent, SWT.NONE);

    GC gc = new GC(parent);
    gc.setFont(parent.getFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();

    GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true,
        false).hint(SWT.DEFAULT,
        Dialog.convertHeightInCharsToPixels(fontMetrics, 1)).applyTo(
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.