KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > forms > widgets > LayoutComposite


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.forms.widgets;
12 import org.eclipse.swt.graphics.Point;
13 import org.eclipse.swt.widgets.*;
14 /**
15  * The class overrides default method for computing size in Composite by
16  * accepting size returned from layout managers as-is. The default code accepts
17  * width or height hint assuming it is correct. However, it is possible that
18  * the computation using the provided width hint results in a real size that is
19  * larger. This can result in wrapped text widgets being clipped, asking to
20  * render in bounds narrower than the longest word.
21  */

22 /* package */class LayoutComposite extends Composite {
23     public LayoutComposite(Composite parent, int style) {
24         super(parent, style);
25         setMenu(parent.getMenu());
26     }
27     public Point computeSize(int wHint, int hHint, boolean changed) {
28         Layout layout = getLayout();
29         if (layout instanceof TableWrapLayout)
30             return ((TableWrapLayout) layout).computeSize(this, wHint, hHint,
31                     changed);
32         if (layout instanceof ColumnLayout)
33             return ((ColumnLayout) layout).computeSize(this, wHint, hHint,
34                     changed);
35         return super.computeSize(wHint, hHint, changed);
36     }
37 }
38
Popular Tags