1 11 package org.eclipse.ui.internal.editors.text; 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 24 class PixelConverter { 25 26 private FontMetrics fFontMetrics; 27 28 public PixelConverter(Control control) { 29 GC gc = new GC(control); 30 gc.setFont(control.getFont()); 31 fFontMetrics= gc.getFontMetrics(); 32 gc.dispose(); 33 } 34 35 38 public int convertHeightInCharsToPixels(int chars) { 39 return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars); 40 } 41 42 45 public int convertHorizontalDLUsToPixels(int dlus) { 46 return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus); 47 } 48 49 52 public int convertVerticalDLUsToPixels(int dlus) { 53 return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus); 54 } 55 56 59 public int convertWidthInCharsToPixels(int chars) { 60 return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars); 61 } 62 } 63 | Popular Tags |