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