From 0f98b0bb298e033ba5db3f883f1bd05f0dc11102 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Wed, 14 Feb 2018 08:35:19 +0300 Subject: [PATCH] comctl32/listbox: Merge theming logic. Signed-off-by: Nikolay Sivov Signed-off-by: Alexandre Julliard --- dlls/comctl32/Makefile.in | 1 - dlls/comctl32/listbox.c | 53 +++++++++++++++- dlls/comctl32/theme_listbox.c | 116 ---------------------------------- dlls/comctl32/theming.c | 9 --- 4 files changed, 52 insertions(+), 127 deletions(-) delete mode 100644 dlls/comctl32/theme_listbox.c diff --git a/dlls/comctl32/Makefile.in b/dlls/comctl32/Makefile.in index 25d5e6716cb..48167849349 100644 --- a/dlls/comctl32/Makefile.in +++ b/dlls/comctl32/Makefile.in @@ -37,7 +37,6 @@ C_SRCS = \ tab.c \ taskdialog.c \ theme_dialog.c \ - theme_listbox.c \ theme_scrollbar.c \ theming.c \ toolbar.c \ diff --git a/dlls/comctl32/listbox.c b/dlls/comctl32/listbox.c index 7a16500bd17..3184e200989 100644 --- a/dlls/comctl32/listbox.c +++ b/dlls/comctl32/listbox.c @@ -2,6 +2,7 @@ * Listbox controls * * Copyright 1996 Alexandre Julliard + * Copyright 2005 Frank Richter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,6 +31,8 @@ #include "wingdi.h" #include "winuser.h" #include "commctrl.h" +#include "uxtheme.h" +#include "vssym32.h" #include "wine/unicode.h" #include "wine/exception.h" #include "wine/debug.h" @@ -1072,6 +1075,38 @@ static LRESULT LISTBOX_Paint( LB_DESCR *descr, HDC hdc ) return 0; } +static void LISTBOX_NCPaint( LB_DESCR *descr, HRGN region ) +{ + DWORD exstyle = GetWindowLongW( descr->self, GWL_EXSTYLE); + HTHEME theme = GetWindowTheme( descr->self ); + HRGN cliprgn = region; + int cxEdge, cyEdge; + HDC hdc; + RECT r; + + if (!theme || !(exstyle & WS_EX_CLIENTEDGE)) + return; + + cxEdge = GetSystemMetrics(SM_CXEDGE), + cyEdge = GetSystemMetrics(SM_CYEDGE); + + GetWindowRect(descr->self, &r); + + /* New clipping region passed to default proc to exclude border */ + cliprgn = CreateRectRgn(r.left + cxEdge, r.top + cyEdge, + r.right - cxEdge, r.bottom - cyEdge); + if (region != (HRGN)1) + CombineRgn(cliprgn, cliprgn, region, RGN_AND); + OffsetRect(&r, -r.left, -r.top); + + hdc = GetDCEx(descr->self, region, DCX_WINDOW|DCX_INTERSECTRGN); + OffsetRect(&r, -r.left, -r.top); + + if (IsThemeBackgroundPartiallyTransparent (theme, 0, 0)) + DrawThemeParentBackground(descr->self, hdc, &r); + DrawThemeBackground (theme, hdc, 0, 0, &r, 0); + ReleaseDC(descr->self, hdc); +} /*********************************************************************** * LISTBOX_InvalidateItems @@ -2500,6 +2535,8 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) } } + OpenThemeData( descr->self, WC_LISTBOXW ); + TRACE("owner: %p, style: %08x, width: %d, height: %d\n", descr->owner, descr->style, descr->width, descr->height); return TRUE; } @@ -2510,6 +2547,8 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) */ static BOOL LISTBOX_Destroy( LB_DESCR *descr ) { + HTHEME theme = GetWindowTheme( descr->self ); + CloseThemeData( theme ); LISTBOX_ResetContent( descr ); SetWindowLongPtrW( descr->self, 0, 0 ); HeapFree( GetProcessHeap(), 0, descr ); @@ -2523,7 +2562,8 @@ static BOOL LISTBOX_Destroy( LB_DESCR *descr ) static LRESULT CALLBACK LISTBOX_WindowProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam ) { LB_DESCR *descr = (LB_DESCR *)GetWindowLongPtrW( hwnd, 0 ); - LPHEADCOMBO lphc = 0; + HEADCOMBO *lphc = NULL; + HTHEME theme; LRESULT ret; if (!descr) @@ -2833,6 +2873,11 @@ static LRESULT CALLBACK LISTBOX_WindowProc( HWND hwnd, UINT msg, WPARAM wParam, if( !wParam ) EndPaint( descr->self, &ps ); } return ret; + + case WM_NCPAINT: + LISTBOX_NCPaint( descr, (HRGN)wParam ); + break; + case WM_SIZE: LISTBOX_UpdateSize( descr ); return 0; @@ -2983,6 +3028,12 @@ static LRESULT CALLBACK LISTBOX_WindowProc( HWND hwnd, UINT msg, WPARAM wParam, if (lphc) return 0; break; + case WM_THEMECHANGED: + theme = GetWindowTheme( hwnd ); + CloseThemeData( theme ); + OpenThemeData( hwnd, WC_LISTBOXW ); + break; + default: if ((msg >= WM_USER) && (msg < 0xc000)) WARN("[%p]: unknown msg %04x wp %08lx lp %08lx\n", diff --git a/dlls/comctl32/theme_listbox.c b/dlls/comctl32/theme_listbox.c deleted file mode 100644 index 91772144aa8..00000000000 --- a/dlls/comctl32/theme_listbox.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Theming - List box control - * - * Copyright (c) 2005 by Frank Richter - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA - * - */ - -#include -#include -#include - -#include "windef.h" -#include "winbase.h" -#include "wingdi.h" -#include "winuser.h" -#include "uxtheme.h" -#include "vssym32.h" -#include "comctl32.h" -#include "wine/debug.h" - -/* Draw themed border */ -static void nc_paint (HTHEME theme, HWND hwnd, HRGN region) -{ - HRGN cliprgn = region; - DWORD exStyle = GetWindowLongW (hwnd, GWL_EXSTYLE); - if (exStyle & WS_EX_CLIENTEDGE) - { - HDC dc; - RECT r; - int cxEdge = GetSystemMetrics (SM_CXEDGE), - cyEdge = GetSystemMetrics (SM_CYEDGE); - - GetWindowRect(hwnd, &r); - - /* New clipping region passed to default proc to exclude border */ - cliprgn = CreateRectRgn (r.left + cxEdge, r.top + cyEdge, - r.right - cxEdge, r.bottom - cyEdge); - if (region != (HRGN)1) - CombineRgn (cliprgn, cliprgn, region, RGN_AND); - OffsetRect(&r, -r.left, -r.top); - - dc = GetDCEx(hwnd, region, DCX_WINDOW|DCX_INTERSECTRGN); - OffsetRect(&r, -r.left, -r.top); - - if (IsThemeBackgroundPartiallyTransparent (theme, 0, 0)) - DrawThemeParentBackground(hwnd, dc, &r); - DrawThemeBackground (theme, dc, 0, 0, &r, 0); - ReleaseDC(hwnd, dc); - } - - /* Call default proc to get the scrollbars etc. painted */ - DefWindowProcW (hwnd, WM_NCPAINT, (WPARAM)cliprgn, 0); -} - -/********************************************************************** - * The list control subclass window proc. - */ -LRESULT CALLBACK THEMING_ListBoxSubclassProc (HWND hwnd, UINT msg, - WPARAM wParam, LPARAM lParam, - ULONG_PTR dwRefData) -{ - const WCHAR* themeClass = WC_LISTBOXW; - HTHEME theme; - LRESULT result; - - switch (msg) - { - case WM_CREATE: - result = THEMING_CallOriginalClass (hwnd, msg, wParam, lParam); - OpenThemeData( hwnd, themeClass ); - return result; - - case WM_DESTROY: - theme = GetWindowTheme( hwnd ); - CloseThemeData ( theme ); - return THEMING_CallOriginalClass (hwnd, msg, wParam, lParam); - - case WM_THEMECHANGED: - theme = GetWindowTheme( hwnd ); - CloseThemeData ( theme ); - OpenThemeData( hwnd, themeClass ); - break; - - case WM_SYSCOLORCHANGE: - theme = GetWindowTheme( hwnd ); - if (!theme) return THEMING_CallOriginalClass (hwnd, msg, wParam, lParam); - /* Do nothing. When themed, a WM_THEMECHANGED will be received, too, - * which will do the repaint. */ - break; - - case WM_NCPAINT: - theme = GetWindowTheme( hwnd ); - if (!theme) return THEMING_CallOriginalClass (hwnd, msg, wParam, lParam); - nc_paint (theme, hwnd, (HRGN)wParam); - break; - - default: - /* Call old proc */ - return THEMING_CallOriginalClass (hwnd, msg, wParam, lParam); - } - return 0; -} diff --git a/dlls/comctl32/theming.c b/dlls/comctl32/theming.c index 0d47489dd5c..e9305cc3b73 100644 --- a/dlls/comctl32/theming.c +++ b/dlls/comctl32/theming.c @@ -36,13 +36,10 @@ typedef LRESULT (CALLBACK* THEMING_SUBCLASSPROC)(HWND, UINT, WPARAM, LPARAM, extern LRESULT CALLBACK THEMING_DialogSubclassProc (HWND, UINT, WPARAM, LPARAM, ULONG_PTR) DECLSPEC_HIDDEN; -extern LRESULT CALLBACK THEMING_ListBoxSubclassProc (HWND, UINT, WPARAM, LPARAM, - ULONG_PTR) DECLSPEC_HIDDEN; extern LRESULT CALLBACK THEMING_ScrollbarSubclassProc (HWND, UINT, WPARAM, LPARAM, ULONG_PTR) DECLSPEC_HIDDEN; static const WCHAR dialogClass[] = {'#','3','2','7','7','0',0}; -static const WCHAR comboLboxClass[] = {'C','o','m','b','o','L','b','o','x',0}; static const struct ThemingSubclass { @@ -51,8 +48,6 @@ static const struct ThemingSubclass } subclasses[] = { /* Note: list must be sorted by class name */ {dialogClass, THEMING_DialogSubclassProc}, - {comboLboxClass, THEMING_ListBoxSubclassProc}, - {WC_LISTBOXW, THEMING_ListBoxSubclassProc}, {WC_SCROLLBARW, THEMING_ScrollbarSubclassProc} }; @@ -85,14 +80,10 @@ static LRESULT CALLBACK subclass_proc ## N (HWND wnd, UINT msg, \ MAKE_SUBCLASS_PROC(0) MAKE_SUBCLASS_PROC(1) -MAKE_SUBCLASS_PROC(2) -MAKE_SUBCLASS_PROC(3) static const WNDPROC subclassProcs[NUM_SUBCLASSES] = { subclass_proc0, subclass_proc1, - subclass_proc2, - subclass_proc3, }; /***********************************************************************