summaryrefslogtreecommitdiffstats
path: root/bundles/org.eclipse.swt
diff options
context:
space:
mode:
authorSteve Northover <steve>2004-12-08 18:57:07 +0000
committerSteve Northover <steve>2004-12-08 18:57:07 +0000
commita281499d8873bd9607aed91d940442fee735d769 (patch)
treee1b67a0810e8f65f9498607309d1d5181f63db5e /bundles/org.eclipse.swt
parent12ece00abae016986e462d684584d1e2d896e24f (diff)
downloadeclipse.platform.swt-a281499d8873bd9607aed91d940442fee735d769.tar.gz
eclipse.platform.swt-a281499d8873bd9607aed91d940442fee735d769.tar.xz
eclipse.platform.swt-a281499d8873bd9607aed91d940442fee735d769.zip
topHandle changes
Diffstat (limited to 'bundles/org.eclipse.swt')
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java85
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java3
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java6
-rwxr-xr-xbundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java20
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java4
5 files changed, 67 insertions, 51 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
index 2d51d30492..76526c5591 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java
@@ -332,6 +332,14 @@ public void addTraverseListener (TraverseListener listener) {
addListener (SWT.Traverse,typedListener);
}
+int borderHandle () {
+ return handle;
+}
+
+void checkBorder () {
+ if (getBorderWidth () == 0) style &= ~SWT.BORDER;
+}
+
boolean checkHandle (int hwnd) {
return hwnd == handle;
}
@@ -481,6 +489,7 @@ void createWidget () {
subclass ();
setDefaultFont ();
checkMirrored ();
+ checkBorder ();
}
int defaultBackground () {
@@ -501,7 +510,7 @@ void deregister () {
}
void destroyWidget () {
- int hwnd = handle;
+ int hwnd = topHandle ();
releaseHandle ();
if (hwnd != 0) {
OS.DestroyWindow (hwnd);
@@ -511,10 +520,10 @@ void destroyWidget () {
void drawBackground (int hDC) {
RECT rect = new RECT ();
OS.GetClientRect (handle, rect);
- drawBackground (hDC, rect);
+ drawBackground (hDC, getBackgroundPixel (), rect);
}
-void drawBackground (int hDC, RECT rect) {
+void drawBackground (int hDC, int pixel, RECT rect) {
Control control = null;
if (OS.COMCTL32_MAJOR >= 6 && OS.IsAppThemed ()) {
control = findThemeControl ();
@@ -525,7 +534,6 @@ void drawBackground (int hDC, RECT rect) {
OS.SelectPalette (hDC, hPalette, false);
OS.RealizePalette (hDC);
}
- int pixel = getBackgroundPixel ();
int hBrush = findBrush (pixel);
OS.FillRect (hDC, rect, hBrush);
} else {
@@ -536,6 +544,10 @@ void drawBackground (int hDC, RECT rect) {
}
}
+void drawBackground (int hDC, RECT rect) {
+ drawBackground (hDC, getBackgroundPixel (), rect);
+}
+
void drawThemeBackground (int hDC, RECT rect) {
/* Do nothing */
}
@@ -711,10 +723,11 @@ int getBackgroundPixel () {
*/
public int getBorderWidth () {
checkWidget ();
- int bits1 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
+ int borderHandle = borderHandle ();
+ int bits1 = OS.GetWindowLong (borderHandle, OS.GWL_EXSTYLE);
if ((bits1 & OS.WS_EX_CLIENTEDGE) != 0) return OS.GetSystemMetrics (OS.SM_CXEDGE);
if ((bits1 & OS.WS_EX_STATICEDGE) != 0) return OS.GetSystemMetrics (OS.SM_CXBORDER);
- int bits2 = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int bits2 = OS.GetWindowLong (borderHandle, OS.GWL_STYLE);
if ((bits2 & OS.WS_BORDER) != 0) return OS.GetSystemMetrics (OS.SM_CXBORDER);
return 0;
}
@@ -736,7 +749,7 @@ public Rectangle getBounds () {
checkWidget ();
forceResize ();
RECT rect = new RECT ();
- OS.GetWindowRect (handle, rect);
+ OS.GetWindowRect (topHandle (), rect);
int hwndParent = parent == null ? 0 : parent.handle;
OS.MapWindowPoints (0, hwndParent, rect, 2);
int width = rect.right - rect.left;
@@ -867,7 +880,7 @@ public Point getLocation () {
checkWidget ();
forceResize ();
RECT rect = new RECT ();
- OS.GetWindowRect (handle, rect);
+ OS.GetWindowRect (topHandle (), rect);
int hwndParent = parent == null ? 0 : parent.handle;
OS.MapWindowPoints (0, hwndParent, rect, 2);
return new Point (rect.left, rect.top);
@@ -993,7 +1006,7 @@ public Point getSize () {
checkWidget ();
forceResize ();
RECT rect = new RECT ();
- OS.GetWindowRect (handle, rect);
+ OS.GetWindowRect (topHandle (), rect);
int width = rect.right - rect.left;
int height = rect.bottom - rect.top;
return new Point (width, height);
@@ -1356,12 +1369,12 @@ boolean mnemonicMatch (char key) {
*/
public void moveAbove (Control control) {
checkWidget ();
- int hwndAbove = OS.HWND_TOP;
+ int topHandle = topHandle (), hwndAbove = OS.HWND_TOP;
if (control != null) {
if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
if (parent != control.parent) return;
- int hwnd = control.handle;
- if (hwnd == 0 || hwnd == handle) return;
+ int hwnd = control.topHandle ();
+ if (hwnd == 0 || hwnd == topHandle) return;
hwndAbove = OS.GetWindow (hwnd, OS.GW_HWNDPREV);
/*
* Bug in Windows. For some reason, when GetWindow ()
@@ -1375,7 +1388,7 @@ public void moveAbove (Control control) {
}
}
int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
- SetWindowPos (handle, hwndAbove, 0, 0, 0, 0, flags);
+ SetWindowPos (topHandle, hwndAbove, 0, 0, 0, 0, flags);
}
/**
@@ -1400,15 +1413,15 @@ public void moveAbove (Control control) {
*/
public void moveBelow (Control control) {
checkWidget ();
- int hwndAbove = OS.HWND_BOTTOM;
+ int topHandle = topHandle (), hwndAbove = OS.HWND_BOTTOM;
if (control != null) {
if (control.isDisposed ()) error(SWT.ERROR_INVALID_ARGUMENT);
if (parent != control.parent) return;
- hwndAbove = control.handle;
+ hwndAbove = control.topHandle ();
}
- if (hwndAbove == 0 || hwndAbove == handle) return;
+ if (hwndAbove == 0 || hwndAbove == topHandle) return;
int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
- SetWindowPos (handle, hwndAbove, 0, 0, 0, 0, flags);
+ SetWindowPos (topHandle, hwndAbove, 0, 0, 0, 0, flags);
}
Accessible new_Accessible (Control control) {
@@ -1796,6 +1809,10 @@ public void removeTraverseListener(TraverseListener listener) {
eventTable.unhook (SWT.Traverse, listener);
}
+void showWidget (boolean visible) {
+ OS.ShowWindow (handle, visible ? OS.SW_SHOW : OS.SW_HIDE);
+}
+
boolean sendFocusEvent (int type) {
Shell shell = getShell ();
@@ -1903,6 +1920,7 @@ void setBounds (int x, int y, int width, int height, int flags) {
}
void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
+ int topHandle = topHandle ();
if (defer && parent != null) {
forceResize ();
WINDOWPOS [] lpwp = parent.lpwp;
@@ -1917,7 +1935,7 @@ void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
// int bits = OS.GetWindowLong (handle, OS.GWL_STYLE);
// if ((bits & OS.WS_CLIPSIBLINGS) == 0) flags |= OS.SWP_NOCOPYBITS;
// }
- SetWindowPos (handle, 0, x, y, width, height, flags);
+ SetWindowPos (topHandle, 0, x, y, width, height, flags);
} else {
int index = 0;
while (index < lpwp.length) {
@@ -1930,7 +1948,7 @@ void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
parent.lpwp = lpwp = newLpwp;
}
WINDOWPOS wp = new WINDOWPOS ();
- wp.hwnd = handle;
+ wp.hwnd = topHandle;
wp.x = x;
wp.y = y;
wp.cx = width;
@@ -1939,7 +1957,7 @@ void setBounds (int x, int y, int width, int height, int flags, boolean defer) {
lpwp [index] = wp;
}
} else {
- SetWindowPos (handle, 0, x, y, width, height, flags);
+ SetWindowPos (topHandle, 0, x, y, width, height, flags);
}
}
@@ -2420,11 +2438,6 @@ public void setVisible (boolean visible) {
if (((bits & OS.WS_VISIBLE) != 0) == visible) return;
}
if (visible) {
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the show
- * event. If this happens, just return.
- */
sendEvent (SWT.Show);
if (isDisposed ()) return;
}
@@ -2447,21 +2460,10 @@ public void setVisible (boolean visible) {
if (drawCount != 0) {
state = visible ? state & ~HIDDEN : state | HIDDEN;
} else {
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in an event
- * triggered by ShowWindow(). If this happens, just
- * return.
- */
- OS.ShowWindow (handle, visible ? OS.SW_SHOW : OS.SW_HIDE);
+ showWidget (visible);
if (isDisposed ()) return;
}
if (!visible) {
- /*
- * It is possible (but unlikely), that application
- * code could have disposed the widget in the hide
- * event. If this happens, just return.
- */
sendEvent (SWT.Hide);
if (isDisposed ()) return;
}
@@ -2583,6 +2585,10 @@ public Point toDisplay (Point point) {
return toDisplay (point.x, point.y);
}
+int topHandle () {
+ return handle;
+}
+
boolean translateAccelerator (MSG msg) {
return menuShell ().translateAccelerator (msg);
}
@@ -2986,10 +2992,11 @@ public boolean setParent (Composite parent) {
Menu [] menus = oldShell.findMenus (this);
fixChildren (newShell, oldShell, newDecorations, oldDecorations, menus);
}
- if (OS.SetParent (handle, parent.handle) == 0) return false;
+ int topHandle = topHandle ();
+ if (OS.SetParent (topHandle, parent.handle) == 0) return false;
this.parent = parent;
int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
- SetWindowPos (handle, OS.HWND_BOTTOM, 0, 0, 0, 0, flags);
+ SetWindowPos (topHandle, OS.HWND_BOTTOM, 0, 0, 0, 0, flags);
return true;
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
index 398faa7b16..b8c412993c 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolItem.java
@@ -322,8 +322,7 @@ public void setControl (Control control) {
}
Control oldControl = this.control, newControl = control;
int hwnd = parent.handle;
- int hwndChild = 0;
- if (newControl != null) hwndChild = control.handle;
+ int hwndChild = newControl != null ? control.topHandle () : 0;
REBARBANDINFO rbBand = new REBARBANDINFO ();
rbBand.cbSize = REBARBANDINFO.sizeof;
rbBand.fMask = OS.RBBIM_CHILD;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
index 49790ed4dc..366c2530b0 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ScrollBar.java
@@ -203,7 +203,7 @@ Rectangle getBounds () {
// checkWidget ();
parent.forceResize ();
RECT rect = new RECT ();
- OS.GetClientRect (parent.handle, rect);
+ OS.GetClientRect (parent.scrolledHandle (), rect);
int x = 0, y = 0, width, height;
if ((style & SWT.HORIZONTAL) != 0) {
y = rect.bottom - rect.top;
@@ -366,7 +366,7 @@ public Point getSize () {
checkWidget();
parent.forceResize ();
RECT rect = new RECT ();
- OS.GetClientRect (parent.handle, rect);
+ OS.GetClientRect (parent.scrolledHandle (), rect);
int width, height;
if ((style & SWT.HORIZONTAL) != 0) {
width = rect.right - rect.left;
@@ -426,7 +426,7 @@ public boolean getVisible () {
}
int hwndScrollBar () {
- return parent.handle;
+ return parent.scrolledHandle ();
}
/**
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
index bbfcfbd30f..f4647288e6 100755
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java
@@ -106,10 +106,11 @@ int callWindowProc (int hwnd, int msg, int wParam, int lParam) {
*/
public Rectangle computeTrim (int x, int y, int width, int height) {
checkWidget ();
+ int scrolledHandle = scrolledHandle ();
RECT rect = new RECT ();
OS.SetRect (rect, x, y, x + width, y + height);
- int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
- int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
+ int bits1 = OS.GetWindowLong (scrolledHandle, OS.GWL_STYLE);
+ int bits2 = OS.GetWindowLong (scrolledHandle, OS.GWL_EXSTYLE);
OS.AdjustWindowRectEx (rect, bits1, false, bits2);
if (horizontalBar != null) rect.bottom += OS.GetSystemMetrics (OS.SM_CYHSCROLL);
if (verticalBar != null) rect.right += OS.GetSystemMetrics (OS.SM_CXVSCROLL);
@@ -150,7 +151,8 @@ public Rectangle getClientArea () {
checkWidget ();
forceResize ();
RECT rect = new RECT ();
- OS.GetClientRect (handle, rect);
+ int scrolledHandle = scrolledHandle ();
+ OS.GetClientRect (scrolledHandle, rect);
return new Rectangle (0, 0, rect.right, rect.bottom);
}
@@ -193,6 +195,10 @@ void releaseWidget () {
super.releaseWidget ();
}
+int scrolledHandle () {
+ return handle;
+}
+
int widgetExtStyle () {
return super.widgetExtStyle ();
/*
@@ -234,7 +240,7 @@ LRESULT WM_HSCROLL (int wParam, int lParam) {
* both.
*/
if (horizontalBar != null && (lParam == 0 || lParam == handle)) {
- return wmScroll (horizontalBar, handle, OS.WM_HSCROLL, wParam, lParam);
+ return wmScroll (horizontalBar, (state & CANVAS) != 0, handle, OS.WM_HSCROLL, wParam, lParam);
}
return result;
}
@@ -327,14 +333,14 @@ LRESULT WM_VSCROLL (int wParam, int lParam) {
* both.
*/
if (verticalBar != null && (lParam == 0 || lParam == handle)) {
- return wmScroll (verticalBar, handle, OS.WM_VSCROLL, wParam, lParam);
+ return wmScroll (verticalBar, (state & CANVAS) != 0, handle, OS.WM_VSCROLL, wParam, lParam);
}
return result;
}
-LRESULT wmScroll (ScrollBar bar, int hwnd, int msg, int wParam, int lParam) {
+LRESULT wmScroll (ScrollBar bar, boolean update, int hwnd, int msg, int wParam, int lParam) {
LRESULT result = null;
- if ((state & CANVAS) != 0) {
+ if (update) {
int type = msg == OS.WM_HSCROLL ? OS.SB_HORZ : OS.SB_VERT;
SCROLLINFO info = new SCROLLINFO ();
info.cbSize = SCROLLINFO.sizeof;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
index bde12dd307..1df4d9f83b 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Spinner.java
@@ -240,6 +240,10 @@ void addVerifyListener (VerifyListener listener) {
addListener (SWT.Verify, typedListener);
}
+int borderHandle () {
+ return hwndText;
+}
+
public Point computeSize (int wHint, int hHint, boolean changed) {
checkWidget ();
int width = 0, height = 0;