ReactOS 0.4.15-dev-7907-g95bf896
sizebox.cpp
Go to the documentation of this file.
1/*
2 * PROJECT: PAINT for ReactOS
3 * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4 * PURPOSE: Window procedure of the size boxes
5 * COPYRIGHT: Copyright 2015 Benedikt Freisen <b.freisen@gmx.net>
6 * Copyright 2017 Katayama Hirofumi MZ <katayama.hirofumi.mz@gmail.com>
7 */
8
9#include "precomp.h"
10
12{
16};
17
18/* FUNCTIONS ********************************************************/
19
21{
22 if (HIT_UPPER_LEFT <= hit && hit <= HIT_LOWER_RIGHT)
23 {
25 return TRUE;
26 }
27 return FALSE;
28}
29
31{
32 switch (hit)
33 {
34 case HIT_UPPER_LEFT:
35 prc->left = prcBase->left;
36 prc->top = prcBase->top;
37 break;
39 prc->left = (prcBase->left + prcBase->right - GRIP_SIZE) / 2;
40 prc->top = prcBase->top;
41 break;
42 case HIT_UPPER_RIGHT:
43 prc->left = prcBase->right - GRIP_SIZE;
44 prc->top = prcBase->top;
45 break;
46 case HIT_MIDDLE_LEFT:
47 prc->left = prcBase->left;
48 prc->top = (prcBase->top + prcBase->bottom - GRIP_SIZE) / 2;
49 break;
51 prc->left = prcBase->right - GRIP_SIZE;
52 prc->top = (prcBase->top + prcBase->bottom - GRIP_SIZE) / 2;
53 break;
54 case HIT_LOWER_LEFT:
55 prc->left = prcBase->left;
56 prc->top = prcBase->bottom - GRIP_SIZE;
57 break;
59 prc->left = (prcBase->left + prcBase->right - GRIP_SIZE) / 2;
60 prc->top = prcBase->bottom - GRIP_SIZE;
61 break;
62 case HIT_LOWER_RIGHT:
63 prc->left = prcBase->right - GRIP_SIZE;
64 prc->top = prcBase->bottom - GRIP_SIZE;
65 break;
66 case HIT_INNER:
67 *prc = *prcBase;
69 return TRUE;
70 default:
72 return FALSE;
73 }
74
77 return TRUE;
78}
79
81{
82 CRect rc;
83
84 if (!::PtInRect(prcBase, pt))
85 return HIT_NONE;
86
87 rc = *prcBase;
89 if (rc.PtInRect(pt))
90 return HIT_INNER;
91
92 for (INT i = HIT_UPPER_LEFT; i <= HIT_LOWER_RIGHT; ++i)
93 {
94 HITTEST hit = (HITTEST)i;
95 getSizeBoxRect(&rc, hit, prcBase);
96 if (rc.PtInRect(pt))
97 return hit;
98 }
99
100 return HIT_BORDER;
101}
102
103VOID drawSizeBoxes(HDC hdc, LPCRECT prcBase, BOOL bDrawFrame, LPCRECT prcPaint)
104{
105 CRect rc, rcIntersect;
106
107 if (prcPaint && !::IntersectRect(&rcIntersect, prcPaint, prcBase))
108 return;
109
110 if (bDrawFrame)
111 {
112 rc = *prcBase;
113 rc.InflateRect(-GRIP_SIZE / 2, -GRIP_SIZE / 2);
114
115 LOGBRUSH logBrush = { BS_HOLLOW, 0, 0 };
116 COLORREF rgbHighlight = ::GetSysColor(COLOR_HIGHLIGHT);
117 HGDIOBJ oldPen = ::SelectObject(hdc, ::CreatePen(PS_DOT, 1, rgbHighlight));
118 HGDIOBJ oldBrush = ::SelectObject(hdc, ::CreateBrushIndirect(&logBrush));
119 ::Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
122 }
123
124 for (INT i = HIT_UPPER_LEFT; i <= HIT_LOWER_RIGHT; ++i)
125 {
126 getSizeBoxRect(&rc, (HITTEST)i, prcBase);
127 if (!prcPaint || ::IntersectRect(&rcIntersect, &rc, prcPaint))
128 ::FillRect(hdc, &rc, (HBRUSH)(COLOR_HIGHLIGHT + 1));
129 }
130}
#define GRIP_SIZE
Definition: precomp.h:43
HITTEST
Definition: precomp.h:55
@ HIT_NONE
Definition: precomp.h:56
@ HIT_BORDER
Definition: precomp.h:65
@ HIT_LOWER_RIGHT
Definition: precomp.h:64
@ HIT_LOWER_CENTER
Definition: precomp.h:63
@ HIT_UPPER_LEFT
Definition: precomp.h:57
@ HIT_INNER
Definition: precomp.h:66
@ HIT_LOWER_LEFT
Definition: precomp.h:62
@ HIT_UPPER_CENTER
Definition: precomp.h:58
@ HIT_UPPER_RIGHT
Definition: precomp.h:59
@ HIT_MIDDLE_RIGHT
Definition: precomp.h:61
@ HIT_MIDDLE_LEFT
Definition: precomp.h:60
void InflateRect(int x, int y) noexcept
Definition: atltypes.h:323
BOOL PtInRect(POINT point) const noexcept
Definition: atltypes.h:418
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define pt(x, y)
Definition: drawing.c:79
unsigned int BOOL
Definition: ntddk_ex.h:94
pKey DeleteObject()
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
_Out_ LPRECT prc
Definition: ntgdi.h:1658
BOOL setCursorOnSizeBox(HITTEST hit)
Definition: sizebox.cpp:20
static LPCWSTR s_cursor_shapes[]
Definition: sizebox.cpp:11
VOID drawSizeBoxes(HDC hdc, LPCRECT prcBase, BOOL bDrawFrame, LPCRECT prcPaint)
Definition: sizebox.cpp:103
HITTEST getSizeBoxHitTest(POINT pt, LPCRECT prcBase)
Definition: sizebox.cpp:80
BOOL getSizeBoxRect(LPRECT prc, HITTEST hit, LPCRECT prcBase)
Definition: sizebox.cpp:30
LONG right
Definition: windef.h:308
LONG bottom
Definition: windef.h:309
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
int32_t INT
Definition: typedefs.h:58
DWORD COLORREF
Definition: windef.h:300
HBRUSH WINAPI CreateBrushIndirect(_In_ const LOGBRUSH *plb)
#define PS_DOT
Definition: wingdi.h:588
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
#define BS_HOLLOW
Definition: wingdi.h:1088
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
DWORD WINAPI GetSysColor(_In_ int)
#define IDC_SIZENESW
Definition: winuser.h:693
#define COLOR_HIGHLIGHT
Definition: winuser.h:926
#define IDC_SIZENWSE
Definition: winuser.h:692
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2105
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define IDC_SIZENS
Definition: winuser.h:695
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define IDC_SIZEWE
Definition: winuser.h:694
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185