|
|
< Day Day Up > |
|
15.1 When Are Layouts Invoked?There are two situations in SWT when layout functionality is invoked. Both are the result of some action on a composite.
When the composite is resized, the layout places the children of the composite at their new positions, using its layout algorithm. When a child control is resized, it may also contain a layout, causing the process to continue downward in the control hierarchy. The layout is invoked after the SWT.Resize event. This means that you can configure the layout just before it is invoked. Generally speaking, this is something that you will not need to do but there are cases when this feature can be useful (see Forcing Controls to Wrap). Programmers new to SWT sometimes find it confusing that layout does not happen in more situations. For example, they expect layout to be invoked when a control is hidden, shown, or disposed of, or when a string is assigned into a label.[2] The problem with this approach is that only the programmer really knows when layout should occur. Because layout operations are expensive, layout should be invoked only when necessary. For example, if layout were to happen when each control is disposed of, multiple layouts and redraws would occur in the composite, causing a potential performance problem.[3] The section Forcing a Layout describes how you can make a layout happen.
15.1.1 Layout and Z-OrderMost layouts position and resize their controls in the order that they appear in the children list of their composite. This means that when the z-order of a control is changed, using moveAbove() or moveBelow(), the order of the controls in the layout will change.[4] Some programs make use of this feature to move controls within a layout. If you do not change the z-order of a control, the layout order will not change.
|
|
|
< Day Day Up > |
|