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:ar.com.tadp.xml.rinzo.jdt.eclipse.copies.PixelConverter.java

License:Open Source License

public int convertHorizontalDLUsToPixels(int dlus) {
    return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus);
}

From source file:au.com.cybersearch2.controls.DialogPixels.java

License:Open Source License

public DialogPixels(FontMetrics fontMetrics) {
    marginWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN);
    marginHeight = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN);
    horizontalSpacing = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING);
    verticalSpacing = Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING);
    buttonWidth = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
}

From source file:com.aptana.ide.core.ui.PixelConverter.java

License:Open Source License

/**
 * @see DialogPage#convertHorizontalDLUsToPixels
 *///from ww w  .ja  v a 2 s  .co  m
public int convertHorizontalDLUsToPixels(int dlus) {
    return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus);
}

From source file:com.aptana.internal.ui.text.spelling.PixelConverter.java

License:Open Source License

public int convertHorizontalDLUsToPixels(int dlus) {
    return Dialog.convertHorizontalDLUsToPixels(this.fFontMetrics, dlus);
}

From source file:com.foglyn.ui.FoglynFilterQueryPage.java

License:Open Source License

public void createControl(Composite parent) {
    Composite control = new Composite(parent, SWT.NO_SCROLL);

    Label queryNameLabel = new Label(control, SWT.RIGHT);
    queryNameLabel.setText("Query name:");

    queryText = new Text(control, SWT.SINGLE | SWT.BORDER);

    Label filtersLabel = new Label(control, SWT.RIGHT);
    filtersLabel.setText("Choose filter:");

    filtersList = new ListViewer(control, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);

    // set correct margin
    GC gc = new GC(control);
    gc.setFont(control.getFont());//from  w w w  . j a v  a2 s.c  o  m
    FontMetrics fm = gc.getFontMetrics();
    gc.dispose();

    int margin = Dialog.convertHorizontalDLUsToPixels(fm, IDialogConstants.HORIZONTAL_MARGIN);

    // layout
    // parent has 5 pixel margin already :-(
    GridLayoutFactory.fillDefaults().numColumns(2).margins(margin - 5, 0).applyTo(control);

    GridDataFactory.fillDefaults().align(SWT.TRAIL, SWT.CENTER).applyTo(queryNameLabel);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(queryText);
    GridDataFactory.fillDefaults().align(SWT.TRAIL, SWT.BEGINNING).indent(0, 2).applyTo(filtersLabel);
    GridDataFactory.fillDefaults().grab(true, true).applyTo(filtersList.getControl());

    setControl(control);

    queryText.addKeyListener(new KeyListener() {
        public void keyPressed(KeyEvent e) {
            // ignore
        }

        public void keyReleased(KeyEvent e) {
            getContainer().updateButtons();

            automaticFilterNameSet = false;
        }
    });

    filtersList.setContentProvider(new CollectionContentProvider(false));
    filtersList.setLabelProvider(new FilterLabelProvider());

    filtersList.addSelectionChangedListener(new ISelectionChangedListener() {
        public void selectionChanged(SelectionChangedEvent event) {
            FogBugzFilter filter = getSelectedFilter();

            if (filter != null && (automaticFilterNameSet || queryText.getText().trim().length() == 0)) {
                queryText.setText(filter.getDescription());
                automaticFilterNameSet = true;
            }

            getContainer().updateButtons();
        }
    });

    if (queryToEdit != null) {
        queryText.setText(queryToEdit.getQueryTitle());
    }
}

From source file:com.google.dart.tools.ui.omni.OmniBoxPopup.java

License:Open Source License

@Override
protected Point getDefaultSize() {
    GC gc = new GC(table);
    FontMetrics fontMetrics = gc.getFontMetrics();
    gc.dispose();/* ww w. j a  va  2 s.com*/
    int x = Dialog.convertHorizontalDLUsToPixels(fontMetrics, 300);
    x = Math.max(x, 350);
    int y = Dialog.convertVerticalDLUsToPixels(fontMetrics, 270);
    y = Math.max(y, 420);
    return new Point(x, y);
}

