2015-02-15 17:10:10 +01:00
|
|
|
/*
|
|
|
|
* Theming - Scrollbar control
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015 Mark Harmstone
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
|
|
|
#include "winuser.h"
|
|
|
|
#include "uxtheme.h"
|
2021-07-20 15:04:14 +02:00
|
|
|
#include "uxthemedll.h"
|
2015-02-15 17:10:10 +01:00
|
|
|
#include "vssym32.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(theme_scroll);
|
|
|
|
|
2021-07-20 15:04:33 +02:00
|
|
|
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)
|
2015-03-03 22:56:37 +01:00
|
|
|
{
|
2021-07-20 15:04:33 +02:00
|
|
|
BOOL disabled = !IsWindowEnabled(hwnd);
|
|
|
|
HTHEME theme;
|
|
|
|
DWORD style;
|
2015-03-03 22:56:37 +01:00
|
|
|
|
2021-07-20 15:04:33 +02:00
|
|
|
theme = bar == SB_CTL ? GetWindowTheme(hwnd) : OpenThemeData(NULL, WC_SCROLLBARW);
|
|
|
|
if (!theme)
|
2015-03-03 22:56:37 +01:00
|
|
|
{
|
2021-07-20 15:04:33 +02:00
|
|
|
user_api.pScrollBarDraw(hwnd, dc, bar, hit_test, tracking_info, draw_arrows, draw_interior,
|
|
|
|
rect, arrowsize, thumbpos, thumbsize, vertical);
|
2015-03-03 22:56:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-07-20 15:04:33 +02:00
|
|
|
style = GetWindowLongW(hwnd, GWL_STYLE);
|
|
|
|
if (bar == SB_CTL && (style & SBS_SIZEBOX || style & SBS_SIZEGRIP)) {
|
2015-03-03 08:44:42 +01:00
|
|
|
int state;
|
|
|
|
|
|
|
|
if (style & SBS_SIZEBOXTOPLEFTALIGN)
|
|
|
|
state = SZB_TOPLEFTALIGN;
|
|
|
|
else
|
|
|
|
state = SZB_RIGHTALIGN;
|
|
|
|
|
2021-06-22 10:20:51 +02:00
|
|
|
if (IsThemeBackgroundPartiallyTransparent(theme, SBP_SIZEBOX, state))
|
|
|
|
DrawThemeParentBackground(hwnd, dc, NULL);
|
2021-07-20 15:04:33 +02:00
|
|
|
DrawThemeBackground(theme, dc, SBP_SIZEBOX, state, rect, NULL);
|
2015-03-03 08:44:42 +01:00
|
|
|
} else {
|
|
|
|
int uppertrackstate, lowertrackstate, thumbstate;
|
2021-07-20 15:04:33 +02:00
|
|
|
RECT partrect;
|
2015-03-03 08:44:42 +01:00
|
|
|
SIZE grippersize;
|
|
|
|
|
|
|
|
if (disabled) {
|
|
|
|
uppertrackstate = SCRBS_DISABLED;
|
|
|
|
lowertrackstate = SCRBS_DISABLED;
|
|
|
|
thumbstate = SCRBS_DISABLED;
|
|
|
|
} else {
|
|
|
|
uppertrackstate = SCRBS_NORMAL;
|
|
|
|
lowertrackstate = SCRBS_NORMAL;
|
|
|
|
thumbstate = SCRBS_NORMAL;
|
2015-03-03 22:56:37 +01:00
|
|
|
|
2021-07-20 15:04:40 +02:00
|
|
|
if (vertical == tracking_info->vertical && hit_test == tracking_info->hit_test
|
|
|
|
&& GetCapture() == hwnd)
|
|
|
|
{
|
|
|
|
if (hit_test == SCROLL_TOP_RECT)
|
|
|
|
uppertrackstate = SCRBS_PRESSED;
|
|
|
|
else if (hit_test == SCROLL_BOTTOM_RECT)
|
|
|
|
lowertrackstate = SCRBS_PRESSED;
|
|
|
|
else if (hit_test == SCROLL_THUMB)
|
|
|
|
thumbstate = SCRBS_PRESSED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (hit_test == SCROLL_TOP_RECT)
|
|
|
|
uppertrackstate = SCRBS_HOT;
|
|
|
|
else if (hit_test == SCROLL_BOTTOM_RECT)
|
|
|
|
lowertrackstate = SCRBS_HOT;
|
|
|
|
else if (hit_test == SCROLL_THUMB)
|
|
|
|
thumbstate = SCRBS_HOT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Thumb is also shown as pressed when tracking */
|
|
|
|
if (tracking_info->win == hwnd && tracking_info->bar == bar)
|
|
|
|
thumbstate = SCRBS_PRESSED;
|
2015-03-03 08:44:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (vertical) {
|
|
|
|
int uparrowstate, downarrowstate;
|
|
|
|
|
|
|
|
if (disabled) {
|
|
|
|
uparrowstate = ABS_UPDISABLED;
|
|
|
|
downarrowstate = ABS_DOWNDISABLED;
|
|
|
|
} else {
|
|
|
|
uparrowstate = ABS_UPNORMAL;
|
|
|
|
downarrowstate = ABS_DOWNNORMAL;
|
2015-03-03 22:56:37 +01:00
|
|
|
|
2021-07-20 15:04:40 +02:00
|
|
|
if (vertical == tracking_info->vertical && hit_test == tracking_info->hit_test
|
|
|
|
&& GetCapture() == hwnd)
|
|
|
|
{
|
|
|
|
if (hit_test == SCROLL_TOP_ARROW)
|
|
|
|
uparrowstate = ABS_UPPRESSED;
|
|
|
|
else if (hit_test == SCROLL_BOTTOM_ARROW)
|
|
|
|
downarrowstate = ABS_DOWNPRESSED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (hit_test == SCROLL_TOP_ARROW)
|
|
|
|
uparrowstate = ABS_UPHOT;
|
|
|
|
else if (hit_test == SCROLL_BOTTOM_ARROW)
|
|
|
|
downarrowstate = ABS_DOWNHOT;
|
|
|
|
}
|
2015-03-03 08:44:42 +01:00
|
|
|
}
|
|
|
|
|
2021-07-20 15:04:33 +02:00
|
|
|
partrect = *rect;
|
|
|
|
partrect.bottom = partrect.top + arrowsize;
|
2021-08-25 08:24:42 +02:00
|
|
|
if (bar == SB_CTL && IsThemeBackgroundPartiallyTransparent(theme, SBP_ARROWBTN, uparrowstate))
|
|
|
|
DrawThemeParentBackground(hwnd, dc, &partrect);
|
2015-03-03 08:44:42 +01:00
|
|
|
DrawThemeBackground(theme, dc, SBP_ARROWBTN, uparrowstate, &partrect, NULL);
|
|
|
|
|
2021-07-20 15:04:33 +02:00
|
|
|
partrect.bottom = rect->bottom;
|
|
|
|
partrect.top = partrect.bottom - arrowsize;
|
2021-08-25 08:24:42 +02:00
|
|
|
if (bar == SB_CTL && IsThemeBackgroundPartiallyTransparent(theme, SBP_ARROWBTN, downarrowstate))
|
|
|
|
DrawThemeParentBackground(hwnd, dc, &partrect);
|
2015-03-03 08:44:42 +01:00
|
|
|
DrawThemeBackground(theme, dc, SBP_ARROWBTN, downarrowstate, &partrect, NULL);
|
|
|
|
|
|
|
|
if (thumbpos > 0) {
|
2021-07-20 15:04:33 +02:00
|
|
|
partrect.top = rect->top + arrowsize;
|
|
|
|
partrect.bottom = rect->top + thumbpos;
|
2015-03-03 08:44:42 +01:00
|
|
|
|
2021-08-25 08:24:42 +02:00
|
|
|
if (bar == SB_CTL && IsThemeBackgroundPartiallyTransparent(theme, SBP_UPPERTRACKVERT, uppertrackstate))
|
|
|
|
DrawThemeParentBackground(hwnd, dc, &partrect);
|
2015-03-03 08:44:42 +01:00
|
|
|
DrawThemeBackground(theme, dc, SBP_UPPERTRACKVERT, uppertrackstate, &partrect, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thumbsize > 0) {
|
2021-07-20 15:04:33 +02:00
|
|
|
partrect.top = rect->top + thumbpos;
|
2015-03-03 08:44:42 +01:00
|
|
|
partrect.bottom = partrect.top + thumbsize;
|
|
|
|
|
2021-08-25 08:24:42 +02:00
|
|
|
if (bar == SB_CTL && IsThemeBackgroundPartiallyTransparent(theme, SBP_THUMBBTNVERT, thumbstate))
|
|
|
|
DrawThemeParentBackground(hwnd, dc, &partrect);
|
2015-03-03 08:44:42 +01:00
|
|
|
DrawThemeBackground(theme, dc, SBP_THUMBBTNVERT, thumbstate, &partrect, NULL);
|
|
|
|
|
|
|
|
if (SUCCEEDED(GetThemePartSize(theme, dc, SBP_GRIPPERVERT, thumbstate, NULL, TS_DRAW, &grippersize))) {
|
|
|
|
MARGINS margins;
|
|
|
|
|
|
|
|
if (SUCCEEDED(GetThemeMargins(theme, dc, SBP_THUMBBTNVERT, thumbstate, TMT_CONTENTMARGINS, &partrect, &margins))) {
|
|
|
|
if (grippersize.cy <= (thumbsize - margins.cyTopHeight - margins.cyBottomHeight))
|
|
|
|
DrawThemeBackground(theme, dc, SBP_GRIPPERVERT, thumbstate, &partrect, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-20 15:04:33 +02:00
|
|
|
partrect.bottom = rect->bottom - arrowsize;
|
|
|
|
if (thumbsize > 0)
|
|
|
|
partrect.top = rect->top + thumbpos + thumbsize;
|
|
|
|
else
|
|
|
|
partrect.top = rect->top + arrowsize;
|
|
|
|
if (partrect.bottom > partrect.top)
|
2021-08-25 08:24:42 +02:00
|
|
|
{
|
|
|
|
if (bar == SB_CTL && IsThemeBackgroundPartiallyTransparent(theme, SBP_LOWERTRACKVERT, lowertrackstate))
|
|
|
|
DrawThemeParentBackground(hwnd, dc, &partrect);
|
2015-03-03 08:44:42 +01:00
|
|
|
DrawThemeBackground(theme, dc, SBP_LOWERTRACKVERT, lowertrackstate, &partrect, NULL);
|
2021-08-25 08:24:42 +02:00
|
|
|
}
|
2015-03-03 08:44:42 +01:00
|
|
|
} else {
|
|
|
|
int leftarrowstate, rightarrowstate;
|
|
|
|
|
|
|
|
if (disabled) {
|
|
|
|
leftarrowstate = ABS_LEFTDISABLED;
|
|
|
|
rightarrowstate = ABS_RIGHTDISABLED;
|
|
|
|
} else {
|
|
|
|
leftarrowstate = ABS_LEFTNORMAL;
|
|
|
|
rightarrowstate = ABS_RIGHTNORMAL;
|
2015-03-03 22:56:37 +01:00
|
|
|
|
2021-07-20 15:04:40 +02:00
|
|
|
if (vertical == tracking_info->vertical && hit_test == tracking_info->hit_test
|
|
|
|
&& GetCapture() == hwnd)
|
|
|
|
{
|
|
|
|
if (hit_test == SCROLL_TOP_ARROW)
|
|
|
|
leftarrowstate = ABS_LEFTPRESSED;
|
|
|
|
else if (hit_test == SCROLL_BOTTOM_ARROW)
|
|
|
|
rightarrowstate = ABS_RIGHTPRESSED;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (hit_test == SCROLL_TOP_ARROW)
|
|
|
|
leftarrowstate = ABS_LEFTHOT;
|
|
|
|
else if (hit_test == SCROLL_BOTTOM_ARROW)
|
|
|
|
rightarrowstate = ABS_RIGHTHOT;
|
|
|
|
}
|
2015-03-03 08:44:42 +01:00
|
|
|
}
|
|
|
|
|
2021-07-20 15:04:33 +02:00
|
|
|
partrect = *rect;
|
|
|
|
partrect.right = partrect.left + arrowsize;
|
2021-08-25 08:24:42 +02:00
|
|
|
if (bar == SB_CTL && IsThemeBackgroundPartiallyTransparent(theme, SBP_ARROWBTN, leftarrowstate))
|
|
|
|
DrawThemeParentBackground(hwnd, dc, &partrect);
|
2015-03-03 08:44:42 +01:00
|
|
|
DrawThemeBackground(theme, dc, SBP_ARROWBTN, leftarrowstate, &partrect, NULL);
|
|
|
|
|
2021-07-20 15:04:33 +02:00
|
|
|
partrect.right = rect->right;
|
|
|
|
partrect.left = partrect.right - arrowsize;
|
2021-08-25 08:24:42 +02:00
|
|
|
if (bar == SB_CTL && IsThemeBackgroundPartiallyTransparent(theme, SBP_ARROWBTN, rightarrowstate))
|
|
|
|
DrawThemeParentBackground(hwnd, dc, &partrect);
|
2015-03-03 08:44:42 +01:00
|
|
|
DrawThemeBackground(theme, dc, SBP_ARROWBTN, rightarrowstate, &partrect, NULL);
|
|
|
|
|
|
|
|
if (thumbpos > 0) {
|
2021-07-20 15:04:33 +02:00
|
|
|
partrect.left = rect->left + arrowsize;
|
|
|
|
partrect.right = rect->left + thumbpos;
|
2015-03-03 08:44:42 +01:00
|
|
|
|
2021-08-25 08:24:42 +02:00
|
|
|
if (bar == SB_CTL && IsThemeBackgroundPartiallyTransparent(theme, SBP_UPPERTRACKHORZ, uppertrackstate))
|
|
|
|
DrawThemeParentBackground(hwnd, dc, &partrect);
|
2015-03-03 08:44:42 +01:00
|
|
|
DrawThemeBackground(theme, dc, SBP_UPPERTRACKHORZ, uppertrackstate, &partrect, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (thumbsize > 0) {
|
2021-07-20 15:04:33 +02:00
|
|
|
partrect.left = rect->left + thumbpos;
|
2015-03-03 08:44:42 +01:00
|
|
|
partrect.right = partrect.left + thumbsize;
|
|
|
|
|
2021-08-25 08:24:42 +02:00
|
|
|
if (bar == SB_CTL && IsThemeBackgroundPartiallyTransparent(theme, SBP_THUMBBTNHORZ, thumbstate))
|
|
|
|
DrawThemeParentBackground(hwnd, dc, &partrect);
|
2015-03-03 08:44:42 +01:00
|
|
|
DrawThemeBackground(theme, dc, SBP_THUMBBTNHORZ, thumbstate, &partrect, NULL);
|
|
|
|
|
|
|
|
if (SUCCEEDED(GetThemePartSize(theme, dc, SBP_GRIPPERHORZ, thumbstate, NULL, TS_DRAW, &grippersize))) {
|
|
|
|
MARGINS margins;
|
|
|
|
|
|
|
|
if (SUCCEEDED(GetThemeMargins(theme, dc, SBP_THUMBBTNHORZ, thumbstate, TMT_CONTENTMARGINS, &partrect, &margins))) {
|
|
|
|
if (grippersize.cx <= (thumbsize - margins.cxLeftWidth - margins.cxRightWidth))
|
|
|
|
DrawThemeBackground(theme, dc, SBP_GRIPPERHORZ, thumbstate, &partrect, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-20 15:04:33 +02:00
|
|
|
partrect.right = rect->right - arrowsize;
|
|
|
|
if (thumbsize > 0)
|
|
|
|
partrect.left = rect->left + thumbpos + thumbsize;
|
|
|
|
else
|
|
|
|
partrect.left = rect->left + arrowsize;
|
|
|
|
if (partrect.right > partrect.left)
|
2021-08-25 08:24:42 +02:00
|
|
|
{
|
|
|
|
if (bar == SB_CTL && IsThemeBackgroundPartiallyTransparent(theme, SBP_LOWERTRACKHORZ, lowertrackstate))
|
|
|
|
DrawThemeParentBackground(hwnd, dc, &partrect);
|
2015-03-03 08:44:42 +01:00
|
|
|
DrawThemeBackground(theme, dc, SBP_LOWERTRACKHORZ, lowertrackstate, &partrect, NULL);
|
2021-08-25 08:24:42 +02:00
|
|
|
}
|
2015-03-03 08:44:42 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-20 15:04:33 +02:00
|
|
|
if (bar != SB_CTL)
|
|
|
|
CloseThemeData(theme);
|
2015-03-03 08:44:42 +01:00
|
|
|
}
|
|
|
|
|
2021-07-20 15:04:14 +02:00
|
|
|
LRESULT WINAPI UXTHEME_ScrollbarWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam,
|
|
|
|
BOOL unicode)
|
2015-02-15 17:10:10 +01:00
|
|
|
{
|
2015-02-28 17:37:08 +01:00
|
|
|
const WCHAR* themeClass = WC_SCROLLBARW;
|
|
|
|
HTHEME theme;
|
|
|
|
LRESULT result;
|
|
|
|
|
2021-07-20 15:04:14 +02:00
|
|
|
TRACE("(%p, 0x%x, %lu, %lu, %d)\n", hwnd, msg, wParam, lParam, unicode);
|
2015-02-15 17:10:10 +01:00
|
|
|
|
2015-02-28 17:37:08 +01:00
|
|
|
switch (msg) {
|
|
|
|
case WM_CREATE:
|
2021-07-20 15:04:14 +02:00
|
|
|
result = user_api.pScrollBarWndProc(hwnd, msg, wParam, lParam, unicode);
|
2015-02-28 17:37:08 +01:00
|
|
|
OpenThemeData(hwnd, themeClass);
|
|
|
|
return result;
|
|
|
|
|
|
|
|
case WM_DESTROY:
|
|
|
|
theme = GetWindowTheme(hwnd);
|
|
|
|
CloseThemeData(theme);
|
2021-07-20 15:04:14 +02:00
|
|
|
return user_api.pScrollBarWndProc(hwnd, msg, wParam, lParam, unicode);
|
2015-02-28 17:37:08 +01:00
|
|
|
|
|
|
|
case WM_THEMECHANGED:
|
|
|
|
theme = GetWindowTheme(hwnd);
|
|
|
|
CloseThemeData(theme);
|
|
|
|
OpenThemeData(hwnd, themeClass);
|
2021-04-27 05:35:01 +02:00
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
2015-02-28 17:37:08 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_SYSCOLORCHANGE:
|
|
|
|
theme = GetWindowTheme(hwnd);
|
2021-07-20 15:04:14 +02:00
|
|
|
if (!theme) return user_api.pScrollBarWndProc(hwnd, msg, wParam, lParam, unicode);
|
2015-02-28 17:37:08 +01:00
|
|
|
/* Do nothing. When themed, a WM_THEMECHANGED will be received, too,
|
|
|
|
* which will do the repaint. */
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2021-07-20 15:04:14 +02:00
|
|
|
return user_api.pScrollBarWndProc(hwnd, msg, wParam, lParam, unicode);
|
2015-02-28 17:37:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2015-02-15 17:10:10 +01:00
|
|
|
}
|