summaryrefslogtreecommitdiffstats
path: root/bundles
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2009-10-20 18:24:26 +0000
committerSilenio Quarti <silenio>2009-10-20 18:24:26 +0000
commit63f803a737d416603789d25d5eba7834fce0e4c9 (patch)
tree11e8f83b9bbe9155b22756eb178ac70c2cdde90b /bundles
parent3f16243f15249d0c5b9acd8d735db116a6188e83 (diff)
downloadeclipse.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')
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Composite.java83
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java30
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java83
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java28
4 files changed, 160 insertions, 64 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;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
index e026007d46..a4f1b6eb66 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Composite.java
@@ -746,42 +746,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);
}
}
void manageChildren () {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
index 454bc76bd1..93d5eb6300 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Display.java
@@ -170,6 +170,10 @@ public class Display extends Device {
/* Display Shutdown */
Runnable [] disposeList;
+ /* Deferred Layout list */
+ Composite[] layoutDeferred;
+ int layoutDeferredCount;
+
/* System Tray */
Tray tray;
@@ -497,6 +501,15 @@ public void addFilter (int eventType, Listener listener) {
if (filterTable == null) filterTable = new EventTable ();
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;
+}
/**
* Adds the listener to the collection of listeners who will
* be notified when an event of the given type occurs. The event
@@ -2816,6 +2829,7 @@ void postEvent (Event event) {
*/
public boolean readAndDispatch () {
checkDevice ();
+ runDeferredLayouts ();
boolean events = runPopups ();
int xtContext = OS.XtDisplayToApplicationContext (xDisplay);
int status = OS.XtAppPending (xtContext);
@@ -3207,6 +3221,20 @@ boolean runFocusOutEvents () {
}
return true;
}
+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;