Porting fixes.
[wine/wine64.git] / dlls / comctl32 / smoothscroll.c
blob1eb503978b837acc84b644f6459160b7bd391c0c
1 /*
2 * Undocumented SmoothScrollWindow function from COMCTL32.DLL
4 * Copyright 2000 Marcus Meissner <marcus@jet.franken.de>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 * TODO
21 * - actually add smooth scrolling
24 #include <stdarg.h>
26 #include "windef.h"
27 #include "winbase.h"
28 #include "winreg.h"
29 #include "winerror.h"
30 #include "wingdi.h"
31 #include "winuser.h"
32 #include "winnls.h"
33 #include "commctrl.h"
34 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
38 static DWORD smoothscroll = 2;
40 typedef BOOL (CALLBACK *SCROLLWINDOWEXPROC)(HWND,INT,INT,LPRECT,LPRECT,HRGN,LPRECT,DWORD);
41 typedef struct tagSMOOTHSCROLLSTRUCT {
42 DWORD dwSize;
43 DWORD x2;
44 HWND hwnd;
45 DWORD dx;
47 DWORD dy;
48 LPRECT lpscrollrect;
49 LPRECT lpcliprect;
50 HRGN hrgnupdate;
52 LPRECT lpupdaterect;
53 DWORD flags;
54 DWORD stepinterval;
55 DWORD dx_step;
57 DWORD dy_step;
58 SCROLLWINDOWEXPROC scrollfun; /* same parameters as ScrollWindowEx */
59 } SMOOTHSCROLLSTRUCT;
61 /**************************************************************************
62 * SmoothScrollWindow [COMCTL32.382]
64 * Lots of magic for smooth scrolling windows.
66 * Currently only scrolls ONCE. The comctl32 implementation uses GetTickCount
67 * and what else to do smooth scrolling.
70 BOOL WINAPI SmoothScrollWindow( SMOOTHSCROLLSTRUCT *smooth ) {
71 LPRECT lpupdaterect = smooth->lpupdaterect;
72 HRGN hrgnupdate = smooth->hrgnupdate;
73 RECT tmprect;
74 BOOL ret = TRUE;
75 DWORD flags = smooth->flags;
77 if (smooth->dwSize!=sizeof(SMOOTHSCROLLSTRUCT))
78 return FALSE;
80 if (!lpupdaterect)
81 lpupdaterect = &tmprect;
82 SetRectEmpty(lpupdaterect);
84 if (!(flags & 0x40000)) { /* no override, use system wide defaults */
85 if (smoothscroll == 2) {
86 HKEY hkey;
88 smoothscroll = 0;
89 if (!RegOpenKeyA(HKEY_CURRENT_USER,"Control Panel\\Desktop",&hkey)) {
90 DWORD len = 4;
92 RegQueryValueExA(hkey,"SmoothScroll",0,0,(LPBYTE)&smoothscroll,&len);
93 RegCloseKey(hkey);
96 if (!smoothscroll)
97 flags |= 0x20000;
100 if (flags & 0x20000) { /* are we doing jump scrolling? */
101 if ((smooth->x2 & 1) && smooth->scrollfun)
102 return smooth->scrollfun(
103 smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
104 smooth->lpcliprect,hrgnupdate,lpupdaterect,
105 flags & 0xffff
107 else
108 return ScrollWindowEx(
109 smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
110 smooth->lpcliprect,hrgnupdate,lpupdaterect,
111 flags & 0xffff
115 FIXME("(hwnd=%p,flags=%lx,x2=%lx): should smooth scroll here.\n",
116 smooth->hwnd,flags,smooth->x2
118 /* FIXME: do timer based smooth scrolling */
119 if ((smooth->x2 & 1) && smooth->scrollfun)
120 return smooth->scrollfun(
121 smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
122 smooth->lpcliprect,hrgnupdate,lpupdaterect,
123 flags & 0xffff
125 else
126 return ScrollWindowEx(
127 smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
128 smooth->lpcliprect,hrgnupdate,lpupdaterect,
129 flags & 0xffff
131 return ret;