2001-12-13 02:03:30 +01:00
|
|
|
/*
|
|
|
|
* Window painting functions
|
|
|
|
*
|
2004-12-07 18:31:53 +01:00
|
|
|
* Copyright 1993, 1994, 1995, 2001, 2004 Alexandre Julliard
|
2001-12-13 02:03:30 +01:00
|
|
|
* Copyright 1999 Alex Korobka
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2001-12-13 02:03:30 +01:00
|
|
|
*/
|
2003-11-26 23:29:30 +01:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2001-12-13 02:03:30 +01:00
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winbase.h"
|
2001-12-13 02:03:30 +01:00
|
|
|
#include "wingdi.h"
|
2004-12-07 18:31:53 +01:00
|
|
|
#include "ntstatus.h"
|
|
|
|
#include "winuser.h"
|
2001-12-13 02:03:30 +01:00
|
|
|
#include "wine/server.h"
|
|
|
|
#include "win.h"
|
2005-03-25 17:47:04 +01:00
|
|
|
#include "user_private.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
2001-12-13 02:03:30 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(win);
|
2001-12-13 02:03:30 +01:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
|
2001-12-13 02:03:30 +01:00
|
|
|
/***********************************************************************
|
2004-12-07 18:31:53 +01:00
|
|
|
* dump_rdw_flags
|
|
|
|
*/
|
|
|
|
static void dump_rdw_flags(UINT flags)
|
|
|
|
{
|
|
|
|
TRACE("flags:");
|
|
|
|
if (flags & RDW_INVALIDATE) TRACE(" RDW_INVALIDATE");
|
|
|
|
if (flags & RDW_INTERNALPAINT) TRACE(" RDW_INTERNALPAINT");
|
|
|
|
if (flags & RDW_ERASE) TRACE(" RDW_ERASE");
|
|
|
|
if (flags & RDW_VALIDATE) TRACE(" RDW_VALIDATE");
|
|
|
|
if (flags & RDW_NOINTERNALPAINT) TRACE(" RDW_NOINTERNALPAINT");
|
|
|
|
if (flags & RDW_NOERASE) TRACE(" RDW_NOERASE");
|
|
|
|
if (flags & RDW_NOCHILDREN) TRACE(" RDW_NOCHILDREN");
|
|
|
|
if (flags & RDW_ALLCHILDREN) TRACE(" RDW_ALLCHILDREN");
|
|
|
|
if (flags & RDW_UPDATENOW) TRACE(" RDW_UPDATENOW");
|
|
|
|
if (flags & RDW_ERASENOW) TRACE(" RDW_ERASENOW");
|
|
|
|
if (flags & RDW_FRAME) TRACE(" RDW_FRAME");
|
|
|
|
if (flags & RDW_NOFRAME) TRACE(" RDW_NOFRAME");
|
|
|
|
|
|
|
|
#define RDW_FLAGS \
|
|
|
|
(RDW_INVALIDATE | \
|
|
|
|
RDW_INTERNALPAINT | \
|
|
|
|
RDW_ERASE | \
|
|
|
|
RDW_VALIDATE | \
|
|
|
|
RDW_NOINTERNALPAINT | \
|
|
|
|
RDW_NOERASE | \
|
|
|
|
RDW_NOCHILDREN | \
|
|
|
|
RDW_ALLCHILDREN | \
|
|
|
|
RDW_UPDATENOW | \
|
|
|
|
RDW_ERASENOW | \
|
|
|
|
RDW_FRAME | \
|
|
|
|
RDW_NOFRAME)
|
|
|
|
|
|
|
|
if (flags & ~RDW_FLAGS) TRACE(" %04x", flags & ~RDW_FLAGS);
|
|
|
|
TRACE("\n");
|
|
|
|
#undef RDW_FLAGS
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* get_update_region
|
2001-12-13 02:03:30 +01:00
|
|
|
*
|
2005-03-30 19:11:46 +02:00
|
|
|
* Return update region (in screen coordinates) for a window.
|
2001-12-13 02:03:30 +01:00
|
|
|
*/
|
2004-12-07 18:31:53 +01:00
|
|
|
static HRGN get_update_region( HWND hwnd, UINT *flags, HWND *child )
|
2001-12-13 02:03:30 +01:00
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
HRGN hrgn = 0;
|
|
|
|
NTSTATUS status;
|
|
|
|
RGNDATA *data;
|
|
|
|
size_t size = 256;
|
|
|
|
|
|
|
|
do
|
2001-12-13 02:03:30 +01:00
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
if (!(data = HeapAlloc( GetProcessHeap(), 0, sizeof(*data) + size - 1 )))
|
|
|
|
{
|
|
|
|
SetLastError( ERROR_OUTOFMEMORY );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_update_region )
|
|
|
|
{
|
|
|
|
req->window = hwnd;
|
|
|
|
req->flags = *flags;
|
|
|
|
wine_server_set_reply( req, data->Buffer, size );
|
|
|
|
if (!(status = wine_server_call( req )))
|
|
|
|
{
|
|
|
|
size_t reply_size = wine_server_reply_size( reply );
|
|
|
|
data->rdh.dwSize = sizeof(data->rdh);
|
|
|
|
data->rdh.iType = RDH_RECTANGLES;
|
|
|
|
data->rdh.nCount = reply_size / sizeof(RECT);
|
|
|
|
data->rdh.nRgnSize = reply_size;
|
|
|
|
hrgn = ExtCreateRegion( NULL, size, data );
|
|
|
|
if (child) *child = reply->child;
|
|
|
|
*flags = reply->flags;
|
|
|
|
}
|
|
|
|
else size = reply->total_size;
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
|
|
|
} while (status == STATUS_BUFFER_OVERFLOW);
|
|
|
|
|
|
|
|
if (status) SetLastError( RtlNtStatusToDosError(status) );
|
|
|
|
return hrgn;
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2004-12-07 18:31:53 +01:00
|
|
|
* get_update_flags
|
2001-12-13 02:03:30 +01:00
|
|
|
*
|
2004-12-07 18:31:53 +01:00
|
|
|
* Get only the update flags, not the update region.
|
2001-12-13 02:03:30 +01:00
|
|
|
*/
|
2004-12-07 18:31:53 +01:00
|
|
|
static BOOL get_update_flags( HWND hwnd, HWND *child, UINT *flags )
|
2001-12-13 02:03:30 +01:00
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
SERVER_START_REQ( get_update_region )
|
2001-12-13 02:03:30 +01:00
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
req->window = hwnd;
|
|
|
|
req->flags = *flags | UPDATE_NOREGION;
|
|
|
|
if ((ret = !wine_server_call_err( req )))
|
|
|
|
{
|
|
|
|
if (child) *child = reply->child;
|
|
|
|
*flags = reply->flags;
|
|
|
|
}
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
2004-12-07 18:31:53 +01:00
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-08-26 02:46:11 +02:00
|
|
|
/***********************************************************************
|
2004-12-07 18:31:53 +01:00
|
|
|
* redraw_window_rects
|
2004-08-26 02:46:11 +02:00
|
|
|
*
|
2004-12-07 18:31:53 +01:00
|
|
|
* Redraw part of a window.
|
2004-08-26 02:46:11 +02:00
|
|
|
*/
|
2004-12-07 18:31:53 +01:00
|
|
|
static BOOL redraw_window_rects( HWND hwnd, UINT flags, const RECT *rects, UINT count )
|
2004-08-26 02:46:11 +02:00
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
SERVER_START_REQ( redraw_window )
|
|
|
|
{
|
|
|
|
req->window = hwnd;
|
|
|
|
req->flags = flags;
|
|
|
|
wine_server_add_data( req, rects, count * sizeof(RECT) );
|
|
|
|
ret = !wine_server_call_err( req );
|
|
|
|
}
|
|
|
|
SERVER_END_REQ;
|
|
|
|
return ret;
|
2004-08-26 02:46:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-13 02:03:30 +01:00
|
|
|
/***********************************************************************
|
2004-12-07 18:31:53 +01:00
|
|
|
* send_ncpaint
|
2001-12-13 02:03:30 +01:00
|
|
|
*
|
2005-03-30 19:11:46 +02:00
|
|
|
* Send a WM_NCPAINT message if needed, and return the resulting update region (in screen coords).
|
2004-12-07 18:31:53 +01:00
|
|
|
* Helper for erase_now and BeginPaint.
|
2001-12-13 02:03:30 +01:00
|
|
|
*/
|
2004-12-07 18:31:53 +01:00
|
|
|
static HRGN send_ncpaint( HWND hwnd, HWND *child, UINT *flags )
|
2001-12-13 02:03:30 +01:00
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
HRGN whole_rgn = get_update_region( hwnd, flags, child );
|
|
|
|
HRGN client_rgn = 0;
|
|
|
|
|
|
|
|
if (child) hwnd = *child;
|
|
|
|
|
|
|
|
if (whole_rgn)
|
2001-12-13 02:03:30 +01:00
|
|
|
{
|
|
|
|
RECT client, update;
|
2004-12-07 18:31:53 +01:00
|
|
|
INT type;
|
2001-12-13 02:03:30 +01:00
|
|
|
|
|
|
|
/* check if update rgn overlaps with nonclient area */
|
2004-12-07 18:31:53 +01:00
|
|
|
type = GetRgnBox( whole_rgn, &update );
|
2005-03-30 19:11:46 +02:00
|
|
|
GetClientRect( hwnd, &client );
|
|
|
|
MapWindowPoints( hwnd, 0, (POINT *)&client, 2 );
|
2001-12-13 02:03:30 +01:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
if ((*flags & UPDATE_NONCLIENT) ||
|
|
|
|
update.left < client.left || update.top < client.top ||
|
2001-12-13 02:03:30 +01:00
|
|
|
update.right > client.right || update.bottom > client.bottom)
|
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
client_rgn = CreateRectRgnIndirect( &client );
|
|
|
|
CombineRgn( client_rgn, client_rgn, whole_rgn, RGN_AND );
|
|
|
|
|
|
|
|
/* check if update rgn contains complete nonclient area */
|
2005-03-30 19:11:46 +02:00
|
|
|
if (type == SIMPLEREGION)
|
2001-12-13 02:03:30 +01:00
|
|
|
{
|
2005-03-30 19:11:46 +02:00
|
|
|
RECT window;
|
|
|
|
GetWindowRect( hwnd, &window );
|
|
|
|
if (EqualRect( &window, &update ))
|
|
|
|
{
|
|
|
|
DeleteObject( whole_rgn );
|
|
|
|
whole_rgn = (HRGN)1;
|
|
|
|
}
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
client_rgn = whole_rgn;
|
|
|
|
whole_rgn = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (whole_rgn) /* NOTE: WM_NCPAINT allows wParam to be 1 */
|
|
|
|
{
|
|
|
|
if (*flags & UPDATE_NONCLIENT) SendMessageW( hwnd, WM_NCPAINT, (WPARAM)whole_rgn, 0 );
|
|
|
|
if (whole_rgn > (HRGN)1) DeleteObject( whole_rgn );
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
|
|
|
}
|
2004-12-07 18:31:53 +01:00
|
|
|
return client_rgn;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* send_erase
|
|
|
|
*
|
|
|
|
* Send a WM_ERASEBKGND message if needed, and optionally return the DC for painting.
|
2005-05-05 18:52:21 +02:00
|
|
|
* If a DC is requested, the region is selected into it. In all cases the region is deleted.
|
2004-12-07 18:31:53 +01:00
|
|
|
* Helper for erase_now and BeginPaint.
|
|
|
|
*/
|
|
|
|
static BOOL send_erase( HWND hwnd, UINT flags, HRGN client_rgn,
|
|
|
|
RECT *clip_rect, HDC *hdc_ret )
|
|
|
|
{
|
|
|
|
BOOL need_erase = FALSE;
|
2005-05-05 18:52:21 +02:00
|
|
|
HDC hdc = 0;
|
2005-03-30 19:11:46 +02:00
|
|
|
RECT dummy;
|
2004-12-07 18:31:53 +01:00
|
|
|
|
2005-03-30 19:11:46 +02:00
|
|
|
if (!clip_rect) clip_rect = &dummy;
|
2004-12-07 18:31:53 +01:00
|
|
|
if (hdc_ret || (flags & UPDATE_ERASE))
|
2001-12-13 02:03:30 +01:00
|
|
|
{
|
2005-03-30 12:28:58 +02:00
|
|
|
UINT dcx_flags = DCX_INTERSECTRGN | DCX_USESTYLE;
|
2004-12-07 18:31:53 +01:00
|
|
|
if (IsIconic(hwnd)) dcx_flags |= DCX_WINDOW;
|
|
|
|
|
|
|
|
if ((hdc = GetDCEx( hwnd, client_rgn, dcx_flags )))
|
|
|
|
{
|
|
|
|
INT type = GetClipBox( hdc, clip_rect );
|
|
|
|
|
|
|
|
if (flags & UPDATE_ERASE)
|
|
|
|
{
|
|
|
|
/* don't erase if the clip box is empty */
|
|
|
|
if (type != NULLREGION)
|
|
|
|
need_erase = !SendMessageW( hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0 );
|
|
|
|
}
|
|
|
|
if (!hdc_ret)
|
|
|
|
{
|
2005-01-11 16:15:11 +01:00
|
|
|
if (need_erase && hwnd != GetDesktopWindow()) /* FIXME: mark it as needing erase again */
|
2005-03-30 19:11:46 +02:00
|
|
|
RedrawWindow( hwnd, clip_rect, 0, RDW_INVALIDATE | RDW_ERASE | RDW_NOCHILDREN );
|
2004-12-07 18:31:53 +01:00
|
|
|
ReleaseDC( hwnd, hdc );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (hdc_ret) *hdc_ret = hdc;
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
2005-05-05 18:52:21 +02:00
|
|
|
if (!hdc) DeleteObject( client_rgn );
|
2004-12-07 18:31:53 +01:00
|
|
|
return need_erase;
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2004-12-07 18:31:53 +01:00
|
|
|
* erase_now
|
2001-12-13 02:03:30 +01:00
|
|
|
*
|
2004-12-07 18:31:53 +01:00
|
|
|
* Implementation of RDW_ERASENOW behavior.
|
2001-12-13 02:03:30 +01:00
|
|
|
*/
|
2005-01-11 16:15:11 +01:00
|
|
|
static void erase_now( HWND hwnd, UINT rdw_flags )
|
2001-12-13 02:03:30 +01:00
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
HWND child;
|
|
|
|
HRGN hrgn;
|
2001-12-13 02:03:30 +01:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
/* loop while we find a child to repaint */
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
UINT flags = UPDATE_NONCLIENT | UPDATE_ERASE;
|
2001-12-13 02:03:30 +01:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
if (rdw_flags & RDW_NOCHILDREN) flags |= UPDATE_NOCHILDREN;
|
|
|
|
else if (rdw_flags & RDW_ALLCHILDREN) flags |= UPDATE_ALLCHILDREN;
|
2001-12-13 02:03:30 +01:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
if (!(hrgn = send_ncpaint( hwnd, &child, &flags ))) break;
|
2005-03-30 19:11:46 +02:00
|
|
|
send_erase( child, flags, hrgn, NULL, NULL );
|
2001-12-13 02:03:30 +01:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
if (!flags) break; /* nothing more to do */
|
|
|
|
if (rdw_flags & RDW_NOCHILDREN) break;
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
2004-12-07 18:31:53 +01:00
|
|
|
}
|
2001-12-13 02:03:30 +01:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* update_now
|
|
|
|
*
|
|
|
|
* Implementation of RDW_UPDATENOW behavior.
|
|
|
|
*
|
|
|
|
* FIXME: Windows uses WM_SYNCPAINT to cut down the number of intertask
|
|
|
|
* SendMessage() calls. This is a comment inside DefWindowProc() source
|
|
|
|
* from 16-bit SDK:
|
|
|
|
*
|
|
|
|
* This message avoids lots of inter-app message traffic
|
|
|
|
* by switching to the other task and continuing the
|
|
|
|
* recursion there.
|
|
|
|
*
|
|
|
|
* wParam = flags
|
|
|
|
* LOWORD(lParam) = hrgnClip
|
|
|
|
* HIWORD(lParam) = hwndSkip (not used; always NULL)
|
|
|
|
*
|
|
|
|
*/
|
2005-01-11 16:15:11 +01:00
|
|
|
static void update_now( HWND hwnd, UINT rdw_flags )
|
2004-12-07 18:31:53 +01:00
|
|
|
{
|
2005-02-24 20:42:08 +01:00
|
|
|
HWND prev = 0, child;
|
2004-12-07 18:31:53 +01:00
|
|
|
|
2005-03-08 20:26:57 +01:00
|
|
|
/* process pending expose events before painting */
|
|
|
|
MsgWaitForMultipleObjects( 0, NULL, FALSE, 0, QS_PAINT );
|
|
|
|
|
2005-01-11 16:15:11 +01:00
|
|
|
/* desktop window never gets WM_PAINT, only WM_ERASEBKGND */
|
|
|
|
if (hwnd == GetDesktopWindow()) erase_now( hwnd, rdw_flags | RDW_NOCHILDREN );
|
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
/* loop while we find a child to repaint */
|
|
|
|
for (;;)
|
|
|
|
{
|
|
|
|
UINT flags = UPDATE_PAINT | UPDATE_INTERNALPAINT;
|
|
|
|
|
|
|
|
if (rdw_flags & RDW_NOCHILDREN) flags |= UPDATE_NOCHILDREN;
|
|
|
|
else if (rdw_flags & RDW_ALLCHILDREN) flags |= UPDATE_ALLCHILDREN;
|
|
|
|
|
|
|
|
if (!get_update_flags( hwnd, &child, &flags )) break;
|
|
|
|
if (!flags) break; /* nothing more to do */
|
|
|
|
|
2005-02-24 20:42:08 +01:00
|
|
|
if (child == prev) /* same window again, didn't get repainted properly */
|
|
|
|
{
|
|
|
|
UINT erase_flags = UPDATE_NONCLIENT | UPDATE_ERASE | UPDATE_NOCHILDREN;
|
|
|
|
HRGN hrgn;
|
2004-12-07 18:31:53 +01:00
|
|
|
|
2005-02-24 20:42:08 +01:00
|
|
|
TRACE( "%p not repainted properly, erasing\n", child );
|
|
|
|
if ((hrgn = send_ncpaint( child, NULL, &erase_flags )))
|
2005-03-30 19:11:46 +02:00
|
|
|
send_erase( child, erase_flags, hrgn, NULL, NULL );
|
2005-05-05 18:52:21 +02:00
|
|
|
|
2005-03-07 12:06:30 +01:00
|
|
|
prev = 0;
|
2005-02-24 20:42:08 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
prev = child;
|
|
|
|
SendMessageW( child, WM_PAINT, 0, 0 );
|
|
|
|
}
|
2004-12-07 18:31:53 +01:00
|
|
|
if (rdw_flags & RDW_NOCHILDREN) break;
|
|
|
|
}
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-25 18:13:17 +02:00
|
|
|
/*************************************************************************
|
|
|
|
* fix_caret
|
|
|
|
*
|
|
|
|
* Helper for ScrollWindowEx.
|
|
|
|
*/
|
|
|
|
static HWND fix_caret(HWND hWnd, LPRECT lprc, UINT flags)
|
|
|
|
{
|
|
|
|
GUITHREADINFO info;
|
|
|
|
|
|
|
|
if (!GetGUIThreadInfo( GetCurrentThreadId(), &info )) return 0;
|
|
|
|
if (!info.hwndCaret) return 0;
|
|
|
|
if (info.hwndCaret == hWnd ||
|
|
|
|
((flags & SW_SCROLLCHILDREN) && IsChild(hWnd, info.hwndCaret)))
|
|
|
|
{
|
|
|
|
POINT pt;
|
|
|
|
pt.x = info.rcCaret.left;
|
|
|
|
pt.y = info.rcCaret.top;
|
|
|
|
MapWindowPoints( info.hwndCaret, hWnd, (LPPOINT)&info.rcCaret, 2 );
|
|
|
|
if( IntersectRect(lprc, lprc, &info.rcCaret) )
|
|
|
|
{
|
|
|
|
HideCaret(0);
|
|
|
|
lprc->left = pt.x;
|
|
|
|
lprc->top = pt.y;
|
|
|
|
return info.hwndCaret;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-13 02:03:30 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* BeginPaint (USER32.@)
|
|
|
|
*/
|
|
|
|
HDC WINAPI BeginPaint( HWND hwnd, PAINTSTRUCT *lps )
|
|
|
|
{
|
|
|
|
HWND full_handle;
|
2004-12-07 18:31:53 +01:00
|
|
|
HRGN hrgn;
|
|
|
|
UINT flags = UPDATE_NONCLIENT | UPDATE_ERASE | UPDATE_PAINT | UPDATE_INTERNALPAINT | UPDATE_NOCHILDREN;
|
2001-12-13 02:03:30 +01:00
|
|
|
|
2003-04-30 02:50:43 +02:00
|
|
|
if (!lps) return 0;
|
|
|
|
|
2001-12-13 02:03:30 +01:00
|
|
|
if (!(full_handle = WIN_IsCurrentThread( hwnd )))
|
|
|
|
{
|
|
|
|
if (IsWindow(hwnd))
|
2002-11-22 22:22:14 +01:00
|
|
|
FIXME( "window %p belongs to other thread\n", hwnd );
|
2001-12-13 02:03:30 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
hwnd = full_handle;
|
|
|
|
|
|
|
|
HideCaret( hwnd );
|
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
if (!(hrgn = send_ncpaint( hwnd, NULL, &flags ))) return 0;
|
2001-12-13 02:03:30 +01:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
lps->fErase = send_erase( hwnd, flags, hrgn, &lps->rcPaint, &lps->hdc );
|
2001-12-13 02:03:30 +01:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
TRACE("hdc = %p box = (%ld,%ld - %ld,%ld), fErase = %d\n",
|
|
|
|
lps->hdc, lps->rcPaint.left, lps->rcPaint.top, lps->rcPaint.right, lps->rcPaint.bottom,
|
|
|
|
lps->fErase);
|
|
|
|
|
|
|
|
return lps->hdc;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* EndPaint (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI EndPaint( HWND hwnd, const PAINTSTRUCT *lps )
|
|
|
|
{
|
|
|
|
if (!lps) return FALSE;
|
2005-03-30 12:28:58 +02:00
|
|
|
if (USER_Driver.pReleaseDC) USER_Driver.pReleaseDC( hwnd, lps->hdc, TRUE );
|
2004-12-07 18:31:53 +01:00
|
|
|
ShowCaret( hwnd );
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-25 17:47:04 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* GetDCEx (USER32.@)
|
|
|
|
*/
|
|
|
|
HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
|
|
|
|
{
|
|
|
|
if (!hwnd) hwnd = GetDesktopWindow();
|
|
|
|
else hwnd = WIN_GetFullHandle( hwnd );
|
|
|
|
|
|
|
|
if (USER_Driver.pGetDCEx) return USER_Driver.pGetDCEx( hwnd, hrgnClip, flags );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetDC (USER32.@)
|
|
|
|
*
|
|
|
|
* Get a device context.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: Handle to the device context
|
|
|
|
* Failure: NULL.
|
|
|
|
*/
|
|
|
|
HDC WINAPI GetDC( HWND hwnd )
|
|
|
|
{
|
|
|
|
if (!hwnd) return GetDCEx( 0, 0, DCX_CACHE | DCX_WINDOW );
|
|
|
|
return GetDCEx( hwnd, 0, DCX_USESTYLE );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetWindowDC (USER32.@)
|
|
|
|
*/
|
|
|
|
HDC WINAPI GetWindowDC( HWND hwnd )
|
|
|
|
{
|
|
|
|
return GetDCEx( hwnd, 0, DCX_USESTYLE | DCX_WINDOW );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ReleaseDC (USER32.@)
|
|
|
|
*
|
|
|
|
* Release a device context.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: Non-zero. Resources used by hdc are released.
|
|
|
|
* Failure: 0.
|
|
|
|
*/
|
|
|
|
INT WINAPI ReleaseDC( HWND hwnd, HDC hdc )
|
|
|
|
{
|
2005-03-30 12:28:58 +02:00
|
|
|
if (USER_Driver.pReleaseDC) return USER_Driver.pReleaseDC( hwnd, hdc, FALSE );
|
2005-03-25 17:47:04 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* WindowFromDC (USER32.@)
|
|
|
|
*/
|
|
|
|
HWND WINAPI WindowFromDC( HDC hDC )
|
|
|
|
{
|
|
|
|
if (USER_Driver.pWindowFromDC) return USER_Driver.pWindowFromDC( hDC );
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* LockWindowUpdate (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI LockWindowUpdate( HWND hwnd )
|
|
|
|
{
|
|
|
|
static HWND lockedWnd;
|
|
|
|
|
|
|
|
/* This function is fully implemented by the following patch:
|
|
|
|
*
|
|
|
|
* http://www.winehq.org/hypermail/wine-patches/2004/01/0142.html
|
|
|
|
*
|
|
|
|
* but in order to work properly, it needs the ability to invalidate
|
|
|
|
* DCEs in other processes when the lock window is changed, which
|
|
|
|
* isn't possible yet.
|
|
|
|
* -mike
|
|
|
|
*/
|
|
|
|
|
|
|
|
FIXME("(%p), partial stub!\n",hwnd);
|
|
|
|
|
|
|
|
USER_Lock();
|
|
|
|
if (lockedWnd)
|
|
|
|
{
|
|
|
|
if (!hwnd)
|
|
|
|
{
|
|
|
|
/* Unlock lockedWnd */
|
|
|
|
/* FIXME: Do something */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Attempted to lock a second window */
|
|
|
|
/* Return FALSE and do nothing */
|
|
|
|
USER_Unlock();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lockedWnd = hwnd;
|
|
|
|
USER_Unlock();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* RedrawWindow (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI RedrawWindow( HWND hwnd, const RECT *rect, HRGN hrgn, UINT flags )
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
if (!hwnd) hwnd = GetDesktopWindow();
|
|
|
|
|
|
|
|
if (TRACE_ON(win))
|
2001-12-13 02:03:30 +01:00
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
if (hrgn)
|
2001-12-13 02:03:30 +01:00
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
RECT r;
|
|
|
|
GetRgnBox( hrgn, &r );
|
|
|
|
TRACE( "%p region %p box %s ", hwnd, hrgn, wine_dbgstr_rect(&r) );
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
2004-12-07 18:31:53 +01:00
|
|
|
else if (rect)
|
|
|
|
TRACE( "%p rect %s ", hwnd, wine_dbgstr_rect(rect) );
|
|
|
|
else
|
|
|
|
TRACE( "%p whole window ", hwnd );
|
|
|
|
|
|
|
|
dump_rdw_flags(flags);
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
if (rect && !hrgn)
|
2001-12-13 02:03:30 +01:00
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
ret = redraw_window_rects( hwnd, flags, rect, 1 );
|
|
|
|
}
|
|
|
|
else if (!hrgn)
|
|
|
|
{
|
|
|
|
ret = redraw_window_rects( hwnd, flags, NULL, 0 );
|
|
|
|
}
|
|
|
|
else /* need to build a list of the region rectangles */
|
|
|
|
{
|
|
|
|
DWORD size;
|
|
|
|
RGNDATA *data = NULL;
|
2005-01-28 18:23:25 +01:00
|
|
|
static const RECT empty;
|
2004-12-07 18:31:53 +01:00
|
|
|
|
|
|
|
if (!(size = GetRegionData( hrgn, 0, NULL ))) return FALSE;
|
|
|
|
if (!(data = HeapAlloc( GetProcessHeap(), 0, size ))) return FALSE;
|
|
|
|
GetRegionData( hrgn, size, data );
|
2005-01-28 18:23:25 +01:00
|
|
|
if (!data->rdh.nCount) /* empty region -> use a single all-zero rectangle */
|
|
|
|
ret = redraw_window_rects( hwnd, flags, &empty, 1 );
|
|
|
|
else
|
|
|
|
ret = redraw_window_rects( hwnd, flags, (const RECT *)data->Buffer, data->rdh.nCount );
|
2004-12-07 18:31:53 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, data );
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
if (flags & RDW_UPDATENOW) update_now( hwnd, flags );
|
|
|
|
else if (flags & RDW_ERASENOW) erase_now( hwnd, flags );
|
2001-12-13 02:03:30 +01:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
return ret;
|
|
|
|
}
|
2001-12-13 02:03:30 +01:00
|
|
|
|
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* UpdateWindow (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI UpdateWindow( HWND hwnd )
|
|
|
|
{
|
|
|
|
return RedrawWindow( hwnd, NULL, 0, RDW_UPDATENOW | RDW_ALLCHILDREN );
|
|
|
|
}
|
2001-12-13 02:03:30 +01:00
|
|
|
|
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* InvalidateRgn (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InvalidateRgn( HWND hwnd, HRGN hrgn, BOOL erase )
|
|
|
|
{
|
|
|
|
return RedrawWindow(hwnd, NULL, hrgn, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
|
|
|
|
}
|
2003-05-11 04:58:53 +02:00
|
|
|
|
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* InvalidateRect (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI InvalidateRect( HWND hwnd, const RECT *rect, BOOL erase )
|
|
|
|
{
|
|
|
|
return RedrawWindow( hwnd, rect, 0, RDW_INVALIDATE | (erase ? RDW_ERASE : 0) );
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2004-12-07 18:31:53 +01:00
|
|
|
* ValidateRgn (USER32.@)
|
2001-12-13 02:03:30 +01:00
|
|
|
*/
|
2004-12-07 18:31:53 +01:00
|
|
|
BOOL WINAPI ValidateRgn( HWND hwnd, HRGN hrgn )
|
2001-12-13 02:03:30 +01:00
|
|
|
{
|
2005-02-16 18:52:01 +01:00
|
|
|
return RedrawWindow( hwnd, NULL, hrgn, RDW_VALIDATE );
|
2004-12-07 18:31:53 +01:00
|
|
|
}
|
2003-04-30 02:50:43 +02:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ValidateRect (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ValidateRect( HWND hwnd, const RECT *rect )
|
|
|
|
{
|
2005-02-16 18:52:01 +01:00
|
|
|
return RedrawWindow( hwnd, rect, 0, RDW_VALIDATE );
|
2001-12-13 02:03:30 +01:00
|
|
|
}
|
2004-08-26 02:46:11 +02:00
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetUpdateRgn (USER32.@)
|
|
|
|
*/
|
|
|
|
INT WINAPI GetUpdateRgn( HWND hwnd, HRGN hrgn, BOOL erase )
|
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
INT retval = ERROR;
|
|
|
|
UINT flags = UPDATE_NOCHILDREN;
|
2004-08-26 02:46:11 +02:00
|
|
|
HRGN update_rgn;
|
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
if (erase) flags |= UPDATE_NONCLIENT | UPDATE_ERASE;
|
2004-08-26 02:46:11 +02:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
if ((update_rgn = send_ncpaint( hwnd, NULL, &flags )))
|
2004-08-26 02:46:11 +02:00
|
|
|
{
|
2005-03-30 19:11:46 +02:00
|
|
|
POINT offset;
|
2005-05-05 18:52:21 +02:00
|
|
|
|
|
|
|
retval = CombineRgn( hrgn, update_rgn, 0, RGN_COPY );
|
2005-03-30 19:11:46 +02:00
|
|
|
send_erase( hwnd, flags, update_rgn, NULL, NULL );
|
|
|
|
/* map region to client coordinates */
|
|
|
|
offset.x = offset.y = 0;
|
|
|
|
ScreenToClient( hwnd, &offset );
|
2005-05-05 18:52:21 +02:00
|
|
|
OffsetRgn( hrgn, offset.x, offset.y );
|
2004-08-26 02:46:11 +02:00
|
|
|
}
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetUpdateRect (USER32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI GetUpdateRect( HWND hwnd, LPRECT rect, BOOL erase )
|
|
|
|
{
|
2004-12-07 18:31:53 +01:00
|
|
|
UINT flags = UPDATE_NOCHILDREN;
|
|
|
|
HRGN update_rgn;
|
2004-09-02 22:13:19 +02:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
if (erase) flags |= UPDATE_NONCLIENT | UPDATE_ERASE;
|
2004-08-26 02:46:11 +02:00
|
|
|
|
2004-12-07 18:31:53 +01:00
|
|
|
if (!(update_rgn = send_ncpaint( hwnd, NULL, &flags ))) return FALSE;
|
|
|
|
|
2005-03-30 19:11:46 +02:00
|
|
|
if (rect)
|
|
|
|
{
|
|
|
|
if (GetRgnBox( update_rgn, rect ) != NULLREGION)
|
2005-05-05 18:52:21 +02:00
|
|
|
{
|
|
|
|
HDC hdc = GetDCEx( hwnd, 0, DCX_USESTYLE );
|
2005-03-30 19:11:46 +02:00
|
|
|
MapWindowPoints( 0, hwnd, (LPPOINT)rect, 2 );
|
2005-05-05 18:52:21 +02:00
|
|
|
DPtoLP( hdc, (LPPOINT)rect, 2 );
|
|
|
|
ReleaseDC( hwnd, hdc );
|
|
|
|
}
|
2005-03-30 19:11:46 +02:00
|
|
|
}
|
2005-05-05 18:52:21 +02:00
|
|
|
send_erase( hwnd, flags, update_rgn, NULL, NULL );
|
2004-12-07 18:31:53 +01:00
|
|
|
|
|
|
|
/* check if we still have an update region */
|
|
|
|
flags = UPDATE_PAINT | UPDATE_NOCHILDREN;
|
|
|
|
return (get_update_flags( hwnd, NULL, &flags ) && (flags & UPDATE_PAINT));
|
2004-08-26 02:46:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* ExcludeUpdateRgn (USER32.@)
|
|
|
|
*/
|
|
|
|
INT WINAPI ExcludeUpdateRgn( HDC hdc, HWND hwnd )
|
|
|
|
{
|
|
|
|
HRGN update_rgn = CreateRectRgn( 0, 0, 0, 0 );
|
|
|
|
INT ret = GetUpdateRgn( hwnd, update_rgn, FALSE );
|
|
|
|
|
|
|
|
if (ret != ERROR)
|
|
|
|
{
|
2005-01-04 13:11:09 +01:00
|
|
|
POINT pt;
|
2004-08-26 02:46:11 +02:00
|
|
|
|
2005-01-04 13:11:09 +01:00
|
|
|
GetDCOrgEx( hdc, &pt );
|
|
|
|
MapWindowPoints( 0, hwnd, &pt, 1 );
|
|
|
|
OffsetRgn( update_rgn, -pt.x, -pt.y );
|
|
|
|
ret = ExtSelectClipRgn( hdc, update_rgn, RGN_DIFF );
|
2004-08-26 02:46:11 +02:00
|
|
|
DeleteObject( update_rgn );
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2005-04-25 18:13:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* ScrollWindowEx (USER32.@)
|
|
|
|
*
|
|
|
|
* Note: contrary to what the doc says, pixels that are scrolled from the
|
|
|
|
* outside of clipRect to the inside are NOT painted.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
INT WINAPI ScrollWindowEx( HWND hwnd, INT dx, INT dy,
|
|
|
|
const RECT *rect, const RECT *clipRect,
|
|
|
|
HRGN hrgnUpdate, LPRECT rcUpdate,
|
|
|
|
UINT flags )
|
|
|
|
{
|
|
|
|
INT retVal = NULLREGION;
|
|
|
|
BOOL bOwnRgn = TRUE;
|
|
|
|
BOOL bUpdate = (rcUpdate || hrgnUpdate || flags & (SW_INVALIDATE | SW_ERASE));
|
|
|
|
int rdw_flags;
|
|
|
|
HRGN hrgnTemp;
|
|
|
|
HRGN hrgnWinupd = 0;
|
|
|
|
HDC hDC;
|
|
|
|
RECT rc, cliprc;
|
|
|
|
RECT caretrc;
|
|
|
|
HWND hwndCaret = NULL;
|
|
|
|
|
|
|
|
TRACE( "%p, %d,%d hrgnUpdate=%p rcUpdate = %p %s %04x\n",
|
|
|
|
hwnd, dx, dy, hrgnUpdate, rcUpdate, wine_dbgstr_rect(rect), flags );
|
|
|
|
TRACE( "clipRect = %s\n", wine_dbgstr_rect(clipRect));
|
|
|
|
if( flags & ~( SW_SCROLLCHILDREN | SW_INVALIDATE | SW_ERASE))
|
|
|
|
FIXME("some flags (%04x) are unhandled\n", flags);
|
|
|
|
|
|
|
|
rdw_flags = (flags & SW_ERASE) && (flags & SW_INVALIDATE) ?
|
|
|
|
RDW_INVALIDATE | RDW_ERASE : RDW_INVALIDATE ;
|
|
|
|
|
|
|
|
if (!WIN_IsWindowDrawable( hwnd, TRUE )) return ERROR;
|
|
|
|
hwnd = WIN_GetFullHandle( hwnd );
|
|
|
|
|
|
|
|
GetClientRect(hwnd, &rc);
|
|
|
|
if (rect) IntersectRect(&rc, &rc, rect);
|
|
|
|
|
|
|
|
if (clipRect) IntersectRect(&cliprc,&rc,clipRect);
|
|
|
|
else cliprc = rc;
|
|
|
|
|
|
|
|
if( hrgnUpdate ) bOwnRgn = FALSE;
|
|
|
|
else if( bUpdate ) hrgnUpdate = CreateRectRgn( 0, 0, 0, 0 );
|
|
|
|
|
|
|
|
if( !IsRectEmpty(&cliprc) && (dx || dy)) {
|
|
|
|
DWORD dcxflags = DCX_CACHE;
|
|
|
|
DWORD style = GetWindowLongW( hwnd, GWL_STYLE );
|
|
|
|
caretrc = rc;
|
|
|
|
hwndCaret = fix_caret(hwnd, &caretrc, flags);
|
|
|
|
|
|
|
|
if( style & WS_CLIPSIBLINGS) dcxflags |= DCX_CLIPSIBLINGS;
|
|
|
|
if( GetClassLongW( hwnd, GCL_STYLE ) & CS_PARENTDC)
|
|
|
|
dcxflags |= DCX_PARENTCLIP;
|
|
|
|
if( !(flags & SW_SCROLLCHILDREN) && (style & WS_CLIPCHILDREN))
|
|
|
|
dcxflags |= DCX_CLIPCHILDREN;
|
|
|
|
hDC = GetDCEx( hwnd, 0, dcxflags);
|
|
|
|
if (hDC)
|
|
|
|
{
|
|
|
|
ScrollDC( hDC, dx, dy, &rc, &cliprc, hrgnUpdate, rcUpdate );
|
|
|
|
|
|
|
|
ReleaseDC( hwnd, hDC );
|
|
|
|
|
|
|
|
if (!bUpdate)
|
|
|
|
RedrawWindow( hwnd, NULL, hrgnUpdate, rdw_flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If the windows has an update region, this must be
|
|
|
|
* scrolled as well. Keep a copy in hrgnWinupd
|
|
|
|
* to be added to hrngUpdate at the end. */
|
|
|
|
hrgnTemp = CreateRectRgn( 0, 0, 0, 0 );
|
|
|
|
retVal = GetUpdateRgn( hwnd, hrgnTemp, FALSE );
|
|
|
|
if (retVal != NULLREGION)
|
|
|
|
{
|
|
|
|
HRGN hrgnClip = CreateRectRgnIndirect(&cliprc);
|
|
|
|
if( !bOwnRgn) {
|
|
|
|
hrgnWinupd = CreateRectRgn( 0, 0, 0, 0);
|
|
|
|
CombineRgn( hrgnWinupd, hrgnTemp, 0, RGN_COPY);
|
|
|
|
}
|
|
|
|
OffsetRgn( hrgnTemp, dx, dy );
|
|
|
|
CombineRgn( hrgnTemp, hrgnTemp, hrgnClip, RGN_AND );
|
|
|
|
if( !bOwnRgn)
|
|
|
|
CombineRgn( hrgnWinupd, hrgnWinupd, hrgnTemp, RGN_OR );
|
|
|
|
RedrawWindow( hwnd, NULL, hrgnTemp, rdw_flags);
|
|
|
|
DeleteObject( hrgnClip );
|
|
|
|
}
|
|
|
|
DeleteObject( hrgnTemp );
|
|
|
|
} else {
|
|
|
|
/* nothing was scrolled */
|
|
|
|
if( !bOwnRgn)
|
|
|
|
SetRectRgn( hrgnUpdate, 0, 0, 0, 0 );
|
|
|
|
SetRectEmpty( rcUpdate);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( flags & SW_SCROLLCHILDREN )
|
|
|
|
{
|
|
|
|
HWND *list = WIN_ListChildren( hwnd );
|
|
|
|
if (list)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
RECT r, dummy;
|
|
|
|
for (i = 0; list[i]; i++)
|
|
|
|
{
|
|
|
|
GetWindowRect( list[i], &r );
|
|
|
|
MapWindowPoints( 0, hwnd, (POINT *)&r, 2 );
|
|
|
|
if (!rect || IntersectRect(&dummy, &r, rect))
|
|
|
|
SetWindowPos( list[i], 0, r.left + dx, r.top + dy, 0, 0,
|
|
|
|
SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE |
|
|
|
|
SWP_NOREDRAW | SWP_DEFERERASE );
|
|
|
|
}
|
|
|
|
HeapFree( GetProcessHeap(), 0, list );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( flags & (SW_INVALIDATE | SW_ERASE) )
|
|
|
|
RedrawWindow( hwnd, NULL, hrgnUpdate, rdw_flags |
|
|
|
|
((flags & SW_SCROLLCHILDREN) ? RDW_ALLCHILDREN : 0 ) );
|
|
|
|
|
|
|
|
if( hrgnWinupd) {
|
|
|
|
CombineRgn( hrgnUpdate, hrgnUpdate, hrgnWinupd, RGN_OR);
|
|
|
|
DeleteObject( hrgnWinupd);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( hwndCaret ) {
|
|
|
|
SetCaretPos( caretrc.left + dx, caretrc.top + dy );
|
|
|
|
ShowCaret(hwndCaret);
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bOwnRgn && hrgnUpdate ) DeleteObject( hrgnUpdate );
|
|
|
|
|
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* ScrollWindow (USER32.@)
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ScrollWindow( HWND hwnd, INT dx, INT dy,
|
|
|
|
const RECT *rect, const RECT *clipRect )
|
|
|
|
{
|
|
|
|
return (ERROR != ScrollWindowEx( hwnd, dx, dy, rect, clipRect, 0, NULL,
|
|
|
|
(rect ? 0 : SW_SCROLLCHILDREN) |
|
|
|
|
SW_INVALIDATE | SW_ERASE ));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
* ScrollDC (USER32.@)
|
|
|
|
*
|
|
|
|
* dx, dy, lprcScroll and lprcClip are all in logical coordinates (msdn is
|
|
|
|
* wrong) hrgnUpdate is returned in device coordinates with rcUpdate in
|
|
|
|
* logical coordinates.
|
|
|
|
*/
|
|
|
|
BOOL WINAPI ScrollDC( HDC hdc, INT dx, INT dy, const RECT *lprcScroll,
|
|
|
|
const RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate )
|
|
|
|
|
|
|
|
{
|
|
|
|
if (USER_Driver.pScrollDC)
|
|
|
|
return USER_Driver.pScrollDC( hdc, dx, dy, lprcScroll, lprcClip, hrgnUpdate, lprcUpdate );
|
|
|
|
return FALSE;
|
|
|
|
}
|