Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/eclipse/swt/widgets/Layout.java


1   /*******************************************************************************
2    * Copyright (c) 2000, 2003 IBM Corporation and others.
3    * All rights reserved. This program and the accompanying materials 
4    * are made available under the terms of the Common Public License v1.0
5    * which accompanies this distribution, and is available at
6    * http://www.eclipse.org/legal/cpl-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  public abstract class Layout {
23  
24  /**
25   * Computes and returns the size of the specified
26   * composite's client area according to this layout.
27   * <p>
28   * This method computes the minimum size that the
29   * client area of the composite must be in order to
30   * position all children at their minimum size inside
31   * the composite according to the layout algorithm
32   * encoded by this layout.
33   * </p>
34   * <p>
35   * When a width or height hint is supplied, it is
36   * used to constrain the result. For example, if a
37   * width hint is provided that is less than the minimum
38   * width of the client area, the layout may choose
39   * to wrap and increase height, clip, overlap, or
40   * otherwise constrain the children.
41   * </p>
42   *
43   * @param composite a composite widget using this layout
44   * @param wHint width (<code>SWT.DEFAULT</code> for minimum)
45   * @param hHint height (<code>SWT.DEFAULT</code> for minimum)
46   * @param flushCache <code>true</code> means flush cached layout values
47   * @return a point containing the computed size (width, height)
48   * 
49   * @see #layout
50   * @see Control#getBorderWidth
51   * @see Control#getBounds
52   * @see Control#getSize
53   * @see Control#pack
54   * @see "computeTrim, getClientArea for controls that implement them"
55   */
56  protected abstract Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache);
57  
58  /**
59   * Lays out the children of the specified composite
60   * according to this layout.
61   * <p>
62   * This method positions and sizes the children of a
63   * composite using the layout algorithm encoded by this
64   * layout. Children of the composite are positioned in
65   * the client area of the composite. The position of
66   * the composite is not altered by this method.
67   * </p>
68   * <p>
69   * When the flush cache hint is true, the layout is
70   * instructed to flush any cached values associated
71   * with the children. Typically, a layout will cache
72   * the preferred sizes of the children to avoid the
73   * expense of computing these values each time the
74   * widget is layed out.
75   * </p>
76   * <p>
77   * When layout is triggered explicitly by the programmer
78   * the flush cache hint is true. When layout is triggered
79   * by a resize, either caused by the programmer or by the
80   * user, the hint is false.
81   * </p>
82   *
83   * @param composite a composite widget using this layout
84   * @param flushCache <code>true</code> means flush cached layout values
85   */
86  protected abstract void layout (Composite composite, boolean flushCache);
87  }