From 8dfb20d174695353a6328acf804b508442ac6b93 Mon Sep 17 00:00:00 2001 From: Heiko Klare Date: Sat, 30 May 2026 20:50:36 +0200 Subject: [PATCH] =?UTF-8?q?[Win32]=20Remove=20OS.IsAppThemed()=20=E2=80=94?= =?UTF-8?q?=20always=20true=20on=20Windows=2010+?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Windows Classic theme was removed in Windows 8. Since SWT targets Windows 10 and later, OS.IsAppThemed() unconditionally returns true, making every !OS.IsAppThemed() branch unreachable dead code and every if (OS.IsAppThemed()) guard reducible to its body. Removes all 70+ call sites across 21 widget files: - Dead !OS.IsAppThemed() else-branches are deleted (Classic theme fallbacks for DrawFrameControl, DFCS_* drawing, TBSTYLE_TRANSPARENT clearing, RTL text-clipping space-padding, ILC_MASK flag, etc.) - if (OS.IsAppThemed()) guards are unwrapped to unconditional code (Explorer theme setup in Tree/Table createHandle, themed checkbox image lists in Tree/Table, THEME_BACKGROUND checks, wmColorChild, WM_ERASEBKGND, WM_MOVE, wmNCPaint, widgetStyle bits, etc.) - Ternary OS.IsAppThemed() ? x : y expressions replaced with x (Group offsetY adjustments, ToolBar widgetStyle TBSTYLE_TRANSPARENT) - Stale TEMPORARY CODE commented-out blocks removed (CoolBar, TabFolder) - Group.fixText(boolean enabled): enabled parameter removed as it became unused once the Classic-theme space-padding workaround was deleted - OS.IsAppThemed() declaration removed from OS.java (and auto-generated os.c / os_stats.h updated accordingly) The following OS.java declarations became unused as a result and are also removed: - OS.DrawFrameControl() and its eleven associated constants (DFCS_BUTTONCHECK, DFCS_CHECKED, DFCS_FLAT, DFCS_INACTIVE, DFCS_PUSHED, DFCS_SCROLLDOWN, DFCS_SCROLLLEFT, DFCS_SCROLLRIGHT, DFCS_SCROLLUP, DFC_BUTTON, DFC_SCROLL) — only used in the non-themed checkbox and arrow-button drawing fallbacks - OS.ImageList_AddMasked() — only used in the non-themed setCheckboxImageList() path (replaced by ImageList_Add) - OS.BS_BITMAP and OS.BS_ICON — only used in the non-themed Button.enableWidget() RTL clipping workaround Co-Authored-By: Claude Sonnet 4.6 --- .../Eclipse SWT PI/win32/library/os.c | 39 --- .../Eclipse SWT PI/win32/library/os_stats.h | 3 - .../org/eclipse/swt/internal/win32/OS.java | 28 +-- .../win32/org/eclipse/swt/widgets/Button.java | 113 +++------ .../org/eclipse/swt/widgets/Composite.java | 68 +++--- .../org/eclipse/swt/widgets/Control.java | 50 ++-- .../org/eclipse/swt/widgets/CoolBar.java | 42 +--- .../org/eclipse/swt/widgets/Decorations.java | 11 +- .../org/eclipse/swt/widgets/ExpandBar.java | 2 +- .../win32/org/eclipse/swt/widgets/Group.java | 54 ++--- .../win32/org/eclipse/swt/widgets/Label.java | 4 +- .../org/eclipse/swt/widgets/MenuItem.java | 22 +- .../org/eclipse/swt/widgets/ProgressBar.java | 30 --- .../win32/org/eclipse/swt/widgets/Scale.java | 8 +- .../org/eclipse/swt/widgets/ScrollBar.java | 16 +- .../org/eclipse/swt/widgets/TabFolder.java | 6 +- .../win32/org/eclipse/swt/widgets/Table.java | 127 ++++------ .../org/eclipse/swt/widgets/TableColumn.java | 3 +- .../win32/org/eclipse/swt/widgets/Text.java | 34 ++- .../org/eclipse/swt/widgets/ToolBar.java | 227 +++++++----------- .../win32/org/eclipse/swt/widgets/Tree.java | 220 +++++++---------- .../org/eclipse/swt/widgets/TreeColumn.java | 21 +- .../win32/org/eclipse/swt/widgets/Widget.java | 26 +- 23 files changed, 369 insertions(+), 785 deletions(-) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c index 0f8d6efc34f..1d3bc521aa4 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os.c @@ -1421,21 +1421,6 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(DrawFocusRect) } #endif -#ifndef NO_DrawFrameControl -JNIEXPORT jboolean JNICALL OS_NATIVE(DrawFrameControl) - (JNIEnv *env, jclass that, jlong arg0, jobject arg1, jint arg2, jint arg3) -{ - RECT _arg1, *lparg1=NULL; - jboolean rc = 0; - OS_NATIVE_ENTER(env, that, DrawFrameControl_FUNC); - if (arg1) if ((lparg1 = getRECTFields(env, arg1, &_arg1)) == NULL) goto fail; - rc = (jboolean)DrawFrameControl((HDC)arg0, lparg1, arg2, arg3); -fail: - OS_NATIVE_EXIT(env, that, DrawFrameControl_FUNC); - return rc; -} -#endif - #ifndef NO_DrawIconEx JNIEXPORT jboolean JNICALL OS_NATIVE(DrawIconEx) (JNIEnv *env, jclass that, jlong arg0, jint arg1, jint arg2, jlong arg3, jint arg4, jint arg5, jint arg6, jlong arg7, jint arg8) @@ -3880,18 +3865,6 @@ JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1Add) } #endif -#ifndef NO_ImageList_1AddMasked -JNIEXPORT jint JNICALL OS_NATIVE(ImageList_1AddMasked) - (JNIEnv *env, jclass that, jlong arg0, jlong arg1, jint arg2) -{ - jint rc = 0; - OS_NATIVE_ENTER(env, that, ImageList_1AddMasked_FUNC); - rc = (jint)ImageList_AddMasked((HIMAGELIST)arg0, (HBITMAP)arg1, (COLORREF)arg2); - OS_NATIVE_EXIT(env, that, ImageList_1AddMasked_FUNC); - return rc; -} -#endif - #ifndef NO_ImageList_1BeginDrag JNIEXPORT jboolean JNICALL OS_NATIVE(ImageList_1BeginDrag) (JNIEnv *env, jclass that, jlong arg0, jint arg1, jint arg2, jint arg3) @@ -4442,18 +4415,6 @@ JNIEXPORT jboolean JNICALL OS_NATIVE(InvalidateRgn) } #endif -#ifndef NO_IsAppThemed -JNIEXPORT jboolean JNICALL OS_NATIVE(IsAppThemed) - (JNIEnv *env, jclass that) -{ - jboolean rc = 0; - OS_NATIVE_ENTER(env, that, IsAppThemed_FUNC); - rc = (jboolean)IsAppThemed(); - OS_NATIVE_EXIT(env, that, IsAppThemed_FUNC); - return rc; -} -#endif - #ifndef NO_IsHungAppWindow JNIEXPORT jboolean JNICALL OS_NATIVE(IsHungAppWindow) (JNIEnv *env, jclass that, jlong arg0) diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h index b9e62062010..57f63940b32 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/library/os_stats.h @@ -129,7 +129,6 @@ typedef enum { DragQueryFile_FUNC, DrawEdge_FUNC, DrawFocusRect_FUNC, - DrawFrameControl_FUNC, DrawIconEx_FUNC, DrawMenuBar_FUNC, DrawText_FUNC, @@ -304,7 +303,6 @@ typedef enum { INITCOMMONCONTROLSEX_1sizeof_FUNC, INPUT_1sizeof_FUNC, ImageList_1Add_FUNC, - ImageList_1AddMasked_FUNC, ImageList_1BeginDrag_FUNC, ImageList_1Create_FUNC, ImageList_1Destroy_FUNC, @@ -344,7 +342,6 @@ typedef enum { IntersectRect_FUNC, InvalidateRect_FUNC, InvalidateRgn_FUNC, - IsAppThemed_FUNC, IsDarkModeAvailable_FUNC, IsHungAppWindow_FUNC, IsIconic_FUNC, diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java index 347d8dcbb95..46b87be0b2b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java +++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java @@ -134,14 +134,12 @@ public class OS extends C { public static final int BST_INDETERMINATE = 0x2; public static final int BST_UNCHECKED = 0x0; public static final int BS_3STATE = 0x5; - public static final int BS_BITMAP = 0x80; public static final int BS_CENTER = 0x300; public static final int BS_CHECKBOX = 0x2; public static final int BS_COMMANDLINK = 0xe; public static final int BS_DEFPUSHBUTTON = 0x1; public static final int BS_FLAT = 0x8000; public static final int BS_GROUPBOX = 0x7; - public static final int BS_ICON = 0x40; public static final int BS_LEFT = 0x100; public static final int BS_MULTILINE = 0x2000; public static final int BS_NOTIFY = 0x4000; @@ -309,17 +307,7 @@ public class OS extends C { public static final int DCX_CACHE = 0x2; public static final int DEFAULT_CHARSET = 0x1; public static final int DEFAULT_GUI_FONT = 0x11; - public static final int DFCS_BUTTONCHECK = 0x0; - public static final int DFCS_CHECKED = 0x400; - public static final int DFCS_FLAT = 0x4000; - public static final int DFCS_INACTIVE = 0x100; - public static final int DFCS_PUSHED = 0x200; - public static final int DFCS_SCROLLDOWN = 0x1; - public static final int DFCS_SCROLLLEFT = 0x2; - public static final int DFCS_SCROLLRIGHT = 0x3; - public static final int DFCS_SCROLLUP = 0x0; - public static final int DFC_BUTTON = 0x4; - public static final int DFC_SCROLL = 0x3; + public static final int DIB_RGB_COLORS = 0x0; public static final int DI_NORMAL = 0x3; public static final int DI_NOMIRROR = 0x10; @@ -2605,11 +2593,7 @@ public static int HRESULT_FROM_WIN32(int x) { * @param lpRect flags=no_out */ public static final native boolean DrawFocusRect (long hDC, RECT lpRect); -/** - * @param hdc cast=(HDC) - * @param lprc flags=no_out - */ -public static final native boolean DrawFrameControl (long hdc, RECT lprc, int uType, int uState); + /** * @param hdc cast=(HDC) * @param hIcon cast=(HICON) @@ -3108,12 +3092,7 @@ public static int HRESULT_FROM_WIN32(int x) { * @param hbmMask cast=(HBITMAP) */ public static final native int ImageList_Add (long himl, long hbmImage, long hbmMask); -/** - * @param himl cast=(HIMAGELIST) - * @param hbmImage cast=(HBITMAP) - * @param crMask cast=(COLORREF) - */ -public static final native int ImageList_AddMasked (long himl, long hbmImage, int crMask); + /** @param himl cast=(HIMAGELIST) */ public static final native boolean ImageList_BeginDrag (long himl, int iTrack, int dxHotspot, int dyHotspot); public static final native long ImageList_Create (int cx, int cy, int flags, int cInitial, int cGrow); @@ -3254,7 +3233,6 @@ public static int HRESULT_FROM_WIN32(int x) { * @param hRgn cast=(HRGN) */ public static final native boolean InvalidateRgn (long hWnd, long hRgn, boolean bErase); -public static final native boolean IsAppThemed (); /** @method flags=no_gen */ public static final native boolean IsDarkModeAvailable(); /** @param hWnd cast=(HWND) */ diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java index 8a72095b366..06f5955b9de 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Button.java @@ -211,11 +211,6 @@ void _setText (String text) { * is disabled, the first pixel of the text is clipped. The fix * is to append a space to the text. */ - if ((style & SWT.RIGHT_TO_LEFT) != 0) { - if (!OS.IsAppThemed ()) { - text = OS.IsWindowEnabled (handle) ? text : text + " "; - } - } TCHAR buffer = new TCHAR (getCodePage (), text, true); OS.SetWindowText (handle, buffer); if ((state & HAS_AUTO_DIRECTION) != 0) { @@ -391,12 +386,6 @@ Point computeSizeInPixels (Point hintInPoints, int zoom, boolean changed) { } else { rect.right -= 6; } - if (!OS.IsAppThemed ()) { - rect.right -= 2; - if (isRadioOrCheck()) { - rect.right -= 2; - } - } } OS.DrawText (hDC, buffer, buffer.length, rect, flags); width += rect.right - rect.left; @@ -436,37 +425,31 @@ void createHandle () { super.createHandle (); parent.state &= ~IGNORE_WM_CHANGEUISTATE; - if (OS.IsAppThemed ()) { - /* Set the theme background. - * - * NOTE: On Vista this causes problems when the tab - * key is pressed for push buttons so disable the - * theme background drawing for these widgets for - * now. - */ - if ((style & (SWT.PUSH | SWT.TOGGLE)) == 0) { - state |= THEME_BACKGROUND; - } - - /* - * Bug in Windows. For some reason, the HBRUSH that - * is returned from WM_CTRLCOLOR is misaligned when - * the button uses it to draw. If the brush is a solid - * color, this does not matter. However, if the brush - * contains an image, the image is misaligned. The - * fix is to draw the background in WM_CTRLCOLOR. - * - * NOTE: For comctl32.dll 6.0 with themes disabled, - * drawing in WM_ERASEBKGND will draw on top of the - * text of the control. - */ - if ((style & SWT.RADIO) != 0) { - state |= DRAW_BACKGROUND; - } + /* Set the theme background. + * + * NOTE: On Vista this causes problems when the tab + * key is pressed for push buttons so disable the + * theme background drawing for these widgets for + * now. + */ + if ((style & (SWT.PUSH | SWT.TOGGLE)) == 0) { + state |= THEME_BACKGROUND; + } - useDarkModeExplorerTheme = display.useDarkModeExplorerTheme; - maybeEnableDarkSystemTheme(); + /* + * Bug in Windows. For some reason, the HBRUSH that + * is returned from WM_CTRLCOLOR is misaligned when + * the button uses it to draw. If the brush is a solid + * color, this does not matter. However, if the brush + * contains an image, the image is misaligned. The + * fix is to draw the background in WM_CTRLCOLOR. + */ + if ((style & SWT.RADIO) != 0) { + state |= DRAW_BACKGROUND; } + + useDarkModeExplorerTheme = display.useDarkModeExplorerTheme; + maybeEnableDarkSystemTheme(); } private boolean customBackgroundDrawing() { @@ -498,22 +481,6 @@ int defaultForeground () { void enableWidget (boolean enabled) { super.enableWidget (enabled); /* - * Bug in Windows. When a Button control is right-to-left and - * is disabled, the first pixel of the text is clipped. The fix - * is to append a space to the text. - */ - if ((style & SWT.RIGHT_TO_LEFT) != 0) { - if (!OS.IsAppThemed ()) { - int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); - boolean hasImage = (bits & (OS.BS_BITMAP | OS.BS_ICON)) != 0; - if (!hasImage) { - String string = enabled ? text : text + " "; - TCHAR buffer = new TCHAR (getCodePage (), string, true); - OS.SetWindowText (handle, buffer); - } - } - } - /* * Bug in Windows. When a button has the style BS_CHECKBOX * or BS_RADIOBUTTON, is checked, and is displaying both an * image and some text, when BCM_SETIMAGELIST is used to @@ -1257,9 +1224,7 @@ LRESULT WM_UPDATEUISTATE (long wParam, long lParam) { boolean redraw = findImageControl () != null; if (!redraw) { if ((state & THEME_BACKGROUND) != 0) { - if (OS.IsAppThemed ()) { - redraw = findThemeControl () != null; - } + redraw = findThemeControl () != null; } if (!redraw) redraw = findBackgroundControl () != null; } @@ -1311,12 +1276,8 @@ private int getCheckboxTextOffset(long hdc) { SIZE size = new SIZE(); - if (OS.IsAppThemed ()) { - OS.GetThemePartSize(display.hButtonTheme(nativeZoom), hdc, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, null, OS.TS_TRUE, size); - result += size.cx; - } else { - result += DPIUtil.pointToPixel(13, nativeZoom); - } + OS.GetThemePartSize(display.hButtonTheme(nativeZoom), hdc, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, null, OS.TS_TRUE, size); + result += size.cx; // Windows uses half width of '0' as checkbox-to-text distance. OS.GetTextExtentPoint32(hdc, STRING_WITH_ZERO_CHAR, 1, size); @@ -1540,24 +1501,10 @@ LRESULT wmDrawChild (long wParam, long lParam) { OS.MoveMemory (struct, lParam, DRAWITEMSTRUCT.sizeof); RECT rect = new RECT (); OS.SetRect (rect, struct.left, struct.top, struct.right, struct.bottom); - if (OS.IsAppThemed ()) { - boolean pressed = ((struct.itemState & OS.ODS_SELECTED) != 0); - boolean enabled = getEnabled (); - int iStateId = getThemeStateId(style, pressed, enabled); - OS.DrawThemeBackground (display.hScrollBarThemeAuto(nativeZoom), struct.hDC, OS.SBP_ARROWBTN, iStateId, rect, null); - } else { - int uState = OS.DFCS_SCROLLLEFT; - switch (style & (SWT.UP | SWT.DOWN | SWT.LEFT | SWT.RIGHT)) { - case SWT.UP: uState = OS.DFCS_SCROLLUP; break; - case SWT.DOWN: uState = OS.DFCS_SCROLLDOWN; break; - case SWT.LEFT: uState = OS.DFCS_SCROLLLEFT; break; - case SWT.RIGHT: uState = OS.DFCS_SCROLLRIGHT; break; - } - if (!getEnabled ()) uState |= OS.DFCS_INACTIVE; - if ((style & SWT.FLAT) == SWT.FLAT) uState |= OS.DFCS_FLAT; - if ((struct.itemState & OS.ODS_SELECTED) != 0) uState |= OS.DFCS_PUSHED; - OS.DrawFrameControl (struct.hDC, rect, OS.DFC_SCROLL, uState); - } + boolean pressed = ((struct.itemState & OS.ODS_SELECTED) != 0); + boolean enabled = getEnabled (); + int iStateId = getThemeStateId(style, pressed, enabled); + OS.DrawThemeBackground (display.hScrollBarThemeAuto(nativeZoom), struct.hDC, OS.SBP_ARROWBTN, iStateId, rect, null); return null; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java index bda694137da..2a3285275b1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java @@ -1445,23 +1445,21 @@ LRESULT WM_NCHITTEST (long wParam, long lParam) { * and the point is not in the client area, and redraw * the trim, which somehow fixes the next WM_NCHITTEST. */ - if (OS.IsAppThemed ()) { - if ((state & CANVAS)!= 0) { - long code = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam); - if (code == OS.HTCLIENT) { - RECT rect = new RECT (); - OS.GetClientRect (handle, rect); - POINT pt = new POINT (); - pt.x = OS.GET_X_LPARAM (lParam); - pt.y = OS.GET_Y_LPARAM (lParam); - OS.MapWindowPoints (0, handle, pt, 1); - if (!OS.PtInRect (rect, pt)) { - int flags = OS.RDW_FRAME | OS.RDW_INVALIDATE; - OS.RedrawWindow (handle, null, 0, flags); - } + if ((state & CANVAS)!= 0) { + long code = callWindowProc (handle, OS.WM_NCHITTEST, wParam, lParam); + if (code == OS.HTCLIENT) { + RECT rect = new RECT (); + OS.GetClientRect (handle, rect); + POINT pt = new POINT (); + pt.x = OS.GET_X_LPARAM (lParam); + pt.y = OS.GET_Y_LPARAM (lParam); + OS.MapWindowPoints (0, handle, pt, 1); + if (!OS.PtInRect (rect, pt)) { + int flags = OS.RDW_FRAME | OS.RDW_INVALIDATE; + OS.RedrawWindow (handle, null, 0, flags); } - return new LRESULT (code); } + return new LRESULT (code); } return result; } @@ -1752,9 +1750,7 @@ LRESULT WM_SIZE (long wParam, long lParam) { } } } - if (OS.IsAppThemed ()) { - if (findThemeControl () != null) redrawChildren (); - } + if (findThemeControl () != null) redrawChildren (); } /* Resize the embedded window */ @@ -1832,26 +1828,24 @@ LRESULT wmNCPaint (long hwnd, long wParam, long lParam) { if (result != null) return result; long borderHandle = borderHandle (); if ((state & CANVAS) != 0 || (hwnd == borderHandle && handle != borderHandle)) { - if (OS.IsAppThemed ()) { - int bits1 = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE); - if ((bits1 & OS.WS_EX_CLIENTEDGE) != 0) { - long code = 0; - int bits2 = OS.GetWindowLong (hwnd, OS.GWL_STYLE); - if ((bits2 & (OS.WS_HSCROLL | OS.WS_VSCROLL)) != 0) { - code = callWindowProc (hwnd, OS.WM_NCPAINT, wParam, lParam); - } - long hDC = OS.GetWindowDC (hwnd); - RECT rect = new RECT (); - OS.GetWindowRect (hwnd, rect); - rect.right -= rect.left; - rect.bottom -= rect.top; - rect.left = rect.top = 0; - int border = getSystemMetrics (OS.SM_CXEDGE); - OS.ExcludeClipRect (hDC, border, border, rect.right - border, rect.bottom - border); - OS.DrawThemeBackground(display.hEditTheme(nativeZoom), hDC, OS.EP_EDITTEXT, OS.ETS_NORMAL, rect, null); - OS.ReleaseDC (hwnd, hDC); - return new LRESULT (code); + int bits1 = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE); + if ((bits1 & OS.WS_EX_CLIENTEDGE) != 0) { + long code = 0; + int bits2 = OS.GetWindowLong (hwnd, OS.GWL_STYLE); + if ((bits2 & (OS.WS_HSCROLL | OS.WS_VSCROLL)) != 0) { + code = callWindowProc (hwnd, OS.WM_NCPAINT, wParam, lParam); } + long hDC = OS.GetWindowDC (hwnd); + RECT rect = new RECT (); + OS.GetWindowRect (hwnd, rect); + rect.right -= rect.left; + rect.bottom -= rect.top; + rect.left = rect.top = 0; + int border = getSystemMetrics (OS.SM_CXEDGE); + OS.ExcludeClipRect (hDC, border, border, rect.right - border, rect.bottom - border); + OS.DrawThemeBackground(display.hEditTheme(nativeZoom), hDC, OS.EP_EDITTEXT, OS.ETS_NORMAL, rect, null); + OS.ReleaseDC (hwnd, hDC); + return new LRESULT (code); } } return result; 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 15873a83b54..a2877b380e2 100644 --- 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 @@ -922,12 +922,10 @@ void drawBackground (long hDC, RECT rect, int pixel, int tx, int ty) { } if (pixel == -1) { if ((state & THEME_BACKGROUND) != 0) { - if (OS.IsAppThemed ()) { - control = findThemeControl (); - if (control != null) { - fillThemeBackground (hDC, control, rect); - return; - } + control = findThemeControl (); + if (control != null) { + fillThemeBackground (hDC, control, rect); + return; } } } @@ -2547,10 +2545,8 @@ boolean redrawChildren () { Control control = findBackgroundControl (); if (control == null) { if ((state & THEME_BACKGROUND) != 0) { - if (OS.IsAppThemed ()) { - OS.InvalidateRect (handle, null, true); - return true; - } + OS.InvalidateRect (handle, null, true); + return true; } } else { if (control.backgroundImage != null) { @@ -3274,9 +3270,7 @@ void setBoundsInPixels (int x, int y, int width, int height, int flags, boolean if (backgroundImage == null) flags |= OS.SWP_NOCOPYBITS; } else { if (OS.GetWindow (handle, OS.GW_CHILD) == 0) { - if (OS.IsAppThemed ()) { - if (findThemeControl () != null) flags |= OS.SWP_NOCOPYBITS; - } + if (findThemeControl () != null) flags |= OS.SWP_NOCOPYBITS; } } long topHandle = topHandle (); @@ -5201,9 +5195,7 @@ LRESULT WM_ERASEBKGND (long wParam, long lParam) { if (findImageControl () != null) return LRESULT.ONE; } if ((state & THEME_BACKGROUND) != 0) { - if (OS.IsAppThemed ()) { - if (findThemeControl () != null) return LRESULT.ONE; - } + if (findThemeControl () != null) return LRESULT.ONE; } return null; } @@ -5558,10 +5550,8 @@ LRESULT WM_MOVE (long wParam, long lParam) { if (this != getShell ()) redrawChildren (); } else { if ((state & THEME_BACKGROUND) != 0) { - if (OS.IsAppThemed ()) { - if (OS.IsWindowVisible (handle)) { - if (findThemeControl () != null) redrawChildren (); - } + if (OS.IsWindowVisible (handle)) { + if (findThemeControl () != null) redrawChildren (); } } } @@ -5963,17 +5953,15 @@ LRESULT wmColorChild (long wParam, long lParam) { Control control = findBackgroundControl (); if (control == null) { if ((state & THEME_BACKGROUND) != 0) { - if (OS.IsAppThemed ()) { - control = findThemeControl (); - if (control != null) { - RECT rect = new RECT (); - OS.GetClientRect (handle, rect); - OS.SetTextColor (wParam, getForegroundPixel ()); - OS.SetBkColor (wParam, getBackgroundPixel ()); - fillThemeBackground (wParam, control, rect); - OS.SetBkMode (wParam, OS.TRANSPARENT); - return new LRESULT (OS.GetStockObject (OS.NULL_BRUSH)); - } + control = findThemeControl (); + if (control != null) { + RECT rect = new RECT (); + OS.GetClientRect (handle, rect); + OS.SetTextColor (wParam, getForegroundPixel ()); + OS.SetBkColor (wParam, getBackgroundPixel ()); + fillThemeBackground (wParam, control, rect); + OS.SetBkMode (wParam, OS.TRANSPARENT); + return new LRESULT (OS.GetStockObject (OS.NULL_BRUSH)); } } if (foreground == -1) return null; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java index afca95dca5f..481b272754c 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/CoolBar.java @@ -362,13 +362,11 @@ void destroyItem (CoolItem item) { @Override void drawThemeBackground (long hDC, long hwnd, RECT rect) { - if (OS.IsAppThemed ()) { - if (background == -1 && (style & SWT.FLAT) != 0) { - Control control = findBackgroundControl (); - if (control != null && control.backgroundImage != null) { - fillBackground (hDC, control.getBackgroundPixel (), rect); - return; - } + if (background == -1 && (style & SWT.FLAT) != 0) { + Control control = findBackgroundControl (); + if (control != null && control.backgroundImage != null) { + fillBackground (hDC, control.getBackgroundPixel (), rect); + return; } } RECT rect2 = new RECT (); @@ -1029,29 +1027,6 @@ LRESULT WM_COMMAND (long wParam, long lParam) { return LRESULT.ZERO; } -@Override -LRESULT WM_ERASEBKGND (long wParam, long lParam) { - LRESULT result = super.WM_ERASEBKGND (wParam, lParam); - /* - * Feature in Windows. For some reason, Windows - * does not fully erase the area that the cool bar - * occupies when the size of the cool bar is larger - * than the space occupied by the cool bar items. - * The fix is to erase the cool bar background. - * - * NOTE: On versions of Windows prior to XP, for - * some reason, the cool bar draws separators in - * WM_ERASEBKGND. Therefore it is essential to run - * the cool bar window proc after the background has - * been erased. - */ - if (!OS.IsAppThemed ()) { - drawBackground (wParam); - return null; - } - return result; -} - @Override LRESULT WM_NOTIFY (long wParam, long lParam) { /* @@ -1110,12 +1085,7 @@ LRESULT WM_SIZE (long wParam, long lParam) { if (code == 0) return LRESULT.ZERO; return new LRESULT (code); } - //TEMPORARY CODE -// if (OS.IsAppThemed ()) { -// if (background == -1 && (style & SWT.FLAT) == 0) { -// OS.InvalidateRect (handle, null, true); -// } -// } + return super.WM_SIZE (wParam, lParam); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java index 734a266b700..985899fbc2d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Decorations.java @@ -1319,16 +1319,7 @@ public void setVisible (boolean visible) { oldWidth = rect.width; oldHeight = rect.height; } - /* - * Bug in Windows. On Vista using the Classic theme, - * when the window is hung and UpdateWindow() is called, - * nothing is drawn, and outstanding WM_PAINTs are cleared. - * This causes pixel corruption. The fix is to avoid calling - * update on hung windows. - */ - if (OS.IsAppThemed () || !OS.IsHungAppWindow (handle)) { - OS.UpdateWindow (handle); - } + OS.UpdateWindow (handle); } } else { if (OS.IsIconic (handle)) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java index 073afd3700e..39aa8d40e5a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ExpandBar.java @@ -427,7 +427,7 @@ boolean isAppThemed () { if (background != -1) return false; if (foreground != -1) return false; if (hFont != 0) return false; - return OS.IsAppThemed (); + return true; } void layoutItems (int index, boolean setScrollbar) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java index 3872a19efb3..2802ca63ad9 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Group.java @@ -144,7 +144,7 @@ Point computeSizeInPixels (Point hintInPoints, int zoom, boolean changed) { Point size = super.computeSizeInPixels (hintInPoints, zoom, changed); int length = text.length (); if (length != 0) { - String string = fixText (false); + String string = fixText (); /* * If the group has text, and the text is wider than the @@ -160,8 +160,7 @@ Point computeSizeInPixels (Point hintInPoints, int zoom, boolean changed) { OS.DrawText (hDC, buffer, buffer.length, rect, flags); if (newFont != 0) OS.SelectObject (hDC, oldFont); OS.ReleaseDC (handle, hDC); - int offsetY = OS.IsAppThemed () ? 0 : 1; - size.x = Math.max (size.x, rect.right - rect.left + CLIENT_INSET * 6 + offsetY); + size.x = Math.max (size.x, rect.right - rect.left + CLIENT_INSET * 6); } return size; } @@ -177,11 +176,10 @@ Point computeSizeInPixels (Point hintInPoints, int zoom, boolean changed) { OS.GetTextMetrics (hDC, tm); if (newFont != 0) OS.SelectObject (hDC, oldFont); OS.ReleaseDC (handle, hDC); - int offsetY = OS.IsAppThemed () ? 0 : 1; trim.x -= CLIENT_INSET; - trim.y -= tm.tmHeight + offsetY; + trim.y -= tm.tmHeight; trim.width += CLIENT_INSET * 2; - trim.height += tm.tmHeight + CLIENT_INSET + offsetY; + trim.height += tm.tmHeight + CLIENT_INSET; return trim; } @@ -206,12 +204,7 @@ void createHandle () { @Override void enableWidget (boolean enabled) { super.enableWidget (enabled); - /* - * Bug in Windows. When a group control is right-to-left and - * is disabled, the first pixel of the text is clipped. The - * fix is to add a space to both sides of the text. - */ - String string = fixText (enabled); + String string = fixText (); if (string != null) { TCHAR buffer = new TCHAR (getCodePage (), string, true); OS.SetWindowText (handle, buffer); @@ -221,19 +214,10 @@ void enableWidget (boolean enabled) { } } -String fixText (boolean enabled) { - /* - * Bug in Windows. When a group control is right-to-left and - * is disabled, the first pixel of the text is clipped. The - * fix is to add a space to both sides of the text. - */ +String fixText () { if (text.length() == 0) return null; if ((style & SWT.RIGHT_TO_LEFT) != 0) { - String string = null; - if (!enabled && !OS.IsAppThemed ()) { - string = " " + text + " "; - } - return (style & SWT.FLIP_TEXT_DIRECTION) == 0 ? string : string != null ? LRE + string : LRE + text; + return (style & SWT.FLIP_TEXT_DIRECTION) == 0 ? null : LRE + text; } else if ((style & SWT.FLIP_TEXT_DIRECTION) != 0) { return RLE + text; } @@ -253,8 +237,7 @@ String fixText (boolean enabled) { OS.GetTextMetrics (hDC, tm); if (newFont != 0) OS.SelectObject (hDC, oldFont); OS.ReleaseDC (handle, hDC); - int offsetY = OS.IsAppThemed () ? 0 : 1; - int x = CLIENT_INSET, y = tm.tmHeight + offsetY; + int x = CLIENT_INSET, y = tm.tmHeight; int width = Math.max (0, rect.right - CLIENT_INSET * 2); int height = Math.max (0, rect.bottom - y - CLIENT_INSET); return new Rectangle (x, y, width, height); @@ -418,7 +401,7 @@ public void setText (String string) { if (string == null) error (SWT.ERROR_NULL_ARGUMENT); text = string; if ((state & HAS_AUTO_DIRECTION) == 0 || !updateTextDirection (AUTO_TEXT_DIRECTION)) { - string = fixText (OS.IsWindowEnabled (handle)); + string = fixText (); TCHAR buffer = new TCHAR (getCodePage (), string == null ? text : string, true); OS.SetWindowText (handle, buffer); } @@ -427,7 +410,7 @@ public void setText (String string) { @Override boolean updateTextDirection(int textDirection) { if (super.updateTextDirection(textDirection)) { - String string = fixText (OS.IsWindowEnabled (handle)); + String string = fixText (); TCHAR buffer = new TCHAR (getCodePage (), string == null ? text : string, true); OS.SetWindowText (handle, buffer); return true; @@ -510,7 +493,7 @@ LRESULT WM_PAINT (long wParam, long lParam) { LRESULT result = super.WM_PAINT(wParam, lParam); if (hasCustomForeground() && text.length () != 0) { - String string = fixText (false); + String string = fixText (); char [] buffer = (string == null ? text : string).toCharArray (); // We cannot use BeginPaint and EndPaint, because that removes the group border @@ -553,13 +536,10 @@ LRESULT WM_PRINTCLIENT (long wParam, long lParam) { * BS_GROUP, there is no problem. The fix is to save * and restore the current font. */ - if (OS.IsAppThemed ()) { - int nSavedDC = OS.SaveDC (wParam); - long code = callWindowProc (handle, OS.WM_PRINTCLIENT, wParam, lParam); - OS.RestoreDC (wParam, nSavedDC); - return new LRESULT (code); - } - return result; + int nSavedDC = OS.SaveDC (wParam); + long code = callWindowProc (handle, OS.WM_PRINTCLIENT, wParam, lParam); + OS.RestoreDC (wParam, nSavedDC); + return new LRESULT (code); } @Override @@ -577,9 +557,7 @@ LRESULT WM_UPDATEUISTATE (long wParam, long lParam) { boolean redraw = findImageControl () != null; if (!redraw) { if ((state & THEME_BACKGROUND) != 0) { - if (OS.IsAppThemed ()) { - redraw = findThemeControl () != null; - } + redraw = findThemeControl () != null; } if (!redraw) redraw = findBackgroundControl () != null; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java index 70c1835b706..4f6b9f74356 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Label.java @@ -519,9 +519,7 @@ LRESULT WM_UPDATEUISTATE (long wParam, long lParam) { boolean redraw = findImageControl () != null; if (!redraw) { if ((state & THEME_BACKGROUND) != 0) { - if (OS.IsAppThemed ()) { - redraw = findThemeControl () != null; - } + redraw = findThemeControl () != null; } } if (redraw) { 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 1f8daf090d9..f66a50c2bdc 100644 --- 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 @@ -802,19 +802,15 @@ private void updateImage () { if (parent.needsMenuCallback()) { info.hbmpItem = OS.HBMMENU_CALLBACK; } else { - if (OS.IsAppThemed ()) { - if (hBitmap != 0) OS.DeleteObject (hBitmap); - hBitmap = getMenuItemIconBitmapHandle(image); - if ((style & (SWT.CHECK | SWT.RADIO)) != 0 && CUSTOM_SELECTION_IMAGE > 0) { - info.fMask |= OS.MIIM_CHECKMARKS; - info.hbmpUnchecked = hBitmap; - info.hbmpChecked = getMenuItemIconSelectedBitmapHandle(); - } - else { - info.hbmpItem = hBitmap; - } - } else { - info.hbmpItem = image != null ? OS.HBMMENU_CALLBACK : 0; + if (hBitmap != 0) OS.DeleteObject (hBitmap); + hBitmap = getMenuItemIconBitmapHandle(image); + if ((style & (SWT.CHECK | SWT.RADIO)) != 0 && CUSTOM_SELECTION_IMAGE > 0) { + info.fMask |= OS.MIIM_CHECKMARKS; + info.hbmpUnchecked = hBitmap; + info.hbmpChecked = getMenuItemIconSelectedBitmapHandle(); + } + else { + info.hbmpItem = hBitmap; } } long hMenu = parent.handle; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java index 9a3d4f484e6..e0521106f39 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ProgressBar.java @@ -412,36 +412,6 @@ LRESULT WM_GETDLGCODE (long wParam, long lParam) { LRESULT WM_SIZE (long wParam, long lParam) { LRESULT result = super.WM_SIZE (wParam, lParam); if (result != null) return result; - /* - * Feature in Windows. When a progress bar with the style - * PBS_MARQUEE becomes too small, the animation (currently - * a small bar moving from right to left) does not have - * enough space to draw. The result is that the progress - * bar does not appear to be moving. The fix is to detect - * this case, clear the PBS_MARQUEE style and emulate the - * animation using PBM_STEPIT. - * - * NOTE: This only happens on Window XP. - */ - if ((style & SWT.INDETERMINATE) != 0) { - if (!OS.IsAppThemed()) { - forceResize (); - RECT rect = new RECT (); - OS.GetClientRect (handle, rect); - int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE); - int newBits = oldBits; - if (rect.right - rect.left < MINIMUM_WIDTH) { - newBits &= ~OS.PBS_MARQUEE; - } else { - newBits |= OS.PBS_MARQUEE; - } - if (newBits != oldBits) { - stopTimer (); - OS.SetWindowLong (handle, OS.GWL_STYLE, newBits); - startTimer (); - } - } - } return result; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java index ddee3e86926..98b489b93ee 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scale.java @@ -528,13 +528,7 @@ LRESULT WM_PAINT (long wParam, long lParam) { * results. The fix is to send a fake WM_SIZE to force it * to redraw every time there is a WM_PAINT. */ - boolean fixPaint = findBackgroundControl () != null; - if (!fixPaint) { - if (OS.IsAppThemed ()) { - Control control = findThemeControl (); - fixPaint = control != null; - } - } + boolean fixPaint = findBackgroundControl () != null || findThemeControl () != null; if (fixPaint) { boolean redraw = getDrawing () && OS.IsWindowVisible (handle); if (redraw) OS.SendMessage (handle, OS.WM_SETREDRAW, 0, 0); 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 32eec597493..65cdeb8d284 100644 --- 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 @@ -932,15 +932,13 @@ public void setVisible (boolean visible) { * bar and hide both. */ if (!visible) { - if (OS.IsAppThemed ()) { - SCROLLBARINFO psbi = new SCROLLBARINFO (); - psbi.cbSize = SCROLLBARINFO.sizeof; - int idObject = (style & SWT.VERTICAL) != 0 ? OS.OBJID_HSCROLL : OS.OBJID_VSCROLL; - OS.GetScrollBarInfo (hwnd, idObject, psbi); - if ((psbi.rgstate [0] & OS.STATE_SYSTEM_INVISIBLE) != 0) { - OS.ShowScrollBar (hwnd, type == OS.SB_VERT ? OS.SB_HORZ : OS.SB_VERT, true); - type = OS.SB_BOTH; - } + SCROLLBARINFO psbi = new SCROLLBARINFO (); + psbi.cbSize = SCROLLBARINFO.sizeof; + int idObject = (style & SWT.VERTICAL) != 0 ? OS.OBJID_HSCROLL : OS.OBJID_VSCROLL; + OS.GetScrollBarInfo (hwnd, idObject, psbi); + if ((psbi.rgstate [0] & OS.STATE_SYSTEM_INVISIBLE) != 0) { + OS.ShowScrollBar (hwnd, type == OS.SB_VERT ? OS.SB_HORZ : OS.SB_VERT, true); + type = OS.SB_BOTH; } } if (OS.ShowScrollBar (hwnd, type, visible)) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java index 61b30313ef9..91234dfa3ee 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TabFolder.java @@ -1060,11 +1060,7 @@ LRESULT WM_WINDOWPOSCHANGING (long wParam, long lParam) { if ((lpwp.flags & (OS.SWP_NOSIZE | OS.SWP_NOREDRAW)) != 0) { return result; } - // TEMPORARY CODE -// if (OS.IsAppThemed ()) { -// OS.InvalidateRect (handle, null, true); -// return result; -// } + int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); if ((bits & OS.TCS_MULTILINE) != 0) { OS.InvalidateRect (handle, null, true); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java index 635f9a969c2..3229c103acb 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Table.java @@ -886,22 +886,20 @@ LRESULT CDDS_PREPAINT (NMLVCUSTOMDRAW nmcd, long wParam, long lParam) { if (enabled && (int)OS.SendMessage (handle, OS.LVM_GETBKCOLOR, 0, 0) == OS.CLR_NONE || !enabled && hasCustomBackground()) { if (control == null) control = this; fillBackground (nmcd.hdc, control.getBackgroundPixel (), rect); - if (OS.IsAppThemed ()) { - if (sortColumn != null && sortDirection != SWT.NONE) { - int index = indexOf (sortColumn); - if (index != -1) { - parent.forceResize (); - int clrSortBk = getSortColumnPixel (); - RECT columnRect = new RECT (), headerRect = new RECT (); - OS.GetClientRect (handle, columnRect); - long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0); - if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect) != 0) { - OS.MapWindowPoints (hwndHeader, handle, headerRect, 2); - columnRect.left = headerRect.left; - columnRect.right = headerRect.right; - if (OS.IntersectRect(columnRect, columnRect, rect)) { - fillBackground (nmcd.hdc, clrSortBk, columnRect); - } + if (sortColumn != null && sortDirection != SWT.NONE) { + int index = indexOf (sortColumn); + if (index != -1) { + parent.forceResize (); + int clrSortBk = getSortColumnPixel (); + RECT columnRect = new RECT (), headerRect = new RECT (); + OS.GetClientRect (handle, columnRect); + long hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0); + if (OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect) != 0) { + OS.MapWindowPoints (hwndHeader, handle, headerRect, 2); + columnRect.left = headerRect.left; + columnRect.right = headerRect.right; + if (OS.IntersectRect(columnRect, columnRect, rect)) { + fillBackground (nmcd.hdc, clrSortBk, columnRect); } } } @@ -1493,10 +1491,8 @@ void createHandle () { state &= ~(CANVAS | THEME_BACKGROUND); /* Use the Explorer theme */ - if (OS.IsAppThemed ()) { - explorerTheme = true; - OS.SetWindowTheme (handle, Display.EXPLORER, null); - } + explorerTheme = true; + OS.SetWindowTheme (handle, Display.EXPLORER, null); /* Get the header window handle */ hwndHeader = OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0); @@ -4229,7 +4225,6 @@ void setCheckboxImageList (int width, int height, boolean fixScroll) { if ((style & SWT.CHECK) == 0) return; int count = 8, flags = OS.ILC_COLOR32; if ((style & SWT.RIGHT_TO_LEFT) != 0) flags |= OS.ILC_MIRROR; - if (!OS.IsAppThemed ()) flags |= OS.ILC_MASK; long hStateList = OS.ImageList_Create (width, height, flags, count, count); long hDC = OS.GetDC (handle); long memDC = OS.CreateCompatibleDC (hDC); @@ -4237,17 +4232,9 @@ void setCheckboxImageList (int width, int height, boolean fixScroll) { long hOldBitmap = OS.SelectObject (memDC, hBitmap); RECT rect = new RECT (); OS.SetRect (rect, 0, 0, width * count, height); - int clrBackground; - if (OS.IsAppThemed ()) { - Control control = findBackgroundControl (); - if (control == null) control = this; - clrBackground = control.getBackgroundPixel (); - } else { - clrBackground = 0x020000FF; - if ((clrBackground & 0xFFFFFF) == OS.GetSysColor (OS.COLOR_WINDOW)) { - clrBackground = 0x0200FF00; - } - } + Control control = findBackgroundControl (); + if (control == null) control = this; + int clrBackground = control.getBackgroundPixel (); long hBrush = OS.CreateSolidBrush (clrBackground); OS.FillRect (memDC, rect, hBrush); OS.DeleteObject (hBrush); @@ -4257,61 +4244,37 @@ void setCheckboxImageList (int width, int height, boolean fixScroll) { OS.SelectObject (hDC, oldFont); int itemWidth = Math.min (tm.tmHeight, width); int itemHeight = Math.min (tm.tmHeight, height); - if (OS.IsAppThemed()) { - /* - * Feature in Windows. DrawThemeBackground stretches the checkbox - * bitmap to fill the provided rectangle. To avoid stretching - * artifacts, limit the rectangle to actual checkbox bitmap size. - */ - SIZE size = new SIZE(); - OS.GetThemePartSize(display.hButtonTheme(nativeZoom), memDC, OS.BP_CHECKBOX, 0, null, OS.TS_TRUE, size); - itemWidth = Math.min (size.cx, itemWidth); - itemHeight = Math.min (size.cy, itemHeight); - } + /* + * Feature in Windows. DrawThemeBackground stretches the checkbox + * bitmap to fill the provided rectangle. To avoid stretching + * artifacts, limit the rectangle to actual checkbox bitmap size. + */ + SIZE size = new SIZE(); + OS.GetThemePartSize(display.hButtonTheme(nativeZoom), memDC, OS.BP_CHECKBOX, 0, null, OS.TS_TRUE, size); + itemWidth = Math.min (size.cx, itemWidth); + itemHeight = Math.min (size.cy, itemHeight); int left = (width - itemWidth) / 2, top = (height - itemHeight) / 2; OS.SetRect (rect, left, top, left + itemWidth, top + itemHeight); - if (OS.IsAppThemed ()) { - long hTheme = display.hButtonTheme(nativeZoom); - OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, rect, null); - rect.left += width; rect.right += width; - OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_CHECKEDNORMAL, rect, null); - rect.left += width; rect.right += width; - OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, rect, null); - rect.left += width; rect.right += width; - OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_MIXEDNORMAL, rect, null); - rect.left += width; rect.right += width; - OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDDISABLED, rect, null); - rect.left += width; rect.right += width; - OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_CHECKEDDISABLED, rect, null); - rect.left += width; rect.right += width; - OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDDISABLED, rect, null); - rect.left += width; rect.right += width; - OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_MIXEDDISABLED, rect, null); - } else { - OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_FLAT); - rect.left += width; rect.right += width; - OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_CHECKED | OS.DFCS_FLAT); - rect.left += width; rect.right += width; - OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_INACTIVE | OS.DFCS_FLAT); - rect.left += width; rect.right += width; - OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_CHECKED | OS.DFCS_INACTIVE | OS.DFCS_FLAT); - rect.left += width; rect.right += width; - OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_FLAT); - rect.left += width; rect.right += width; - OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_CHECKED | OS.DFCS_FLAT); - rect.left += width; rect.right += width; - OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_INACTIVE | OS.DFCS_FLAT); - rect.left += width; rect.right += width; - OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_CHECKED | OS.DFCS_INACTIVE | OS.DFCS_FLAT); - } + long hTheme = display.hButtonTheme(nativeZoom); + OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, rect, null); + rect.left += width; rect.right += width; + OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_CHECKEDNORMAL, rect, null); + rect.left += width; rect.right += width; + OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, rect, null); + rect.left += width; rect.right += width; + OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_MIXEDNORMAL, rect, null); + rect.left += width; rect.right += width; + OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDDISABLED, rect, null); + rect.left += width; rect.right += width; + OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_CHECKEDDISABLED, rect, null); + rect.left += width; rect.right += width; + OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDDISABLED, rect, null); + rect.left += width; rect.right += width; + OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_MIXEDDISABLED, rect, null); OS.SelectObject (memDC, hOldBitmap); OS.DeleteDC (memDC); OS.ReleaseDC (handle, hDC); - if (OS.IsAppThemed ()) { - OS.ImageList_Add (hStateList, hBitmap, 0); - } else { - OS.ImageList_AddMasked (hStateList, hBitmap, clrBackground); - } + OS.ImageList_Add (hStateList, hBitmap, 0); OS.DeleteObject (hBitmap); /* * Bug in Windows. Making any change to an item that diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java index 00d35c0f42a..63ebef69095 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TableColumn.java @@ -401,8 +401,7 @@ public void pack () { long hwnd = parent.handle; int oldWidth = (int)OS.SendMessage (hwnd, OS.LVM_GETCOLUMNWIDTH, index, 0); TCHAR buffer = new TCHAR (parent.getCodePage (), text, true); - int headerWidth = (int) (OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer) + Win32DPIUtils.pointToPixel(Table.HEADER_MARGIN, getAutoscalingZoom())); - if (OS.IsAppThemed ()) headerWidth += Win32DPIUtils.pointToPixel(Table.HEADER_EXTRA, getAutoscalingZoom()); + int headerWidth = (int) (OS.SendMessage (hwnd, OS.LVM_GETSTRINGWIDTH, 0, buffer) + Win32DPIUtils.pointToPixel(Table.HEADER_MARGIN + Table.HEADER_EXTRA, getAutoscalingZoom())); boolean hasHeaderImage = false; if (image != null) { hasHeaderImage = true; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java index cc5b3069d6c..797e65ba472 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Text.java @@ -2574,9 +2574,7 @@ int widgetStyle () { */ if ((style & SWT.READ_ONLY) != 0) { if ((style & (SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.PASSWORD)) == 0) { - if (OS.IsAppThemed ()) { - bits |= OS.ES_MULTILINE; - } + bits |= OS.ES_MULTILINE; } } return bits; @@ -2754,7 +2752,7 @@ LRESULT WM_DRAWITEM (long wParam, long lParam) { POINT pt = new POINT (); OS.MapWindowPoints (struct.hwndItem, handle, pt, 1); drawBackground (struct.hDC, rect, -1, pt.x, pt.y); - if (struct.CtlID == SWT.ICON_CANCEL && struct.hwndItem == hwndActiveIcon && OS.IsAppThemed()) { + if (struct.CtlID == SWT.ICON_CANCEL && struct.hwndItem == hwndActiveIcon) { int state = OS.GetKeyState (OS.VK_LBUTTON) < 0 ? OS.PBS_PRESSED : OS.PBS_HOT; OS.DrawThemeBackground(display.hButtonThemeAuto(nativeZoom), struct.hDC, OS.BP_PUSHBUTTON, state, rect, null); } @@ -2777,14 +2775,12 @@ LRESULT WM_ERASEBKGND (long wParam, long lParam) { Control control = findBackgroundControl (); if (control == null && background == -1) { if ((state & THEME_BACKGROUND) != 0) { - if (OS.IsAppThemed ()) { - control = findThemeControl (); - if (control != null) { - RECT rect = new RECT (); - OS.GetClientRect (handle, rect); - fillThemeBackground (wParam, control, rect); - return LRESULT.ONE; - } + control = findThemeControl (); + if (control != null) { + RECT rect = new RECT (); + OS.GetClientRect (handle, rect); + fillThemeBackground (wParam, control, rect); + return LRESULT.ONE; } } } @@ -3041,14 +3037,12 @@ LRESULT wmColorChild (long wParam, long lParam) { Control control = findBackgroundControl (); if (control == null && background == -1) { if ((state & THEME_BACKGROUND) != 0) { - if (OS.IsAppThemed ()) { - control = findThemeControl (); - if (control != null) { - OS.SetTextColor (wParam, getForegroundPixel ()); - OS.SetBkColor (wParam, getBackgroundPixel ()); - OS.SetBkMode (wParam, OS.TRANSPARENT); - return new LRESULT (OS.GetStockObject (OS.NULL_BRUSH)); - } + control = findThemeControl (); + if (control != null) { + OS.SetTextColor (wParam, getForegroundPixel ()); + OS.SetBkColor (wParam, getBackgroundPixel ()); + OS.SetBkMode (wParam, OS.TRANSPARENT); + return new LRESULT (OS.GetStockObject (OS.NULL_BRUSH)); } } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java index 90ea3747dda..fa3af9498e8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/ToolBar.java @@ -136,9 +136,7 @@ public ToolBar (Composite parent, int style) { * not lay out properly. The work around does not run * in this case. */ - if (OS.IsAppThemed ()) { - if ((style & SWT.RIGHT) != 0) bits |= OS.TBSTYLE_LIST; - } + if ((style & SWT.RIGHT) != 0) bits |= OS.TBSTYLE_LIST; OS.SetWindowLong (handle, OS.GWL_STYLE, bits | OS.CCS_VERT); } else { this.style |= SWT.HORIZONTAL; @@ -337,24 +335,6 @@ void createHandle () { super.createHandle (); state &= ~CANVAS; - /* - * Feature in Windows. When TBSTYLE_FLAT is used to create - * a flat toolbar, for some reason TBSTYLE_TRANSPARENT is - * also set. This causes the toolbar to flicker when it is - * moved or resized. The fix is to clear TBSTYLE_TRANSPARENT. - * - * NOTE: This work around is unnecessary on XP. There is no - * flickering and clearing the TBSTYLE_TRANSPARENT interferes - * with the XP theme. - */ - if ((style & SWT.FLAT) != 0) { - if (!OS.IsAppThemed ()) { - int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); - bits &= ~OS.TBSTYLE_TRANSPARENT; - OS.SetWindowLong (handle, OS.GWL_STYLE, bits); - } - } - /* * Feature in Windows. Despite the fact that the * tool tip text contains \r\n, the tooltip will @@ -708,36 +688,34 @@ void layoutItems () { * not lay out properly. The work around does not run * in this case. */ - if (OS.IsAppThemed ()) { - if ((style & SWT.RIGHT) != 0 && (style & SWT.VERTICAL) == 0) { - boolean hasText = false, hasImage = false; - for (ToolItem item : items) { - if (item != null) { - if (!hasText) hasText = item.text.length () != 0; - if (!hasImage) hasImage = item.image != null; - if (hasText && hasImage) break; - } - } - int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE), newBits = oldBits; - if (hasText && hasImage) { - newBits |= OS.TBSTYLE_LIST; - } else { - newBits &= ~OS.TBSTYLE_LIST; - } - if (newBits != oldBits) { - setDropDownItems (false); - OS.SetWindowLong (handle, OS.GWL_STYLE, newBits); - /* - * Feature in Windows. For some reason, when the style - * is changed to TBSTYLE_LIST, Windows does not lay out - * the tool items. The fix is to use WM_SETFONT to force - * the tool bar to redraw and lay out. - */ - long hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); - OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0); - setDropDownItems (true); + if ((style & SWT.RIGHT) != 0 && (style & SWT.VERTICAL) == 0) { + boolean hasText = false, hasImage = false; + for (ToolItem item : items) { + if (item != null) { + if (!hasText) hasText = item.text.length () != 0; + if (!hasImage) hasImage = item.image != null; + if (hasText && hasImage) break; } } + int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE), newBits = oldBits; + if (hasText && hasImage) { + newBits |= OS.TBSTYLE_LIST; + } else { + newBits &= ~OS.TBSTYLE_LIST; + } + if (newBits != oldBits) { + setDropDownItems (false); + OS.SetWindowLong (handle, OS.GWL_STYLE, newBits); + /* + * Feature in Windows. For some reason, when the style + * is changed to TBSTYLE_LIST, Windows does not lay out + * the tool items. The fix is to use WM_SETFONT to force + * the tool bar to redraw and lay out. + */ + long hFont = OS.SendMessage (handle, OS.WM_GETFONT, 0, 0); + OS.SendMessage (handle, OS.WM_SETFONT, hFont, 0); + setDropDownItems (true); + } } /* @@ -747,44 +725,42 @@ void layoutItems () { * This affects every button in the tool bar and makes the preferred height too big. * The fix is to set the TBSTYLE_LIST, so that Windows can condense the unused space. */ - if (OS.IsAppThemed()) { - if ((style & SWT.RIGHT) == 0 && (style & SWT.HORIZONTAL) != 0) { - boolean hasText = false, hasImage = false, hasTextAndImageInSingleItem = false; - for (ToolItem item : items) { - if (item != null) { - boolean itemHasText = false, itemHasImage = false; - itemHasText = item.text.length() != 0; - itemHasImage = item.image != null; - if (!hasText) { - hasText = itemHasText; - } - if (!hasImage) { - hasImage = itemHasImage; - } - if (itemHasText && itemHasImage) { - hasTextAndImageInSingleItem = true; - break; - } + if ((style & SWT.RIGHT) == 0 && (style & SWT.HORIZONTAL) != 0) { + boolean hasText = false, hasImage = false, hasTextAndImageInSingleItem = false; + for (ToolItem item : items) { + if (item != null) { + boolean itemHasText = false, itemHasImage = false; + itemHasText = item.text.length() != 0; + itemHasImage = item.image != null; + if (!hasText) { + hasText = itemHasText; + } + if (!hasImage) { + hasImage = itemHasImage; + } + if (itemHasText && itemHasImage) { + hasTextAndImageInSingleItem = true; + break; } } - int oldBits = OS.GetWindowLong(handle, OS.GWL_STYLE), newBits = oldBits; - if (hasText && hasImage && !hasTextAndImageInSingleItem) { - newBits |= OS.TBSTYLE_LIST; - } else { - newBits &= ~OS.TBSTYLE_LIST; - } - if (newBits != oldBits) { - setDropDownItems(false); - OS.SetWindowLong(handle, OS.GWL_STYLE, newBits); - /* - * Feature in Windows. For some reason, when the style is changed to - * TBSTYLE_LIST, Windows does not lay out the tool items. The fix is to use - * WM_SETFONT to force the tool bar to redraw and lay out. - */ - long hFont = OS.SendMessage(handle, OS.WM_GETFONT, 0, 0); - OS.SendMessage(handle, OS.WM_SETFONT, hFont, 0); - setDropDownItems(true); - } + } + int oldBits = OS.GetWindowLong(handle, OS.GWL_STYLE), newBits = oldBits; + if (hasText && hasImage && !hasTextAndImageInSingleItem) { + newBits |= OS.TBSTYLE_LIST; + } else { + newBits &= ~OS.TBSTYLE_LIST; + } + if (newBits != oldBits) { + setDropDownItems(false); + OS.SetWindowLong(handle, OS.GWL_STYLE, newBits); + /* + * Feature in Windows. For some reason, when the style is changed to + * TBSTYLE_LIST, Windows does not lay out the tool items. The fix is to use + * WM_SETFONT to force the tool bar to redraw and lay out. + */ + long hFont = OS.SendMessage(handle, OS.WM_GETFONT, 0, 0); + OS.SendMessage(handle, OS.WM_SETFONT, hFont, 0); + setDropDownItems(true); } } @@ -957,28 +933,6 @@ void setBackgroundPixel (int pixel) { } void setBackgroundTransparent (boolean transparent) { - /* - * Feature in Windows. When TBSTYLE_TRANSPARENT is set - * in a tool bar that is drawing a background, images in - * the image list that include transparency information - * do not draw correctly. The fix is to clear and set - * TBSTYLE_TRANSPARENT depending on the background color. - * - * NOTE: This work around is unnecessary on XP. The - * TBSTYLE_TRANSPARENT style is never cleared on that - * platform. - */ - if ((style & SWT.FLAT) != 0) { - if (!OS.IsAppThemed ()) { - int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); - if (!transparent && findBackgroundControl () == null) { - bits &= ~OS.TBSTYLE_TRANSPARENT; - } else { - bits |= OS.TBSTYLE_TRANSPARENT; - } - OS.SetWindowLong (handle, OS.GWL_STYLE, bits); - } - } } @Override @@ -1020,29 +974,27 @@ void setDropDownItems (boolean set) { * NOTE: This work around only runs when the tool bar contains * only images. */ - if (OS.IsAppThemed ()) { - boolean hasText = false, hasImage = false; - for (ToolItem item : items) { - if (item != null) { - if (!hasText) hasText = item.text.length () != 0; - if (!hasImage) hasImage = item.image != null; - if (hasText && hasImage) break; - } + boolean hasText = false, hasImage = false; + for (ToolItem item : items) { + if (item != null) { + if (!hasText) hasText = item.text.length () != 0; + if (!hasImage) hasImage = item.image != null; + if (hasText && hasImage) break; } - if (hasImage && !hasText) { - for (ToolItem item : items) { - if (item != null && (item.style & SWT.DROP_DOWN) != 0) { - TBBUTTONINFO info = new TBBUTTONINFO (); - info.cbSize = TBBUTTONINFO.sizeof; - info.dwMask = OS.TBIF_STYLE; - OS.SendMessage (handle, OS.TB_GETBUTTONINFO, item.id, info); - if (set) { - info.fsStyle |= OS.BTNS_DROPDOWN; - } else { - info.fsStyle &= ~OS.BTNS_DROPDOWN; - } - OS.SendMessage (handle, OS.TB_SETBUTTONINFO, item.id, info); + } + if (hasImage && !hasText) { + for (ToolItem item : items) { + if (item != null && (item.style & SWT.DROP_DOWN) != 0) { + TBBUTTONINFO info = new TBBUTTONINFO (); + info.cbSize = TBBUTTONINFO.sizeof; + info.dwMask = OS.TBIF_STYLE; + OS.SendMessage (handle, OS.TB_GETBUTTONINFO, item.id, info); + if (set) { + info.fsStyle |= OS.BTNS_DROPDOWN; + } else { + info.fsStyle &= ~OS.BTNS_DROPDOWN; } + OS.SendMessage (handle, OS.TB_SETBUTTONINFO, item.id, info); } } } @@ -1314,27 +1266,10 @@ void updateOrientation () { @Override int widgetStyle () { - int bits = super.widgetStyle () | OS.CCS_NORESIZE | OS.TBSTYLE_TOOLTIPS | OS.TBSTYLE_CUSTOMERASE; - if (OS.IsAppThemed ()) bits |= OS.TBSTYLE_TRANSPARENT; + int bits = super.widgetStyle () | OS.CCS_NORESIZE | OS.TBSTYLE_TOOLTIPS | OS.TBSTYLE_CUSTOMERASE | OS.TBSTYLE_TRANSPARENT; if ((style & SWT.SHADOW_OUT) == 0) bits |= OS.CCS_NODIVIDER; if ((style & SWT.WRAP) != 0) bits |= OS.TBSTYLE_WRAPABLE; if ((style & SWT.FLAT) != 0) bits |= OS.TBSTYLE_FLAT; - /* - * Feature in Windows. When a tool bar has the style - * TBSTYLE_LIST and has a drop down item, Window leaves - * too much padding around the button. This affects - * every button in the tool bar and makes the preferred - * height too big. The fix is to set the TBSTYLE_LIST - * when the tool bar contains both text and images. - * - * NOTE: Tool bars with CCS_VERT must have TBSTYLE_LIST - * set before any item is added or the tool bar does - * not lay out properly. The work around does not run - * in this case. - */ - if (!OS.IsAppThemed ()) { - if ((style & SWT.RIGHT) != 0) bits |= OS.TBSTYLE_LIST; - } return bits; } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java index cd1dec42ca4..13d5eae347a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Tree.java @@ -437,12 +437,10 @@ LRESULT CDDS_ITEMPOSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { } } int sortIndex = -1, clrSortBk = -1; - if (OS.IsAppThemed ()) { - if (sortColumn != null && sortDirection != SWT.NONE) { - if (findImageControl () == null) { - sortIndex = indexOf (sortColumn); - clrSortBk = getSortColumnPixel (); - } + if (sortColumn != null && sortDirection != SWT.NONE) { + if (findImageControl () == null) { + sortIndex = indexOf (sortColumn); + clrSortBk = getSortColumnPixel (); } } int x = 0; @@ -1003,13 +1001,11 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { if (clrTextBk == -1) clrTextBk = item.background; } int clrSortBk = -1; - if (OS.IsAppThemed ()) { - if (sortColumn != null && sortDirection != SWT.NONE) { - if (findImageControl () == null) { - if (indexOf (sortColumn) == index) { - clrSortBk = getSortColumnPixel (); - if (clrTextBk == -1) clrTextBk = clrSortBk; - } + if (sortColumn != null && sortDirection != SWT.NONE) { + if (findImageControl () == null) { + if (indexOf (sortColumn) == index) { + clrSortBk = getSortColumnPixel (); + if (clrTextBk == -1) clrTextBk = clrSortBk; } } } @@ -1263,12 +1259,6 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { hdItem.mask = OS.HDI_WIDTH; OS.SendMessage (hwndHeader, OS.HDM_GETITEM, index, hdItem); OS.SetRect (rect, nmcd.left, nmcd.top, nmcd.left + hdItem.cxy, nmcd.bottom); - if (!OS.IsAppThemed ()) { - RECT itemRect = new RECT (); - if (OS.TreeView_GetItemRect (handle, item.handle, itemRect, true)) { - rect.left = Math.min (itemRect.left, rect.right); - } - } if ((style & SWT.FULL_SELECTION) != 0) { if (!selected) fillBackground (hDC, clrTextBk, rect); } else { @@ -1368,43 +1358,41 @@ LRESULT CDDS_ITEMPREPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { LRESULT CDDS_POSTPAINT (NMTVCUSTOMDRAW nmcd, long wParam, long lParam) { if (ignoreCustomDraw) return null; if (OS.IsWindowVisible (handle)) { - if (OS.IsAppThemed ()) { - if (sortColumn != null && sortDirection != SWT.NONE) { - if (findImageControl () == null) { - int index = indexOf (sortColumn); - if (index != -1) { - int top = nmcd.top; - /* - * Bug in Windows. For some reason, during a collapse, - * when TVM_GETNEXTITEM is sent with TVGN_LASTVISIBLE - * and the collapse causes the item being collapsed - * to become the last visible item in the tree, the - * message takes a long time to process. In order for - * the slowness to happen, the children of the item - * must have children. Times of up to 11 seconds have - * been observed with 23 children, each having one - * child. The fix is to use the bottom partially - * visible item rather than the last possible item - * that could be visible. - * - * NOTE: This problem only happens on Vista during - * WM_NOTIFY with NM_CUSTOMDRAW and CDDS_POSTPAINT. - */ - long hItem = getBottomItem (); - if (hItem != 0) { - RECT rect = new RECT (); - if (OS.TreeView_GetItemRect (handle, hItem, rect, false)) { - top = rect.bottom; - } - } + if (sortColumn != null && sortDirection != SWT.NONE) { + if (findImageControl () == null) { + int index = indexOf (sortColumn); + if (index != -1) { + int top = nmcd.top; + /* + * Bug in Windows. For some reason, during a collapse, + * when TVM_GETNEXTITEM is sent with TVGN_LASTVISIBLE + * and the collapse causes the item being collapsed + * to become the last visible item in the tree, the + * message takes a long time to process. In order for + * the slowness to happen, the children of the item + * must have children. Times of up to 11 seconds have + * been observed with 23 children, each having one + * child. The fix is to use the bottom partially + * visible item rather than the last possible item + * that could be visible. + * + * NOTE: This problem only happens on Vista during + * WM_NOTIFY with NM_CUSTOMDRAW and CDDS_POSTPAINT. + */ + long hItem = getBottomItem (); + if (hItem != 0) { RECT rect = new RECT (); - OS.SetRect (rect, nmcd.left, top, nmcd.right, nmcd.bottom); - RECT headerRect = new RECT (); - OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect); - rect.left = headerRect.left; - rect.right = headerRect.right; - fillBackground (nmcd.hdc, getSortColumnPixel (), rect); + if (OS.TreeView_GetItemRect (handle, hItem, rect, false)) { + top = rect.bottom; + } } + RECT rect = new RECT (); + OS.SetRect (rect, nmcd.left, top, nmcd.right, nmcd.bottom); + RECT headerRect = new RECT (); + OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect); + rect.left = headerRect.left; + rect.right = headerRect.right; + fillBackground (nmcd.hdc, getSortColumnPixel (), rect); } } } @@ -1645,10 +1633,8 @@ void checkBuffered () { style |= SWT.DOUBLE_BUFFERED; OS.SendMessage (handle, OS.TVM_SETSCROLLTIME, 0, 0); } - if (OS.IsAppThemed ()) { - int exStyle = (int)OS.SendMessage (handle, OS.TVM_GETEXTENDEDSTYLE, 0, 0); - if ((exStyle & OS.TVS_EX_DOUBLEBUFFER) != 0) style |= SWT.DOUBLE_BUFFERED; - } + int exStyle = (int)OS.SendMessage (handle, OS.TVM_GETEXTENDEDSTYLE, 0, 0); + if ((exStyle & OS.TVS_EX_DOUBLEBUFFER) != 0) style |= SWT.DOUBLE_BUFFERED; } boolean checkData (TreeItem item, boolean redraw) { @@ -1876,20 +1862,18 @@ void createHandle () { state &= ~(CANVAS | THEME_BACKGROUND); /* Use the Explorer theme */ - if (OS.IsAppThemed ()) { - explorerTheme = true; - OS.SetWindowTheme (handle, Display.EXPLORER, null); - int bits = OS.TVS_EX_DOUBLEBUFFER | OS.TVS_EX_RICHTOOLTIP; - if (ENABLE_TVS_EX_FADEINOUTEXPANDOS) bits |= OS.TVS_EX_FADEINOUTEXPANDOS; - OS.SendMessage (handle, OS.TVM_SETEXTENDEDSTYLE, 0, bits); - /* - * Bug in Windows. When the tree is using the explorer - * theme, it does not use COLOR_WINDOW_TEXT for the - * default foreground color. The fix is to explicitly - * set the foreground. - */ - setForegroundPixel (-1); - } + explorerTheme = true; + OS.SetWindowTheme (handle, Display.EXPLORER, null); + int bits = OS.TVS_EX_DOUBLEBUFFER | OS.TVS_EX_RICHTOOLTIP; + if (ENABLE_TVS_EX_FADEINOUTEXPANDOS) bits |= OS.TVS_EX_FADEINOUTEXPANDOS; + OS.SendMessage (handle, OS.TVM_SETEXTENDEDSTYLE, 0, bits); + /* + * Bug in Windows. When the tree is using the explorer + * theme, it does not use COLOR_WINDOW_TEXT for the + * default foreground color. The fix is to explicitly + * set the foreground. + */ + setForegroundPixel (-1); /* Set the checkbox image list */ if ((style & SWT.CHECK) != 0) setCheckboxImageList (); @@ -4741,7 +4725,6 @@ void setCheckboxImageList () { if ((style & SWT.CHECK) == 0) return; int count = 5, flags = OS.ILC_COLOR32; if ((style & SWT.RIGHT_TO_LEFT) != 0) flags |= OS.ILC_MIRROR; - if (!OS.IsAppThemed ()) flags |= OS.ILC_MASK; int height = (int)OS.SendMessage (handle, OS.TVM_GETITEMHEIGHT, 0, 0), width = height; long hStateList = OS.ImageList_Create (width, height, flags, count, count); long hDC = OS.GetDC (handle); @@ -4750,23 +4733,9 @@ void setCheckboxImageList () { long hOldBitmap = OS.SelectObject (memDC, hBitmap); RECT rect = new RECT (); OS.SetRect (rect, 0, 0, width * count, height); - /* - * NOTE: DrawFrameControl() draws a black and white - * mask when not drawing a push button. In order to - * make the box surrounding the check mark transparent, - * fill it with a color that is neither black or white. - */ - int clrBackground = 0; - if (OS.IsAppThemed ()) { - Control control = findBackgroundControl (); - if (control == null) control = this; - clrBackground = control.getBackgroundPixel (); - } else { - clrBackground = 0x020000FF; - if ((clrBackground & 0xFFFFFF) == OS.GetSysColor (OS.COLOR_WINDOW)) { - clrBackground = 0x0200FF00; - } - } + Control control = findBackgroundControl (); + if (control == null) control = this; + int clrBackground = control.getBackgroundPixel (); long hBrush = OS.CreateSolidBrush (clrBackground); OS.FillRect (memDC, rect, hBrush); OS.DeleteObject (hBrush); @@ -4776,45 +4745,29 @@ void setCheckboxImageList () { OS.SelectObject (hDC, oldFont); int itemWidth = Math.min (tm.tmHeight, width); int itemHeight = Math.min (tm.tmHeight, height); - if (OS.IsAppThemed()) { - /* - * Feature in Windows. DrawThemeBackground stretches the checkbox - * bitmap to fill the provided rectangle. To avoid stretching - * artifacts, limit the rectangle to actual checkbox bitmap size. - */ - SIZE size = new SIZE(); - OS.GetThemePartSize(display.hButtonTheme(nativeZoom), memDC, OS.BP_CHECKBOX, 0, null, OS.TS_TRUE, size); - itemWidth = Math.min (size.cx, itemWidth); - itemHeight = Math.min (size.cy, itemHeight); - } + /* + * Feature in Windows. DrawThemeBackground stretches the checkbox + * bitmap to fill the provided rectangle. To avoid stretching + * artifacts, limit the rectangle to actual checkbox bitmap size. + */ + SIZE size = new SIZE(); + OS.GetThemePartSize(display.hButtonTheme(nativeZoom), memDC, OS.BP_CHECKBOX, 0, null, OS.TS_TRUE, size); + itemWidth = Math.min (size.cx, itemWidth); + itemHeight = Math.min (size.cy, itemHeight); int left = (width - itemWidth) / 2, top = (height - itemHeight) / 2 + 1; OS.SetRect (rect, left + width, top, left + width + itemWidth, top + itemHeight); - if (OS.IsAppThemed ()) { - long hTheme = display.hButtonTheme(nativeZoom); - OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, rect, null); - rect.left += width; rect.right += width; - OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_CHECKEDNORMAL, rect, null); - rect.left += width; rect.right += width; - OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, rect, null); - rect.left += width; rect.right += width; - OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_MIXEDNORMAL, rect, null); - } else { - OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_FLAT); - rect.left += width; rect.right += width; - OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_CHECKED | OS.DFCS_FLAT); - rect.left += width; rect.right += width; - OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_INACTIVE | OS.DFCS_FLAT); - rect.left += width; rect.right += width; - OS.DrawFrameControl (memDC, rect, OS.DFC_BUTTON, OS.DFCS_BUTTONCHECK | OS.DFCS_CHECKED | OS.DFCS_INACTIVE | OS.DFCS_FLAT); - } + long hTheme = display.hButtonTheme(nativeZoom); + OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, rect, null); + rect.left += width; rect.right += width; + OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_CHECKEDNORMAL, rect, null); + rect.left += width; rect.right += width; + OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_UNCHECKEDNORMAL, rect, null); + rect.left += width; rect.right += width; + OS.DrawThemeBackground (hTheme, memDC, OS.BP_CHECKBOX, OS.CBS_MIXEDNORMAL, rect, null); OS.SelectObject (memDC, hOldBitmap); OS.DeleteDC (memDC); OS.ReleaseDC (handle, hDC); - if (OS.IsAppThemed ()) { - OS.ImageList_Add (hStateList, hBitmap, 0); - } else { - OS.ImageList_AddMasked (hStateList, hBitmap, clrBackground); - } + OS.ImageList_Add (hStateList, hBitmap, 0); OS.DeleteObject (hBitmap); long hOldStateList = OS.SendMessage (handle, OS.TVM_GETIMAGELIST, OS.TVSIL_STATE, 0); OS.SendMessage (handle, OS.TVM_SETIMAGELIST, OS.TVSIL_STATE, hStateList); @@ -5890,17 +5843,8 @@ void unsubclass () { @Override int widgetStyle () { - int bits = super.widgetStyle () | OS.TVS_SHOWSELALWAYS | OS.TVS_LINESATROOT | OS.TVS_HASBUTTONS | OS.TVS_NONEVENHEIGHT; - if (OS.IsAppThemed ()) { - bits |= OS.TVS_TRACKSELECT; - if ((style & SWT.FULL_SELECTION) != 0) bits |= OS.TVS_FULLROWSELECT; - } else { - if ((style & SWT.FULL_SELECTION) != 0) { - bits |= OS.TVS_FULLROWSELECT; - } else { - bits |= OS.TVS_HASLINES; - } - } + int bits = super.widgetStyle () | OS.TVS_SHOWSELALWAYS | OS.TVS_LINESATROOT | OS.TVS_HASBUTTONS | OS.TVS_NONEVENHEIGHT | OS.TVS_TRACKSELECT; + if ((style & SWT.FULL_SELECTION) != 0) bits |= OS.TVS_FULLROWSELECT; if ((style & (SWT.H_SCROLL | SWT.V_SCROLL)) == 0) { bits &= ~(OS.WS_HSCROLL | OS.WS_VSCROLL); bits |= OS.TVS_NOSCROLL; @@ -7559,10 +7503,8 @@ LRESULT wmNotifyChild (NMHDR hdr, long wParam, long lParam) { if (hwndHeader == 0) createParent (); } if (!customDraw && findImageControl () == null) { - if (OS.IsAppThemed ()) { - if (sortColumn == null || sortDirection == SWT.NONE) { - break; - } + if (sortColumn == null || sortDirection == SWT.NONE) { + break; } } NMTVCUSTOMDRAW nmcd = new NMTVCUSTOMDRAW (); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java index 0d6924b81e9..7f1ef4b98a8 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/TreeColumn.java @@ -371,8 +371,7 @@ public void pack () { int flags = OS.DT_CALCRECT | OS.DT_NOPREFIX; char [] buffer = text.toCharArray (); OS.DrawText (hDC, buffer, buffer.length, rect, flags); - int headerWidth = rect.right - rect.left + DPIUtil.pointToPixel(Tree.HEADER_MARGIN, getAutoscalingZoom()); - if (OS.IsAppThemed ()) headerWidth += DPIUtil.pointToPixel(Tree.HEADER_EXTRA, getAutoscalingZoom()); + int headerWidth = rect.right - rect.left + DPIUtil.pointToPixel(Tree.HEADER_MARGIN + Tree.HEADER_EXTRA, getAutoscalingZoom()); if (image != null) { Rectangle bounds = Win32DPIUtils.pointToPixel(image.getBounds(), getAutoscalingZoom()); headerWidth += bounds.width; @@ -613,16 +612,14 @@ void setSortDirection (int direction) { break; } OS.SendMessage (hwndHeader, OS.HDM_SETITEM, index, hdItem); - if (OS.IsAppThemed ()) { - long hwnd = parent.handle; - parent.forceResize (); - RECT rect = new RECT (), headerRect = new RECT (); - OS.GetClientRect (hwnd, rect); - OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect); - rect.left = headerRect.left; - rect.right = headerRect.right; - OS.InvalidateRect (hwnd, rect, true); - } + long hwnd = parent.handle; + parent.forceResize (); + RECT rect = new RECT (), headerRect = new RECT (); + OS.GetClientRect (hwnd, rect); + OS.SendMessage (hwndHeader, OS.HDM_GETITEMRECT, index, headerRect); + rect.left = headerRect.left; + rect.right = headerRect.right; + OS.InvalidateRect (hwnd, rect, true); } } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java index 8aaad0a03c6..d501c6da139 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Widget.java @@ -2382,20 +2382,18 @@ LRESULT wmPrint (long hwnd, long wParam, long lParam) { * default window proc and then draw the theme border on top. */ if ((lParam & OS.PRF_NONCLIENT) != 0) { - if (OS.IsAppThemed ()) { - int bits = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE); - if ((bits & OS.WS_EX_CLIENTEDGE) != 0) { - long code = callWindowProc (hwnd, OS.WM_PRINT, wParam, lParam); - RECT rect = new RECT (); - OS.GetWindowRect (hwnd, rect); - rect.right -= rect.left; - rect.bottom -= rect.top; - rect.left = rect.top = 0; - int border = getSystemMetrics (OS.SM_CXEDGE); - OS.ExcludeClipRect (wParam, border, border, rect.right - border, rect.bottom - border); - OS.DrawThemeBackground(display.hEditTheme(nativeZoom), wParam, OS.EP_EDITTEXT, OS.ETS_NORMAL, rect, null); - return new LRESULT (code); - } + int bits = OS.GetWindowLong (hwnd, OS.GWL_EXSTYLE); + if ((bits & OS.WS_EX_CLIENTEDGE) != 0) { + long code = callWindowProc (hwnd, OS.WM_PRINT, wParam, lParam); + RECT rect = new RECT (); + OS.GetWindowRect (hwnd, rect); + rect.right -= rect.left; + rect.bottom -= rect.top; + rect.left = rect.top = 0; + int border = getSystemMetrics (OS.SM_CXEDGE); + OS.ExcludeClipRect (wParam, border, border, rect.right - border, rect.bottom - border); + OS.DrawThemeBackground(display.hEditTheme(nativeZoom), wParam, OS.EP_EDITTEXT, OS.ETS_NORMAL, rect, null); + return new LRESULT (code); } } return null;