1 /*******************************************************************************
2  * Copyright (c) 2000, 2008 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  * Port to the D programming language:
11  *     Frank Benoit <benoit@tionex.de>
12  *******************************************************************************/
13 module org.eclipse.swt.widgets.Layout;
14 
15 import java.lang.all;
16 
17 
18 import org.eclipse.swt.graphics.Point;
19 import org.eclipse.swt.widgets.Control;
20 import org.eclipse.swt.widgets.Composite;
21 
22 /**
23  * A layout controls the position and size
24  * of the children of a composite widget.
25  * This class is the abstract base class for
26  * layouts.
27  *
28  * @see Composite#setLayout(Layout)
29  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
30  */
31 public abstract class Layout {
32 
33 /**
34  * Computes and returns the size of the specified
35  * composite's client area according to this layout.
36  * <p>
37  * This method computes the size that the client area
38  * of the composite must be in order to position all
39  * children at their preferred size inside the
40  * composite according to the layout algorithm
41  * encoded by this layout.
42  * </p>
43  * <p>
44  * When a width or height hint is supplied, it is
45  * used to constrain the result. For example, if a
46  * width hint is provided that is less than the
47  * width of the client area, the layout may choose
48  * to wrap and increase height, clip, overlap, or
49  * otherwise constrain the children.
50  * </p>
51  *
52  * @param composite a composite widget using this layout
53  * @param wHint width (<code>SWT.DEFAULT</code> for preferred size)
54  * @param hHint height (<code>SWT.DEFAULT</code> for preferred size)
55  * @param flushCache <code>true</code> means flush cached layout values
56  * @return a point containing the computed size (width, height)
57  *
58  * @see #layout
59  * @see Control#getBorderWidth
60  * @see Control#getBounds
61  * @see Control#getSize
62  * @see Control#pack(boolean)
63  * @see "computeTrim, getClientArea for controls that implement them"
64  */
65 abstract Point computeSize (Composite composite, int wHint, int hHint, bool flushCache);
66 
67 /**
68  * Instruct the layout to flush any cached values
69  * associated with the control specified in the argument
70  * <code>control</code>.
71  *
72  * @param control a control managed by this layout
73  * @return true if the Layout has flushed all cached information associated with control
74  *
75  * @since 3.1
76  */
77 bool flushCache (Control control) {
78     return false;
79 }
80 
81 /**
82  * Lays out the children of the specified composite
83  * according to this layout.
84  * <p>
85  * This method positions and sizes the children of a
86  * composite using the layout algorithm encoded by this
87  * layout. Children of the composite are positioned in
88  * the client area of the composite. The position of
89  * the composite is not altered by this method.
90  * </p>
91  * <p>
92  * When the flush cache hint is true, the layout is
93  * instructed to flush any cached values associated
94  * with the children. Typically, a layout will cache
95  * the preferred sizes of the children to avoid the
96  * expense of computing these values each time the
97  * widget is laid out.
98  * </p>
99  * <p>
100  * When layout is triggered explicitly by the programmer
101  * the flush cache hint is true. When layout is triggered
102  * by a resize, either caused by the programmer or by the
103  * user, the hint is false.
104  * </p>
105  *
106  * @param composite a composite widget using this layout
107  * @param flushCache <code>true</code> means flush cached layout values
108  */
109 abstract void layout (Composite composite, bool flushCache);
110 }