Author: gadamopoulos
Date: Tue Feb 21 21:47:41 2017
New Revision: 73873
URL:
http://svn.reactos.org/svn/reactos?rev=73873&view=rev
Log:
[COMCTL32] -Rename BUTTON_Paint to BUTTON_PaintWithTheme and use it in the newly added
code for the v6 button.
Modified:
trunk/reactos/dll/win32/comctl32/button.c
trunk/reactos/dll/win32/comctl32/theme_button.c
Modified: trunk/reactos/dll/win32/comctl32/button.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comctl32/button.…
==============================================================================
--- trunk/reactos/dll/win32/comctl32/button.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/comctl32/button.c [iso-8859-1] Tue Feb 21 21:47:41 2017
@@ -205,7 +205,7 @@
return hrgn;
}
-BOOL BUTTON_Paint(HTHEME theme, HWND hwnd, HDC hParamDC, UINT action);
+BOOL BUTTON_PaintWithTheme(HTHEME theme, HWND hwnd, HDC hParamDC);
#endif
@@ -227,12 +227,31 @@
/* paint a button of any type */
static inline void paint_button( HWND hwnd, LONG style, UINT action )
{
+#ifndef _USER32_
+ HTHEME theme = GetWindowTheme(hwnd);
+ RECT rc;
+ HDC hdc = GetDC( hwnd );
+ /* GetDC appears to give a dc with a clip rect that includes the whoe parent, not
sure if it is correct or not. */
+ GetClientRect(hwnd, &rc);
+ IntersectClipRect (hdc, rc.left, rc. top, rc.right, rc.bottom);
+ if (theme && BUTTON_PaintWithTheme(theme, hwnd, hdc))
+ {
+ ReleaseDC( hwnd, hdc );
+ return;
+ }
+ if (btnPaintFunc[style] && IsWindowVisible(hwnd))
+ {
+ btnPaintFunc[style]( hwnd, hdc, action );
+ }
+ ReleaseDC( hwnd, hdc );
+#elif
if (btnPaintFunc[style] && IsWindowVisible(hwnd))
{
HDC hdc = GetDC( hwnd );
btnPaintFunc[style]( hwnd, hdc, action );
ReleaseDC( hwnd, hdc );
}
+#endif
}
/* retrieve the button text; returned buffer must be freed by caller */
@@ -343,6 +362,9 @@
#ifdef __REACTOS__
button_update_uistate( hWnd, unicode );
#endif
+#ifndef _USER32_
+ OpenThemeData(hWnd, WC_BUTTONW);
+#endif
return 0;
#if defined(__REACTOS__) && defined(_USER32_)
@@ -351,7 +373,31 @@
case WM_DESTROY:
break;
#endif
-
+#ifndef _USER32_
+ case WM_DESTROY:
+ CloseThemeData (GetWindowTheme(hWnd));
+ break;
+ case WM_THEMECHANGED:
+ CloseThemeData (GetWindowTheme(hWnd));
+ OpenThemeData(hWnd, WC_BUTTONW);
+ break;
+
+ case WM_MOUSEHOVER:
+ {
+ int state = (int)SendMessageW(hWnd, BM_GETSTATE, 0, 0);
+ SetWindowLongW(hWnd, 0, state|BST_HOT);
+ InvalidateRect(hWnd, NULL, FALSE);
+ break;
+ }
+
+ case WM_MOUSELEAVE:
+ {
+ int state = (int)SendMessageW(hWnd, BM_GETSTATE, 0, 0);
+ SetWindowLongW(hWnd, 0, state&(~BST_HOT));
+ InvalidateRect(hWnd, NULL, FALSE);
+ break;
+ }
+#endif
case WM_ERASEBKGND:
if (btn_type == BS_OWNERDRAW)
{
@@ -378,6 +424,14 @@
{
PAINTSTRUCT ps;
HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &ps );
+#ifndef _USER32_
+ HTHEME theme = GetWindowTheme(hWnd);
+ if (theme && BUTTON_PaintWithTheme(theme, hWnd, hdc))
+ {
+ if ( !wParam ) EndPaint( hWnd, &ps );
+ return 0;
+ }
+#endif
if (btnPaintFunc[btn_type])
{
int nOldMode = SetBkMode( hdc, OPAQUE );
@@ -480,6 +534,21 @@
break;
case WM_MOUSEMOVE:
+#ifndef _USER32_
+ {
+ TRACKMOUSEEVENT mouse_event;
+ mouse_event.cbSize = sizeof(TRACKMOUSEEVENT);
+ mouse_event.dwFlags = TME_QUERY;
+ if(!TrackMouseEvent(&mouse_event) ||
!(mouse_event.dwFlags&(TME_HOVER|TME_LEAVE)))
+ {
+ mouse_event.dwFlags = TME_HOVER|TME_LEAVE;
+ mouse_event.hwndTrack = hWnd;
+ mouse_event.dwHoverTime = 1;
+ TrackMouseEvent(&mouse_event);
+ }
+ }
+#endif
+
if ((wParam & MK_LBUTTON) && GetCapture() == hWnd)
{
GetClientRect( hWnd, &rect );
Modified: trunk/reactos/dll/win32/comctl32/theme_button.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/comctl32/theme_b…
==============================================================================
--- trunk/reactos/dll/win32/comctl32/theme_button.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/comctl32/theme_button.c [iso-8859-1] Tue Feb 21 21:47:41 2017
@@ -294,16 +294,16 @@
NULL, /* Not defined */
};
-static BOOL BUTTON_Paint(HTHEME theme, HWND hwnd, HDC hParamDC)
-{
- PAINTSTRUCT ps;
- HDC hDC;
+BOOL BUTTON_PaintWithTheme(HTHEME theme, HWND hwnd, HDC hParamDC)
+{
DWORD dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
DWORD dwStyleEx = GetWindowLongW(hwnd, GWL_EXSTYLE);
UINT dtFlags = get_drawtext_flags(dwStyle, dwStyleEx);
int state = (int)SendMessageW(hwnd, BM_GETSTATE, 0, 0);
ButtonState drawState;
pfThemedPaint paint = btnThemedPaintFunc[ dwStyle & BUTTON_TYPE ];
+ if (!paint)
+ return FALSE;
if(IsWindowEnabled(hwnd))
{
@@ -314,105 +314,6 @@
}
else drawState = STATE_DISABLED;
- hDC = hParamDC ? hParamDC : BeginPaint(hwnd, &ps);
- if (paint) paint(theme, hwnd, hDC, drawState, dtFlags, state & BST_FOCUS);
- if (!hParamDC) EndPaint(hwnd, &ps);
+ paint(theme, hwnd, hParamDC, drawState, dtFlags, state & BST_FOCUS);
return TRUE;
}
-
-/**********************************************************************
- * The button control subclass window proc.
- */
-LRESULT CALLBACK THEMING_ButtonSubclassProc(HWND hwnd, UINT msg,
- WPARAM wParam, LPARAM lParam,
- ULONG_PTR dwRefData)
-{
- const WCHAR* themeClass = WC_BUTTONW;
- 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_PAINT:
- theme = GetWindowTheme(hwnd);
- if (theme && BUTTON_Paint(theme, hwnd, (HDC)wParam))
- return 0;
- else
- return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
-
- case WM_ENABLE:
- theme = GetWindowTheme(hwnd);
- if (theme) {
- RedrawWindow(hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE | RDW_UPDATENOW);
- return 0;
- } else
- return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
-
- case WM_MOUSEMOVE:
- {
- TRACKMOUSEEVENT mouse_event;
- mouse_event.cbSize = sizeof(TRACKMOUSEEVENT);
- mouse_event.dwFlags = TME_QUERY;
- if(!TrackMouseEvent(&mouse_event) ||
!(mouse_event.dwFlags&(TME_HOVER|TME_LEAVE)))
- {
- mouse_event.dwFlags = TME_HOVER|TME_LEAVE;
- mouse_event.hwndTrack = hwnd;
- mouse_event.dwHoverTime = 1;
- TrackMouseEvent(&mouse_event);
- }
- break;
- }
-
- case WM_MOUSEHOVER:
- {
- int state = (int)SendMessageW(hwnd, BM_GETSTATE, 0, 0);
- SetWindowLongW(hwnd, 0, state|BST_HOT);
- InvalidateRect(hwnd, NULL, FALSE);
- break;
- }
-
- case WM_MOUSELEAVE:
- {
- int state = (int)SendMessageW(hwnd, BM_GETSTATE, 0, 0);
- SetWindowLongW(hwnd, 0, state&(~BST_HOT));
- InvalidateRect(hwnd, NULL, FALSE);
- break;
- }
-
- case BM_SETCHECK:
- case BM_SETSTATE:
- theme = GetWindowTheme(hwnd);
- if (theme) {
- InvalidateRect(hwnd, NULL, FALSE);
- }
- return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
-
- default:
- /* Call old proc */
- return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
- }
- return 0;
-}