ReactOS  0.4.14-dev-49-gfb4591c
theme_scrollbar.c File Reference
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "uxtheme.h"
#include "vssym32.h"
#include "comctl32.h"
#include "wine/debug.h"
Include dependency graph for theme_scrollbar.c:

Go to the source code of this file.

Macros

#define SCROLL_MIN_THUMB   6
 
#define SCROLL_MIN_RECT   4
 

Enumerations

enum  SCROLL_HITTEST {
  SCROLL_NOWHERE, SCROLL_TOP_ARROW, SCROLL_TOP_RECT, SCROLL_THUMB,
  SCROLL_BOTTOM_RECT, SCROLL_BOTTOM_ARROW, SCROLL_NOWHERE, SCROLL_TOP_ARROW,
  SCROLL_TOP_RECT, SCROLL_THUMB, SCROLL_BOTTOM_RECT, SCROLL_BOTTOM_ARROW
}
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (theme_scroll)
 
static void calc_thumb_dimensions (unsigned int size, SCROLLINFO *si, unsigned int *thumbpos, unsigned int *thumbsize)
 
static enum SCROLL_HITTEST hit_test (HWND hwnd, HTHEME theme, POINT pt)
 
static void redraw_part (HWND hwnd, HTHEME theme, enum SCROLL_HITTEST part)
 
static void scroll_event (HWND hwnd, HTHEME theme, UINT msg, POINT pt)
 
static void paint_scrollbar (HWND hwnd, HTHEME theme)
 
LRESULT CALLBACK THEMING_ScrollbarSubclassProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam, ULONG_PTR dwRefData)
 

Variables

static HWND tracking_win = 0
 
static enum SCROLL_HITTEST tracking_hot_part = SCROLL_NOWHERE
 

Macro Definition Documentation

◆ SCROLL_MIN_RECT

#define SCROLL_MIN_RECT   4

Definition at line 39 of file theme_scrollbar.c.

◆ SCROLL_MIN_THUMB

#define SCROLL_MIN_THUMB   6

Definition at line 36 of file theme_scrollbar.c.

Enumeration Type Documentation

◆ SCROLL_HITTEST

Enumerator
SCROLL_NOWHERE 
SCROLL_TOP_ARROW 
SCROLL_TOP_RECT 
SCROLL_THUMB 
SCROLL_BOTTOM_RECT 
SCROLL_BOTTOM_ARROW 
SCROLL_NOWHERE 
SCROLL_TOP_ARROW 
SCROLL_TOP_RECT 
SCROLL_THUMB 
SCROLL_BOTTOM_RECT 
SCROLL_BOTTOM_ARROW 

Definition at line 41 of file theme_scrollbar.c.

42 {
43  SCROLL_NOWHERE, /* Outside the scroll bar */
44  SCROLL_TOP_ARROW, /* Top or left arrow */
45  SCROLL_TOP_RECT, /* Rectangle between the top arrow and the thumb */
46  SCROLL_THUMB, /* Thumb rectangle */
47  SCROLL_BOTTOM_RECT, /* Rectangle between the thumb and the bottom arrow */
48  SCROLL_BOTTOM_ARROW /* Bottom or right arrow */
49 };

Function Documentation

◆ calc_thumb_dimensions()

static void calc_thumb_dimensions ( unsigned int  size,
SCROLLINFO si,
unsigned int thumbpos,
unsigned int thumbsize 
)
static

Definition at line 56 of file theme_scrollbar.c.

