summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Northover <steve>2004-10-15 21:48:14 +0000
committerSteve Northover <steve>2004-10-15 21:48:14 +0000
commit9c87272537119e7f61e2165062d7df27e520d462 (patch)
tree6afd1ffcf99ee73d5f8b834c8657f785558d832a
parent351861b19af46a9f2811783c81c87f6e52323c58 (diff)
downloadeclipse.platform.swt-9c87272537119e7f61e2165062d7df27e520d462.tar.gz
eclipse.platform.swt-9c87272537119e7f61e2165062d7df27e520d462.tar.xz
eclipse.platform.swt-9c87272537119e7f61e2165062d7df27e520d462.zip
68876
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Sash.java32
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java69
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java71
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java88
5 files changed, 140 insertions, 121 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Sash.java
index 9adfac3c40..aa54a1eb84 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/carbon/org/eclipse/swt/widgets/Sash.java
@@ -110,6 +110,10 @@ public void addSelectionListener(SelectionListener listener) {
}
static int checkStyle (int style) {
+ /*
+ * Macintosh only supports smooth dragging.
+ */
+ style |= SWT.SMOOTH;
return checkBits (style, SWT.HORIZONTAL, SWT.VERTICAL, 0, 0, 0, 0);
}
@@ -210,13 +214,12 @@ int kEventMouseDown (int nextHandler, int theEvent, int userData) {
event.y = newY;
event.width = width;
event.height = height;
- event.detail = 0; //outResult [0] == OS.kMouseTrackingMouseDragged ? SWT.DRAG : 0;
sendEvent (SWT.Selection, event);
if (isDisposed ()) return result;
if (event.doit) {
setBounds (event.x, event.y, width, height);
- Shell shell = parent.getShell ();
- shell.update (true);
+ if (isDisposed ()) return result;
+ parent.update (true);
}
break;
}
@@ -274,23 +277,20 @@ int kEventTextInputUnicodeForKeyEvent (int nextHandler, int theEvent, int userDa
newY = Math.min (Math.max (0, lastY + yChange - startY), parentHeight - height);
}
if (newX == lastX && newY == lastY) return result;
-
- /* The event must be sent because its doit flag is used. */
Event event = new Event ();
- event.x = newX; event.y = newY;
- event.width = width; event.height = height;
+ event.x = newX;
+ event.y = newY;
+ event.width = width;
+ event.height = height;
sendEvent (SWT.Selection, event);
-
- /*
- * It is possible (but unlikely) that client code could have disposed
- * the widget in the selection event. If this happens end the processing
- * of this message by returning.
- */
if (isDisposed ()) break;
if (event.doit) {
- lastX = event.x; lastY = event.y;
- /* Adjust the pointer position */
- int cursorX = newX; int cursorY = newY;
+ setBounds (event.x, event.y, width, height);
+ if (isDisposed ()) break;
+ lastX = event.x;
+ lastY = event.y;
+ if (isDisposed ()) return result;
+ int cursorX = event.x, cursorY = event.y;
if ((style & SWT.VERTICAL) != 0) {
cursorY += height / 2;
} else {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
index 533e32ee59..6a4d175d71 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/common/org/eclipse/swt/SWT.java
@@ -696,6 +696,7 @@ public class SWT {
* <br>Note that this is a <em>HINT</em>.
* <p><b>Used By:</b><ul>
* <li><code>ProgressBar</code></li>
+ * <li><code>Sash</code></li>
* </ul></p>
*/
public static final int SMOOTH = 1 << 16;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
index 3713815078..d0e036a2e8 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Sash.java
@@ -138,6 +138,7 @@ void createHandle (int index) {
}
void drawBand (int x, int y, int width, int height) {
+ if ((style & SWT.SMOOTH) != 0) return;
int /*long*/ window = OS.GTK_WIDGET_WINDOW (parent.paintHandle());
if (window == 0) return;
byte [] bits = {-86, 85, -86, 85, -86, 85, -86, 85};
@@ -176,25 +177,27 @@ int /*long*/ gtk_button_press_event (int /*long*/ widget, int /*long*/ eventPtr)
int height = OS.GTK_WIDGET_HEIGHT (handle);
lastX = x - border;
lastY = y - border;
- /* The event must be sent because its doit flag is used. */
Event event = new Event ();
- event.detail = SWT.DRAG;
event.time = gdkEvent.time;
event.x = lastX;
event.y = lastY;
event.width = width;
event.height = height;
- /*
- * It is possible (but unlikely) that client code could have disposed
- * the widget in the selection event. If this happens end the processing
- * of this message by returning.
- */
+ if ((style & SWT.SMOOTH) == 0) {
+ event.detail = SWT.DRAG;
+ }
sendEvent (SWT.Selection, event);
if (isDisposed ()) return 0;
if (event.doit) {
dragging = true;
+ lastX = event.x;
+ lastY = event.y;
parent.update (true);
- drawBand (lastX = event.x, lastY = event.y, width, height);
+ drawBand (event.x, event.y, width, height);
+ if ((style & SWT.SMOOTH) != 0) {
+ setBounds (event.x, event.y, width, height);
+ // widget could be disposed at this point
+ }
}
return result;
}
@@ -209,7 +212,6 @@ int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ eventPt
dragging = false;
int width = OS.GTK_WIDGET_WIDTH (handle);
int height = OS.GTK_WIDGET_HEIGHT (handle);
- /* The event must be sent because its doit flag is used. */
Event event = new Event ();
event.time = gdkEvent.time;
event.x = lastX;
@@ -218,7 +220,13 @@ int /*long*/ gtk_button_release_event (int /*long*/ widget, int /*long*/ eventPt
event.height = height;
drawBand (lastX, lastY, width, height);
sendEvent (SWT.Selection, event);
- /* widget could be disposed here */
+ if (isDisposed ()) return result;
+ if (event.doit) {
+ if ((style & SWT.SMOOTH) != 0) {
+ setBounds (event.x, event.y, width, height);
+ // widget could be disposed at this point
+ }
+ }
return result;
}
@@ -283,23 +291,22 @@ int /*long*/ gtk_key_press_event (int /*long*/ widget, int /*long*/ eventPtr) {
event.height = height;
sendEvent (SWT.Selection, event);
if (ptrGrabResult == OS.GDK_GRAB_SUCCESS) OS.gdk_pointer_ungrab (OS.GDK_CURRENT_TIME);
-
- /*
- * It is possible (but unlikely) that client code could have disposed
- * the widget in the selection event. If this happens end the processing
- * of this message by returning.
- */
if (isDisposed ()) break;
+
if (event.doit) {
- lastX = event.x; lastY = event.y;
- /* Adjust the pointer position */
- int cursorX = newX; int cursorY = newY;
+ lastX = event.x;
+ lastY = event.y;
+ if ((style & SWT.SMOOTH) != 0) {
+ setBounds (event.x, event.y, width, height);
+ if (isDisposed ()) break;
+ }
+ int cursorX = event.x, cursorY = event.y;
if ((style & SWT.VERTICAL) != 0) {
cursorY += height / 2;
} else {
cursorX += width / 2;
}
- //OS.XWarpPointer (xDisplay, OS.None, xWindow, 0, 0, 0, 0, cursorX, cursorY);
+ display.setCursorLocation (parent.toDisplay (cursorX, cursorY));
}
break;
}
@@ -339,25 +346,27 @@ int /*long*/ gtk_motion_notify_event (int /*long*/ widget, int /*long*/ eventPtr
}
if (newX == lastX && newY == lastY) return 0;
drawBand (lastX, lastY, width, height);
- /* The event must be sent because its doit flag is used. */
+
Event event = new Event ();
- event.detail = SWT.DRAG;
event.time = gdkEvent.time;
event.x = newX;
event.y = newY;
event.width = width;
event.height = height;
- /*
- * It is possible (but unlikely) that client code could have disposed
- * the widget in the selection event. If this happens end the processing
- * of this message by returning.
- */
+ if ((style & SWT.SMOOTH) == 0) {
+ event.detail = SWT.DRAG;
+ }
sendEvent (SWT.Selection, event);
if (isDisposed ()) return 0;
if (event.doit) {
- lastX = event.x; lastY = event.y;
- parent.update (true);
- drawBand (lastX, lastY, width, height);
+ lastX = event.x;
+ lastY = event.y;
+ }
+ parent.update (true);
+ drawBand (lastX, lastY, width, height);
+ if ((style & SWT.SMOOTH) != 0) {
+ setBounds (lastX, lastY, width, height);
+ // widget could be disposed at this point
}
return result;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java
index 3c3bfb258b..75cf1a18be 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Sash.java
@@ -136,6 +136,7 @@ void createHandle (int index) {
handle = OS.XmCreateDrawingArea (parentHandle, null, argList, argList.length / 2);
}
void drawBand (int x, int y, int width, int height) {
+ if ((style & SWT.SMOOTH) != 0) return;
int display = OS.XtDisplay (parent.handle);
if (display == 0) return;
int window = OS.XtWindow (parent.handle);
@@ -237,25 +238,27 @@ int XButtonPress (int w, int client_data, int call_data, int continue_to_dispatc
OS.XtGetValues (handle, argList, argList.length / 2);
int border = argList [9], width = argList [5] + (border * 2), height = argList [7] + (border * 2);
lastX = ((short) argList [1]) - border; lastY = ((short) argList [3]) - border;
- /* The event must be sent because its doit flag is used. */
Event event = new Event ();
- event.detail = SWT.DRAG;
event.time = xEvent.time;
event.x = lastX;
event.y = lastY;
event.width = width;
event.height = height;
- /*
- * It is possible (but unlikely) that client code could have disposed
- * the widget in the selection event. If this happens end the processing
- * of this message by returning.
- */
+ if ((style & SWT.SMOOTH) == 0) {
+ event.detail = SWT.DRAG;
+ }
sendEvent (SWT.Selection, event);
if (isDisposed ()) return result;
if (event.doit) {
dragging = true;
- OS.XmUpdateDisplay (handle);
- drawBand (lastX = event.x, lastY = event.y, width, height);
+ lastX = event.x;
+ lastY = event.y;
+ parent.update (true);
+ drawBand (event.x, event.y, width, height);
+ if ((style & SWT.SMOOTH) != 0) {
+ setBounds (event.x, event.y, width, height);
+ // widget could be disposed at this point
+ }
}
return result;
}
@@ -271,7 +274,6 @@ int XButtonRelease (int w, int client_data, int call_data, int continue_to_dispa
OS.XtGetValues (handle, argList, argList.length / 2);
int border = argList [5];
int width = argList [1] + (border * 2), height = argList [3] + (border * 2);
- /* The event must be sent because its doit flag is used. */
Event event = new Event ();
event.time = xEvent.time;
event.x = lastX;
@@ -280,7 +282,13 @@ int XButtonRelease (int w, int client_data, int call_data, int continue_to_dispa
event.height = height;
drawBand (lastX, lastY, width, height);
sendEvent (SWT.Selection, event);
- /* widget could be disposed here */
+ if (isDisposed ()) return result;
+ if (event.doit) {
+ if ((style & SWT.SMOOTH) != 0) {
+ setBounds (event.x, event.y, width, height);
+ // widget could be disposed at this point
+ }
+ }
return result;
}
int xFocusIn (XFocusChangeEvent xEvent) {
@@ -347,8 +355,7 @@ int XKeyPress (int w, int client_data, int call_data, int continue_to_dispatch)
OS.None,
cursor,
OS.CurrentTime);
-
- /* The event must be sent because its doit flag is used. */
+
Event event = new Event ();
event.time = xEvent.time;
event.x = newX;
@@ -357,17 +364,16 @@ int XKeyPress (int w, int client_data, int call_data, int continue_to_dispatch)
event.height = height;
sendEvent (SWT.Selection, event);
if (ptrGrabResult == OS.GrabSuccess) OS.XUngrabPointer (xDisplay, OS.CurrentTime);
-
- /*
- * It is possible (but unlikely) that client code could have disposed
- * the widget in the selection event. If this happens end the processing
- * of this message by returning.
- */
if (isDisposed ()) break;
+
if (event.doit) {
- lastX = event.x; lastY = event.y;
- /* Adjust the pointer position */
- int cursorX = newX; int cursorY = newY;
+ lastX = event.x;
+ lastY = event.y;
+ if ((style & SWT.SMOOTH) != 0) {
+ setBounds (event.x, event.y, width, height);
+ if (isDisposed ()) break;
+ }
+ int cursorX = event.x, cursorY = event.y;
if ((style & SWT.VERTICAL) != 0) {
cursorY += height / 2;
} else {
@@ -406,25 +412,26 @@ int XPointerMotion (int w, int client_data, int call_data, int continue_to_dispa
}
if (newX == lastX && newY == lastY) return result;
drawBand (lastX, lastY, width, height);
- /* The event must be sent because its doit flag is used. */
Event event = new Event ();
- event.detail = SWT.DRAG;
event.time = xEvent.time;
event.x = newX;
event.y = newY;
event.width = width;
event.height = height;
- /*
- * It is possible (but unlikely) that client code could have disposed
- * the widget in the selection event. If this happens end the processing
- * of this message by returning.
- */
+ if ((style & SWT.SMOOTH) == 0) {
+ event.detail = SWT.DRAG;
+ }
sendEvent (SWT.Selection, event);
if (isDisposed ()) return result;
if (event.doit) {
- lastX = event.x; lastY = event.y;
- OS.XmUpdateDisplay (handle);
- drawBand (lastX, lastY, width, height);
+ lastX = event.x;
+ lastY = event.y;
+ }
+ parent.update (true);
+ drawBand (lastX, lastY, width, height);
+ if ((style & SWT.SMOOTH) != 0) {
+ setBounds (lastX, lastY, width, height);
+ // widget could be disposed at this point
}
return result;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
index 94ed4dabe4..a423f6bf6f 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Sash.java
@@ -22,7 +22,7 @@ import org.eclipse.swt.events.*;
* the parent control.
* <dl>
* <dt><b>Styles:</b></dt>
- * <dd>HORIZONTAL, VERTICAL</dd>
+ * <dd>HORIZONTAL, VERTICAL, SMOOTH</dd>
* <dt><b>Events:</b></dt>
* <dd>Selection</dd>
* </dl>
@@ -129,6 +129,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) {
}
void drawBand (int x, int y, int width, int height) {
+ if ((style & SWT.SMOOTH) != 0) return;
int hwndTrack = parent.handle;
byte [] bits = {-86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0, -86, 0, 85, 0};
int stippleBitmap = OS.CreateBitmap (8, 8, 1, 1, bits);
@@ -231,20 +232,18 @@ LRESULT WM_KEYDOWN (int wParam, int lParam) {
}
OS.SetCursorPos (cursorPt.x, cursorPt.y);
- /* The event must be sent because doit flag is used */
Event event = new Event ();
- event.x = newX; event.y = newY;
- event.width = width; event.height = height;
-
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the selection
- * event. If this happens, end the processing of the
- * Windows message by returning zero as the result of
- * the window proc.
- */
+ event.x = newX;
+ event.y = newY;
+ event.width = width;
+ event.height = height;
sendEvent (SWT.Selection, event);
if (isDisposed ()) return LRESULT.ZERO;
+ if (event.doit) {
+ if ((style & SWT.SMOOTH) != 0) {
+ setBounds (event.x, event.y, width, height);
+ }
+ }
return result;
}
return result;
@@ -279,21 +278,17 @@ LRESULT WM_LBUTTONDOWN (int wParam, int lParam) {
event.y = lastY;
event.width = width;
event.height = height;
- event.detail = SWT.DRAG;
-
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the selection
- * event. If this happens, end the processing of the
- * Windows message by returning zero as the result of
- * the window proc.
- */
+ if ((style & SWT.SMOOTH) == 0) {
+ event.detail = SWT.DRAG;
+ }
sendEvent (SWT.Selection, event);
if (isDisposed ()) return LRESULT.ZERO;
/* Draw the banding rectangle */
if (event.doit) {
dragging = true;
+ lastX = event.x;
+ lastY = event.y;
menuShell ().bringToTop ();
if (OS.IsWinCE) {
OS.UpdateWindow (hwndTrack);
@@ -301,7 +296,11 @@ LRESULT WM_LBUTTONDOWN (int wParam, int lParam) {
int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
OS.RedrawWindow (hwndTrack, null, 0, flags);
}
- drawBand (lastX = event.x, lastY = event.y, width, height);
+ drawBand (event.x, event.y, width, height);
+ if ((style & SWT.SMOOTH) != 0) {
+ setBounds (event.x, event.y, width, height);
+ // widget could be disposed at this point
+ }
}
return result;
}
@@ -323,9 +322,15 @@ LRESULT WM_LBUTTONUP (int wParam, int lParam) {
event.y = lastY;
event.width = width;
event.height = height;
- drawBand (lastX, lastY, width, height);
+ drawBand (event.x, event.y, width, height);
sendEvent (SWT.Selection, event);
- // widget could be disposed at this point
+ if (isDisposed ()) return result;
+ if (event.doit) {
+ if ((style & SWT.SMOOTH) != 0) {
+ setBounds (event.x, event.y, width, height);
+ // widget could be disposed at this point
+ }
+ }
return result;
}
@@ -362,28 +367,25 @@ LRESULT WM_MOUSEMOVE (int wParam, int lParam) {
event.y = newY;
event.width = width;
event.height = height;
- event.detail = SWT.DRAG;
-
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the selection
- * event. If this happens, end the processing of the
- * Windows message by returning zero as the result of
- * the window proc.
- */
+ if ((style & SWT.SMOOTH) == 0) {
+ event.detail = SWT.DRAG;
+ }
sendEvent (SWT.Selection, event);
if (isDisposed ()) return LRESULT.ZERO;
-
- /* Draw the banding rectangle */
if (event.doit) {
- lastX = event.x; lastY = event.y;
- if (OS.IsWinCE) {
- OS.UpdateWindow (hwndTrack);
- } else {
- int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
- OS.RedrawWindow (hwndTrack, null, 0, flags);
- }
- drawBand (lastX, lastY, width, height);
+ lastX = event.x;
+ lastY = event.y;
+ }
+ if (OS.IsWinCE) {
+ OS.UpdateWindow (hwndTrack);
+ } else {
+ int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
+ OS.RedrawWindow (hwndTrack, null, 0, flags);
+ }
+ drawBand (lastX, lastY, width, height);
+ if ((style & SWT.SMOOTH) != 0) {
+ setBounds (lastX, lastY, width, height);
+ // widget could be disposed at this point
}
return result;
}