2 * Scroll windows and DCs
4 * Copyright 1993 David W. Metcalfe
5 * Copyright 1995, 1996 Alex Korobka
6 * Copyright 2001 Alexandre Julliard
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
35 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(scroll
);
40 /*************************************************************************
41 * ScrollWindowEx (X11DRV.@)
43 * Note: contrary to what the doc says, pixels that are scrolled from the
44 * outside of clipRect to the inside are NOT painted.
46 * Parameter are the same as in ScrollWindowEx, with the additional
47 * requirement that rect and clipRect are _valid_ pointers, to
48 * rectangles _within_ the client are. Moreover, there is something
51 INT
X11DRV_ScrollWindowEx( HWND hwnd
, INT dx
, INT dy
,
52 const RECT
*rect
, const RECT
*clipRect
,
53 HRGN hrgnUpdate
, LPRECT rcUpdate
, UINT flags
)
57 BOOL bUpdate
= (rcUpdate
|| hrgnUpdate
|| flags
& (SW_INVALIDATE
| SW_ERASE
));
62 TRACE( "%p, %d,%d hrgnUpdate=%p rcUpdate = %p %s %04x\n",
63 hwnd
, dx
, dy
, hrgnUpdate
, rcUpdate
, wine_dbgstr_rect(rect
), flags
);
64 TRACE( "clipRect = %s\n", wine_dbgstr_rect(clipRect
));
66 GetClientRect(hwnd
, &rc
);
67 if (rect
) IntersectRect(&rc
, &rc
, rect
);
69 if (clipRect
) IntersectRect(&cliprc
,&rc
,clipRect
);
72 if( hrgnUpdate
) bOwnRgn
= FALSE
;
73 else if( bUpdate
) hrgnUpdate
= CreateRectRgn( 0, 0, 0, 0 );
75 hDC
= GetDCEx( hwnd
, 0, DCX_CACHE
| DCX_USESTYLE
);
78 enum x11drv_escape_codes code
= X11DRV_START_EXPOSURES
;
81 ExtEscape( hDC
, X11DRV_ESCAPE
, sizeof(code
), (LPSTR
)&code
, 0, NULL
);
82 ScrollDC( hDC
, dx
, dy
, &rc
, &cliprc
, hrgnUpdate
, rcUpdate
);
83 code
= X11DRV_END_EXPOSURES
;
84 ExtEscape( hDC
, X11DRV_ESCAPE
, sizeof(code
), (LPSTR
)&code
, sizeof(hrgn
), (LPSTR
)&hrgn
);
85 ReleaseDC( hwnd
, hDC
);
88 if (bUpdate
) CombineRgn( hrgnUpdate
, hrgnUpdate
, hrgn
, RGN_OR
);
89 else RedrawWindow( hwnd
, NULL
, hrgn
, RDW_INVALIDATE
| RDW_ERASE
);
94 /* Take into account the fact that some damage may have occurred during the scroll */
95 hrgnTemp
= CreateRectRgn( 0, 0, 0, 0 );
96 retVal
= GetUpdateRgn( hwnd
, hrgnTemp
, FALSE
);
97 if (retVal
!= NULLREGION
)
99 HRGN hrgnClip
= CreateRectRgnIndirect(&cliprc
);
100 OffsetRgn( hrgnTemp
, dx
, dy
);
101 CombineRgn( hrgnTemp
, hrgnTemp
, hrgnClip
, RGN_AND
);
102 RedrawWindow( hwnd
, NULL
, hrgnTemp
, RDW_INVALIDATE
| RDW_ERASE
);
103 DeleteObject( hrgnClip
);
105 DeleteObject( hrgnTemp
);
107 if( flags
& SW_SCROLLCHILDREN
)
109 HWND
*list
= WIN_ListChildren( hwnd
);
114 for (i
= 0; list
[i
]; i
++)
116 GetWindowRect( list
[i
], &r
);
117 MapWindowPoints( 0, hwnd
, (POINT
*)&r
, 2 );
118 if (!rect
|| IntersectRect(&dummy
, &r
, &rc
))
119 SetWindowPos( list
[i
], 0, r
.left
+ dx
, r
.top
+ dy
, 0, 0,
120 SWP_NOZORDER
| SWP_NOSIZE
| SWP_NOACTIVATE
|
121 SWP_NOREDRAW
| SWP_DEFERERASE
);
123 HeapFree( GetProcessHeap(), 0, list
);
127 if( flags
& (SW_INVALIDATE
| SW_ERASE
) )
128 RedrawWindow( hwnd
, NULL
, hrgnUpdate
, RDW_INVALIDATE
| RDW_ERASE
|
129 ((flags
& SW_ERASE
) ? RDW_ERASENOW
: 0) |
130 ((flags
& SW_SCROLLCHILDREN
) ? RDW_ALLCHILDREN
: 0 ) );
132 if( bOwnRgn
&& hrgnUpdate
) DeleteObject( hrgnUpdate
);