01: /*******************************************************************************
02: * Copyright (c) 2004 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Common Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/cpl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.examples.presentation.wrappedtabs;
11:
12: import org.eclipse.swt.widgets.ToolBar;
13: import org.eclipse.swt.widgets.ToolItem;
14:
15: /**
16: * @since 3.0
17: */
18: public class WrappedTabsUtil {
19: private WrappedTabsUtil() {
20:
21: }
22:
23: /**
24: * Returns the width of the widest ToolItem in the given toolbar
25: *
26: * @param toMeasure toolbar to measure
27: * @return the width (pixels) of the widest ToolItem in the given toolbar
28: */
29: public static int getMaximumItemWidth(ToolBar toMeasure) {
30: int maxWidth = 0;
31: ToolItem items[] = toMeasure.getItems();
32:
33: for (int i = 0; i < items.length; i++) {
34: ToolItem item = items[i];
35:
36: maxWidth = Math.max(maxWidth, item.getBounds().width);
37: }
38:
39: return maxWidth;
40: }
41: }
|