1 11 package org.eclipse.search.internal.ui.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 public class PixelConverter { 20 21 private FontMetrics fFontMetrics; 22 23 public PixelConverter(Control control) { 24 GC gc = new GC(control); 25 gc.setFont(control.getFont()); 26 fFontMetrics= gc.getFontMetrics(); 27 gc.dispose(); 28 } 29 30 33 public int convertHeightInCharsToPixels(int chars) { 34 return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars); 35 } 36 37 40 public int convertHorizontalDLUsToPixels(int dlus) { 41 return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus); 42 } 43 44 47 public int convertVerticalDLUsToPixels(int dlus) { 48 return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus); 49 } 50 51 54 public int convertWidthInCharsToPixels(int chars) { 55 return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars); 56 } 57 58 } 59 | Popular Tags |