2 * Scroll windows and DCs
4 * Copyright David W. Metcalfe, 1993
5 * Alex Korobka 1995,1996
14 #include "wine/winuser16.h"
21 #include "debugtools.h"
23 DEFAULT_DEBUG_CHANNEL(scroll);
25 /*************************************************************************
26 * ScrollWindow (USER.61)
28 void WINAPI ScrollWindow16(HWND16 hwnd, INT16 dx, INT16 dy, const RECT16 *rect,
29 const RECT16 *clipRect )
31 RECT rect32, clipRect32;
33 if (rect) CONV_RECT16TO32( rect, &rect32 );
34 if (clipRect) CONV_RECT16TO32( clipRect, &clipRect32 );
35 ScrollWindow( hwnd, dx, dy, rect ? &rect32 : NULL,
36 clipRect ? &clipRect32 : NULL );
39 /*************************************************************************
40 * ScrollWindow (USER32.@)
43 BOOL WINAPI ScrollWindow( HWND hwnd, INT dx, INT dy,
44 const RECT *rect, const RECT *clipRect )
47 (ERROR != ScrollWindowEx( hwnd, dx, dy, rect, clipRect, 0, NULL,
48 (rect ? 0 : SW_SCROLLCHILDREN) |
52 /*************************************************************************
55 BOOL16 WINAPI ScrollDC16( HDC16 hdc, INT16 dx, INT16 dy, const RECT16 *rect,
56 const RECT16 *cliprc, HRGN16 hrgnUpdate,
59 RECT rect32, clipRect32, rcUpdate32;
62 if (rect) CONV_RECT16TO32( rect, &rect32 );
63 if (cliprc) CONV_RECT16TO32( cliprc, &clipRect32 );
64 ret = ScrollDC( hdc, dx, dy, rect ? &rect32 : NULL,
65 cliprc ? &clipRect32 : NULL, hrgnUpdate, &rcUpdate32 );
66 if (rcUpdate) CONV_RECT32TO16( &rcUpdate32, rcUpdate );
71 /*************************************************************************
74 * Only the hrgnUpdate is return in device coordinate.
75 * rcUpdate must be returned in logical coordinate to comply with win API.
78 BOOL WINAPI ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc,
79 const RECT *prLClip, HRGN hrgnUpdate,
82 RECT rect, rClip, rSrc;
84 DC *dc = DC_GetDCUpdate( hdc );
86 TRACE("%04x %d,%d hrgnUpdate=%04x rcUpdate = %p cliprc = (%d,%d-%d,%d), rc=(%d,%d-%d,%d)\n",
87 (HDC16)hdc, dx, dy, hrgnUpdate, rcUpdate,
88 prLClip ? prLClip->left : 0, prLClip ? prLClip->top : 0, prLClip ? prLClip->right : 0, prLClip ? prLClip->bottom : 0,
89 rc ? rc->left : 0, rc ? rc->top : 0, rc ? rc->right : 0, rc ? rc->bottom : 0 );
91 if ( !dc || !hdc ) return FALSE;
94 TRACE(scroll,"\t[wndOrgX=%i, wndExtX=%i, vportOrgX=%i, vportExtX=%i]\n",
95 dc->wndOrgX, dc->wndExtX, dc->vportOrgX, dc->vportExtX );
96 TRACE(scroll,"\t[wndOrgY=%i, wndExtY=%i, vportOrgY=%i, vportExtY=%i]\n",
97 dc->wndOrgY, dc->wndExtY, dc->vportOrgY, dc->vportExtY );
100 /* compute device clipping region (in device coordinates) */
104 else /* maybe we should just return FALSE? */
105 GetClipBox( hdc, &rect );
107 LPtoDP( hdc, (LPPOINT)&rect, 2 );
112 LPtoDP( hdc, (LPPOINT)&rClip, 2 );
113 IntersectRect( &rClip, &rect, &rClip );
118 dx = XLPTODP ( dc, rect.left + dx ) - XLPTODP ( dc, rect.left );
119 dy = YLPTODP ( dc, rect.top + dy ) - YLPTODP ( dc, rect.top );
122 OffsetRect( &rSrc, -dx, -dy );
123 IntersectRect( &rSrc, &rSrc, &rect );
127 if (!IsRectEmpty(&rSrc))
129 dest.x = (src.x = rSrc.left) + dx;
130 dest.y = (src.y = rSrc.top) + dy;
134 DPtoLP( hdc, (LPPOINT)&rSrc, 2 );
135 DPtoLP( hdc, &src, 1 );
136 DPtoLP( hdc, &dest, 1 );
138 if (!BitBlt( hdc, dest.x, dest.y,
139 rSrc.right - rSrc.left, rSrc.bottom - rSrc.top,
140 hdc, src.x, src.y, SRCCOPY))
142 GDI_ReleaseObj( hdc );
147 /* compute update areas */
149 if (hrgnUpdate || rcUpdate)
152 (hrgnUpdate) ? hrgnUpdate : CreateRectRgn( 0,0,0,0 );
155 hrgn2 = CreateRectRgnIndirect( &rect );
156 OffsetRgn( hrgn2, dc->DCOrgX, dc->DCOrgY );
157 CombineRgn( hrgn2, hrgn2, dc->hVisRgn, RGN_AND );
158 OffsetRgn( hrgn2, -dc->DCOrgX, -dc->DCOrgY );
159 SetRectRgn( hrgn, rClip.left, rClip.top,
160 rClip.right, rClip.bottom );
161 CombineRgn( hrgn, hrgn, hrgn2, RGN_AND );
162 OffsetRgn( hrgn2, dx, dy );
163 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
167 GetRgnBox( hrgn, rcUpdate );
169 /* Put the rcUpdate in logical coordinate */
170 DPtoLP( hdc, (LPPOINT)rcUpdate, 2 );
172 if (!hrgnUpdate) DeleteObject( hrgn );
173 DeleteObject( hrgn2 );
179 if (hrgnUpdate) SetRectRgn(hrgnUpdate, 0, 0, 0, 0);
180 if (rcUpdate) SetRectEmpty(rcUpdate);
183 GDI_ReleaseObj( hdc );
188 /*************************************************************************
189 * ScrollWindowEx (USER.319)
191 INT16 WINAPI ScrollWindowEx16( HWND16 hwnd, INT16 dx, INT16 dy,
192 const RECT16 *rect, const RECT16 *clipRect,
193 HRGN16 hrgnUpdate, LPRECT16 rcUpdate,
196 RECT rect32, clipRect32, rcUpdate32;
199 if (rect) CONV_RECT16TO32( rect, &rect32 );
200 if (clipRect) CONV_RECT16TO32( clipRect, &clipRect32 );
201 ret = ScrollWindowEx( hwnd, dx, dy, rect ? &rect32 : NULL,
202 clipRect ? &clipRect32 : NULL, hrgnUpdate,
203 (rcUpdate) ? &rcUpdate32 : NULL, flags );
204 if (rcUpdate) CONV_RECT32TO16( &rcUpdate32, rcUpdate );
209 /*************************************************************************
210 * ScrollWindowEx (USER32.@)
212 * NOTE: Use this function instead of ScrollWindow32
214 INT WINAPI ScrollWindowEx( HWND hwnd, INT dx, INT dy,
215 const RECT *rect, const RECT *clipRect,
216 HRGN hrgnUpdate, LPRECT rcUpdate,
219 if (USER_Driver.pScrollWindowEx)
220 return USER_Driver.pScrollWindowEx( hwnd, dx, dy, rect, clipRect,
221 hrgnUpdate, rcUpdate, flags );