Example usage for org.eclipse.jface.dialogs Dialog convertHorizontalDLUsToPixels

List of usage examples for org.eclipse.jface.dialogs Dialog convertHorizontalDLUsToPixels

Introduction

In this page you can find the example usage for org.eclipse.jface.dialogs Dialog convertHorizontalDLUsToPixels.

Prototype

public static int convertHorizontalDLUsToPixels(FontMetrics fontMetrics, int dlus) 

Source Link

Document

Returns the number of pixels corresponding to the given number of horizontal dialog units.

Usage

From source file:org.tigris.subversion.subclipse.ui.dialogs.DialogArea.java

License:Open Source License

protected Button createButton(Composite parent, String label, int style) {
    Button button = new Button(parent, SWT.PUSH);
    button.setText(label);//  w w w .  java2s.  co m
    // we need to explicitly set the font to the parent's font for dialogs
    button.setFont(parent.getFont());
    GridData data = new GridData(style);
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
    button.setLayoutData(data);
    return button;
}

From source file:org.whole.lang.ui.util.UIUtils.java

License:Open Source License

public static int getButtonWidthHint(Composite composite) {
    GC gc = new GC(composite);
    gc.setFont(composite.getFont());/*w  w  w. j a va2  s.c  o  m*/
    FontMetrics fFontMetrics = gc.getFontMetrics();
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fFontMetrics, IDialogConstants.BUTTON_WIDTH);
    gc.dispose();
    return widthHint;
}

From source file:phasereditor.canvas.ui.editors.QuickOutlineDialog.java

License:Open Source License

@Override
protected Point getDefaultSize() {
    GC gc = new GC(getContents());
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();/*w w  w . j  ava2  s  . c  o m*/
    int x = Dialog.convertHorizontalDLUsToPixels(fontMetrics, 300);
    if (x < 350) {
        x = 350;
    }
    int y = Dialog.convertVerticalDLUsToPixels(fontMetrics, 270);
    if (y < 420) {
        y = 420;
    }
    return new Point(x, y);
}