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