57 {
58  if (size <= SCROLL_MIN_RECT)
59  *thumbpos = *thumbsize = 0;
60  else if (si->nPage > si->nMax - si->nMin)
61  *thumbpos = *thumbsize = 0;
62  else {
63  if (si->nPage > 0) {
64  *thumbsize = MulDiv(size, si->nPage, si->nMax - si->nMin + 1);
65  if (*thumbsize < SCROLL_MIN_THUMB) *thumbsize = SCROLL_MIN_THUMB;
66  }
67  else *thumbsize = GetSystemMetrics(SM_CXVSCROLL);
68 
69  if (size < *thumbsize)
70  *thumbpos = *thumbsize = 0;
71  else {
72  int max = si->nMax - max(si->nPage - 1, 0);
73  size -= *thumbsize;
74  if (si->nMin >= max)
75  *thumbpos = 0;
76  else
77  *thumbpos = MulDiv(size, si->nTrackPos - si->nMin, max - si->nMin);
78  }
79  }
80 }
#define max(a, b)
Definition: svc.c:63
GLsizeiptr size
Definition: glext.h:5919
#define SCROLL_MIN_RECT
int WINAPI GetSystemMetrics(_In_ int)
#define SCROLL_MIN_THUMB
#define SM_CXVSCROLL
Definition: winuser.h:951
#define MulDiv(x, y, z)
Definition: gdifloat.h:86

Referenced by hit_test(), paint_scrollbar(), and redraw_part().

◆ hit_test()

static enum SCROLL_HITTEST hit_test ( HWND  hwnd,
HTHEME  theme,
POINT  pt 
)
static

Definition at line 82 of file theme_scrollbar.c.

83 {
84  RECT r;
86  BOOL vertical = style & SBS_VERT;
87  SIZE sz;
88  SCROLLINFO si;
89  unsigned int offset, size, upsize, downsize, thumbpos, thumbsize;
90 
91  GetWindowRect(hwnd, &r);
92  OffsetRect(&r, -r.left, -r.top);
93 
94  if (vertical) {
95  offset = pt.y;
96  size = r.bottom;
97 
98  if (FAILED(GetThemePartSize(theme, NULL, SBP_ARROWBTN, ABS_UPNORMAL, NULL, TS_DRAW, &sz))) {
99  WARN("Could not get up arrow size.\n");
100  upsize = 0;
101  } else
102  upsize = sz.cy;
103 
104  if (FAILED(GetThemePartSize(theme, NULL, SBP_ARROWBTN, ABS_DOWNNORMAL, NULL, TS_DRAW, &sz))) {
105  WARN("Could not get down arrow size.\n");
106  downsize = 0;
107  } else
108  downsize = sz.cy;
109  } else {
110  offset = pt.x;
111  size = r.right;
112 
113  if (FAILED(GetThemePartSize(theme, NULL, SBP_ARROWBTN, ABS_LEFTNORMAL, NULL, TS_DRAW, &sz))) {
114  WARN("Could not get left arrow size.\n");
115  upsize = 0;
116  } else
117  upsize = sz.cx;
118 
119  if (FAILED(GetThemePartSize(theme, NULL, SBP_ARROWBTN, ABS_RIGHTNORMAL, NULL, TS_DRAW, &sz))) {
120  WARN("Could not get right arrow size.\n");
121  downsize = 0;
122  } else
123  downsize = sz.cx;
124  }
125 
126  if (pt.x < 0 || pt.x > r.right || pt.y < 0 || pt.y > r.bottom)
127  return SCROLL_NOWHERE;
128 
129  if (size < SCROLL_MIN_RECT + upsize + downsize)
130  upsize = downsize = (size - SCROLL_MIN_RECT)/2;
131 
132  if (offset < upsize)
133  return SCROLL_TOP_ARROW;
134 
135  if (offset > size - downsize)
136  return SCROLL_BOTTOM_ARROW;
137 
138  si.cbSize = sizeof(si);
139  si.fMask = SIF_ALL;
140  if (!GetScrollInfo(hwnd, SB_CTL, &si)) {
141  WARN("GetScrollInfo failed.\n");
142  return SCROLL_NOWHERE;
143  }
144 
145  calc_thumb_dimensions(size - upsize - downsize, &si, &thumbpos, &thumbsize);
146 
147  if (offset < upsize + thumbpos)
148  return SCROLL_TOP_RECT;
149  else if (offset < upsize + thumbpos + thumbsize)
150  return SCROLL_THUMB;
151  else
152  return SCROLL_BOTTOM_RECT;
153 }
HRESULT WINAPI GetThemePartSize(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz)
Definition: draw.c:1777
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define SB_CTL
Definition: winuser.h:554
#define pt(x, y)
Definition: drawing.c:79
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WARN(fmt,...)
Definition: debug.h:111
GLintptr offset
Definition: glext.h:5920
static void calc_thumb_dimensions(unsigned int size, SCROLLINFO *si, unsigned int *thumbpos, unsigned int *thumbsize)
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:319
#define SBS_VERT
Definition: winuser.h:334
GLsizeiptr size
Definition: glext.h:5919
#define SCROLL_MIN_RECT
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define GWL_STYLE
Definition: winuser.h:846
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
Arabic default style
Definition: afstyles.h:93
LONG cy
Definition: windef.h:320
#define SIF_ALL
Definition: winuser.h:1218

Referenced by scroll_event().

◆ paint_scrollbar()

static void paint_scrollbar ( HWND  hwnd,
HTHEME  theme 
)
static

Definition at line 313 of file theme_scrollbar.c.

314 {
315  HDC dc;
316  PAINTSTRUCT ps;
317  RECT r;
319  BOOL vertical = style & SBS_VERT;
320  BOOL disabled = !IsWindowEnabled(hwnd);
321 
322  GetWindowRect(hwnd, &r);
323  OffsetRect(&r, -r.left, -r.top);
324 
325  dc = BeginPaint(hwnd, &ps);
326 
327  if (style & SBS_SIZEBOX || style & SBS_SIZEGRIP) {
328  int state;
329 
332  else
334 
336  } else {
337  SCROLLBARINFO sbi;
338  SCROLLINFO si;
339  unsigned int thumbpos, thumbsize;
340  int uppertrackstate, lowertrackstate, thumbstate;
341  RECT partrect, trackrect;
342  SIZE grippersize;
343 
344  sbi.cbSize = sizeof(sbi);
346 
347  si.cbSize = sizeof(si);
348  si.fMask = SIF_ALL;
349  GetScrollInfo(hwnd, SB_CTL, &si);
350 
351  trackrect = r;
352 
353  if (disabled) {
354  uppertrackstate = SCRBS_DISABLED;
355  lowertrackstate = SCRBS_DISABLED;
356  thumbstate = SCRBS_DISABLED;
357  } else {
358  uppertrackstate = SCRBS_NORMAL;
359  lowertrackstate = SCRBS_NORMAL;
360  thumbstate = SCRBS_NORMAL;
361 
362  if (tracking_win == hwnd) {
364  uppertrackstate = SCRBS_HOT;
366  lowertrackstate = SCRBS_HOT;
367  else if (tracking_hot_part == SCROLL_THUMB)
368  thumbstate = SCRBS_HOT;
369  }
370  }
371 
372  if (vertical) {
373  SIZE upsize, downsize;
374  int uparrowstate, downarrowstate;
375 
376  if (disabled) {
377  uparrowstate = ABS_UPDISABLED;
378  downarrowstate = ABS_DOWNDISABLED;
379  } else {
380  uparrowstate = ABS_UPNORMAL;
381  downarrowstate = ABS_DOWNNORMAL;
382 
383  if (tracking_win == hwnd) {
385  uparrowstate = ABS_UPHOT;
387  downarrowstate = ABS_DOWNHOT;
388  }
389  }
390 
391  if (FAILED(GetThemePartSize(theme, dc, SBP_ARROWBTN, uparrowstate, NULL, TS_DRAW, &upsize))) {
392  WARN("Could not get up arrow size.\n");
393  return;
394  }
395 
396  if (FAILED(GetThemePartSize(theme, dc, SBP_ARROWBTN, downarrowstate, NULL, TS_DRAW, &downsize))) {
397  WARN("Could not get down arrow size.\n");
398  return;
399  }
400 
401  if (r.bottom - r.top - upsize.cy - downsize.cy < SCROLL_MIN_RECT)
402  upsize.cy = downsize.cy = (r.bottom - r.top - SCROLL_MIN_RECT)/2;
403 
404  partrect = r;
405  partrect.bottom = partrect.top + upsize.cy;
406  DrawThemeBackground(theme, dc, SBP_ARROWBTN, uparrowstate, &partrect, NULL);
407 
408  trackrect.top = partrect.bottom;
409 
410  partrect.bottom = r.bottom;
411  partrect.top = partrect.bottom - downsize.cy;
412  DrawThemeBackground(theme, dc, SBP_ARROWBTN, downarrowstate, &partrect, NULL);
413 
414  trackrect.bottom = partrect.top;
415 
416  calc_thumb_dimensions(trackrect.bottom - trackrect.top, &si, &thumbpos, &thumbsize);
417 
418  if (thumbpos > 0) {
419  partrect.top = trackrect.top;
420  partrect.bottom = partrect.top + thumbpos;
421 
422  DrawThemeBackground(theme, dc, SBP_UPPERTRACKVERT, uppertrackstate, &partrect, NULL);
423  }
424 
425  if (thumbsize > 0) {
426  partrect.top = trackrect.top + thumbpos;
427  partrect.bottom = partrect.top + thumbsize;
428 
429  DrawThemeBackground(theme, dc, SBP_THUMBBTNVERT, thumbstate, &partrect, NULL);
430 
431  if (SUCCEEDED(GetThemePartSize(theme, dc, SBP_GRIPPERVERT, thumbstate, NULL, TS_DRAW, &grippersize))) {
433 
434  if (SUCCEEDED(GetThemeMargins(theme, dc, SBP_THUMBBTNVERT, thumbstate, TMT_CONTENTMARGINS, &partrect, &margins))) {
435  if (grippersize.cy <= (thumbsize - margins.cyTopHeight - margins.cyBottomHeight))
436  DrawThemeBackground(theme, dc, SBP_GRIPPERVERT, thumbstate, &partrect, NULL);
437  }
438  }
439  }
440 
441  if (thumbpos + thumbsize < trackrect.bottom - trackrect.top) {
442  partrect.bottom = trackrect.bottom;
443  partrect.top = trackrect.top + thumbsize + thumbpos;
444 
445  DrawThemeBackground(theme, dc, SBP_LOWERTRACKVERT, lowertrackstate, &partrect, NULL);
446  }
447  } else {
448  SIZE leftsize, rightsize;
449  int leftarrowstate, rightarrowstate;
450 
451  if (disabled) {
452  leftarrowstate = ABS_LEFTDISABLED;
453  rightarrowstate = ABS_RIGHTDISABLED;
454  } else {
455  leftarrowstate = ABS_LEFTNORMAL;
456  rightarrowstate = ABS_RIGHTNORMAL;
457 
458  if (tracking_win == hwnd) {
460  leftarrowstate = ABS_LEFTHOT;
462  rightarrowstate = ABS_RIGHTHOT;
463  }
464  }
465 
466  if (FAILED(GetThemePartSize(theme, dc, SBP_ARROWBTN, leftarrowstate, NULL, TS_DRAW, &leftsize))) {
467  WARN("Could not get left arrow size.\n");
468  return;
469  }
470 
471  if (FAILED(GetThemePartSize(theme, dc, SBP_ARROWBTN, rightarrowstate, NULL, TS_DRAW, &rightsize))) {
472  WARN("Could not get right arrow size.\n");
473  return;
474  }
475 
476  if (r.right - r.left - leftsize.cx - rightsize.cx < SCROLL_MIN_RECT)
477  leftsize.cx = rightsize.cx = (r.right - r.left - SCROLL_MIN_RECT)/2;
478 
479  partrect = r;
480  partrect.right = partrect.left + leftsize.cx;
481  DrawThemeBackground(theme, dc, SBP_ARROWBTN, leftarrowstate, &partrect, NULL);
482 
483  trackrect.left = partrect.right;
484 
485  partrect.right = r.right;
486  partrect.left = partrect.right - rightsize.cx;
487  DrawThemeBackground(theme, dc, SBP_ARROWBTN, rightarrowstate, &partrect, NULL);
488 
489  trackrect.right = partrect.left;
490 
491  calc_thumb_dimensions(trackrect.right - trackrect.left, &si, &thumbpos, &thumbsize);
492 
493  if (thumbpos > 0) {
494  partrect.left = trackrect.left;
495  partrect.right = partrect.left + thumbpos;
496 
497  DrawThemeBackground(theme, dc, SBP_UPPERTRACKHORZ, uppertrackstate, &partrect, NULL);
498  }
499 
500  if (thumbsize > 0) {
501  partrect.left = trackrect.left + thumbpos;
502  partrect.right = partrect.left + thumbsize;
503 
504  DrawThemeBackground(theme, dc, SBP_THUMBBTNHORZ, thumbstate, &partrect, NULL);
505 
506  if (SUCCEEDED(GetThemePartSize(theme, dc, SBP_GRIPPERHORZ, thumbstate, NULL, TS_DRAW, &grippersize))) {
508 
509  if (SUCCEEDED(GetThemeMargins(theme, dc, SBP_THUMBBTNHORZ, thumbstate, TMT_CONTENTMARGINS, &partrect, &margins))) {
510  if (grippersize.cx <= (thumbsize - margins.cxLeftWidth - margins.cxRightWidth))
511  DrawThemeBackground(theme, dc, SBP_GRIPPERHORZ, thumbstate, &partrect, NULL);
512  }
513  }
514  }
515 
516  if (thumbpos + thumbsize < trackrect.right - trackrect.left) {
517  partrect.right = trackrect.right;
518  partrect.left = trackrect.left + thumbsize + thumbpos;
519 
520  DrawThemeBackground(theme, dc, SBP_LOWERTRACKHORZ, lowertrackstate, &partrect, NULL);
521  }
522  }
523  }
524 
525  EndPaint(hwnd, &ps);
526 }
#define SBS_SIZEBOXTOPLEFTALIGN
Definition: winuser.h:331
HRESULT WINAPI GetThemePartSize(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz)
Definition: draw.c:1777
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define SBS_SIZEBOX
Definition: winuser.h:329
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define SB_CTL
Definition: winuser.h:554
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WARN(fmt,...)
Definition: debug.h:111
static HDC
Definition: imagelist.c:92
LONG top
Definition: windef.h:292
HDC dc
Definition: cylfrac.c:34
static void calc_thumb_dimensions(unsigned int size, SCROLLINFO *si, unsigned int *thumbpos, unsigned int *thumbsize)
LONG left
Definition: windef.h:291
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
LONG right
Definition: windef.h:293
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
Definition: misc.c:279
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TMT_CONTENTMARGINS
Definition: vssym32.h:324
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:319
BOOL WINAPI IsWindowEnabled(_In_ HWND)
BOOL WINAPI GetScrollBarInfo(_In_ HWND, _In_ LONG, _Inout_ PSCROLLBARINFO)
#define SBS_VERT
Definition: winuser.h:334
#define SBS_SIZEGRIP
Definition: winuser.h:332
#define OBJID_CLIENT
Definition: winable.h:19
#define SCROLL_MIN_RECT
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
static HWND tracking_win
static int state
Definition: maze.c:121
static RECT margins
Definition: print.c:55
HRESULT WINAPI GetThemeMargins(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, int iPropId, RECT *prc, MARGINS *pMargins)
Definition: property.c:216
#define GWL_STYLE
Definition: winuser.h:846
LONG bottom
Definition: windef.h:294
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
Arabic default style
Definition: afstyles.h:93
LONG cy
Definition: windef.h:320
#define SUCCEEDED(hr)
Definition: intsafe.h:57
static enum SCROLL_HITTEST tracking_hot_part
#define SIF_ALL
Definition: winuser.h:1218

