Author: gadamopoulos
Date: Sat May 14 19:01:50 2011
New Revision: 51746
URL:
http://svn.reactos.org/svn/reactos?rev=51746&view=rev
Log:
[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
Modified:
branches/GSoC_2011/ThemesSupport/dll/win32/uxtheme/nonclient.c
Modified: branches/GSoC_2011/ThemesSupport/dll/win32/uxtheme/nonclient.c
URL:
http://svn.reactos.org/svn/reactos/branches/GSoC_2011/ThemesSupport/dll/win…
==============================================================================
--- branches/GSoC_2011/ThemesSupport/dll/win32/uxtheme/nonclient.c [iso-8859-1]
(original)
+++ branches/GSoC_2011/ThemesSupport/dll/win32/uxtheme/nonclient.c [iso-8859-1] Sat May 14
19:01:50 2011
@@ -6,17 +6,8 @@
* PROGRAMMER: Giannis Adamopoulos
*/
-
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdarg.h>
-
-#include "windef.h"
-#include "winbase.h"
-#include "winuser.h"
-#include "wingdi.h"
+#include <windows.h>
+#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);
+ }
}