1 package net.sourceforge.phpdt.internal.ui.util;
3 import org.eclipse.jface.dialogs.Dialog;
4 import org.eclipse.swt.graphics.FontMetrics;
5 import org.eclipse.swt.graphics.GC;
6 import org.eclipse.swt.widgets.Control;
8 public class PixelConverter {
10 private FontMetrics fFontMetrics;
12 public PixelConverter(Control control) {
13 GC gc = new GC(control);
14 gc.setFont(control.getFont());
15 fFontMetrics = gc.getFontMetrics();
19 private FontMetrics fgFontMetrics;
22 * @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int)
24 public int convertHeightInCharsToPixels(int chars) {
25 return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
29 * @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int)
31 public int convertHorizontalDLUsToPixels(int dlus) {
32 return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus);
36 * @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int)
38 public int convertVerticalDLUsToPixels(int dlus) {
39 return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus);
43 * @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int)
45 public int convertWidthInCharsToPixels(int chars) {
46 return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);