first scanner /parser copied from the jdt java version
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / util / PixelConverter.java
1 package net.sourceforge.phpdt.internal.ui.util;
2
3 import org.eclipse.swt.graphics.FontMetrics;
4 import org.eclipse.swt.graphics.GC;
5 import org.eclipse.swt.widgets.Control;
6
7 import org.eclipse.jface.dialogs.Dialog;
8
9 public class PixelConverter {
10         
11         private FontMetrics fFontMetrics;
12         
13         public PixelConverter(Control control) {
14                 GC gc = new GC(control);
15                 gc.setFont(control.getFont());
16                 fFontMetrics= gc.getFontMetrics();
17                 gc.dispose();
18         }
19         
20         private FontMetrics fgFontMetrics;
21                 
22         /**
23          * @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int)
24          */
25         public int convertHeightInCharsToPixels(int chars) {
26                 return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
27         }
28
29         /**
30          * @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int)
31          */
32         public int convertHorizontalDLUsToPixels(int dlus) {
33                 return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus);
34         }
35
36         /**
37          * @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int)
38          */
39         public int convertVerticalDLUsToPixels(int dlus) {
40                 return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus);
41         }
42         
43         /**
44          * @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int)
45          */
46         public int convertWidthInCharsToPixels(int chars) {
47                 return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
48         }       
49
50 }