Referenced by THEMING_ScrollbarSubclassProc().

◆ redraw_part()

static void redraw_part ( HWND  hwnd,
HTHEME  theme,
enum SCROLL_HITTEST  part 
)
static

Definition at line 155 of file theme_scrollbar.c.

156 {
158  BOOL vertical = style & SBS_VERT;
159  SIZE sz;
160  RECT r, partrect;
161  unsigned int size, upsize, downsize;
162 
163  if (part == SCROLL_NOWHERE) { /* redraw everything */
165  return;
166  }
167 
168  GetWindowRect(hwnd, &r);
169  OffsetRect(&r, -r.left, -r.top);
170 
171  if (vertical) {
172  size = r.bottom;
173 
174  if (FAILED(GetThemePartSize(theme, NULL, SBP_ARROWBTN, ABS_UPNORMAL, NULL, TS_DRAW, &sz))) {
175  WARN("Could not get up arrow size.\n");
176  upsize = 0;
177  } else
178  upsize = sz.cy;
179 
180  if (FAILED(GetThemePartSize(theme, NULL, SBP_ARROWBTN, ABS_DOWNNORMAL, NULL, TS_DRAW, &sz))) {
181  WARN("Could not get down arrow size.\n");
182  downsize = 0;
183  } else
184  downsize = sz.cy;
185  } else {
186  size = r.right;
187 
188  if (FAILED(GetThemePartSize(theme, NULL, SBP_ARROWBTN, ABS_LEFTNORMAL, NULL, TS_DRAW, &sz))) {
189  WARN("Could not get left arrow size.\n");
190  upsize = 0;
191  } else
192  upsize = sz.cx;
193 
194  if (FAILED(GetThemePartSize(theme, NULL, SBP_ARROWBTN, ABS_RIGHTNORMAL, NULL, TS_DRAW, &sz))) {
195  WARN("Could not get right arrow size.\n");
196  downsize = 0;
197  } else
198  downsize = sz.cx;
199  }
200 
201  if (size < SCROLL_MIN_RECT + upsize + downsize)
202  upsize = downsize = (size - SCROLL_MIN_RECT)/2;
203 
204  partrect = r;
205 
206  if (part == SCROLL_TOP_ARROW) {
207  if (vertical)
208  partrect.bottom = partrect.top + upsize;
209  else
210  partrect.right = partrect.left + upsize;
211  } else if (part == SCROLL_BOTTOM_ARROW) {
212  if (vertical)
213  partrect.top = partrect.bottom - downsize;
214  else
215  partrect.left = partrect.right - downsize;
216  } else {
217  unsigned int thumbpos, thumbsize;
218  SCROLLINFO si;
219 
220  si.cbSize = sizeof(si);
221  si.fMask = SIF_ALL;
222  if (!GetScrollInfo(hwnd, SB_CTL, &si)) {
223  WARN("GetScrollInfo failed.\n");
224  return;
225  }
226 
227  calc_thumb_dimensions(size - upsize - downsize, &si, &thumbpos, &thumbsize);
228 
229  if (part == SCROLL_TOP_RECT) {
230  if (vertical) {
231  partrect.top = r.top + upsize;
232  partrect.bottom = partrect.top + thumbpos;
233  } else {
234  partrect.left = r.left + upsize;
235  partrect.right = partrect.left + thumbpos;
236  }
237  } else if (part == SCROLL_THUMB) {
238  if (vertical) {
239  partrect.top = r.top + upsize + thumbpos;
240  partrect.bottom = partrect.top + thumbsize;
241  } else {
242  partrect.left = r.left + upsize + thumbpos;
243  partrect.right = partrect.left + thumbsize;
244  }
245  } else if (part == SCROLL_BOTTOM_RECT) {
246  if (vertical) {
247  partrect.top = r.top + upsize + thumbpos + thumbsize;
248  partrect.bottom = r.bottom - downsize;
249  } else {
250  partrect.left = r.left + upsize + thumbpos + thumbsize;
251  partrect.right = r.right - downsize;
252  }
253  }
254  }
255 
256  InvalidateRect(hwnd, &partrect, TRUE);
257 }
HRESULT WINAPI GetThemePartSize(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, RECT *prc, THEMESIZE eSize, SIZE *psz)
Definition: draw.c:1777
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define SB_CTL
Definition: winuser.h:554
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define WARN(fmt,...)
Definition: debug.h:111
LONG top
Definition: windef.h:292
static void calc_thumb_dimensions(unsigned int size, SCROLLINFO *si, unsigned int *thumbpos, unsigned int *thumbsize)
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
smooth NULL
Definition: ftsmooth.c:416
LONG cx
Definition: windef.h:319
#define SBS_VERT
Definition: winuser.h:334
GLsizeiptr size
Definition: glext.h:5919
#define SCROLL_MIN_RECT
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define GWL_STYLE
Definition: winuser.h:846
LONG bottom
Definition: windef.h:294
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
Arabic default style
Definition: afstyles.h:93
LONG cy
Definition: windef.h:320
#define SIF_ALL
Definition: winuser.h:1218

