mirror of
https://github.com/reactos/reactos.git
synced 2025-01-05 22:12:46 +00:00
[COMCTL32] -Rename BUTTON_Paint to BUTTON_PaintWithTheme and use it in the newly added code for the v6 button.
svn path=/trunk/; revision=73873
This commit is contained in:
parent
5c77ae15e6
commit
2ed266de0c
2 changed files with 74 additions and 104 deletions
|
@ -205,7 +205,7 @@ HRGN set_control_clipping( HDC hdc, const RECT *rect )
|
||||||
return hrgn;
|
return hrgn;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL BUTTON_Paint(HTHEME theme, HWND hwnd, HDC hParamDC, UINT action);
|
BOOL BUTTON_PaintWithTheme(HTHEME theme, HWND hwnd, HDC hParamDC);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -227,12 +227,31 @@ static inline UINT get_button_type( LONG window_style )
|
||||||
/* paint a button of any type */
|
/* paint a button of any type */
|
||||||
static inline void paint_button( HWND hwnd, LONG style, UINT action )
|
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))
|
if (btnPaintFunc[style] && IsWindowVisible(hwnd))
|
||||||
{
|
{
|
||||||
HDC hdc = GetDC( hwnd );
|
HDC hdc = GetDC( hwnd );
|
||||||
btnPaintFunc[style]( hwnd, hdc, action );
|
btnPaintFunc[style]( hwnd, hdc, action );
|
||||||
ReleaseDC( hwnd, hdc );
|
ReleaseDC( hwnd, hdc );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* retrieve the button text; returned buffer must be freed by caller */
|
/* retrieve the button text; returned buffer must be freed by caller */
|
||||||
|
@ -342,6 +361,9 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
|
||||||
set_button_state( hWnd, BST_UNCHECKED );
|
set_button_state( hWnd, BST_UNCHECKED );
|
||||||
#ifdef __REACTOS__
|
#ifdef __REACTOS__
|
||||||
button_update_uistate( hWnd, unicode );
|
button_update_uistate( hWnd, unicode );
|
||||||
|
#endif
|
||||||
|
#ifndef _USER32_
|
||||||
|
OpenThemeData(hWnd, WC_BUTTONW);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -351,7 +373,31 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
|
||||||
case WM_DESTROY:
|
case WM_DESTROY:
|
||||||
break;
|
break;
|
||||||
#endif
|
#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:
|
case WM_ERASEBKGND:
|
||||||
if (btn_type == BS_OWNERDRAW)
|
if (btn_type == BS_OWNERDRAW)
|
||||||
{
|
{
|
||||||
|
@ -378,6 +424,14 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
|
||||||
{
|
{
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
HDC hdc = wParam ? (HDC)wParam : BeginPaint( hWnd, &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])
|
if (btnPaintFunc[btn_type])
|
||||||
{
|
{
|
||||||
int nOldMode = SetBkMode( hdc, OPAQUE );
|
int nOldMode = SetBkMode( hdc, OPAQUE );
|
||||||
|
@ -480,6 +534,21 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_MOUSEMOVE:
|
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)
|
if ((wParam & MK_LBUTTON) && GetCapture() == hWnd)
|
||||||
{
|
{
|
||||||
GetClientRect( hWnd, &rect );
|
GetClientRect( hWnd, &rect );
|
||||||
|
|
|
@ -294,16 +294,16 @@ static const pfThemedPaint btnThemedPaintFunc[BUTTON_TYPE + 1] =
|
||||||
NULL, /* Not defined */
|
NULL, /* Not defined */
|
||||||
};
|
};
|
||||||
|
|
||||||
static BOOL BUTTON_Paint(HTHEME theme, HWND hwnd, HDC hParamDC)
|
BOOL BUTTON_PaintWithTheme(HTHEME theme, HWND hwnd, HDC hParamDC)
|
||||||
{
|
{
|
||||||
PAINTSTRUCT ps;
|
|
||||||
HDC hDC;
|
|
||||||
DWORD dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
|
DWORD dwStyle = GetWindowLongW(hwnd, GWL_STYLE);
|
||||||
DWORD dwStyleEx = GetWindowLongW(hwnd, GWL_EXSTYLE);
|
DWORD dwStyleEx = GetWindowLongW(hwnd, GWL_EXSTYLE);
|
||||||
UINT dtFlags = get_drawtext_flags(dwStyle, dwStyleEx);
|
UINT dtFlags = get_drawtext_flags(dwStyle, dwStyleEx);
|
||||||
int state = (int)SendMessageW(hwnd, BM_GETSTATE, 0, 0);
|
int state = (int)SendMessageW(hwnd, BM_GETSTATE, 0, 0);
|
||||||
ButtonState drawState;
|
ButtonState drawState;
|
||||||
pfThemedPaint paint = btnThemedPaintFunc[ dwStyle & BUTTON_TYPE ];
|
pfThemedPaint paint = btnThemedPaintFunc[ dwStyle & BUTTON_TYPE ];
|
||||||
|
if (!paint)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
if(IsWindowEnabled(hwnd))
|
if(IsWindowEnabled(hwnd))
|
||||||
{
|
{
|
||||||
|
@ -314,105 +314,6 @@ static BOOL BUTTON_Paint(HTHEME theme, HWND hwnd, HDC hParamDC)
|
||||||
}
|
}
|
||||||
else drawState = STATE_DISABLED;
|
else drawState = STATE_DISABLED;
|
||||||
|
|
||||||
hDC = hParamDC ? hParamDC : BeginPaint(hwnd, &ps);
|
paint(theme, hwnd, hParamDC, drawState, dtFlags, state & BST_FOCUS);
|
||||||
if (paint) paint(theme, hwnd, hDC, drawState, dtFlags, state & BST_FOCUS);
|
|
||||||
if (!hParamDC) EndPaint(hwnd, &ps);
|
|
||||||
return TRUE;
|
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;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue