Authors: David Hammerton <david@transgaming.com>, Peter Hunnisett <peter@transgaming...
[wine] / windows / scroll.c
1 /*
2  * Scroll windows and DCs
3  *
4  * Copyright  David W. Metcalfe, 1993
5  *            Alex Korobka       1995,1996
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20  */
21
22 #include <stdlib.h>
23
24 #include "windef.h"
25 #include "wingdi.h"
26 #include "wine/winuser16.h"
27 #include "winuser.h"
28 #include "user.h"
29 #include "wine/debug.h"
30
31 WINE_DEFAULT_DEBUG_CHANNEL(scroll);
32
33 /*************************************************************************
34  *              ScrollWindow (USER32.@)
35  *
36  */
37 BOOL WINAPI ScrollWindow( HWND hwnd, INT dx, INT dy,
38                               const RECT *rect, const RECT *clipRect )
39 {
40     return
41         (ERROR != ScrollWindowEx( hwnd, dx, dy, rect, clipRect, 0, NULL,
42                                     (rect ? 0 : SW_SCROLLCHILDREN) |
43                                     SW_INVALIDATE ));
44 }
45
46 /*************************************************************************
47  *              ScrollDC (USER.221)
48  */
49 BOOL16 WINAPI ScrollDC16( HDC16 hdc, INT16 dx, INT16 dy, const RECT16 *rect,
50                           const RECT16 *cliprc, HRGN16 hrgnUpdate,
51                           LPRECT16 rcUpdate )
52 {
53     RECT rect32, clipRect32, rcUpdate32;
54     BOOL16 ret;
55
56     if (rect) CONV_RECT16TO32( rect, &rect32 );
57     if (cliprc) CONV_RECT16TO32( cliprc, &clipRect32 );
58     ret = ScrollDC( hdc, dx, dy, rect ? &rect32 : NULL,
59                       cliprc ? &clipRect32 : NULL, hrgnUpdate, &rcUpdate32 );
60     if (rcUpdate) CONV_RECT32TO16( &rcUpdate32, rcUpdate );
61     return ret;
62 }
63
64
65 /*************************************************************************
66  *              ScrollDC (USER32.@)
67  *
68  *   Only the hrgnUpdate is return in device coordinate.
69  *   rcUpdate must be returned in logical coordinate to comply with win API.
70  *
71  */
72 BOOL WINAPI ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc,
73                           const RECT *prLClip, HRGN hrgnUpdate,
74                           LPRECT rcUpdate )
75 {
76     if (USER_Driver.pScrollDC)
77         return USER_Driver.pScrollDC( hdc, dx, dy, rc, prLClip, hrgnUpdate, rcUpdate );
78     return FALSE;
79 }
80
81
82 /*************************************************************************
83  *              ScrollWindowEx (USER32.@)
84  *
85  * NOTE: Use this function instead of ScrollWindow32
86  */
87 INT WINAPI ScrollWindowEx( HWND hwnd, INT dx, INT dy,
88                                const RECT *rect, const RECT *clipRect,
89                                HRGN hrgnUpdate, LPRECT rcUpdate,
90                                UINT flags )
91 {
92     if (USER_Driver.pScrollWindowEx)
93         return USER_Driver.pScrollWindowEx( hwnd, dx, dy, rect, clipRect,
94                                             hrgnUpdate, rcUpdate, flags );
95     return ERROR;
96 }