summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilenio Quarti <silenio>2007-02-23 18:17:33 +0000
committerSilenio Quarti <silenio>2007-02-23 18:17:33 +0000
commit128f1189a73a60197af2683c6e15c2a2112e6073 (patch)
tree3899eda91900d8f344cac5f0ef7c0baff6760869
parent3bcf21099cbb4ceaa65387ce65169aac9724f8c8 (diff)
downloadeclipse.platform.swt-128f1189a73a60197af2683c6e15c2a2112e6073.tar.gz
eclipse.platform.swt-128f1189a73a60197af2683c6e15c2a2112e6073.tar.xz
eclipse.platform.swt-128f1189a73a60197af2683c6e15c2a2112e6073.zip
avoiding OnRender() when calling UpdateLayout()
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Combo.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java4
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java42
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Group.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Scrollable.java8
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Shell.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableColumn.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableItem.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TreeItem.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java7
10 files changed, 59 insertions, 16 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Combo.java
index 4060d36536..354f9f5e65 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Combo.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Combo.java
@@ -269,7 +269,7 @@ public void addVerifyListener (VerifyListener listener) {
void addWidget () {
super.addWidget ();
if ((style & SWT.READ_ONLY) == 0) {
- OS.UIElement_UpdateLayout (handle);
+ updateLayout (handle);
int name = createDotNetString ("PART_EditableTextBox", false);
int template = OS.Control_Template (handle);
textHandle = OS.FrameworkTemplate_FindName (template, name, handle);
@@ -367,7 +367,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
OS.GCHandle_Free (size);
for (int i = 0; i < itemCount; i++) {
OS.Selector_SelectedIndex (handle, i);
- OS.UIElement_UpdateLayout (handle);
+ updateLayout (handle);
OS.UIElement_Measure (handle, availSize);
size = OS.UIElement_DesiredSize (handle);
width = Math.max (width, (int) OS.Size_Width (size));
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java
index 31e7cba10b..9c255ca256 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Composite.java
@@ -719,6 +719,10 @@ public void layout (Control [] changed) {
void OnRender(int drawingContext) {
if (isDisposed ()) return;
OS.SWTCanvas_Visual (handle, 0);
+ if (display.ignoreRender) {
+ display.addInvalidate (this);
+ return;
+ }
if (!hooks (SWT.Paint)) return;
int width = (int)OS.FrameworkElement_ActualWidth (handle);
int height = (int)OS.FrameworkElement_ActualHeight (handle);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java
index eee3f25810..a5796f89df 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Display.java
@@ -143,7 +143,10 @@ public class Display extends Device {
Object data;
String [] keys;
Object [] values;
-
+
+ Control[] invalidate;
+ boolean ignoreRender;
+
/* Key Mappings */
static final int [] [] KeyTable = {
@@ -433,6 +436,25 @@ public void addFilter (int eventType, Listener listener) {
filterTable.hook (eventType, listener);
}
+void addInvalidate (Control control) {
+ if (invalidate == null) invalidate = new Control [4];
+ int length = invalidate.length;
+ for (int i=0; i<length; i++) {
+ if (invalidate [i] == control) return;
+ }
+ int index = 0;
+ while (index < length) {
+ if (invalidate [index] == null) break;
+ index++;
+ }
+ if (index == length) {
+ Control [] temp = new Control [length + 4];
+ System.arraycopy (invalidate, 0, temp, 0, length);
+ invalidate = temp;
+ }
+ invalidate [index] = control;
+}
+
/**
* Adds the listener to the collection of listeners who will
* be notified when an event of the given type occurs. The event
@@ -1747,7 +1769,7 @@ public Point map (Control from, Control to, int x, int y) {
Shell shell = to.getShell ();
Point shellLocation = shell.getLocation ();
int point = OS.gcnew_Point (x - shellLocation.x, y - shellLocation.y);
- OS.UIElement_UpdateLayout (to.topHandle ());
+ to.updateLayout (to.topHandle ());
int newPoint = OS.UIElement_TranslatePoint (shell.shellHandle, point, to.topHandle ());
newX = (int) (OS.Point_X (newPoint) + 0.5);
newY = (int) (OS.Point_Y (newPoint) + 0.5);
@@ -1757,7 +1779,7 @@ public Point map (Control from, Control to, int x, int y) {
Shell shell = from.getShell ();
Point shellLocation = shell.getLocation ();
int point = OS.gcnew_Point (x, y);
- OS.UIElement_UpdateLayout (from.topHandle ());
+ from.updateLayout (from.topHandle ());
int newPoint = OS.UIElement_TranslatePoint (from.topHandle (), point, shell.shellHandle);
newX = (int) (OS.Point_X (newPoint) + 0.5) + shellLocation.x;
newY = (int) (OS.Point_Y (newPoint) + 0.5) + shellLocation.y;
@@ -2041,6 +2063,7 @@ void removePopup (Menu menu) {
public boolean readAndDispatch () {
checkDevice ();
// System.out.print("[");
+ runInvalidate ();
runPopups ();
try {
OS.DispatcherFrame_Continue(frame, true);
@@ -2311,6 +2334,19 @@ boolean runDeferredEvents () {
return true;
}
+boolean runInvalidate () {
+ if (invalidate == null) return false;
+ Control[] invalidate = this.invalidate;
+ this.invalidate = null;
+ for (int i = 0; i < invalidate.length; i++) {
+ Control control = invalidate [i];
+ if (control != null && !control.isDisposed()) {
+ control.redraw (true);
+ }
+ }
+ return true;
+}
+
boolean runPopups () {
if (popups == null) return false;
boolean result = false;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Group.java
index f323d7e848..976079a46e 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Group.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Group.java
@@ -117,7 +117,7 @@ public Rectangle computeTrim (int x, int y, int width, int height) {
double currentHeight = OS.FrameworkElement_Height (topHandle);
OS.FrameworkElement_Width (topHandle, 100);
OS.FrameworkElement_Height (topHandle, 100);
- OS.UIElement_UpdateLayout (topHandle);
+ updateLayout (topHandle);
int w = (int) OS.FrameworkElement_ActualWidth (topHandle);
int h = (int) OS.FrameworkElement_ActualHeight (topHandle);
int clientWidth = (int) OS.FrameworkElement_ActualWidth (clientHandle);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Scrollable.java
index f4b49493b1..ce4f60c447 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Scrollable.java
@@ -159,13 +159,9 @@ public Rectangle getClientArea () {
checkWidget ();
int clientHandle = clientHandle ();
int topHandle = topHandle ();
- boolean update = !OS.UIElement_IsMeasureValid (topHandle);
- if (update) OS.UIElement_UpdateLayout (topHandle);
+ updateLayout (topHandle);
int width = (int) OS.FrameworkElement_ActualWidth (clientHandle);
int height = (int) OS.FrameworkElement_ActualHeight (clientHandle);
- if (update && (state & CANVAS) != 0) {
- OS.UIElement_InvalidateVisual (handle);
- }
return new Rectangle (0, 0, width, height);
}
@@ -210,7 +206,7 @@ int getScrollBarHandle (int style) {
OS.GCHandle_Free (enumerator);
OS.GCHandle_Free (children);
} else {
- if (!OS.FrameworkElement_IsLoaded (handle)) OS.UIElement_UpdateLayout (handle);
+ if (!OS.FrameworkElement_IsLoaded (handle)) updateLayout (handle);
int scrollViewerType = OS.ScrollViewer_typeid ();
int scrollViewer = findScrollViewer (handle, scrollViewerType);
int template = OS.Control_Template (scrollViewer);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Shell.java
index 0353c0e74d..48392d189b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Shell.java
@@ -485,7 +485,7 @@ void createHandle () {
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget ();
if ((style & SWT.ON_TOP) != 0) return new Rectangle (x, y, width, height);
- OS.UIElement_UpdateLayout(shellHandle);
+ updateLayout (shellHandle);
int clientX = (int) OS.Window_Left (shellHandle);
int clientY = (int) OS.Window_Top (shellHandle);
int w = (int) OS.FrameworkElement_ActualWidth (shellHandle);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableColumn.java
index c6458c8d58..a825106fce 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableColumn.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableColumn.java
@@ -351,7 +351,7 @@ public int getWidth () {
}
int findPart (int part) {
- if (!OS.FrameworkElement_IsLoaded (headerHandle)) OS.UIElement_UpdateLayout (headerHandle);
+ if (!OS.FrameworkElement_IsLoaded (headerHandle)) updateLayout (headerHandle);
int contentPresenterType = OS.ContentPresenter_typeid ();
int contentPresenter = findStackPanel (headerHandle, contentPresenterType);
OS.GCHandle_Free (contentPresenterType);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableItem.java
index f5f9ca3950..bc3f2b9e3c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TableItem.java
@@ -201,7 +201,7 @@ int findRowPresenter (int current, int rowPresenterType) {
}
int findPart (int column, String partName) {
- if (!OS.FrameworkElement_IsLoaded (handle)) OS.UIElement_UpdateLayout (handle);
+ if (!OS.FrameworkElement_IsLoaded (handle)) updateLayout (handle);
if (!OS.FrameworkElement_IsLoaded (handle)) return 0;
int rowPresenterType = OS.GridViewRowPresenter_typeid ();
int rowPresenter = findRowPresenter (handle, rowPresenterType);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TreeItem.java
index 66c951160a..116ce70856 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TreeItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/TreeItem.java
@@ -456,7 +456,7 @@ public Rectangle getBounds (int index) {
if (!(0 <= index && index < parent.columnCount)) return new Rectangle (0, 0, 0, 0);
if (!OS.UIElement_IsVisible (handle)) return new Rectangle (0, 0, 0, 0);
int point = OS.gcnew_Point (0, 0);
- OS.UIElement_UpdateLayout (handle);
+ updateLayout (handle);
int contentPresenter = findContentPresenter (handle, index);
int location = OS.UIElement_TranslatePoint (contentPresenter, point, parent.handle);
int x = (int) OS.Point_X (location);
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java
index 7a145753fa..9f4984ff5b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/wpf/org/eclipse/swt/widgets/Widget.java
@@ -1390,4 +1390,11 @@ public String toString () {
return getName () + " {" + string + "}"; //$NON-NLS-1$ //$NON-NLS-2$
}
+void updateLayout (int updateHandle) {
+ boolean ignore = display.ignoreRender;
+ display.ignoreRender = true;
+ OS.UIElement_UpdateLayout (updateHandle);
+ display.ignoreRender = ignore;
+}
+
}