root/dwt/widgets/Composite.d

Revision 320:da968414c383, 66.0 kB (checked in by Frank Benoit <benoit@tionex.de>, 3 weeks ago)

Merge changes SWT 3.4.1

Line 
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.Composite;
14
15 import dwt.DWT;
16 import dwt.DWTException;
17 import dwt.graphics.Font;
18 import dwt.graphics.GC;
19 import dwt.graphics.GCData;
20 import dwt.graphics.Image;
21 import dwt.graphics.Point;
22 import dwt.graphics.Rectangle;
23 import dwt.internal.win32.OS;
24 import dwt.widgets.Scrollable;
25 import dwt.widgets.Control;
26 import dwt.widgets.Layout;
27 import dwt.widgets.Menu;
28 import dwt.widgets.Shell;
29 import dwt.widgets.Decorations;
30 import dwt.widgets.Event;
31 import dwt.widgets.ToolTip;
32 import dwt.widgets.Display;
33 import dwt.widgets.Widget;
34
35 import dwt.dwthelper.System;
36 import dwt.dwthelper.utils;
37
38 /**
39  * Instances of this class are controls which are capable
40  * of containing other controls.
41  * <dl>
42  * <dt><b>Styles:</b></dt>
43  * <dd>NO_BACKGROUND, NO_FOCUS, NO_MERGE_PAINTS, NO_REDRAW_RESIZE, NO_RADIO_GROUP, EMBEDDED, DOUBLE_BUFFERED</dd>
44  * <dt><b>Events:</b></dt>
45  * <dd>(none)</dd>
46  * </dl>
47  * <p>
48  * Note: The <code>NO_BACKGROUND</code>, <code>NO_FOCUS</code>, <code>NO_MERGE_PAINTS</code>,
49  * and <code>NO_REDRAW_RESIZE</code> styles are intended for use with <code>Canvas</code>.
50  * They can be used with <code>Composite</code> if you are drawing your own, but their
51  * behavior is undefined if they are used with subclasses of <code>Composite</code> other
52  * than <code>Canvas</code>.
53  * </p><p>
54  * Note: The <code>CENTER</code> style, although undefined for composites, has the
55  * same value as <code>EMBEDDED</code> (which is used to embed widgets from other
56  * widget toolkits into DWT).  On some operating systems (GTK, Motif), this may cause
57  * the children of this composite to be obscured.  The <code>EMBEDDED</code> style
58  * is for use by other widget toolkits and should normally never be used.
59  * </p><p>
60  * This class may be subclassed by custom control implementors
61  * who are building controls that are constructed from aggregates
62  * of other controls.
63  * </p>
64  *
65  * @see Canvas
66  * @see <a href="http://www.eclipse.org/swt/snippets/#composite">Composite snippets</a>
67  * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
68  */
69
70 public class Composite : Scrollable {
71
72     alias Scrollable.setBounds setBounds;
73     alias Scrollable.computeSize computeSize;
74     alias Scrollable.translateMnemonic translateMnemonic;
75
76     Layout layout_;
77     WINDOWPOS* [] lpwp;
78     Control [] tabList;
79     int layoutCount, backgroundMode;
80
81 /**
82  * Prevents uninitialized instances from being created outside the package.
83  */
84 this () {
85 }
86
87 /**
88  * Constructs a new instance of this class given its parent
89  * and a style value describing its behavior and appearance.
90  * <p>
91  * The style value is either one of the style constants defined in
92  * class <code>DWT</code> which is applicable to instances of this
93  * class, or must be built by <em>bitwise OR</em>'ing together
94  * (that is, using the <code>int</code> "|" operator) two or more
95  * of those <code>DWT</code> style constants. The class description
96  * lists the style constants that are applicable to the class.
97  * Style bits are also inherited from superclasses.
98  * </p>
99  *
100  * @param parent a widget which will be the parent of the new instance (cannot be null)
101  * @param style the style of widget to construct
102  *
103  * @exception IllegalArgumentException <ul>
104  *    <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
105  * </ul>
106  * @exception DWTException <ul>
107  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
108  * </ul>
109  *
110  * @see DWT#NO_BACKGROUND
111  * @see DWT#NO_FOCUS
112  * @see DWT#NO_MERGE_PAINTS
113  * @see DWT#NO_REDRAW_RESIZE
114  * @see DWT#NO_RADIO_GROUP
115  * @see Widget#getStyle
116  */
117 public this (Composite parent, int style) {
118     super (parent, style);
119 }
120
121 Control [] _getChildren () {
122     int count = 0;
123     auto hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
124     if (hwndChild is null) return new Control [0];
125     while (hwndChild !is null) {
126         count++;
127         hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT);
128     }
129     Control [] children = new Control [count];
130     int index = 0;
131     hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
132     while (hwndChild !is null) {
133         Control control = display.getControl (hwndChild);
134         if (control !is null && control !is this) {
135             children [index++] = control;
136         }
137         hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT);
138     }
139     if (count is index) return children;
140     Control [] newChildren = new Control [index];
141     System.arraycopy (children, 0, newChildren, 0, index);
142     return newChildren;
143 }
144
145 Control [] _getTabList () {
146     if (tabList is null) return tabList;
147     int count = 0;
148     for (int i=0; i<tabList.length; i++) {
149         if (!tabList [i].isDisposed ()) count++;
150     }
151     if (count is tabList.length) return tabList;
152     Control [] newList = new Control [count];
153     int index = 0;
154     for (int i=0; i<tabList.length; i++) {
155         if (!tabList [i].isDisposed ()) {
156             newList [index++] = tabList [i];
157         }
158     }
159     tabList = newList;
160     return tabList;
161 }
162
163 /**
164  * Clears any data that has been cached by a Layout for all widgets that
165  * are in the parent hierarchy of the changed control up to and including the
166  * receiver.  If an ancestor does not have a layout, it is skipped.
167  *
168  * @param changed an array of controls that changed state and require a recalculation of size
169  *
170  * @exception IllegalArgumentException <ul>
171  *    <li>ERROR_INVALID_ARGUMENT - if the changed array is null any of its controls are null or have been disposed</li>
172  *    <li>ERROR_INVALID_PARENT - if any control in changed is not in the widget tree of the receiver</li>
173  * </ul>
174  * @exception DWTException <ul>
175  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
176  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
177  * </ul>
178  *
179  * @since 3.1
180  */
181 public void changed (Control[] changed) {
182     checkWidget ();
183     if (changed is null) error (DWT.ERROR_INVALID_ARGUMENT);
184     for (int i=0; i<changed.length; i++) {
185         Control control = changed [i];
186         if (control is null) error (DWT.ERROR_INVALID_ARGUMENT);
187         if (control.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
188         bool ancestor = false;
189         Composite composite = control.parent;
190         while (composite !is null) {
191             ancestor = composite is this;
192             if (ancestor) break;
193             composite = composite.parent;
194         }
195         if (!ancestor) error (DWT.ERROR_INVALID_PARENT);
196     }
197     for (int i=0; i<changed.length; i++) {
198         Control child = changed [i];
199         Composite composite = child.parent;
200         while (child !is this) {
201             if (composite.layout_ is null || !composite.layout_.flushCache (child)) {
202                 composite.state |= LAYOUT_CHANGED;
203             }
204             child = composite;
205             composite = child.parent;
206         }
207     }
208 }
209
210 override void checkBuffered () {
211     if (OS.IsWinCE || (state & CANVAS) is 0) {
212         super.checkBuffered ();
213     }
214 }
215
216 override void checkComposited () {
217     if ((state & CANVAS) !is 0) {
218         if ((style & DWT.TRANSPARENT) !is 0) {
219             auto hwndParent = parent.handle;
220             int bits = OS.GetWindowLong (hwndParent, OS.GWL_EXSTYLE);
221             bits |= OS.WS_EX_COMPOSITED;
222             OS.SetWindowLong (hwndParent, OS.GWL_EXSTYLE, bits);
223         }
224     }
225 }
226
227 override protected void checkSubclass () {
228     /* Do nothing - Subclassing is allowed */
229 }
230
231 override Control [] computeTabList () {
232     Control result [] = super.computeTabList ();
233     if (result.length is 0) return result;
234     Control [] list = tabList !is null ? _getTabList () : _getChildren ();
235     for (int i=0; i<list.length; i++) {
236         Control child = list [i];
237         Control [] childList = child.computeTabList ();
238         if (childList.length !is 0) {
239             Control [] newResult = new Control [result.length + childList.length];
240             System.arraycopy (result, 0, newResult, 0, result.length);
241             System.arraycopy (childList, 0, newResult, result.length, childList.length);
242             result = newResult;
243         }
244     }
245     return result;
246 }
247
248 override public Point computeSize (int wHint, int hHint, bool changed) {
249     checkWidget ();
250     Point size;
251     if (layout_ !is null) {
252         if (wHint is DWT.DEFAULT || hHint is DWT.DEFAULT) {
253             changed |= (state & LAYOUT_CHANGED) !is 0;
254             state &= ~LAYOUT_CHANGED;
255             size = layout_.computeSize (this, wHint, hHint, changed);
256         } else {
257             size = new Point (wHint, hHint);
258         }
259     } else {
260         size = minimumSize (wHint, hHint, changed);
261     }
262     if (size.x is 0) size.x = DEFAULT_WIDTH;
263     if (size.y is 0) size.y = DEFAULT_HEIGHT;
264     if (wHint !is DWT.DEFAULT) size.x = wHint;
265     if (hHint !is DWT.DEFAULT) size.y = hHint;
266     Rectangle trim = computeTrim (0, 0, size.x, size.y);
267     return new Point (trim.width, trim.height);
268 }
269
270 /**
271  * Copies a rectangular area of the receiver at the specified
272  * position using the gc.
273  *
274  * @param gc the gc where the rectangle is to be filled
275  * @param x the x coordinate of the rectangle to be filled
276  * @param y the y coordinate of the rectangle to be filled
277  * @param width the width of the rectangle to be filled
278  * @param height the height of the rectangle to be filled
279  *
280  * @exception IllegalArgumentException <ul>
281  *    <li>ERROR_NULL_ARGUMENT - if the gc is null</li>
282  *    <li>ERROR_INVALID_ARGUMENT - if the gc has been disposed</li>
283  * </ul>
284  * @exception DWTException <ul>
285  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
286  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
287  * </ul>
288  */
289 /*public*/ void copyArea (GC gc, int x, int y, int width, int height) {
290     checkWidget ();
291     if (gc is null) error (DWT.ERROR_NULL_ARGUMENT);
292     if (gc.isDisposed ()) error (DWT.ERROR_INVALID_ARGUMENT);
293
294     //XP only, no GDI+
295     //#define PW_CLIENTONLY 0x00000001
296     //DCOrg() wrong
297     //topHandle wrong for Tree?
298     auto hDC = gc.handle;
299     int nSavedDC = OS.SaveDC (hDC);
300     OS.IntersectClipRect (hDC, 0, 0, width, height);
301
302     //WRONG PARENT
303     POINT lpPoint;
304     auto hwndParent = OS.GetParent (handle);
305     OS.MapWindowPoints (handle, hwndParent, &lpPoint, 1);
306     RECT rect;
307     OS.GetWindowRect (handle, &rect);
308     POINT lpPoint1, lpPoint2;
309     x = x + (lpPoint.x - rect.left);
310     y = y + (lpPoint.y - rect.top);
311     OS.SetWindowOrgEx (hDC, x, y, &lpPoint1);
312     OS.SetBrushOrgEx (hDC, x, y, &lpPoint2);
313     int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
314     if ((bits & OS.WS_VISIBLE) is 0) {
315         OS.DefWindowProc (handle, OS.WM_SETREDRAW, 1, 0);
316     }
317     //NECESSARY?
318     OS.RedrawWindow (handle, null, null, OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN);
319     OS.PrintWindow (handle, hDC, 0);//0x00000001);
320     if ((bits & OS.WS_VISIBLE) is 0) {
321         OS.DefWindowProc(handle, OS.WM_SETREDRAW, 0, 0);
322     }
323     OS.RestoreDC (hDC, nSavedDC);
324 }
325
326 override void createHandle () {
327     super.createHandle ();
328     state |= CANVAS;
329     if ((style & (DWT.H_SCROLL | DWT.V_SCROLL)) is 0) {
330         state |= THEME_BACKGROUND;
331     }
332     if ((style & DWT.TRANSPARENT) !is 0) {
333         int bits = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
334         bits |= OS.WS_EX_TRANSPARENT;
335         OS.SetWindowLong (handle, OS.GWL_EXSTYLE, bits);
336     }
337 }
338
339 Composite findDeferredControl () {
340     return layoutCount > 0 ? this : parent.findDeferredControl ();
341 }
342
343 override Menu [] findMenus (Control control) {
344     if (control is this) return new Menu [0];
345     Menu result [] = super.findMenus (control);
346     Control [] children = _getChildren ();
347     for (int i=0; i<children.length; i++) {
348         Control child = children [i];
349         Menu [] menuList = child.findMenus (control);
350         if (menuList.length !is 0) {
351             Menu [] newResult = new Menu [result.length + menuList.length];
352             System.arraycopy (result, 0, newResult, 0, result.length);
353             System.arraycopy (menuList, 0, newResult, result.length, menuList.length);
354             result = newResult;
355         }
356     }
357     return result;
358 }
359
360 override void fixChildren (Shell newShell, Shell oldShell, Decorations newDecorations, Decorations oldDecorations, Menu [] menus) {
361     super.fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
362     Control [] children = _getChildren ();
363     for (int i=0; i<children.length; i++) {
364         children [i].fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
365     }
366 }
367
368 void fixTabList (Control control) {
369     if (tabList is null) return;
370     int count = 0;
371     for (int i=0; i<tabList.length; i++) {
372         if (tabList [i] is control) count++;
373     }
374     if (count is 0) return;
375     Control [] newList = null;
376     int length = tabList.length - count;
377     if (length !is 0) {
378         newList = new Control [length];
379         int index = 0;
380         for (int i=0; i<tabList.length; i++) {
381             if (tabList [i] !is control) {
382                 newList [index++] = tabList [i];
383             }
384         }
385     }
386     tabList = newList;
387 }
388
389 /**
390  * Returns the receiver's background drawing mode. This
391  * will be one of the following constants defined in class
392  * <code>DWT</code>:
393  * <code>INHERIT_NONE</code>, <code>INHERIT_DEFAULT</code>,
394  * <code>INHERTIT_FORCE</code>.
395  *
396  * @return the background mode
397  *
398  * @exception DWTException <ul>
399  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
400  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
401  * </ul>
402  *
403  * @see DWT
404  *
405  * @since 3.2
406  */
407 public int getBackgroundMode () {
408     checkWidget ();
409     return backgroundMode;
410 }
411
412 /**
413  * Returns a (possibly empty) array containing the receiver's children.
414  * Children are returned in the order that they are drawn.  The topmost
415  * control appears at the beginning of the array.  Subsequent controls
416  * draw beneath this control and appear later in the array.
417  * <p>
418  * Note: This is not the actual structure used by the receiver
419  * to maintain its list of children, so modifying the array will
420  * not affect the receiver.
421  * </p>
422  *
423  * @return an array of children
424  *
425  * @see Control#moveAbove
426  * @see Control#moveBelow
427  *
428  * @exception DWTException <ul>
429  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
430  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
431  * </ul>
432  */
433 public Control [] getChildren () {
434     checkWidget ();
435     return _getChildren ();
436 }
437
438 int getChildrenCount () {
439     /*
440     * NOTE: The current implementation will count
441     * non-registered children.
442     */
443     int count = 0;
444     auto hwndChild = OS.GetWindow (handle, OS.GW_CHILD);
445     while (hwndChild !is null) {
446         count++;
447         hwndChild = OS.GetWindow (hwndChild, OS.GW_HWNDNEXT);
448     }
449     return count;
450 }
451
452 /**
453  * Returns layout which is associated with the receiver, or
454  * null if one has not been set.
455  *
456  * @return the receiver's layout or null
457  *
458  * @exception DWTException <ul>
459  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
460  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
461  * </ul>
462  */
463 public Layout getLayout () {
464     checkWidget ();
465     return layout_;
466 }
467
468 /**
469  * Gets the (possibly empty) tabbing order for the control.
470  *
471  * @return tabList the ordered list of controls representing the tab order
472  *
473  * @exception DWTException <ul>
474  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
475  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
476  * </ul>
477  *
478  * @see #setTabList
479  */
480 public Control [] getTabList () {
481     checkWidget ();
482     Control [] tabList = _getTabList ();
483     if (tabList is null) {
484         int count = 0;
485         Control [] list =_getChildren ();
486         for (int i=0; i<list.length; i++) {
487             if (list [i].isTabGroup ()) count++;
488         }
489         tabList = new Control [count];
490         int index = 0;
491         for (int i=0; i<list.length; i++) {
492             if (list [i].isTabGroup ()) {
493                 tabList [index++] = list [i];
494             }
495         }
496     }
497     return tabList;
498 }
499
500 bool hooksKeys () {
501     return hooks (DWT.KeyDown) || hooks (DWT.KeyUp);
502 }
503
504 /**
505  * Returns <code>true</code> if the receiver has deferred
506  * the performing of layout, and <code>false</code> otherwise.
507  *
508  * @return the receiver's deferred layout state
509  *
510  * @exception DWTException <ul>
511  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
512  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
513  * </ul>
514  *
515  * @see #setLayoutDeferred(bool)
516  * @see #isLayoutDeferred()
517  *
518  * @since 3.1
519  */
520 public bool getLayoutDeferred () {
521     checkWidget ();
522     return layoutCount > 0 ;
523 }
524
525 /**
526  * Returns <code>true</code> if the receiver or any ancestor
527  * up to and including the receiver's nearest ancestor shell
528  * has deferred the performing of layouts.  Otherwise, <code>false</code>
529  * is returned.
530  *
531  * @return the receiver's deferred layout state
532  *
533  * @exception DWTException <ul>
534  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
535  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
536  * </ul>
537  *
538  * @see #setLayoutDeferred(bool)
539  * @see #getLayoutDeferred()
540  *
541  * @since 3.1
542  */
543 public bool isLayoutDeferred () {
544     checkWidget ();
545     return findDeferredControl () !is null;
546 }
547
548 /**
549  * If the receiver has a layout, asks the layout to <em>lay out</em>
550  * (that is, set the size and location of) the receiver's children.
551  * If the receiver does not have a layout, do nothing.
552  * <p>
553  * This is equivalent to calling <code>layout(true)</code>.
554  * </p>
555  * <p>
556  * Note: Layout is different from painting. If a child is
557  * moved or resized such that an area in the parent is
558  * exposed, then the parent will paint. If no child is
559  * affected, the parent will not paint.
560  * </p>
561  *
562  * @exception DWTException <ul>
563  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
564  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
565  * </ul>
566  */
567 public void layout () {
568     checkWidget ();
569     layout (true);
570 }
571
572 /**
573  * If the receiver has a layout, asks the layout to <em>lay out</em>
574  * (that is, set the size and location of) the receiver's children.
575  * If the argument is <code>true</code> the layout must not rely
576  * on any information it has cached about the immediate children. If it
577  * is <code>false</code> the layout may (potentially) optimize the
578  * work it is doing by assuming that none of the receiver's
579  * children has changed state since the last layout.
580  * If the receiver does not have a layout, do nothing.
581  * <p>
582  * If a child is resized as a result of a call to layout, the
583  * resize event will invoke the layout of the child.  The layout
584  * will cascade down through all child widgets in the receiver's widget
585  * tree until a child is encountered that does not resize.  Note that
586  * a layout due to a resize will not flush any cached information
587  * (same as <code>layout(false)</code>).
588  * </p>
589  * <p>
590  * Note: Layout is different from painting. If a child is
591  * moved or resized such that an area in the parent is
592  * exposed, then the parent will paint. If no child is
593  * affected, the parent will not paint.
594  * </p>
595  *
596  * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise
597  *
598  * @exception DWTException <ul>
599  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
600  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
601  * </ul>
602  */
603 public void layout (bool changed) {
604     checkWidget ();
605     if (layout_ is null) return;
606     layout (changed, false);
607 }
608
609 /**
610  * If the receiver has a layout, asks the layout to <em>lay out</em>
611  * (that is, set the size and location of) the receiver's children.
612  * If the changed argument is <code>true</code> the layout must not rely
613  * on any information it has cached about its children. If it
614  * is <code>false</code> the layout may (potentially) optimize the
615  * work it is doing by assuming that none of the receiver's
616  * children has changed state since the last layout.
617  * If the all argument is <code>true</code> the layout will cascade down
618  * through all child widgets in the receiver's widget tree, regardless of
619  * whether the child has changed size.  The changed argument is applied to
620  * all layouts.  If the all argument is <code>false</code>, the layout will
621  * <em>not</em> cascade down through all child widgets in the receiver's widget
622  * tree.  However, if a child is resized as a result of a call to layout, the
623  * resize event will invoke the layout of the child.  Note that
624  * a layout due to a resize will not flush any cached information
625  * (same as <code>layout(false)</code>).
626  * </p>
627  * <p>
628  * Note: Layout is different from painting. If a child is
629  * moved or resized such that an area in the parent is
630  * exposed, then the parent will paint. If no child is
631  * affected, the parent will not paint.
632  * </p>
633  *
634  * @param changed <code>true</code> if the layout must flush its caches, and <code>false</code> otherwise
635  * @param all <code>true</code> if all children in the receiver's widget tree should be laid out, and <code>false</code> otherwise
636  *
637  * @exception DWTException <ul>
638  *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
639  *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
640  * </ul>
641  *
642  * @since 3.1
643  */
644 public void layout (bool changed, bool all) {
645     checkWidget ();
646     if (layout_ is null && !all)<