Referenced by scroll_event().

◆ scroll_event()

static void scroll_event ( HWND  hwnd,
HTHEME  theme,
UINT  msg,
POINT  pt 
)
static

Definition at line 259 of file theme_scrollbar.c.

260 {
261  enum SCROLL_HITTEST hittest;
262  TRACKMOUSEEVENT tme;
263 
265  return;
266 
267  hittest = hit_test(hwnd, theme, pt);
268 
269  switch (msg)
270  {
271  case WM_MOUSEMOVE:
272  hittest = hit_test(hwnd, theme, pt);
273  tracking_win = hwnd;
274  break;
275 
276  case WM_MOUSELEAVE:
277  if (tracking_win == hwnd) {
278  hittest = SCROLL_NOWHERE;
279  }
280  break;
281  }
282 
283  tme.cbSize = sizeof(tme);
284  tme.dwFlags = TME_QUERY;
285  TrackMouseEvent(&tme);
286 
287  if (!(tme.dwFlags & TME_LEAVE) || tme.hwndTrack != hwnd) {
288  tme.dwFlags = TME_LEAVE;
289  tme.hwndTrack = hwnd;
290  TrackMouseEvent(&tme);
291  }
292 
293  if (tracking_win != hwnd && msg == WM_MOUSELEAVE) {
295  return;
296  }
297 
298  if (tracking_win == hwnd && hittest != tracking_hot_part) {
299  enum SCROLL_HITTEST oldhotpart = tracking_hot_part;
300 
301  tracking_hot_part = hittest;
302 
303  if (hittest != SCROLL_NOWHERE)
304  redraw_part(hwnd, theme, hittest);
305  else
306  tracking_win = 0;
307 
308  if (oldhotpart != SCROLL_NOWHERE)
309  redraw_part(hwnd, theme, oldhotpart);
310  }
311 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define SBS_SIZEBOX
Definition: winuser.h:329
#define pt(x, y)
Definition: drawing.c:79
BOOL WINAPI TrackMouseEvent(_Inout_ LPTRACKMOUSEEVENT)
#define WM_MOUSELEAVE
Definition: commctrl.h:4946
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
SCROLL_HITTEST
static enum SCROLL_HITTEST hit_test(HWND hwnd, HTHEME theme, POINT pt)
#define SBS_SIZEGRIP
Definition: winuser.h:332
static void redraw_part(HWND hwnd, HTHEME theme, enum SCROLL_HITTEST part)
#define TME_QUERY
Definition: commctrl.h:4954
static HWND tracking_win
#define GWL_STYLE
Definition: winuser.h:846
#define TME_LEAVE
Definition: commctrl.h:4952
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define msg(x)
Definition: auth_time.c:54
static enum SCROLL_HITTEST tracking_hot_part

Referenced by THEMING_ScrollbarSubclassProc().

◆ THEMING_ScrollbarSubclassProc()

LRESULT CALLBACK THEMING_ScrollbarSubclassProc ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam,
ULONG_PTR  dwRefData 
)

