Release 940201
[wine.git] / windows / painting.c
blobc218e237546784240e7c7841f6c2a4dace42b4df
1 /*
2 * Window painting functions
4 * Copyright 1993 Alexandre Julliard
5 */
7 static char Copyright[] = "Copyright Alexandre Julliard, 1993";
9 #include <math.h>
10 #include <X11/Xlib.h>
12 #include "win.h"
13 #include "message.h"
15 /* Last CTLCOLOR id */
16 #define CTLCOLOR_MAX CTLCOLOR_STATIC
19 /***********************************************************************
20 * BeginPaint (USER.39)
22 HDC BeginPaint( HWND hwnd, LPPAINTSTRUCT lps )
24 HRGN hrgnUpdate;
25 WND * wndPtr = WIN_FindWndPtr( hwnd );
26 if (!wndPtr) return 0;
28 hrgnUpdate = wndPtr->hrgnUpdate; /* Save update region */
30 if (!(lps->hdc = GetDCEx( hwnd, wndPtr->hrgnUpdate,
31 DCX_INTERSECTRGN | DCX_USESTYLE ))) return 0;
32 GetRgnBox( InquireVisRgn(lps->hdc), &lps->rcPaint );
34 if (wndPtr->hrgnUpdate)
36 wndPtr->hrgnUpdate = 0;
37 MSG_DecPaintCount( wndPtr->hmemTaskQ );
39 wndPtr->flags &= ~WIN_NEEDS_BEGINPAINT;
41 SendMessage( hwnd, WM_NCPAINT, hrgnUpdate, 0 );
42 if (hrgnUpdate) DeleteObject( hrgnUpdate );
44 if (!(wndPtr->flags & WIN_ERASE_UPDATERGN)) lps->fErase = TRUE;
45 else lps->fErase = !SendMessage( hwnd, WM_ERASEBKGND, lps->hdc, 0 );
47 return lps->hdc;
51 /***********************************************************************
52 * EndPaint (USER.40)
54 void EndPaint( HWND hwnd, LPPAINTSTRUCT lps )
56 ReleaseDC( hwnd, lps->hdc );
60 /***********************************************************************
61 * FillWindow (USER.324)
63 void FillWindow( HWND hwndParent, HWND hwnd, HDC hdc, HBRUSH hbrush )
65 RECT rect;
66 GetClientRect( hwnd, &rect );
67 PaintRect( hwndParent, hwnd, hdc, hbrush, &rect );
71 /***********************************************************************
72 * PaintRect (USER.325)
74 void PaintRect(HWND hwndParent, HWND hwnd, HDC hdc, HBRUSH hbrush, LPRECT rect)
76 /* Send WM_CTLCOLOR message if needed */
78 if (hbrush <= CTLCOLOR_MAX)
80 if (!hwndParent) return;
81 hbrush = (HBRUSH)SendMessage( hwndParent, WM_CTLCOLOR,
82 hdc, hwnd | (hbrush << 16) );
84 if (hbrush) FillRect( hdc, rect, hbrush );