Commit 0a83027e authored by Zhiyi Zhang's avatar Zhiyi Zhang Committed by Alexandre Julliard

uxtheme: Support drawing themed standard scroll bars.

parent b0e51ead
...@@ -180,28 +180,6 @@ extern void NC_GetSysPopupPos( HWND hwnd, RECT* rect ) DECLSPEC_HIDDEN; ...@@ -180,28 +180,6 @@ extern void NC_GetSysPopupPos( HWND hwnd, RECT* rect ) DECLSPEC_HIDDEN;
/* scrollbar */ /* scrollbar */
/* Scroll-bar hit testing */
enum SCROLL_HITTEST
{
SCROLL_NOWHERE, /* Outside the scroll bar */
SCROLL_TOP_ARROW, /* Top or left arrow */
SCROLL_TOP_RECT, /* Rectangle between the top arrow and the thumb */
SCROLL_THUMB, /* Thumb rectangle */
SCROLL_BOTTOM_RECT, /* Rectangle between the thumb and the bottom arrow */
SCROLL_BOTTOM_ARROW /* Bottom or right arrow */
};
/* Scroll bar tracking information */
struct SCROLL_TRACKING_INFO
{
HWND win; /* Tracking window */
INT bar; /* SB_HORZ / SB_VERT / SB_CTL */
INT thumb_pos; /* Thumb position */
INT thumb_val; /* Current thumb value from thumb position */
BOOL vertical; /* Is scroll bar vertical */
enum SCROLL_HITTEST hit_test; /* Hit Test code of the last button-down event */
};
extern void SCROLL_DrawNCScrollBar( HWND hwnd, HDC hdc, BOOL draw_horizontal, BOOL draw_vertical ) DECLSPEC_HIDDEN; extern void SCROLL_DrawNCScrollBar( HWND hwnd, HDC hdc, BOOL draw_horizontal, BOOL draw_vertical ) DECLSPEC_HIDDEN;
extern void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar, enum SCROLL_HITTEST hit_test, extern void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT nBar, enum SCROLL_HITTEST hit_test,
const struct SCROLL_TRACKING_INFO *tracking_info, BOOL arrows, const struct SCROLL_TRACKING_INFO *tracking_info, BOOL arrows,
......
...@@ -84,6 +84,7 @@ WINE_DECLARE_DEBUG_CHANNEL(relay); ...@@ -84,6 +84,7 @@ WINE_DECLARE_DEBUG_CHANNEL(relay);
static struct user_api_hook original_user_api = static struct user_api_hook original_user_api =
{ {
USER_DefDlgProc, USER_DefDlgProc,
USER_ScrollBarDraw,
USER_ScrollBarProc, USER_ScrollBarProc,
}; };
static struct user_api_hook hooked_user_api; static struct user_api_hook hooked_user_api;
......
...@@ -567,10 +567,10 @@ static void SCROLL_DrawInterior( HWND hwnd, HDC hdc, INT nBar, ...@@ -567,10 +567,10 @@ static void SCROLL_DrawInterior( HWND hwnd, HDC hdc, INT nBar,
SelectObject( hdc, hSaveBrush ); SelectObject( hdc, hSaveBrush );
} }
static void SCROLL_DoDrawScrollBar( HWND hwnd, HDC hdc, INT nBar, enum SCROLL_HITTEST hit_test, void WINAPI USER_ScrollBarDraw( HWND hwnd, HDC hdc, INT nBar, enum SCROLL_HITTEST hit_test,
const struct SCROLL_TRACKING_INFO *tracking_info, BOOL arrows, const struct SCROLL_TRACKING_INFO *tracking_info, BOOL arrows,
BOOL interior, RECT *rect, INT arrowSize, INT thumbPos, BOOL interior, RECT *rect, INT arrowSize, INT thumbPos,
INT thumbSize, BOOL vertical ) INT thumbSize, BOOL vertical )
{ {
SCROLLBAR_INFO *infoPtr; SCROLLBAR_INFO *infoPtr;
...@@ -678,8 +678,8 @@ void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT bar, enum SCROLL_HITTEST hit_ ...@@ -678,8 +678,8 @@ void SCROLL_DrawScrollBar( HWND hwnd, HDC hdc, INT bar, enum SCROLL_HITTEST hit_
tracking_info->thumb_val, tracking_info->vertical, tracking_info->hit_test, draw_arrows, tracking_info->thumb_val, tracking_info->vertical, tracking_info->hit_test, draw_arrows,
draw_interior, wine_dbgstr_rect(&rect), arrow_size, thumb_pos, thumb_size, vertical, draw_interior, wine_dbgstr_rect(&rect), arrow_size, thumb_pos, thumb_size, vertical,
GetCapture()); GetCapture());
SCROLL_DoDrawScrollBar( hwnd, hdc, bar, hit_test, tracking_info, draw_arrows, draw_interior, user_api->pScrollBarDraw( hwnd, hdc, bar, hit_test, tracking_info, draw_arrows, draw_interior,
&rect, arrow_size, thumb_pos, thumb_size, vertical ); &rect, arrow_size, thumb_pos, thumb_size, vertical );
} }
void SCROLL_DrawNCScrollBar( HWND hwnd, HDC hdc, BOOL draw_horizontal, BOOL draw_vertical ) void SCROLL_DrawNCScrollBar( HWND hwnd, HDC hdc, BOOL draw_horizontal, BOOL draw_vertical )
...@@ -764,6 +764,7 @@ static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt) ...@@ -764,6 +764,7 @@ static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt)
enum SCROLL_HITTEST hittest; enum SCROLL_HITTEST hittest;
HWND hwndOwner, hwndCtl; HWND hwndOwner, hwndCtl;
TRACKMOUSEEVENT tme;
BOOL vertical; BOOL vertical;
INT arrowSize, thumbSize, thumbPos; INT arrowSize, thumbSize, thumbPos;
RECT rect; RECT rect;
...@@ -771,7 +772,8 @@ static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt) ...@@ -771,7 +772,8 @@ static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt)
SCROLLBAR_INFO *infoPtr = SCROLL_GetInternalInfo( hwnd, nBar, FALSE ); SCROLLBAR_INFO *infoPtr = SCROLL_GetInternalInfo( hwnd, nBar, FALSE );
if (!infoPtr) return; if (!infoPtr) return;
if ((g_tracking_info.hit_test == SCROLL_NOWHERE) && (msg != WM_LBUTTONDOWN)) if ((g_tracking_info.hit_test == SCROLL_NOWHERE)
&& (msg != WM_LBUTTONDOWN && msg != WM_MOUSEMOVE && msg != WM_MOUSELEAVE))
return; return;
if (nBar == SB_CTL && (GetWindowLongW( hwnd, GWL_STYLE ) & (SBS_SIZEGRIP | SBS_SIZEBOX))) if (nBar == SB_CTL && (GetWindowLongW( hwnd, GWL_STYLE ) & (SBS_SIZEGRIP | SBS_SIZEBOX)))
...@@ -821,8 +823,29 @@ static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt) ...@@ -821,8 +823,29 @@ static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt)
break; break;
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
hittest = SCROLL_HitTest( hwnd, nBar, pt, TRUE ); hittest = SCROLL_HitTest( hwnd, nBar, pt, vertical == g_tracking_info.vertical && GetCapture() == hwnd );
prevPt = pt; prevPt = pt;
if (nBar != SB_CTL)
break;
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_QUERY;
TrackMouseEvent( &tme );
if (!(tme.dwFlags & TME_LEAVE) || tme.hwndTrack != hwnd)
{
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = hwnd;
TrackMouseEvent( &tme );
}
break;
case WM_MOUSELEAVE:
if (nBar != SB_CTL)
return;
hittest = SCROLL_NOWHERE;
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
...@@ -847,6 +870,8 @@ static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt) ...@@ -847,6 +870,8 @@ static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt)
switch (g_tracking_info.hit_test) switch (g_tracking_info.hit_test)
{ {
case SCROLL_NOWHERE: /* No tracking in progress */ case SCROLL_NOWHERE: /* No tracking in progress */
if (msg == WM_MOUSEMOVE || msg == WM_MOUSELEAVE)
SCROLL_DrawScrollBar( hwnd, hdc, nBar, hittest, &g_tracking_info, TRUE, TRUE );
break; break;
case SCROLL_TOP_ARROW: case SCROLL_TOP_ARROW:
...@@ -898,7 +923,7 @@ static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt) ...@@ -898,7 +923,7 @@ static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt)
{ {
SCROLL_DrawScrollBar( hwnd, hdc, nBar, SCROLL_NOWHERE, &g_tracking_info, FALSE, TRUE ); SCROLL_DrawScrollBar( hwnd, hdc, nBar, SCROLL_NOWHERE, &g_tracking_info, FALSE, TRUE );
} }
else /* WM_MOUSEMOVE */ else if (msg == WM_MOUSEMOVE)
{ {
INT pos; INT pos;
...@@ -986,6 +1011,8 @@ static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt) ...@@ -986,6 +1011,8 @@ static void SCROLL_HandleScrollEvent( HWND hwnd, INT nBar, UINT msg, POINT pt)
/* Terminate tracking */ /* Terminate tracking */
g_tracking_info.win = 0; g_tracking_info.win = 0;
SCROLL_MovingThumb = FALSE; SCROLL_MovingThumb = FALSE;
hittest = SCROLL_NOWHERE;
SCROLL_DrawScrollBar( hwnd, hdc, nBar, hittest, &g_tracking_info, TRUE, TRUE );
} }
ReleaseDC( hwnd, hdc ); ReleaseDC( hwnd, hdc );
...@@ -1021,6 +1048,7 @@ void SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt ) ...@@ -1021,6 +1048,7 @@ void SCROLL_TrackScrollBar( HWND hwnd, INT scrollbar, POINT pt )
if (CallMsgFilterW( &msg, MSGF_SCROLLBAR )) continue; if (CallMsgFilterW( &msg, MSGF_SCROLLBAR )) continue;
if (msg.message == WM_LBUTTONUP || if (msg.message == WM_LBUTTONUP ||
msg.message == WM_MOUSEMOVE || msg.message == WM_MOUSEMOVE ||
msg.message == WM_MOUSELEAVE ||
(msg.message == WM_SYSTIMER && msg.wParam == SCROLL_TIMER)) (msg.message == WM_SYSTIMER && msg.wParam == SCROLL_TIMER))
{ {
pt.x = (short)LOWORD(msg.lParam) - rect.left; pt.x = (short)LOWORD(msg.lParam) - rect.left;
...@@ -1356,6 +1384,7 @@ LRESULT WINAPI USER_ScrollBarProc( HWND hwnd, UINT message, WPARAM wParam, LPARA ...@@ -1356,6 +1384,7 @@ LRESULT WINAPI USER_ScrollBarProc( HWND hwnd, UINT message, WPARAM wParam, LPARA
break; break;
case WM_LBUTTONUP: case WM_LBUTTONUP:
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
case WM_MOUSELEAVE:
case WM_SYSTIMER: case WM_SYSTIMER:
{ {
POINT pt; POINT pt;
......
...@@ -389,5 +389,8 @@ struct png_funcs ...@@ -389,5 +389,8 @@ struct png_funcs
extern struct user_api_hook *user_api DECLSPEC_HIDDEN; extern struct user_api_hook *user_api DECLSPEC_HIDDEN;
LRESULT WINAPI USER_DefDlgProc(HWND, UINT, WPARAM, LPARAM, BOOL) DECLSPEC_HIDDEN; LRESULT WINAPI USER_DefDlgProc(HWND, UINT, WPARAM, LPARAM, BOOL) DECLSPEC_HIDDEN;
LRESULT WINAPI USER_ScrollBarProc(HWND, UINT, WPARAM, LPARAM, BOOL) DECLSPEC_HIDDEN; LRESULT WINAPI USER_ScrollBarProc(HWND, UINT, WPARAM, LPARAM, BOOL) DECLSPEC_HIDDEN;
void WINAPI USER_ScrollBarDraw(HWND, HDC, INT, enum SCROLL_HITTEST,
const struct SCROLL_TRACKING_INFO *, BOOL, BOOL, RECT *, INT, INT,
INT, BOOL) DECLSPEC_HIDDEN;
#endif /* __WINE_USER_PRIVATE_H */ #endif /* __WINE_USER_PRIVATE_H */
...@@ -1230,6 +1230,7 @@ BOOL WINAPI ThemeHooksInstall(void) ...@@ -1230,6 +1230,7 @@ BOOL WINAPI ThemeHooksInstall(void)
struct user_api_hook hooks; struct user_api_hook hooks;
hooks.pDefDlgProc = UXTHEME_DefDlgProc; hooks.pDefDlgProc = UXTHEME_DefDlgProc;
hooks.pScrollBarDraw = UXTHEME_ScrollBarDraw;
hooks.pScrollBarWndProc = UXTHEME_ScrollbarWndProc; hooks.pScrollBarWndProc = UXTHEME_ScrollbarWndProc;
return RegisterUserApiHook(&hooks, &user_api); return RegisterUserApiHook(&hooks, &user_api);
} }
......
...@@ -103,6 +103,10 @@ extern void UXTHEME_UninitSystem(void) DECLSPEC_HIDDEN; ...@@ -103,6 +103,10 @@ extern void UXTHEME_UninitSystem(void) DECLSPEC_HIDDEN;
extern struct user_api_hook user_api DECLSPEC_HIDDEN; extern struct user_api_hook user_api DECLSPEC_HIDDEN;
LRESULT WINAPI UXTHEME_DefDlgProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL unicode) DECLSPEC_HIDDEN; LRESULT WINAPI UXTHEME_DefDlgProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam, BOOL unicode) DECLSPEC_HIDDEN;
void WINAPI UXTHEME_ScrollBarDraw(HWND hwnd, HDC dc, INT bar, enum SCROLL_HITTEST hit_test,
const struct SCROLL_TRACKING_INFO *tracking_info,
BOOL draw_arrows, BOOL draw_interior, RECT *rect, INT arrowsize,
INT thumbpos, INT thumbsize, BOOL vertical) DECLSPEC_HIDDEN;
LRESULT WINAPI UXTHEME_ScrollbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, LRESULT WINAPI UXTHEME_ScrollbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
BOOL unicode) DECLSPEC_HIDDEN; BOOL unicode) DECLSPEC_HIDDEN;
......
...@@ -4409,9 +4409,35 @@ WORD WINAPI SYSTEM_KillSystemTimer( WORD ); ...@@ -4409,9 +4409,35 @@ WORD WINAPI SYSTEM_KillSystemTimer( WORD );
WINUSERAPI BOOL CDECL __wine_send_input( HWND hwnd, const INPUT *input, const RAWINPUT *rawinput ); WINUSERAPI BOOL CDECL __wine_send_input( HWND hwnd, const INPUT *input, const RAWINPUT *rawinput );
/* Uxtheme hook functions and struct */ /* Uxtheme hook functions and struct */
/* Scroll bar hit testing */
enum SCROLL_HITTEST
{
SCROLL_NOWHERE, /* Outside the scroll bar */
SCROLL_TOP_ARROW, /* Top or left arrow */
SCROLL_TOP_RECT, /* Rectangle between the top arrow and the thumb */
SCROLL_THUMB, /* Thumb rectangle */
SCROLL_BOTTOM_RECT, /* Rectangle between the thumb and the bottom arrow */
SCROLL_BOTTOM_ARROW /* Bottom or right arrow */
};
/* Scroll bar tracking information */
struct SCROLL_TRACKING_INFO
{
HWND win; /* Tracking window */
INT bar; /* SB_HORZ/SB_VERT/SB_CTL */
INT thumb_pos; /* Thumb position */
INT thumb_val; /* Current thumb value from thumb position */
BOOL vertical; /* Is scroll bar vertical */
enum SCROLL_HITTEST hit_test; /* Hit Test code of the last button-down event */
};
struct user_api_hook struct user_api_hook
{ {
LRESULT (WINAPI *pDefDlgProc)(HWND, UINT, WPARAM, LPARAM, BOOL); LRESULT (WINAPI *pDefDlgProc)(HWND, UINT, WPARAM, LPARAM, BOOL);
void (WINAPI *pScrollBarDraw)(HWND, HDC, INT, enum SCROLL_HITTEST,
const struct SCROLL_TRACKING_INFO *, BOOL, BOOL, RECT *, INT, INT,
INT, BOOL);
LRESULT (WINAPI *pScrollBarWndProc)(HWND, UINT, WPARAM, LPARAM, BOOL); LRESULT (WINAPI *pScrollBarWndProc)(HWND, UINT, WPARAM, LPARAM, BOOL);
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment