1 11 12 package org.eclipse.ui.internal; 13 14 import org.eclipse.jface.dialogs.Dialog; 15 import org.eclipse.jface.resource.JFaceResources; 16 import org.eclipse.swt.SWT; 17 import org.eclipse.swt.graphics.GC; 18 import org.eclipse.swt.graphics.Point; 19 import org.eclipse.swt.layout.GridData; 20 import org.eclipse.swt.layout.GridLayout; 21 import org.eclipse.swt.widgets.Display; 22 import org.eclipse.swt.widgets.Shell; 23 import org.eclipse.swt.widgets.ToolBar; 24 import org.eclipse.swt.widgets.ToolItem; 25 26 32 public class TrimUtil { 33 34 37 public static final int TRIM_DEFAULT_HEIGHT; 38 static { 39 Shell s = new Shell(Display.getCurrent(), SWT.NONE); 40 s.setLayout(new GridLayout()); 41 ToolBar t = new ToolBar(s, SWT.NONE); 42 t.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); 43 ToolItem ti = new ToolItem(t, SWT.PUSH); 44 ti.setImage(JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_MESSAGE_INFO)); 45 s.layout(); 46 int toolItemHeight = t.computeSize(SWT.DEFAULT, SWT.DEFAULT).y; 47 GC gc = new GC(s); 48 Point fontSize = gc.textExtent("Wg"); gc.dispose(); 50 TRIM_DEFAULT_HEIGHT = Math.max(toolItemHeight, fontSize.y); 51 s.dispose(); 52 53 } 54 } 55 | Popular Tags |