Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

dcscroll.cpp

Go to the documentation of this file.
00001 /* $Id: dcscroll.cpp,v 1.2 2001/09/05 13:53:50 bird Exp $ */
00002 /*
00003  * ScrollDC implementation
00004  *
00005  * Ported from Wine (windows\scroll.c)
00006  * Fixes for clip rectangles & adaption for Odin (SvL)
00007  *
00008  * Copyright  David W. Metcalfe, 1993
00009  *        Alex Korobka       1995,1996
00010  *
00011  *
00012  */
00013 
00014 #include <os2win.h>
00015 
00016 //******************************************************************************
00017 //TODO: Can be more efficient (update rect/rgn calc.)
00018 //******************************************************************************
00019 BOOL WINAPI ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc,
00020                           const RECT *prLClip, HRGN hrgnUpdate,
00021                           LPRECT rcUpdate )
00022 {
00023     RECT rect, rClip, rSrc;
00024     POINT src, dest;
00025 
00026     dprintf(("USER32: ScrollDC %04x %d,%d hrgnUpdate=%04x rcUpdate = %p cliprc = (%d,%d-%d,%d), rc=(%d,%d-%d,%d)",
00027                    hdc, dx, dy, hrgnUpdate, rcUpdate,
00028            prLClip ? prLClip->left : 0, prLClip ? prLClip->top : 0, prLClip ? prLClip->right : 0, prLClip ? prLClip->bottom : 0,
00029            rc ? rc->left : 0, rc ? rc->top : 0, rc ? rc->right : 0, rc ? rc->bottom : 0 ));
00030 
00031     if ( !hdc ) return FALSE;
00032 
00033     /* compute device clipping region (in device coordinates) */
00034 
00035     if ( rc )
00036     rect = *rc;
00037     else /* maybe we should just return FALSE? */
00038     {
00039         DebugInt3();
00040     GetClipBox( hdc, &rect );
00041     }
00042 
00043     LPtoDP( hdc, (LPPOINT)&rect, 2 );
00044 
00045     if (prLClip)
00046     {
00047         rClip = *prLClip;
00048         LPtoDP( hdc, (LPPOINT)&rClip, 2 );
00049     IntersectRect( &rClip, &rect, &rClip );
00050     }
00051     else
00052         rClip = rect;
00053 
00054     //limit scrolling to DC's clip rectangle
00055     GetClipBox( hdc, &rSrc );
00056     IntersectRect( &rClip, &rSrc, &rClip );
00057     IntersectRect( &rect, &rSrc, &rect );
00058 
00059     POINT ptl[2] = { 0, 0, dx, dy };
00060 
00061     LPtoDP( hdc, ptl, 2);
00062 
00063     dx = (int)(ptl[1].x - ptl[0].x);
00064     dy = (int)(ptl[1].y - ptl[0].y);
00065 
00066     rSrc = rClip;
00067     if (prLClip) {
00068         OffsetRect( &rSrc, -dx, -dy );
00069         IntersectRect( &rSrc, &rSrc, &rect );
00070     }
00071     if (!IsRectEmpty(&rSrc))
00072     {
00073             dest.x = (src.x = rSrc.left) + dx;
00074             dest.y = (src.y = rSrc.top) + dy;
00075 
00076             /* copy bits */
00077 
00078             DPtoLP( hdc, (LPPOINT)&rSrc, 2 );
00079             DPtoLP( hdc, &src, 1 );
00080             DPtoLP( hdc, &dest, 1 );
00081 
00082             if (!BitBlt( hdc, dest.x, dest.y,
00083                            rSrc.right - rSrc.left, rSrc.bottom - rSrc.top,
00084                            hdc, src.x, src.y, SRCCOPY))
00085             {
00086                 return FALSE;
00087             }
00088         }
00089 
00090         /* compute update areas */
00091 
00092         if (hrgnUpdate || rcUpdate)
00093         {
00094             HRGN hrgn =
00095               (hrgnUpdate) ? hrgnUpdate : CreateRectRgn( 0,0,0,0 );
00096             HRGN hrgn2;
00097 
00098             hrgn2 = CreateRectRgnIndirect( &rect );
00099             SetRectRgn( hrgn, rClip.left, rClip.top,
00100                           rClip.right, rClip.bottom );
00101             CombineRgn( hrgn, hrgn, hrgn2, RGN_AND );
00102             OffsetRgn( hrgn2, dx, dy );
00103             CombineRgn( hrgn, hrgn, hrgn2, RGN_DIFF );
00104 
00105             if( rcUpdate )
00106         {
00107         GetRgnBox( hrgn, rcUpdate );
00108 
00109         /* Put the rcUpdate in logical coordinate */
00110         DPtoLP( hdc, (LPPOINT)rcUpdate, 2 );
00111         }
00112             if (!hrgnUpdate) DeleteObject( hrgn );
00113             DeleteObject( hrgn2 );
00114 
00115     }
00116 
00117     return TRUE;
00118 
00119 }
00120 //******************************************************************************
00121 //******************************************************************************

Generated on Wed Jan 23 23:17:29 2002 for ODIN-user32 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001