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