From 942dc5612625ee3ccd295c2828ad2069a00fe2b7 Mon Sep 17 00:00:00 2001 From: Frank Richter Date: Thu, 18 Aug 2005 11:45:43 +0000 Subject: [PATCH] Add theming for listbox (and combo listbox) controls. --- dlls/comctl32/Makefile.in | 1 + dlls/comctl32/theme_listbox.c | 118 ++++++++++++++++++++++++++++++++++ dlls/comctl32/theming.c | 14 +++- 3 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 dlls/comctl32/theme_listbox.c diff --git a/dlls/comctl32/Makefile.in b/dlls/comctl32/Makefile.in index 68f8de1e459..5d8264586b1 100644 --- a/dlls/comctl32/Makefile.in +++ b/dlls/comctl32/Makefile.in @@ -37,6 +37,7 @@ C_SRCS = \ tab.c \ theme_combo.c \ theme_edit.c \ + theme_listbox.c \ theming.c \ toolbar.c \ tooltips.c \ diff --git a/dlls/comctl32/theme_listbox.c b/dlls/comctl32/theme_listbox.c new file mode 100644 index 00000000000..aec9c5585e2 --- /dev/null +++ b/dlls/comctl32/theme_listbox.c @@ -0,0 +1,118 @@ +/* + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include +#include +#include + +#include "windef.h" +#include "winbase.h" +#include "wingdi.h" +#include "winuser.h" +#include "uxtheme.h" +#include "tmschema.h" +#include "comctl32.h" +#include "wine/debug.h" + +WINE_DEFAULT_DEBUG_CHANNEL(theminglistbox); + +/* 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 6c64bfc8abd..01e226d40c9 100644 --- a/dlls/comctl32/theming.c +++ b/dlls/comctl32/theming.c @@ -37,6 +37,10 @@ extern LRESULT CALLBACK THEMING_ComboSubclassProc (HWND, UINT, WPARAM, LPARAM, ULONG_PTR); extern LRESULT CALLBACK THEMING_EditSubclassProc (HWND, UINT, WPARAM, LPARAM, ULONG_PTR); +extern LRESULT CALLBACK THEMING_ListBoxSubclassProc (HWND, UINT, WPARAM, LPARAM, + ULONG_PTR); + +static const WCHAR comboLboxClass[] = {'C','o','m','b','o','L','b','o','x',0}; static const struct ThemingSubclass { @@ -45,7 +49,9 @@ static const struct ThemingSubclass } subclasses[] = { /* Note: list must be sorted by class name */ {WC_COMBOBOXW, THEMING_ComboSubclassProc}, - {WC_EDITW, THEMING_EditSubclassProc} + {comboLboxClass, THEMING_ListBoxSubclassProc}, + {WC_EDITW, THEMING_EditSubclassProc}, + {WC_LISTBOXW, THEMING_ListBoxSubclassProc} }; #define NUM_SUBCLASSES (sizeof(subclasses)/sizeof(subclasses[0])) @@ -92,10 +98,14 @@ static LRESULT CALLBACK subclass_stub ## N (HWND wnd, UINT msg, \ MAKE_SUBCLASS_STUB(0) MAKE_SUBCLASS_STUB(1) +MAKE_SUBCLASS_STUB(2) +MAKE_SUBCLASS_STUB(3) const static WNDPROC subclassStubs[NUM_SUBCLASSES] = { subclass_stub0, - subclass_stub1 + subclass_stub1, + subclass_stub2, + subclass_stub3 }; /***********************************************************************