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