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