Reimplement several RpcServer.* methods in rpc_server.c.
[wine/wine64.git] / windows / scroll.c
blob6be5d6b38c8aa7dfea41997b536340d5a9bce0cf
1 /*
2 * Scroll windows and DCs
4 * Copyright David W. Metcalfe, 1993
5 * Alex Korobka 1995,1996
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include <stdlib.h>
24 #include "windef.h"
25 #include "wingdi.h"
26 #include "wine/winuser16.h"
27 #include "winuser.h"
28 #include "user.h"
29 #include "win.h"
30 #include "wine/debug.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(scroll);
34 /*************************************************************************
35 * fix_caret
37 static HWND fix_caret(HWND hWnd, LPRECT lprc, UINT flags)
39 HWND hCaret = CARET_GetHwnd();
41 if( hCaret )
43 RECT rc;
44 CARET_GetRect( &rc );
45 if( hCaret == hWnd ||
46 (flags & SW_SCROLLCHILDREN && IsChild(hWnd, hCaret)) )
48 POINT pt;
49 pt.x = rc.left;
50 pt.y = rc.top;
51 MapWindowPoints( hCaret, hWnd, (LPPOINT)&rc, 2 );
52 if( IntersectRect(lprc, lprc, &rc) )
54 HideCaret(hCaret);
55 lprc->left = pt.x;
56 lprc->top = pt.y;
57 return hCaret;
61 return 0;
65 /*************************************************************************
66 * ScrollWindow (USER32.@)
69 BOOL WINAPI ScrollWindow( HWND hwnd, INT dx, INT dy,
70 const RECT *rect, const RECT *clipRect )
72 return
73 (ERROR != ScrollWindowEx( hwnd, dx, dy, rect, clipRect, 0, NULL,
74 (rect ? 0 : SW_SCROLLCHILDREN) |
75 SW_INVALIDATE ));
78 /*************************************************************************
79 * ScrollDC (USER.221)
81 BOOL16 WINAPI ScrollDC16( HDC16 hdc, INT16 dx, INT16 dy, const RECT16 *rect,
82 const RECT16 *cliprc, HRGN16 hrgnUpdate,
83 LPRECT16 rcUpdate )
85 RECT rect32, clipRect32, rcUpdate32;
86 BOOL16 ret;
88 if (rect) CONV_RECT16TO32( rect, &rect32 );
89 if (cliprc) CONV_RECT16TO32( cliprc, &clipRect32 );
90 ret = ScrollDC( hdc, dx, dy, rect ? &rect32 : NULL,
91 cliprc ? &clipRect32 : NULL, hrgnUpdate, &rcUpdate32 );
92 if (rcUpdate) CONV_RECT32TO16( &rcUpdate32, rcUpdate );
93 return ret;
97 /*************************************************************************
98 * ScrollDC (USER32.@)
100 * Only the hrgnUpdate is return in device coordinate.
101 * rcUpdate must be returned in logical coordinate to comply with win API.
104 BOOL WINAPI ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc,
105 const RECT *prLClip, HRGN hrgnUpdate,
106 LPRECT rcUpdate )
108 if (USER_Driver.pScrollDC)
109 return USER_Driver.pScrollDC( hdc, dx, dy, rc, prLClip, hrgnUpdate, rcUpdate );
110 return FALSE;
114 /*************************************************************************
115 * ScrollWindowEx (USER32.@)
117 * NOTE: Use this function instead of ScrollWindow32
119 INT WINAPI ScrollWindowEx( HWND hwnd, INT dx, INT dy,
120 const RECT *rect, const RECT *clipRect,
121 HRGN hrgnUpdate, LPRECT rcUpdate,
122 UINT flags )
124 RECT rc, cliprc;
125 INT result;
127 if (!WIN_IsWindowDrawable( hwnd, TRUE )) return ERROR;
128 hwnd = WIN_GetFullHandle( hwnd );
130 GetClientRect(hwnd, &rc);
131 if (rect) IntersectRect(&rc, &rc, rect);
133 if (clipRect) IntersectRect(&cliprc,&rc,clipRect);
134 else cliprc = rc;
136 if (!IsRectEmpty(&cliprc) && (dx || dy))
138 RECT caretrc = rc;
139 HWND hwndCaret = fix_caret(hwnd, &caretrc, flags);
141 if (USER_Driver.pScrollWindowEx)
142 result = USER_Driver.pScrollWindowEx( hwnd, dx, dy, &rc, &cliprc,
143 hrgnUpdate, rcUpdate, flags );
144 else
145 result = ERROR; /* FIXME: we should have a fallback implementation */
147 if( hwndCaret )
149 SetCaretPos( caretrc.left + dx, caretrc.top + dy );
150 ShowCaret(hwndCaret);
153 else
154 result = NULLREGION;
156 return result;