A couple of new functions have been added to the pthread_functions
[wine.git] / windows / scroll.c
blob070c12b68c3048af92ed0a81a37723abe8881414
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 <stdarg.h>
23 #include <stdlib.h>
25 #include "windef.h"
26 #include "winbase.h"
27 #include "wingdi.h"
28 #include "wine/winuser16.h"
29 #include "winuser.h"
30 #include "user.h"
31 #include "win.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(scroll);
36 /*************************************************************************
37 * fix_caret
39 static HWND fix_caret(HWND hWnd, LPRECT lprc, UINT flags)
41 GUITHREADINFO info;
43 if (!GetGUIThreadInfo( GetCurrentThreadId(), &info )) return 0;
44 if (!info.hwndCaret) return 0;
45 if (info.hwndCaret == hWnd ||
46 ((flags & SW_SCROLLCHILDREN) && IsChild(hWnd, info.hwndCaret)))
48 POINT pt;
49 pt.x = info.rcCaret.left;
50 pt.y = info.rcCaret.top;
51 MapWindowPoints( info.hwndCaret, hWnd, (LPPOINT)&info.rcCaret, 2 );
52 if( IntersectRect(lprc, lprc, &info.rcCaret) )
54 HideCaret(0);
55 lprc->left = pt.x;
56 lprc->top = pt.y;
57 return info.hwndCaret;
60 return 0;
64 /*************************************************************************
65 * ScrollWindow (USER32.@)
68 BOOL WINAPI ScrollWindow( HWND hwnd, INT dx, INT dy,
69 const RECT *rect, const RECT *clipRect )
71 return
72 (ERROR != ScrollWindowEx( hwnd, dx, dy, rect, clipRect, 0, NULL,
73 (rect ? 0 : SW_SCROLLCHILDREN) |
74 SW_INVALIDATE ));
77 /*************************************************************************
78 * ScrollDC (USER32.@)
80 * Only the hrgnUpdate is return in device coordinate.
81 * rcUpdate must be returned in logical coordinate to comply with win API.
84 BOOL WINAPI ScrollDC( HDC hdc, INT dx, INT dy, const RECT *rc,
85 const RECT *prLClip, HRGN hrgnUpdate,
86 LPRECT rcUpdate )
88 if (USER_Driver.pScrollDC)
89 return USER_Driver.pScrollDC( hdc, dx, dy, rc, prLClip, hrgnUpdate, rcUpdate );
90 return FALSE;
94 /*************************************************************************
95 * ScrollWindowEx (USER32.@)
97 * NOTE: Use this function instead of ScrollWindow32
99 INT WINAPI ScrollWindowEx( HWND hwnd, INT dx, INT dy,
100 const RECT *rect, const RECT *clipRect,
101 HRGN hrgnUpdate, LPRECT rcUpdate,
102 UINT flags )
104 RECT rc, cliprc;
105 INT result;
107 if (!WIN_IsWindowDrawable( hwnd, TRUE )) return ERROR;
108 hwnd = WIN_GetFullHandle( hwnd );
110 GetClientRect(hwnd, &rc);
111 if (rect) IntersectRect(&rc, &rc, rect);
113 if (clipRect) IntersectRect(&cliprc,&rc,clipRect);
114 else cliprc = rc;
116 if (!IsRectEmpty(&cliprc) && (dx || dy))
118 RECT caretrc = rc;
119 HWND hwndCaret = fix_caret(hwnd, &caretrc, flags);
121 if (USER_Driver.pScrollWindowEx)
122 result = USER_Driver.pScrollWindowEx( hwnd, dx, dy, rect, clipRect,
123 hrgnUpdate, rcUpdate, flags );
124 else
125 result = ERROR; /* FIXME: we should have a fallback implementation */
127 if( hwndCaret )
129 SetCaretPos( caretrc.left + dx, caretrc.top + dy );
130 ShowCaret(hwndCaret);
133 else
134 result = NULLREGION;
136 return result;