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.eclipse.cdt.internal.ui.preferences.PathEntryVariablesGroup.java

License:Open Source License

/**
 * Sets the <code>GridData</code> on the specified button to
 * be one that is spaced for the current dialog page units. The
 * method <code>initializeDialogUnits</code> must be called once
 * before calling this method for the first time.
 *
 * @param button the button to set the <code>GridData</code>
 * @return the <code>GridData</code> set on the specified button
 *///from w w w .  jav  a 2s.com
private GridData setButtonLayoutData(Button button) {
    GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
    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 data;
}

From source file:org.eclipse.dltk.mod.ui.wizards.WorkingSetConfigurationBlock.java

License:Open Source License

private static int getButtonWidthHint(Button button) {
    button.setFont(JFaceResources.getDialogFont());

    GC gc = new GC(button);
    gc.setFont(button.getFont());//  w w  w .j  a  va 2  s  .  c om
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();

    int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}

From source file:org.eclipse.emf.texo.eclipse.properties.DialogUnits.java

License:Open Source License

/**
 * Converts horizontal DLUs to pixels.//w w  w. j  a  va  2s . c  om
 */
public int pixelsX(int dlus) {
    return Dialog.convertHorizontalDLUsToPixels(fontMetrics, dlus);
}

From source file:org.eclipse.emf.texo.eclipse.properties.DialogUnits.java

License:Open Source License

/**
 * Converts vertical DLUs to pixels.//from ww w. j  a v  a 2s.  c o  m
 */
public int pixelsY(int dlus) {
    return Dialog.convertHorizontalDLUsToPixels(fontMetrics, dlus);
}

From source file:org.eclipse.equinox.internal.p2.ui.dialogs.IUDetailsGroup.java

License:Open Source License

/**
 * Creates the group composite that holds the details area
 * @param parent The parent composite/*w  w w  . j  a v  a 2s. c o m*/
 */
void createGroupComposite(Composite parent) {
    Group detailsComposite = new Group(parent, SWT.NONE);
    GC gc = new GC(parent);
    gc.setFont(JFaceResources.getDialogFont());
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();

    detailsComposite.setText(ProvUIMessages.ProfileModificationWizardPage_DetailsLabel);
    layout = new GridLayout();
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    detailsComposite.setLayout(layout);
    gd = new GridData(SWT.FILL, SWT.FILL, true, false);
    detailsComposite.setLayoutData(gd);

    gd = new GridData(SWT.FILL, SWT.FILL, true, true);
    gd.verticalIndent = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING);
    gd.heightHint = Dialog.convertHeightInCharsToPixels(fontMetrics,
            ILayoutConstants.DEFAULT_DESCRIPTION_HEIGHT);
    gd.minimumHeight = Dialog.convertHeightInCharsToPixels(fontMetrics,
            ILayoutConstants.MINIMUM_DESCRIPTION_HEIGHT);
    gd.widthHint = widthHint;
    if (scrollable)
        detailsArea = new Text(detailsComposite, SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL);
    else
        detailsArea = new Text(detailsComposite, SWT.WRAP | SWT.READ_ONLY);
    detailsArea.setLayoutData(gd);

    gd = new GridData(SWT.END, SWT.BOTTOM, true, false);
    gd.horizontalIndent = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN);
    propLink = createLink(detailsComposite,
            new PropertyDialogAction(new SameShellProvider(parent.getShell()), selectionProvider),
            ProvUIMessages.AvailableIUsPage_GotoProperties);
    propLink.setLayoutData(gd);

    // set the initial state based on selection
    propLink.setVisible(!selectionProvider.getSelection().isEmpty());

}

From source file:org.eclipse.equinox.internal.p2.ui.dialogs.RepositorySelectionGroup.java

License:Open Source License

private void setButtonLayoutData(Button button) {
    GridData data = new GridData(SWT.FILL, SWT.CENTER, false, false);
    GC gc = new GC(button);
    gc.setFont(JFaceResources.getDialogFont());
    FontMetrics fm = gc.getFontMetrics();
    gc.dispose();//from   w ww . jav a2 s  .  c  o m
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.BUTTON_WIDTH);
    Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
    data.widthHint = Math.max(widthHint, minSize.x);
    button.setLayoutData(data);
}

From source file:org.eclipse.equinox.internal.p2.ui.dialogs.StructuredIUGroup.java

License:Open Source License

protected int convertHorizontalDLUsToPixels(int dlus) {
    return Dialog.convertHorizontalDLUsToPixels(fm, dlus);
}

From source file:org.eclipse.gmf.runtime.common.ui.util.WindowUtil.java

License:Open Source License

/**
 * Returns height and width data in a GridData for the button that was
 * passed in.  You can call button.setLayoutData with the returned
 * data./*w  w w  .  java  2  s .c  o m*/
 * 
 * @param button which has already been made.  We'll be making the
 * GridData for this button, so be sure that the text has already
 * been set.
 * @return GridData for this button with the suggested height and width
 */
public static GridData makeButtonData(Button button) {
    GC gc = new GC(button);
    gc.setFont(button.getFont());

    GridData data = new GridData();
    data.heightHint = Dialog.convertVerticalDLUsToPixels(gc.getFontMetrics(), 14);
    data.widthHint = Math.max(
            Dialog.convertHorizontalDLUsToPixels(gc.getFontMetrics(), IDialogConstants.BUTTON_WIDTH),
            button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);

    gc.dispose();

    return data;
}

From source file:org.eclipse.gmf.runtime.common.ui.util.WindowUtil.java

License:Open Source License

/**
 * Makes the GridData for a button to be a fixed size, regardless of
 * the contents of the button//  w ww .  j  av  a 2 s  . c  om
 * @param button the button control that we'll make the GridData for.
 * @return GridData the new GridData for the button control.
 */
public static GridData makeFixedButtonData(Button button) {
    GC gc = new GC(button);
    gc.setFont(button.getFont());

    GridData gridData = new GridData();

    gridData.widthHint = Dialog.convertHorizontalDLUsToPixels(gc.getFontMetrics(),
            IDialogConstants.BUTTON_WIDTH);

    gridData.heightHint = Dialog.convertVerticalDLUsToPixels(gc.getFontMetrics(), 14);

    gc.dispose();

    return gridData;
}

From source file:org.eclipse.gmt.modisco.jm2t.internal.ui.util.SWTUtil.java

License:Open Source License

/**
 * Returns a width hint for a button control.
 */// w w  w  . j  av a 2  s  . c  om
public static int getButtonWidthHint(Button button) {
    if (fontMetrics == null)
        initializeDialogUnits(button.getParent());
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}