01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 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.ui.forms.widgets;
11:
12: import org.eclipse.swt.graphics.Point;
13: import org.eclipse.swt.widgets.*;
14:
15: /**
16: * The class overrides default method for computing size in Composite by
17: * accepting size returned from layout managers as-is. The default code accepts
18: * width or height hint assuming it is correct. However, it is possible that
19: * the computation using the provided width hint results in a real size that is
20: * larger. This can result in wrapped text widgets being clipped, asking to
21: * render in bounds narrower than the longest word.
22: */
23: /* package */class LayoutComposite extends Composite {
24: public LayoutComposite(Composite parent, int style) {
25: super (parent, style);
26: setMenu(parent.getMenu());
27: }
28:
29: public Point computeSize(int wHint, int hHint, boolean changed) {
30: Layout layout = getLayout();
31: if (layout instanceof TableWrapLayout)
32: return ((TableWrapLayout) layout).computeSize(this , wHint,
33: hHint, changed);
34: if (layout instanceof ColumnLayout)
35: return ((ColumnLayout) layout).computeSize(this, wHint,
36: hHint, changed);
37: return super.computeSize(wHint, hHint, changed);
38: }
39: }
|