01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.util;
11:
12: import org.eclipse.jface.dialogs.Dialog;
13: import org.eclipse.swt.graphics.FontMetrics;
14: import org.eclipse.swt.graphics.GC;
15: import org.eclipse.swt.widgets.Control;
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: /**
29: * @see DialogPage#convertHeightInCharsToPixels
30: */
31: public int convertHeightInCharsToPixels(int chars) {
32: return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
33: }
34:
35: /**
36: * @see DialogPage#convertHorizontalDLUsToPixels
37: */
38: public int convertHorizontalDLUsToPixels(int dlus) {
39: return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus);
40: }
41:
42: /**
43: * @see DialogPage#convertVerticalDLUsToPixels
44: */
45: public int convertVerticalDLUsToPixels(int dlus) {
46: return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus);
47: }
48:
49: /**
50: * @see DialogPage#convertWidthInCharsToPixels
51: */
52: public int convertWidthInCharsToPixels(int chars) {
53: return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
54: }
55:
56: }
|