1 11 package org.eclipse.team.internal.ui; 12 13 import org.eclipse.jface.dialogs.Dialog; 14 import org.eclipse.swt.graphics.FontMetrics; 15 import org.eclipse.swt.graphics.GC; 16 import org.eclipse.swt.widgets.Control; 17 18 public class PixelConverter { 19 20 private final FontMetrics fFontMetrics; 21 22 public PixelConverter(Control control) { 23 GC gc = new GC(control); 24 try { 25 gc.setFont(control.getFont()); 26 fFontMetrics= gc.getFontMetrics(); 27 } finally { 28 gc.dispose(); 29 } 30 } 31 32 public int convertHeightInCharsToPixels(int chars) { 33 return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars); 34 } 35 36 public int convertHorizontalDLUsToPixels(int dlus) { 37 return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus); 38 } 39 40 public int convertVerticalDLUsToPixels(int dlus) { 41 return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus); 42 } 43 44 public int convertWidthInCharsToPixels(int chars) { 45 return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars); 46 } 47 } 48 | Popular Tags |