diff options
author | Silenio Quarti | 2003-06-02 21:43:43 +0000 |
---|---|---|
committer | Silenio Quarti | 2003-06-02 21:43:43 +0000 |
commit | aa14e77e1ea6052ba1798c3e57a027ecd502ef50 (patch) | |
tree | c13437c95c39ec8b72252538971fac98ff20eb04 | |
parent | 34d8f908103f79ef01befd5c75eb28b372b686b0 (diff) | |
download | eclipse.platform.swt-aa14e77e1ea6052ba1798c3e57a027ecd502ef50.tar.gz eclipse.platform.swt-aa14e77e1ea6052ba1798c3e57a027ecd502ef50.tar.xz eclipse.platform.swt-aa14e77e1ea6052ba1798c3e57a027ecd502ef50.zip |
38331
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java | 23 | ||||
-rwxr-xr-x | bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java | 25 |
2 files changed, 27 insertions, 21 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java index 1cc5c982db..cae7e50568 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/GC.java @@ -310,7 +310,7 @@ public void dispose() { * Dispose the HDC. */ Device device = data.device; - drawable.internal_dispose_GC(handle, data); + if (drawable != null) drawable.internal_dispose_GC(handle, data); drawable = null; handle = 0; data.image = null; @@ -2482,4 +2482,25 @@ public static GC win32_new(Drawable drawable, GCData data) { return gc; } +/** + * Invokes platform specific functionality to wrap a graphics context. + * <p> + * <b>IMPORTANT:</b> This method is <em>not</em> part of the public + * API for <code>GC</code>. It is marked public only so that it + * can be shared within the packages provided by SWT. It is not + * available on all platforms, and should never be called from + * application code. + * </p> + * + * @param hDC the Windows HDC. + * @param data the data for the receiver. + * + * @return a new <code>GC</code> + */ +public static GC win32_new(int hDC, GCData data) { + GC gc = new GC(); + gc.init(null, data, hDC); + return gc; +} + } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java index 0f9b477053..834f5a1fd7 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/MenuItem.java @@ -960,26 +960,11 @@ LRESULT wmDrawChild (int wParam, int lParam) { DRAWITEMSTRUCT struct = new DRAWITEMSTRUCT (); OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof); if (image != null) { - /* - * This code intentionally commented. - */ -// GC gc = GC.win32_new (struct.hDC, null); -// gc.drawImage (image, struct.left, struct.top); - int hImage = image.handle; - switch (image.type) { - case SWT.BITMAP: - BITMAP bm = new BITMAP (); - OS.GetObject (hImage, BITMAP.sizeof, bm); - int hDC = OS.CreateCompatibleDC (struct.hDC); - int oldBitmap = OS.SelectObject (hDC, hImage); - OS.BitBlt (struct.hDC, struct.left, struct.top + 2, bm.bmWidth, bm.bmHeight, hDC, 0, 0, OS.SRCCOPY); - OS.SelectObject (hDC, oldBitmap); - OS.DeleteDC (hDC); - break; - case SWT.ICON: - OS.DrawIconEx (struct.hDC, struct.left, struct.top + 2, hImage, 0, 0, 0, 0, OS.DI_NORMAL); - break; - } + GCData data = new GCData(); + data.device = display; + GC gc = GC.win32_new (struct.hDC, data); + gc.drawImage (image, struct.left, struct.top + 2); + gc.dispose (); } return null; } |