From 125af16c9bc35d7620aa9089ebe668e6e484be71 Mon Sep 17 00:00:00 2001 From: Giannis Adamopoulos Date: Sat, 14 May 2011 19:01:50 +0000 Subject: [PATCH] [uxtheme] - Begin implementing handling WM_NCPAINT - Evert time a draw operation is performed on the non client area, a DRAW_CONTEXT will be initialised in order to keep most used information about the drawing opoeration svn path=/branches/GSoC_2011/ThemesSupport/; revision=51746 --- dll/win32/uxtheme/nonclient.c | 100 ++++++++++++++++++++++++++++------ 1 file changed, 82 insertions(+), 18 deletions(-) diff --git a/dll/win32/uxtheme/nonclient.c b/dll/win32/uxtheme/nonclient.c index 87ecff462fe..8373b211c31 100644 --- a/dll/win32/uxtheme/nonclient.c +++ b/dll/win32/uxtheme/nonclient.c @@ -6,17 +6,8 @@ * PROGRAMMER: Giannis Adamopoulos */ - - -#include "config.h" - -#include -#include - -#include "windef.h" -#include "winbase.h" -#include "winuser.h" -#include "wingdi.h" +#include +#include "undocuser.h" #include "vfwmsgs.h" #include "uxtheme.h" @@ -24,15 +15,88 @@ WINE_DEFAULT_DEBUG_CHANNEL(uxtheme); +typedef struct _DRAW_CONTEXT +{ + HWND hWnd; + HDC hDC; + HTHEME theme; + WINDOWINFO wi; + HRGN hRgn; +} DRAW_CONTEXT, *PDRAW_CONTEXT; + +static void +ThemeInitDrawContext(PDRAW_CONTEXT pcontext, + HWND hWnd, + HRGN hRgn) +{ + GetWindowInfo(hWnd, &pcontext->wi); + pcontext->hWnd = hWnd; + pcontext->theme = OpenThemeData(pcontext->hWnd, L"WINDOW"); + + if(hRgn <= 0) + { + hRgn = CreateRectRgnIndirect(&pcontext->wi.rcWindow); + pcontext->hRgn = hRgn; + } + else + { + pcontext->hRgn = 0; + } + + pcontext->hDC = GetDCEx(hWnd, hRgn, DCX_WINDOW | DCX_INTERSECTRGN | DCX_USESTYLE | DCX_KEEPCLIPRGN); +} + +static void +ThemeCleanupDrawContext(PDRAW_CONTEXT pcontext) +{ + ReleaseDC(pcontext->hWnd ,pcontext->hDC); + + CloseThemeData (pcontext->theme); + + if(pcontext->hRgn != NULL) + { + DeleteObject(pcontext->hRgn); + } +} + +/* + Message handlers + */ + +static void +ThemePaintWindow(PDRAW_CONTEXT pcontext, RECT* prcCurrent) +{ + UNIMPLEMENTED; +} + +static LRESULT +ThemeHandleNCPaint(HWND hWnd, HRGN hRgn) +{ + DRAW_CONTEXT context; + RECT rcCurrent; + + ThemeInitDrawContext(&context, hWnd, hRgn); + + rcCurrent = context.wi.rcWindow; + OffsetRect( &rcCurrent, -context.wi.rcWindow.left, -context.wi.rcWindow.top); + + ThemePaintWindow(&context, &rcCurrent); + ThemeCleanupDrawContext(&context); + + return 0; +} LRESULT CALLBACK ThemeWndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam, WNDPROC DefWndProc) { - UNIMPLEMENTED; - - /* Some test */ - if(Msg == WM_NCPAINT || Msg == WM_NCACTIVATE) - return FALSE; - - return DefWndProc(hWnd, Msg, wParam, lParam); + switch(Msg) + { + case WM_NCPAINT: + return ThemeHandleNCPaint(hWnd, (HRGN)wParam); + case WM_NCACTIVATE: + ThemeHandleNCPaint(hWnd, (HRGN)1); + return TRUE; + default: + return DefWndProc(hWnd, Msg, wParam, lParam); + } }