diff options
author | Silenio Quarti <silenio> | 2009-10-20 18:24:26 +0000 |
---|---|---|
committer | Silenio Quarti <silenio> | 2009-10-20 18:24:26 +0000 |
commit | 63f803a737d416603789d25d5eba7834fce0e4c9 (patch) | |
tree | 11e8f83b9bbe9155b22756eb178ac70c2cdde90b /bundles/org.eclipse.swt/Eclipse SWT/gtk | |
parent | 3f16243f15249d0c5b9acd8d735db116a6188e83 (diff) | |
download | eclipse.platform.swt-63f803a737d416603789d25d5eba7834fce0e4c9.tar.gz eclipse.platform.swt-63f803a737d416603789d25d5eba7834fce0e4c9.tar.xz eclipse.platform.swt-63f803a737d416603789d25d5eba7834fce0e4c9.zip |
Bug 103863 - Support encapsulation in SWT layout mechanism
Diffstat (limited to 'bundles/org.eclipse.swt/Eclipse SWT/gtk')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java | 83 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java | 30 |
2 files changed, 81 insertions, 32 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java index 62cda3117c..23b10c1584 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java @@ -951,42 +951,61 @@ public void layout (boolean changed, boolean all) { public void layout (Control [] changed) { checkWidget (); if (changed == null) error (SWT.ERROR_INVALID_ARGUMENT); - for (int i=0; i<changed.length; i++) { - Control control = changed [i]; - if (control == null) error (SWT.ERROR_INVALID_ARGUMENT); - if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); - boolean ancestor = false; - Composite composite = control.parent; - while (composite != null) { - ancestor = composite == this; - if (ancestor) break; - composite = composite.parent; + layout (changed, SWT.NONE); +} + +/*public*/ void layout (Control [] changed, int flags) { + checkWidget (); + if (changed != null) { + for (int i=0; i<changed.length; i++) { + Control control = changed [i]; + if (control == null) error (SWT.ERROR_INVALID_ARGUMENT); + if (control.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT); + boolean ancestor = false; + Composite composite = control.parent; + while (composite != null) { + ancestor = composite == this; + if (ancestor) break; + composite = composite.parent; + } + if (!ancestor) error (SWT.ERROR_INVALID_PARENT); } - if (!ancestor) error (SWT.ERROR_INVALID_PARENT); - } - int updateCount = 0; - Composite [] update = new Composite [16]; - for (int i=0; i<changed.length; i++) { - Control child = changed [i]; - Composite composite = child.parent; - while (child != this) { - if (composite.layout != null) { - composite.state |= LAYOUT_NEEDED; - if (!composite.layout.flushCache (child)) { - composite.state |= LAYOUT_CHANGED; + int updateCount = 0; + Composite [] update = new Composite [16]; + for (int i=0; i<changed.length; i++) { + Control child = changed [i]; + Composite composite = child.parent; + while (child != this) { + if (composite.layout != null) { + composite.state |= LAYOUT_NEEDED; + if (!composite.layout.flushCache (child)) { + composite.state |= LAYOUT_CHANGED; + } } + if (updateCount == update.length) { + Composite [] newUpdate = new Composite [update.length + 16]; + System.arraycopy (update, 0, newUpdate, 0, update.length); + update = newUpdate; + } + child = update [updateCount++] = composite; + composite = child.parent; } - if (updateCount == update.length) { - Composite [] newUpdate = new Composite [update.length + 16]; - System.arraycopy (update, 0, newUpdate, 0, update.length); - update = newUpdate; - } - child = update [updateCount++] = composite; - composite = child.parent; } - } - for (int i=updateCount-1; i>=0; i--) { - update [i].updateLayout (false); + if ((flags & SWT.DEFER) != 0) { + setLayoutDeferred (true); + display.addLayoutDeferred (this); + } + for (int i=updateCount-1; i>=0; i--) { + update [i].updateLayout (false); + } + } else { + if (layout == null && (flags & SWT.ALL) == 0) return; + markLayout ((flags & SWT.CHANGED) != 0, (flags & SWT.ALL) != 0); + if ((flags & SWT.DEFER) != 0) { + setLayoutDeferred (true); + display.addLayoutDeferred (this); + } + updateLayout ((flags & SWT.ALL) != 0); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java index 5a1610cf57..33fbc9eeea 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java @@ -160,6 +160,10 @@ public class Display extends Device { /* Display Shutdown */ Runnable [] disposeList; + /* Deferred Layout list */ + Composite[] layoutDeferred; + int layoutDeferredCount; + /* System Tray */ Tray tray; @@ -527,6 +531,16 @@ public void addFilter (int eventType, Listener listener) { filterTable.hook (eventType, listener); } +void addLayoutDeferred (Composite comp) { + if (layoutDeferred == null) layoutDeferred = new Composite [64]; + if (layoutDeferredCount == layoutDeferred.length) { + Composite [] temp = new Composite [layoutDeferred.length + 64]; + System.arraycopy (layoutDeferred, 0, temp, 0, layoutDeferred.length); + layoutDeferred = temp; + } + layoutDeferred[layoutDeferredCount++] = comp; +} + void addGdkEvent (int /*long*/ event) { if (gdkEvents == null) { int length = GROW_SIZE; @@ -3089,6 +3103,7 @@ void putGdkEvents () { */ public boolean readAndDispatch () { checkDevice (); + runDeferredLayouts (); boolean events = false; events |= runSettings (); events |= runPopups (); @@ -3491,6 +3506,21 @@ boolean runDeferredEvents () { return run; } +boolean runDeferredLayouts () { + if (layoutDeferredCount != 0) { + Composite[] temp = layoutDeferred; + int count = layoutDeferredCount; + layoutDeferred = null; + layoutDeferredCount = 0; + for (int i = 0; i < count; i++) { + Composite comp = temp[i]; + if (!comp.isDisposed()) comp.setLayoutDeferred (false); + } + return true; + } + return false; +} + boolean runPopups () { if (popups == null) return false; boolean result = false; |