From source file:com.iw.plugins.spindle.ui.PixelConverter.java

License:Mozilla Public License

/**
 * @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int)
 *//* w ww. j av a 2s.c  om*/
public int convertHorizontalDLUsToPixels(int dlus) {
    return Dialog.convertHorizontalDLUsToPixels(fontMetrics, dlus);
}

From source file:com.liferay.ide.ui.util.SWTUtil.java

License:Open Source License

/**
 * Returns a width hint for a button control.
 *//*from  ww w.j a v a2s.  co  m*/
protected static int getButtonWidthHint(Button button) {
    int widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH);
    return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
}

From source file:com.maccasoft.composer.InstrumentChart.java

License:Open Source License

void createChart(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));
    composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
    gridData.widthHint = Dialog.convertHorizontalDLUsToPixels(fontMetrics, 300);
    gridData.heightHint = Dialog.convertVerticalDLUsToPixels(fontMetrics, 180);

    chart = new Chart(composite, SWT.NONE);
    chart.setLayoutData(gridData);//ww  w.ja v a  2 s  . c  o  m
    chart.getTitle().setVisible(false);
    chart.getLegend().setPosition(SWT.TOP);

    createBottomControls(composite);

    IAxisSet axisSet = chart.getAxisSet();

    xAxis = axisSet.getXAxis(0);
    xAxis.getTitle().setVisible(false);

    yAxis1 = axisSet.getYAxis(0);
    yAxis1.getTitle().setVisible(false);
    yAxis1.setRange(new Range(0.0, 100.0));

    yAxis2 = axisSet.getYAxis(axisSet.createYAxis());
    yAxis2.getTitle().setVisible(false);
    yAxis2.setPosition(Position.Secondary);
    yAxis2.setRange(new Range(0.0, 5000.0));

    lineSeries1 = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE, "Volume");
    lineSeries1.setAntialias(SWT.ON);
    lineSeries1.setLineWidth(1);
    lineSeries1.setSymbolType(PlotSymbolType.NONE);
    lineSeries1.setLineColor(Display.getDefault().getSystemColor(SWT.COLOR_RED));
    lineSeries1.setYAxisId(0);

    lineSeries2 = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE, "Frequency");
    lineSeries2.setAntialias(SWT.ON);
    lineSeries2.setLineWidth(1);
    lineSeries2.setSymbolType(PlotSymbolType.NONE);
    lineSeries2.setLineColor(Display.getDefault().getSystemColor(SWT.COLOR_GREEN));
    lineSeries2.setYAxisId(1);

    lineSeries3 = (ILineSeries) chart.getSeriesSet().createSeries(SeriesType.LINE, "Duty (%)");
    lineSeries3.setAntialias(SWT.ON);
    lineSeries3.setLineWidth(1);
    lineSeries3.setSymbolType(PlotSymbolType.NONE);
    lineSeries3.setLineColor(Display.getDefault().getSystemColor(SWT.COLOR_DARK_GRAY));
    lineSeries3.setYAxisId(0);
}

From source file:com.maccasoft.composer.InstrumentEditor.java

License:Open Source License

@Override
protected void configureShell(Shell newShell) {
    super.configureShell(newShell);

    GC gc = new GC(newShell);
    fontMetrics = gc.getFontMetrics();//from www  .  j a  v a  2s .  c  o m
    gc.dispose();

    Rectangle screen = newShell.getDisplay().getClientArea();

    Rectangle rect = new Rectangle(0, 0, Dialog.convertHorizontalDLUsToPixels(fontMetrics, 760),
            Dialog.convertVerticalDLUsToPixels(fontMetrics, 320));
    rect.x = (screen.width - rect.width) / 2;
    rect.y = (screen.height - rect.height) / 2;
    if (rect.y < 0) {
        rect.height += rect.y * 2;
        rect.y = 0;
    }

    newShell.setLocation(rect.x, rect.y);
    newShell.setSize(rect.width, rect.height);

    FillLayout layout = new FillLayout();
    layout.marginWidth = layout.marginHeight = 5;
    newShell.setLayout(layout);
    newShell.setText("Instrument Editor");
}