Definition at line 528 of file theme_scrollbar.c.

531 {
532  const WCHAR* themeClass = WC_SCROLLBARW;
533  HTHEME theme;
534  LRESULT result;
535  POINT pt;
536 
537  TRACE("(%p, 0x%x, %lu, %lu, %lu)\n", hwnd, msg, wParam, lParam, dwRefData);
538 
539  switch (msg) {
540  case WM_CREATE:
543  return result;
544 
545  case WM_DESTROY:
546  theme = GetWindowTheme(hwnd);
547  CloseThemeData(theme);
549 
550  case WM_THEMECHANGED:
551  theme = GetWindowTheme(hwnd);
552  CloseThemeData(theme);
554  break;
555 
556  case WM_SYSCOLORCHANGE:
557  theme = GetWindowTheme(hwnd);
558  if (!theme) return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
559  /* Do nothing. When themed, a WM_THEMECHANGED will be received, too,
560  * which will do the repaint. */
561  break;
562 
563  case WM_PAINT:
564  theme = GetWindowTheme(hwnd);
565  if (!theme) return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
566 
567  paint_scrollbar(hwnd, theme);
568  break;
569 
570  case WM_MOUSEMOVE:
571  case WM_MOUSELEAVE:
572  theme = GetWindowTheme(hwnd);
573  if (!theme) return THEMING_CallOriginalClass(hwnd, msg, wParam, lParam);
574 
575  pt.x = (short)LOWORD(lParam);
576  pt.y = (short)HIWORD(lParam);
577  scroll_event(hwnd, theme, msg, pt);
578  break;
579 
580  default:
582  }
583 
584  return 0;
585 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define WM_SYSCOLORCHANGE
Definition: winuser.h:1608
#define pt(x, y)
Definition: drawing.c:79
_In_ SUBCLASSPROC _In_ UINT_PTR _In_ DWORD_PTR dwRefData
Definition: commctrl.h:5027
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
static const WCHAR themeClass[]
Definition: header.c:115
WPARAM wParam
Definition: combotst.c:138
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:93
#define WM_MOUSELEAVE
Definition: commctrl.h:4946
#define WM_DESTROY
Definition: winuser.h:1591
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void scroll_event(HWND hwnd, HTHEME theme, UINT msg, POINT pt)
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
Definition: system.c:835
#define WM_PAINT
Definition: winuser.h:1602
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:851
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define WC_SCROLLBARW
Definition: commctrl.h:4700
#define msg(x)
Definition: auth_time.c:54
LRESULT THEMING_CallOriginalClass(HWND, UINT, WPARAM, LPARAM) DECLSPEC_HIDDEN
Definition: theming.c:208
#define WM_CREATE
Definition: winuser.h:1590
#define HIWORD(l)
Definition: typedefs.h:246
LONG_PTR LRESULT
Definition: windef.h:209
GLuint64EXT * result
Definition: glext.h:11304
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:950
static void paint_scrollbar(HWND hwnd, HTHEME theme)

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( theme_scroll  )

Variable Documentation

◆ tracking_hot_part

enum SCROLL_HITTEST tracking_hot_part = SCROLL_NOWHERE
static

Definition at line 52 of file theme_scrollbar.c.

Referenced by paint_scrollbar(), and scroll_event().

◆ tracking_win

HWND tracking_win = 0
static

Definition at line 51 of file theme_scrollbar.c.

Referenced by paint_scrollbar(), and scroll_event().