1 | /*
|
---|
2 | * Undocumented SmoothScrollWindow function from COMCTL32.DLL
|
---|
3 | *
|
---|
4 | * Copyright 2000 Marcus Meissner <marcus@jet.franken.de>
|
---|
5 | *
|
---|
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.
|
---|
10 | *
|
---|
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.
|
---|
15 | *
|
---|
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
|
---|
19 | *
|
---|
20 | * TODO
|
---|
21 | * - actually add smooth scrolling
|
---|
22 | */
|
---|
23 |
|
---|
24 | #include "winbase.h"
|
---|
25 | #include "winreg.h"
|
---|
26 | #include "winerror.h"
|
---|
27 | #include "commctrl.h"
|
---|
28 | #include "wine/debug.h"
|
---|
29 |
|
---|
30 | WINE_DEFAULT_DEBUG_CHANNEL(commctrl);
|
---|
31 |
|
---|
32 | static DWORD smoothscroll = 2;
|
---|
33 |
|
---|
34 | #ifdef __WIN32OS2__
|
---|
35 | typedef BOOL (* CALLBACK SCROLLWINDOWEXPROC)(HWND,INT,INT,LPRECT,LPRECT,HRGN,LPRECT,DWORD);
|
---|
36 | #else
|
---|
37 | typedef BOOL (CALLBACK *SCROLLWINDOWEXPROC)(HWND,INT,INT,LPRECT,LPRECT,HRGN,LPRECT,DWORD);
|
---|
38 | #endif
|
---|
39 |
|
---|
40 | typedef struct tagSMOOTHSCROLLSTRUCT {
|
---|
41 | DWORD dwSize;
|
---|
42 | DWORD x2;
|
---|
43 | HWND hwnd;
|
---|
44 | DWORD dx;
|
---|
45 |
|
---|
46 | DWORD dy;
|
---|
47 | LPRECT lpscrollrect;
|
---|
48 | LPRECT lpcliprect;
|
---|
49 | HRGN hrgnupdate;
|
---|
50 |
|
---|
51 | LPRECT lpupdaterect;
|
---|
52 | DWORD flags;
|
---|
53 | DWORD stepinterval;
|
---|
54 | DWORD dx_step;
|
---|
55 |
|
---|
56 | DWORD dy_step;
|
---|
57 | SCROLLWINDOWEXPROC scrollfun; /* same parameters as ScrollWindowEx */
|
---|
58 | } SMOOTHSCROLLSTRUCT;
|
---|
59 |
|
---|
60 | /**************************************************************************
|
---|
61 | * SmoothScrollWindow [COMCTL32.382]
|
---|
62 | *
|
---|
63 | * Lots of magic for smooth scrolling windows.
|
---|
64 | *
|
---|
65 | * Currently only scrolls ONCE. The comctl32 implementation uses GetTickCount
|
---|
66 | * and what else to do smooth scrolling.
|
---|
67 | */
|
---|
68 |
|
---|
69 | BOOL WINAPI SmoothScrollWindow( SMOOTHSCROLLSTRUCT *smooth ) {
|
---|
70 | LPRECT lpupdaterect = smooth->lpupdaterect;
|
---|
71 | HRGN hrgnupdate = smooth->hrgnupdate;
|
---|
72 | RECT tmprect;
|
---|
73 | BOOL ret = TRUE;
|
---|
74 | DWORD flags = smooth->flags;
|
---|
75 |
|
---|
76 | if (smooth->dwSize!=sizeof(SMOOTHSCROLLSTRUCT))
|
---|
77 | return FALSE;
|
---|
78 |
|
---|
79 | if (!lpupdaterect)
|
---|
80 | lpupdaterect = &tmprect;
|
---|
81 | SetRectEmpty(lpupdaterect);
|
---|
82 |
|
---|
83 | if (!(flags & 0x40000)) { /* no override, use system wide defaults */
|
---|
84 | if (smoothscroll == 2) {
|
---|
85 | HKEY hkey;
|
---|
86 |
|
---|
87 | smoothscroll = 0;
|
---|
88 | if (!RegOpenKeyA(HKEY_CURRENT_USER,"Control Panel\\Desktop",&hkey)) {
|
---|
89 | DWORD len = 4;
|
---|
90 |
|
---|
91 | RegQueryValueExA(hkey,"SmoothScroll",0,0,(LPBYTE)&smoothscroll,&len);
|
---|
92 | RegCloseKey(hkey);
|
---|
93 | }
|
---|
94 | }
|
---|
95 | if (!smoothscroll)
|
---|
96 | flags |= 0x20000;
|
---|
97 | }
|
---|
98 |
|
---|
99 | if (flags & 0x20000) { /* are we doing jump scrolling? */
|
---|
100 | if ((smooth->x2 & 1) && smooth->scrollfun)
|
---|
101 | return smooth->scrollfun(
|
---|
102 | smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
|
---|
103 | smooth->lpcliprect,hrgnupdate,lpupdaterect,
|
---|
104 | flags & 0xffff
|
---|
105 | );
|
---|
106 | else
|
---|
107 | return ScrollWindowEx(
|
---|
108 | smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
|
---|
109 | smooth->lpcliprect,hrgnupdate,lpupdaterect,
|
---|
110 | flags & 0xffff
|
---|
111 | );
|
---|
112 | }
|
---|
113 |
|
---|
114 | FIXME("(hwnd=%p,flags=%lx,x2=%lx): should smooth scroll here.\n",
|
---|
115 | smooth->hwnd,flags,smooth->x2
|
---|
116 | );
|
---|
117 | /* FIXME: do timer based smooth scrolling */
|
---|
118 | if ((smooth->x2 & 1) && smooth->scrollfun)
|
---|
119 | return smooth->scrollfun(
|
---|
120 | smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
|
---|
121 | smooth->lpcliprect,hrgnupdate,lpupdaterect,
|
---|
122 | flags & 0xffff
|
---|
123 | );
|
---|
124 | else
|
---|
125 | return ScrollWindowEx(
|
---|
126 | smooth->hwnd,smooth->dx,smooth->dy,smooth->lpscrollrect,
|
---|
127 | smooth->lpcliprect,hrgnupdate,lpupdaterect,
|
---|
128 | flags & 0xffff
|
---|
129 | );
|
---|
130 | return ret;
|
---|
131 | }
|
---|