1 11 package org.eclipse.jface.layout; 12 13 import org.eclipse.jface.dialogs.Dialog; 14 import org.eclipse.jface.dialogs.IDialogConstants; 15 import org.eclipse.jface.resource.JFaceResources; 16 import org.eclipse.swt.graphics.FontMetrics; 17 import org.eclipse.swt.graphics.GC; 18 import org.eclipse.swt.graphics.Point; 19 import org.eclipse.swt.widgets.Display; 20 21 26 public final class LayoutConstants { 27 private static Point dialogMargins = null; 28 private static Point dialogSpacing = null; 29 private static Point minButtonSize = null; 30 31 private static void initializeConstants() { 32 if (dialogMargins != null) { 33 return; 34 } 35 36 GC gc = new GC(Display.getCurrent()); 37 gc.setFont(JFaceResources.getDialogFont()); 38 FontMetrics fontMetrics = gc.getFontMetrics(); 39 40 dialogMargins = new Point(Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_MARGIN), 41 Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_MARGIN)); 42 43 dialogSpacing = new Point(Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.HORIZONTAL_SPACING), 44 Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.VERTICAL_SPACING)); 45 46 minButtonSize = new Point(Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH), 0); 47 48 gc.dispose(); 49 } 50 51 56 public static final Point getMargins() { 57 initializeConstants(); 58 return dialogMargins; 59 } 60 61 66 public static final Point getSpacing() { 67 initializeConstants(); 68 return dialogSpacing; 69 } 70 71 76 public static final Point getMinButtonSize() { 77 initializeConstants(); 78 return minButtonSize; 79 } 80 } 81 | Popular Tags |