KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > swt > widgets > Layout


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.swt.widgets;
12
13
14 import org.eclipse.swt.graphics.*;
15
16 /**
17  * A layout controls the position and size
18  * of the children of a composite widget.
19  * This class is the abstract base class for
20  * layouts.
21  *
22  * @see Composite#setLayout(Layout)
23  */

24 public abstract class Layout {
25
26 /**
27  * Computes and returns the size of the specified
28  * composite's client area according to this layout.
29  * <p>
30  * This method computes the size that the client area
31  * of the composite must be in order to position all
32  * children at their preferred size inside the
33  * composite according to the layout algorithm
34  * encoded by this layout.
35  * </p>
36  * <p>
37  * When a width or height hint is supplied, it is
38  * used to constrain the result. For example, if a
39  * width hint is provided that is less than the
40  * width of the client area, the layout may choose
41  * to wrap and increase height, clip, overlap, or
42  * otherwise constrain the children.
43  * </p>
44  *
45  * @param composite a composite widget using this layout
46  * @param wHint width (<code>SWT.DEFAULT</code> for preferred size)
47  * @param hHint height (<code>SWT.DEFAULT</code> for preferred size)
48  * @param flushCache <code>true</code> means flush cached layout values
49  * @return a point containing the computed size (width, height)
50  *
51  * @see #layout
52  * @see Control#getBorderWidth
53  * @see Control#getBounds
54  * @see Control#getSize
55  * @see Control#pack(boolean)
56  * @see "computeTrim, getClientArea for controls that implement them"
57  */

58 protected abstract Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache);
59
60 /**
61  * Instruct the layout to flush any cached values
62  * associated with the control specified in the argument
63  * <code>control</code>.
64  *
65  * @param control a control managed by this layout
66  * @return true if the Layout has flushed all cached information associated with control
67  *
68  * @since 3.1
69  */

70 protected boolean flushCache (Control control) {
71     return false;
72 }
73
74 /**
75  * Lays out the children of the specified composite
76  * according to this layout.
77  * <p>
78  * This method positions and sizes the children of a
79  * composite using the layout algorithm encoded by this
80  * layout. Children of the composite are positioned in
81  * the client area of the composite. The position of
82  * the composite is not altered by this method.
83  * </p>
84  * <p>
85  * When the flush cache hint is true, the layout is
86  * instructed to flush any cached values associated
87  * with the children. Typically, a layout will cache
88  * the preferred sizes of the children to avoid the
89  * expense of computing these values each time the
90  * widget is laid out.
91  * </p>
92  * <p>
93  * When layout is triggered explicitly by the programmer
94  * the flush cache hint is true. When layout is triggered
95  * by a resize, either caused by the programmer or by the
96  * user, the hint is false.
97  * </p>
98  *
99  * @param composite a composite widget using this layout
100  * @param flushCache <code>true</code> means flush cached layout values
101  */

102 protected abstract void layout (Composite composite, boolean flushCache);
103 }
104
Popular Tags