ReactOS  0.4.14-dev-342-gdc047f9
paint.c File Reference
#include <user32.h>
Include dependency graph for paint.c:

Go to the source code of this file.

Functions

BOOL WINAPI MirrorRgn (HWND hwnd, HRGN hrgn)
 
BOOL WINAPI PolyPatBlt (HDC, DWORD, PPATRECT, INT, ULONG)
 
INT WINAPI MirrorWindowRect (PWND pWnd, LPRECT lprc)
 
VOID CreateFrameBrushes (VOID)
 
VOID DeleteFrameBrushes (VOID)
 
BOOL WINAPI GetUpdateRect (HWND Wnd, LPRECT Rect, BOOL Erase)
 
int WINAPI GetUpdateRgn (HWND hWnd, HRGN hRgn, BOOL bErase)
 
BOOL WINAPI ScrollDC (HDC hDC, int dx, int dy, CONST RECT *lprcScroll, CONST RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
 
int WINAPI SetWindowRgn (HWND hWnd, HRGN hRgn, BOOL bRedraw)
 
BOOL WINAPI UpdateWindow (HWND hWnd)
 
BOOL WINAPI ValidateRgn (HWND hWnd, HRGN hRgn)
 
int WINAPI GetWindowRgn (HWND hWnd, HRGN hRgn)
 
int WINAPI GetWindowRgnBox (HWND hWnd, LPRECT lprc)
 
BOOL WINAPI DrawFrame (HDC hDc, RECT *r, DWORD width, DWORD type)
 

Variables

static HBRUSH FrameBrushes [13]
 
static HBITMAP hHatch
 
const DWORD HatchBitmap [4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA}
 
const BYTE MappingTable [33] = {5,9,2,3,5,7,0,0,0,7,5,5,3,2,7,5,3,3,0,5,7,10,5,0,11,4,1,1,3,8,6,12,7}
 

Function Documentation

◆ CreateFrameBrushes()

VOID CreateFrameBrushes ( VOID  )

Definition at line 52 of file paint.c.

53 {
54  FrameBrushes[0] = CreateSolidBrush(RGB(0,0,0));
55  FrameBrushes[1] = CreateSolidBrush(RGB(0,0,128));
56  FrameBrushes[2] = CreateSolidBrush(RGB(10,36,106));
57  FrameBrushes[3] = CreateSolidBrush(RGB(128,128,128));
58  FrameBrushes[4] = CreateSolidBrush(RGB(181,181,181));
59  FrameBrushes[5] = CreateSolidBrush(RGB(212,208,200));
60  FrameBrushes[6] = CreateSolidBrush(RGB(236,233,216));
61  FrameBrushes[7] = CreateSolidBrush(RGB(255,255,255));
62  FrameBrushes[8] = CreateSolidBrush(RGB(49,106,197));
63  FrameBrushes[9] = CreateSolidBrush(RGB(58,110,165));
64  FrameBrushes[10] = CreateSolidBrush(RGB(64,64,64));
65  FrameBrushes[11] = CreateSolidBrush(RGB(255,255,225));
66  hHatch = CreateBitmap(8, 8, 1, 1, HatchBitmap);
68 }
const DWORD HatchBitmap[4]
Definition: paint.c:34
HBRUSH WINAPI CreatePatternBrush(_In_ HBITMAP)
#define RGB(r, g, b)
Definition: wingdi.h:2935
static HBRUSH FrameBrushes[13]
Definition: paint.c:32
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
static HBITMAP hHatch
Definition: paint.c:33
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

Referenced by DrawFrame().

◆ DeleteFrameBrushes()

VOID DeleteFrameBrushes ( VOID  )

Definition at line 71 of file paint.c.

72 {
73  unsigned Brush;
74 
75  for (Brush = 0; Brush < sizeof(FrameBrushes) / sizeof(HBRUSH); Brush++)
76  {
77  if (NULL != FrameBrushes[Brush])
78  {
81  }
82  }
83  if (NULL != hHatch)
84  {
86  hHatch = NULL;
87  }
88 }
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
void Brush(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG style)
Definition: drawing.cpp:160
smooth NULL
Definition: ftsmooth.c:416
static HBRUSH FrameBrushes[13]
Definition: paint.c:32
static HBITMAP hHatch
Definition: paint.c:33

Referenced by Cleanup().

◆ DrawFrame()

BOOL WINAPI DrawFrame ( HDC  hDc,
RECT r,
DWORD  width,
DWORD  type 
)

Definition at line 335 of file paint.c.

341 {
342  DWORD rop;
343  DWORD brush;
344  HBRUSH hbrFrame;
345  PATRECT p[4];
346  if (NULL == FrameBrushes[0])
347  {
349  }
350  if (type & 4)
351  {
352  rop = PATINVERT;
353  }
354  else
355  {
356  rop = PATCOPY;
357  }
358  brush = type / 8;
359  if (brush >= 33)
360  {
361  brush = 32;
362  }
363  brush = MappingTable[brush];
364  hbrFrame = FrameBrushes[brush];
365  p[0].hBrush = hbrFrame;
366  p[1].hBrush = hbrFrame;
367  p[2].hBrush = hbrFrame;
368  p[3].hBrush = hbrFrame;
369  p[0].r.left = r->left;
370  p[0].r.top = r->top;
371  p[0].r.right = r->right - r->left;
372  p[0].r.bottom = width;
373  p[1].r.left = r->left;
374  p[1].r.top = r->bottom - width;
375  p[1].r.right = r->right - r->left;
376  p[1].r.bottom = width;
377  p[2].r.left = r->left;
378  p[2].r.top = r->top + width;
379  p[2].r.right = width;
380  p[2].r.bottom = r->bottom - r->top - (width * 2);
381  p[3].r.left = r->right - width;
382  p[3].r.top = r->top + width;
383  p[3].r.right = width;
384  p[3].r.bottom = r->bottom - r->top - (width * 2);
385  return PolyPatBlt(hDc,rop,p,4,0);
386 }
GLint GLint GLsizei width
Definition: gl.h:1546
#define PATINVERT
Definition: wingdi.h:327
BOOL WINAPI PolyPatBlt(HDC, DWORD, PPATRECT, INT, ULONG)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static int rop(int rop, int src, int dst)
Definition: nanoxwin.c:124
smooth NULL
Definition: ftsmooth.c:416
VOID CreateFrameBrushes(VOID)
Definition: paint.c:52
unsigned long DWORD
Definition: ntddk_ex.h:95
static HBRUSH FrameBrushes[13]
Definition: paint.c:32
const BYTE MappingTable[33]
Definition: paint.c:329
#define PATCOPY
Definition: wingdi.h:334
unsigned width
Definition: paint.c:495
GLfloat GLfloat p
Definition: glext.h:8902

◆ GetUpdateRect()

BOOL WINAPI GetUpdateRect ( HWND  Wnd,
LPRECT  Rect,
BOOL  Erase 
)

Definition at line 96 of file paint.c.

100 {
101  PWND pWnd;
102 
103  pWnd = ValidateHwnd(Wnd);
104  if (!pWnd)
105  return FALSE;
106 
107  if ( pWnd->hrgnUpdate ||
109  {
110  return NtUserGetUpdateRect(Wnd, Rect, Erase);
111  }
112 
113  if (Rect)
114  { // Did the Rgn update? No! Back set and shutup!
115  Rect->left = Rect->right = Rect->top = Rect->bottom = 0;
116  }
117  return FALSE; // msdn: "If there is no update region, the return value is zero."
118 
119 }
#define WNDS_SENDNCPAINT
Definition: ntuser.h:584
#define WNDS_PAINTNOTPROCESSED
Definition: ntuser.h:595
void Erase(HDC hdc, LONG x1, LONG y1, LONG x2, LONG y2, COLORREF color, LONG radius)
Definition: drawing.cpp:117
HRGN hrgnUpdate
Definition: ntuser.h:685
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
Definition: ntuser.h:657
DWORD state
Definition: ntuser.h:665
#define WNDS_SENDERASEBACKGROUND
Definition: ntuser.h:582
#define WNDS_UPDATEDIRTY
Definition: ntuser.h:586
BOOL NTAPI NtUserGetUpdateRect(HWND hWnd, LPRECT lpRect, BOOL fErase)
Definition: painting.c:1946

◆ GetUpdateRgn()

int WINAPI GetUpdateRgn ( HWND  hWnd,
HRGN  hRgn,
BOOL  bErase 
)

Definition at line 127 of file paint.c.

131 {
132  PWND pWnd;
133 
134  if (!hRgn)
135  {
137  return ERROR;
138  }
139 
140  pWnd = ValidateHwnd(hWnd);
141  if (!pWnd)
142  return ERROR;
143 
144  if ( pWnd->hrgnUpdate ||
146  {
147  return NtUserGetUpdateRgn(hWnd, hRgn, bErase);
148  }
149  SetRectRgn(hRgn, 0, 0, 0, 0);
150  return NULLREGION;
151 }
#define ERROR(name)
Definition: error_private.h:53
#define WNDS_SENDNCPAINT
Definition: ntuser.h:584
#define ERROR_INVALID_HANDLE
Definition: compat.h:88
HWND hWnd
Definition: settings.c:17
#define NULLREGION
Definition: wingdi.h:360
static HRGN hRgn
Definition: mapping.c:33
#define WNDS_PAINTNOTPROCESSED
Definition: ntuser.h:595
BOOL WINAPI SetRectRgn(_In_ HRGN, _In_ int, _In_ int, _In_ int, _In_ int)
HRGN hrgnUpdate
Definition: ntuser.h:685
#define SetLastError(x)
Definition: compat.h:417
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
Definition: ntuser.h:657
DWORD state
Definition: ntuser.h:665
#define WNDS_SENDERASEBACKGROUND
Definition: ntuser.h:582
#define WNDS_UPDATEDIRTY
Definition: ntuser.h:586
INT NTAPI NtUserGetUpdateRgn(HWND hWnd, HRGN hRgn, BOOL bErase)
Definition: painting.c:1914

◆ GetWindowRgn()

int WINAPI GetWindowRgn ( HWND  hWnd,
HRGN  hRgn 
)

Definition at line 265 of file paint.c.

268 {
269  PWND pWnd;
270  int Ret;
271 
272  if (!hRgn)
273  return ERROR;
274 
275  pWnd = ValidateHwnd(hWnd);
276 
277  if (!pWnd || !pWnd->hrgnClip || pWnd->state2 & WNDS2_MAXIMIZEDMONITORREGION)
278  return ERROR;
279 
280  Ret = CombineRgn(hRgn, pWnd->hrgnClip, NULL, RGN_COPY);
281 
282  if (!Ret)
283  return ERROR;
284 /*
285  if (hWnd != GetDesktopWindow()) // pWnd->fnid != FNID_DESKTOP)
286  Ret = OffsetRgn(hRgn, -pWnd->rcWindow.left, -pWnd->rcWindow.top);
287 */
288  if (pWnd->ExStyle & WS_EX_LAYOUTRTL)
289  MirrorRgn(hWnd, hRgn);
290 
291  return Ret;
292 }
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
DWORD ExStyle
Definition: ntuser.h:668
#define ERROR(name)
Definition: error_private.h:53
HWND hWnd
Definition: settings.c:17
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
static HRGN hRgn
Definition: mapping.c:33
#define WNDS2_MAXIMIZEDMONITORREGION
Definition: ntuser.h:620
smooth NULL
Definition: ftsmooth.c:416
HRGN hrgnClip
Definition: ntuser.h:697
BOOL WINAPI MirrorRgn(HWND hwnd, HRGN hrgn)
Definition: region.c:862
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
#define RGN_COPY
Definition: wingdi.h:356
Definition: ntuser.h:657
DWORD state2
Definition: ntuser.h:666

◆ GetWindowRgnBox()

int WINAPI GetWindowRgnBox ( HWND  hWnd,
LPRECT  lprc 
)

Definition at line 299 of file paint.c.

302 {
303  PWND pWnd;
304  int Ret;
305 
306  if (!lprc)
307  return ERROR;
308 
309  pWnd = ValidateHwnd(hWnd);
310 
311  if (!pWnd || !pWnd->hrgnClip || pWnd->state2 & WNDS2_MAXIMIZEDMONITORREGION)
312  return ERROR;
313 
314  Ret = GetRgnBox(pWnd->hrgnClip, lprc);
315 
316  if (!Ret)
317  return ERROR;
318 /*
319  if (hWnd != GetDesktopWindow()) // pWnd->fnid != FNID_DESKTOP)
320  OffsetRect(lprc, -pWnd->rcWindow.left, -pWnd->rcWindow.top);
321 */
322  if (pWnd->ExStyle & WS_EX_LAYOUTRTL)
323  MirrorWindowRect(pWnd, lprc);
324 
325  return Ret;
326 }
DWORD ExStyle
Definition: ntuser.h:668
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4366
#define ERROR(name)
Definition: error_private.h:53
HWND hWnd
Definition: settings.c:17
#define WS_EX_LAYOUTRTL
Definition: winuser.h:390
#define WNDS2_MAXIMIZEDMONITORREGION
Definition: ntuser.h:620
HRGN hrgnClip
Definition: ntuser.h:697
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
int WINAPI GetRgnBox(_In_ HRGN, _Out_ LPRECT)
Definition: ntuser.h:657
DWORD state2
Definition: ntuser.h:666
INT WINAPI MirrorWindowRect(PWND pWnd, LPRECT lprc)
Definition: paint.c:43

Referenced by init_function_pointers().

◆ MirrorRgn()

BOOL WINAPI MirrorRgn ( HWND  hwnd,
HRGN  hrgn 
)

Definition at line 862 of file region.c.

863 {
864  INT l;
865  RECT Rect;
867  l = Rect.right - Rect.left;
868  Rect.right -= Rect.left;
869  return MirrorRgnByWidth(hrgn, l, NULL);
870 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
int32_t INT
Definition: typedefs.h:56
INT FASTCALL MirrorRgnByWidth(_In_ HRGN hrgn, _In_ INT Width, _In_ HRGN *phrgn)
Definition: region.c:87
smooth NULL
Definition: ftsmooth.c:416
r l[0]
Definition: byte_order.h:167
static HRGN hrgn
Definition: win.c:55
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
struct Rect Rect

Referenced by GetWindowRgn().

◆ MirrorWindowRect()

INT WINAPI MirrorWindowRect ( PWND  pWnd,
LPRECT  lprc 
)

Definition at line 43 of file paint.c.

44 {
45  INT Ret = pWnd->rcWindow.right - pWnd->rcWindow.left - lprc->left;
46  lprc->left = pWnd->rcWindow.right - pWnd->rcWindow.left - lprc->right;
47  lprc->right = Ret;
48  return Ret;
49 }
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4366
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
int32_t INT
Definition: typedefs.h:56
RECT rcWindow
Definition: ntuser.h:680

Referenced by GetWindowRgnBox().

◆ PolyPatBlt()

BOOL WINAPI PolyPatBlt ( HDC  ,
DWORD  ,
PPATRECT  ,
INT  ,
ULONG   
)

Referenced by DrawFrame().

◆ ScrollDC()

BOOL WINAPI ScrollDC ( HDC  hDC,
int  dx,
int  dy,
CONST RECT lprcScroll,
CONST RECT lprcClip,
HRGN  hrgnUpdate,
LPRECT  lprcUpdate 
)

Definition at line 158 of file paint.c.

166 {
167  if (hDC == NULL) return FALSE;
168 
169  if (dx == 0 && dy == 0)
170  {
171  if (hrgnUpdate) SetRectRgn(hrgnUpdate, 0, 0, 0, 0);
172  if (lprcUpdate) lprcUpdate->left = lprcUpdate->right =
173  lprcUpdate->top = lprcUpdate->bottom = 0;
174  return TRUE;
175  }
176 
177  return NtUserScrollDC( hDC,
178  dx,
179  dy,
180  lprcScroll,
181  lprcClip,
182  hrgnUpdate,
183  lprcUpdate);
184 }
#define TRUE
Definition: types.h:120
BOOL NTAPI NtUserScrollDC(HDC hDC, int dx, int dy, CONST RECT *lprcScroll, CONST RECT *lprcClip, HRGN hrgnUpdate, LPRECT lprcUpdate)
GLint dy
Definition: linetemp.h:97
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
LONG right
Definition: windef.h:293
smooth NULL
Definition: ftsmooth.c:416
BOOL WINAPI SetRectRgn(_In_ HRGN, _In_ int, _In_ int, _In_ int, _In_ int)
static HDC hDC
Definition: 3dtext.c:33
GLint dx
Definition: linetemp.h:97
LONG bottom
Definition: windef.h:294

◆ SetWindowRgn()

int WINAPI SetWindowRgn ( HWND  hWnd,
HRGN  hRgn,
BOOL  bRedraw 
)

Definition at line 191 of file paint.c.

195 {
196  BOOL Hook;
197  int Ret = 0;
198 
199  LoadUserApiHook();
200 
201  Hook = BeginIfHookedUserApiHook();
202 
203  /* Bypass SEH and go direct. */
204  if (!Hook)
205  {
206  Ret = NtUserSetWindowRgn(hWnd, hRgn, bRedraw);
207  if (Ret)
209  return Ret;
210  }
211 
212  _SEH2_TRY
213  {
214  Ret = guah.SetWindowRgn(hWnd, hRgn, bRedraw);
215  }
217  {
218  }
219  _SEH2_END;
220 
221  EndUserApiHook();
222 
223  return Ret;
224 }
BOOL FASTCALL EndUserApiHook(VOID)
Definition: usrapihk.c:164
USERAPIHOOK guah
Definition: usrapihk.c:344
HWND hWnd
Definition: settings.c:17
static HRGN hRgn
Definition: mapping.c:33
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
_SEH2_TRY
Definition: create.c:4250
SETWINDOWRGN SetWindowRgn
Definition: undocuser.h:338
unsigned int BOOL
Definition: ntddk_ex.h:94
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
_SEH2_END
Definition: create.c:4424
static __inline void LoadUserApiHook()
Definition: user_x.h:85
BOOL FASTCALL BeginIfHookedUserApiHook(VOID)
Definition: usrapihk.c:106
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
INT NTAPI NtUserSetWindowRgn(HWND hWnd, HRGN hRgn, BOOL bRedraw)
Definition: winpos.c:3469

◆ UpdateWindow()

BOOL WINAPI UpdateWindow ( HWND  hWnd)

Definition at line 231 of file paint.c.

233 {
234  PWND pWnd = ValidateHwnd(hWnd);
235 
236  if (!pWnd)
237  return FALSE;
238 
239  if ( pWnd->hrgnUpdate ||
240  pWnd->state & WNDS_INTERNALPAINT ||
241  pWnd->spwndChild )
242  {
243  return NtUserxUpdateWindow(hWnd);
244  }
245  return TRUE;
246 }
#define TRUE
Definition: types.h:120
HWND hWnd
Definition: settings.c:17
EXTINLINE BOOL NtUserxUpdateWindow(HWND hWnd)
Definition: ntwrapper.h:773
HRGN hrgnUpdate
Definition: ntuser.h:685
PWND FASTCALL ValidateHwnd(HWND hwnd)
Definition: misc.c:369
Definition: ntuser.h:657
DWORD state
Definition: ntuser.h:665
#define WNDS_INTERNALPAINT
Definition: ntuser.h:585
struct _WND * spwndChild
Definition: ntuser.h:678

◆ ValidateRgn()

BOOL WINAPI ValidateRgn ( HWND  hWnd,
HRGN  hRgn 
)

Definition at line 253 of file paint.c.

256 {
257  return NtUserxValidateRgn(hWnd, hRgn);
258 }
HWND hWnd
Definition: settings.c:17
static HRGN hRgn
Definition: mapping.c:33
EXTINLINE BOOL NtUserxValidateRgn(HWND hWnd, HRGN hRgn)
Definition: ntwrapper.h:671

Variable Documentation

◆ FrameBrushes

HBRUSH FrameBrushes[13]
static

Definition at line 32 of file paint.c.

Referenced by CreateFrameBrushes(), DeleteFrameBrushes(), and DrawFrame().

◆ HatchBitmap

const DWORD HatchBitmap[4] = {0x5555AAAA, 0x5555AAAA, 0x5555AAAA, 0x5555AAAA}

Definition at line 34 of file paint.c.

Referenced by CreateFrameBrushes().

◆ hHatch

HBITMAP hHatch
static

Definition at line 33 of file paint.c.

Referenced by CreateFrameBrushes(), and DeleteFrameBrushes().

◆ MappingTable

const BYTE MappingTable[33] = {5,9,2,3,5,7,0,0,0,7,5,5,3,2,7,5,3,3,0,5,7,10,5,0,11,4,1,1,3,8,6,12,7}

Definition at line 329 of file paint.c.

Referenced by DrawFrame().