1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
* Scroll windows and DCs
*
* Copyright David W. Metcalfe, 1993
* Alex Korobka 1995,1996
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdlib.h>
#include "windef.h"
#include "wingdi.h"
#include "wine/winuser16.h"
#include "winuser.h"
#include "user.h"
#include "win.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(scroll);
/*************************************************************************
* fix_caret
*/
static HWND fix_caret(HWND hWnd, LPRECT lprc, UINT flags)
{
GUITHREADINFO info;
if (!GetGUIThreadInfo( GetCurrentThreadId(), &info )) return 0;
if (!info.hwndCaret) return 0;
if (info.hwndCaret == hWnd ||
((flags & SW_SCROLLCHILDREN) && IsChild(hWnd, info.hwndCaret)))
{
POINT pt;
pt.x = info.rcCaret.left;
pt.y = info.rcCaret.top;
MapWindowPoints( info.hwndCaret, hWnd, (LPPOINT)&info.rcCaret, 2 );
if( IntersectRect(lprc, lprc, &info.rcCaret) )
{
HideCaret(0);
lprc->left = pt.x;
lprc->top = pt.y;
return info.hwndCaret;
}
}
return 0;
}
/*************************************************************************
* ScrollWindow (USER32.@)
*
*/
BOOL WINAPI ScrollWindow( HWND hwnd, INT dx, INT dy,
const RECT *rect, const RECT *clipRect )
{
return
(ERROR != ScrollWindowEx( hwnd, dx, dy, rect, clipRect, 0, NULL,
(rect ? 0 : SW_SCROLLCHILDREN) |
SW_INVALIDATE ));
}
/*************************************************************************
* ScrollDC (USER32.@)
*
* Only the hrgnUpdate is return in device coordinate.
* rcUpdate must be returned in logical coordinate to comply with win API.
*
*/
BOOL WINAPI ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc,
const RECT *prLClip, HRGN hrgnUpdate,
LPRECT rcUpdate )
{
if (USER_Driver.pScrollDC)
return USER_Driver.pScrollDC( hdc, dx, dy, rc, prLClip, hrgnUpdate, rcUpdate );
return FALSE;
}
/*************************************************************************
* ScrollWindowEx (USER32.@)
*
* NOTE: Use this function instead of ScrollWindow32
*/
INT WINAPI ScrollWindowEx( HWND hwnd, INT dx, INT dy,
const RECT *rect, const RECT *clipRect,
HRGN hrgnUpdate, LPRECT rcUpdate,
UINT flags )
{
RECT rc, cliprc;
INT result;
if (!WIN_IsWindowDrawable( hwnd, TRUE )) return ERROR;
hwnd = WIN_GetFullHandle( hwnd );
GetClientRect(hwnd, &rc);
if (rect) IntersectRect(&rc, &rc, rect);
if (clipRect) IntersectRect(&cliprc,&rc,clipRect);
else cliprc = rc;
if (!IsRectEmpty(&cliprc) && (dx || dy))
{
RECT caretrc = rc;
HWND hwndCaret = fix_caret(hwnd, &caretrc, flags);
if (USER_Driver.pScrollWindowEx)
result = USER_Driver.pScrollWindowEx( hwnd, dx, dy, &rc, &cliprc,
hrgnUpdate, rcUpdate, flags );
else
result = ERROR; /* FIXME: we should have a fallback implementation */
if( hwndCaret )
{
SetCaretPos( caretrc.left + dx, caretrc.top + dy );
ShowCaret(hwndCaret);
}
}
else
result = NULLREGION;
return result;
}