refactory: added UI removed from core plugin.
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpdt / internal / ui / util / PixelConverter.java
diff --git a/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpdt/internal/ui/util/PixelConverter.java b/net.sourceforge.phpeclipse.ui/src/net/sourceforge/phpdt/internal/ui/util/PixelConverter.java
new file mode 100644 (file)
index 0000000..46ace94
--- /dev/null
@@ -0,0 +1,49 @@
+package net.sourceforge.phpdt.internal.ui.util;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.widgets.Control;
+
+public class PixelConverter {
+
+       private FontMetrics fFontMetrics;
+
+       public PixelConverter(Control control) {
+               GC gc = new GC(control);
+               gc.setFont(control.getFont());
+               fFontMetrics = gc.getFontMetrics();
+               gc.dispose();
+       }
+
+       private FontMetrics fgFontMetrics;
+
+       /**
+        * @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int)
+        */
+       public int convertHeightInCharsToPixels(int chars) {
+               return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
+       }
+
+       /**
+        * @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int)
+        */
+       public int convertHorizontalDLUsToPixels(int dlus) {
+               return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus);
+       }
+
+       /**
+        * @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int)
+        */
+       public int convertVerticalDLUsToPixels(int dlus) {
+               return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus);
+       }
+
+       /**
+        * @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int)
+        */
+       public int convertWidthInCharsToPixels(int chars) {
+               return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
+       }
+
+}