1 11 package org.eclipse.jdt.internal.junit.util; 12 13 import org.eclipse.swt.graphics.FontMetrics; 14 import org.eclipse.swt.graphics.GC; 15 import org.eclipse.swt.widgets.Control; 16 17 import org.eclipse.jface.dialogs.Dialog; 18 19 22 public class PixelConverter { 23 24 private FontMetrics fFontMetrics; 25 26 public PixelConverter(Control control) { 27 GC gc = new GC(control); 28 gc.setFont(control.getFont()); 29 fFontMetrics= gc.getFontMetrics(); 30 gc.dispose(); 31 } 32 33 36 public int convertHeightInCharsToPixels(int chars) { 37 return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars); 38 } 39 40 43 public int convertHorizontalDLUsToPixels(int dlus) { 44 return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus); 45 } 46 47 50 public int convertVerticalDLUsToPixels(int dlus) { 51 return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus); 52 } 53 54 57 public int convertWidthInCharsToPixels(int chars) { 58 return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars); 59 } 60 61 } 62 | Popular Tags |