source: trunk/src/user32/dcscroll.cpp@ 6502

Last change on this file since 6502 was 5899, checked in by sandervl, 24 years ago

ScrollDC Wine port + fixes

File size: 3.3 KB
Line 
1#include <os2win.h>
2
3/*
4 * ScrollDC implementation
5 *
6 * Ported from Wine (windows\scroll.c)
7 * Fixes for clip rectangles & adaption for Odin (SvL)
8 *
9 * Copyright David W. Metcalfe, 1993
10 * Alex Korobka 1995,1996
11 *
12 *
13 */
14
15//******************************************************************************
16//TODO: Can be more efficient (update rect/rgn calc.)
17//******************************************************************************
18BOOL WINAPI ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc,
19 const RECT *prLClip, HRGN hrgnUpdate,
20 LPRECT rcUpdate )
21{
22 RECT rect, rClip, rSrc;
23 POINT src, dest;
24
25 dprintf(("USER32: ScrollDC %04x %d,%d hrgnUpdate=%04x rcUpdate = %p cliprc = (%d,%d-%d,%d), rc=(%d,%d-%d,%d)",
26 hdc, dx, dy, hrgnUpdate, rcUpdate,
27 prLClip ? prLClip->left : 0, prLClip ? prLClip->top : 0, prLClip ? prLClip->right : 0, prLClip ? prLClip->bottom : 0,
28 rc ? rc->left : 0, rc ? rc->top : 0, rc ? rc->right : 0, rc ? rc->bottom : 0 ));
29
30 if ( !hdc ) return FALSE;
31
32 /* compute device clipping region (in device coordinates) */
33
34 if ( rc )
35 rect = *rc;
36 else /* maybe we should just return FALSE? */
37 {
38 DebugInt3();
39 GetClipBox( hdc, &rect );
40 }
41
42 LPtoDP( hdc, (LPPOINT)&rect, 2 );
43
44 if (prLClip)
45 {
46 rClip = *prLClip;
47 LPtoDP( hdc, (LPPOINT)&rClip, 2 );
48 IntersectRect( &rClip, &rect, &rClip );
49 }
50 else
51 rClip = rect;
52
53 //limit scrolling to DC's clip rectangle
54 GetClipBox( hdc, &rSrc );
55 IntersectRect( &rClip, &rSrc, &rClip );
56 IntersectRect( &rect, &rSrc, &rect );
57
58 POINT ptl[2] = { 0, 0, dx, dy };
59
60 LPtoDP( hdc, ptl, 2);
61
62 dx = (int)(ptl[1].x - ptl[0].x);
63 dy = (int)(ptl[1].y - ptl[0].y);
64
65 rSrc = rClip;
66 if (prLClip) {
67 OffsetRect( &rSrc, -dx, -dy );
68 IntersectRect( &rSrc, &rSrc, &rect );
69 }
70 if (!IsRectEmpty(&rSrc))
71 {
72 dest.x = (src.x = rSrc.left) + dx;
73 dest.y = (src.y = rSrc.top) + dy;
74
75 /* copy bits */
76
77 DPtoLP( hdc, (LPPOINT)&rSrc, 2 );
78 DPtoLP( hdc, &src, 1 );
79 DPtoLP( hdc, &dest, 1 );
80
81 if (!BitBlt( hdc, dest.x, dest.y,
82 rSrc.right - rSrc.left, rSrc.bottom - rSrc.top,
83 hdc, src.x, src.y, SRCCOPY))
84 {
85 return FALSE;
86 }
87 }
88
89 /* compute update areas */
90
91 if (hrgnUpdate || rcUpdate)
92 {
93 HRGN hrgn =
94 (hrgnUpdate) ? hrgnUpdate : CreateRectRgn( 0,0,0,0 );
95 HRGN hrgn2;
96
97 hrgn2 = CreateRectRgnIndirect( &rect );
98 SetRectRgn( hrgn, rClip.left, rClip.top,
99 rClip.right, rClip.bottom );
100 CombineRgn( hrgn, hrgn, hrgn2, RGN_AND );
101 OffsetRgn( hrgn2, dx, dy );
102 CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
103
104 if( rcUpdate )
105 {
106 GetRgnBox( hrgn, rcUpdate );
107
108 /* Put the rcUpdate in logical coordinate */
109 DPtoLP( hdc, (LPPOINT)rcUpdate, 2 );
110 }
111 if (!hrgnUpdate) DeleteObject( hrgn );
112 DeleteObject( hrgn2 );
113
114 }
115
116 return TRUE;
117
118}
119//******************************************************************************
120//******************************************************************************
Note: See TracBrowser for help on using the repository browser.