ReactOS 0.4.15-dev-6068-g8061a6f
sizebox.cpp File Reference
#include "precomp.h"
Include dependency graph for sizebox.cpp:

Go to the source code of this file.

Functions

BOOL setCursorOnSizeBox (CANVAS_HITTEST hit)
 
BOOL getSizeBoxRect (LPRECT prc, CANVAS_HITTEST hit, LPCRECT prcBase)
 
CANVAS_HITTEST getSizeBoxHitTest (POINT pt, LPCRECT prcBase)
 
VOID drawSizeBoxes (HDC hdc, LPCRECT prcBase, BOOL bDrawFrame, LPCRECT prcPaint)
 

Variables

static LPCWSTR s_cursor_shapes []
 

Function Documentation

◆ drawSizeBoxes()

VOID drawSizeBoxes ( HDC  hdc,
LPCRECT  prcBase,
BOOL  bDrawFrame,
LPCRECT  prcPaint 
)

Definition at line 104 of file sizebox.cpp.

105{
106 CRect rc, rcIntersect;
107
108 if (prcPaint && !::IntersectRect(&rcIntersect, prcPaint, prcBase))
109 return;
110
111 if (bDrawFrame)
112 {
113 rc = *prcBase;
114 ::InflateRect(&rc, -GRIP_SIZE / 2, -GRIP_SIZE / 2);
115
116 LOGBRUSH logBrush = { BS_HOLLOW, 0, 0 };
117 COLORREF rgbHighlight = ::GetSysColor(COLOR_HIGHLIGHT);
118 HGDIOBJ oldPen = ::SelectObject(hdc, ::CreatePen(PS_DOT, 1, rgbHighlight));
119 HGDIOBJ oldBrush = ::SelectObject(hdc, ::CreateBrushIndirect(&logBrush));
120 ::Rectangle(hdc, rc.left, rc.top, rc.right, rc.bottom);
123 }
124
125 for (INT i = HIT_UPPER_LEFT; i <= HIT_LOWER_RIGHT; ++i)
126 {
127 getSizeBoxRect(&rc, (CANVAS_HITTEST)i, prcBase);
128 if (!prcPaint || ::IntersectRect(&rcIntersect, &rc, prcPaint))
129 ::FillRect(hdc, &rc, (HBRUSH)(COLOR_HIGHLIGHT + 1));
130 }
131}
CANVAS_HITTEST
Definition: common.h:41
@ HIT_LOWER_RIGHT
Definition: common.h:50
@ HIT_UPPER_LEFT
Definition: common.h:43
#define GRIP_SIZE
Definition: common.h:13
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
BOOL getSizeBoxRect(LPRECT prc, CANVAS_HITTEST hit, LPCRECT prcBase)
Definition: sizebox.cpp:31
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 COLOR_HIGHLIGHT
Definition: winuser.h:920
BOOL WINAPI IntersectRect(_Out_ LPRECT, _In_ LPCRECT, _In_ LPCRECT)
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)

Referenced by CCanvasWindow::DoDraw(), and CTextEditWindow::DrawGrip().

◆ getSizeBoxHitTest()

CANVAS_HITTEST getSizeBoxHitTest ( POINT  pt,
LPCRECT  prcBase 
)

Definition at line 81 of file sizebox.cpp.

82{
83 RECT rc;
84
85 if (!::PtInRect(prcBase, pt))
86 return HIT_NONE;
87
88 rc = *prcBase;
90 if (::PtInRect(&rc, pt))
91 return HIT_INNER;
92
93 for (INT i = HIT_UPPER_LEFT; i <= HIT_LOWER_RIGHT; ++i)
94 {
96 getSizeBoxRect(&rc, hit, prcBase);
97 if (::PtInRect(&rc, pt))
98 return hit;
99 }
100
101 return HIT_BORDER;
102}
@ HIT_NONE
Definition: common.h:42
@ HIT_BORDER
Definition: common.h:51
@ HIT_INNER
Definition: common.h:52
#define pt(x, y)
Definition: drawing.c:79
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)

Referenced by CCanvasWindow::CanvasHitTest(), CTextEditWindow::DoHitTest(), and CCanvasWindow::SelectionHitTest().

◆ getSizeBoxRect()

BOOL getSizeBoxRect ( LPRECT  prc,
CANVAS_HITTEST  hit,
LPCRECT  prcBase 
)

Definition at line 31 of file sizebox.cpp.

32{
33 switch (hit)
34 {
35 case HIT_UPPER_LEFT:
36 prc->left = prcBase->left;
37 prc->top = prcBase->top;
38 break;
40 prc->left = (prcBase->left + prcBase->right - GRIP_SIZE) / 2;
41 prc->top = prcBase->top;
42 break;
43 case HIT_UPPER_RIGHT:
44 prc->left = prcBase->right - GRIP_SIZE;
45 prc->top = prcBase->top;
46 break;
47 case HIT_MIDDLE_LEFT:
48 prc->left = prcBase->left;
49 prc->top = (prcBase->top + prcBase->bottom - GRIP_SIZE) / 2;
50 break;
52 prc->left = prcBase->right - GRIP_SIZE;
53 prc->top = (prcBase->top + prcBase->bottom - GRIP_SIZE) / 2;
54 break;
55 case HIT_LOWER_LEFT:
56 prc->left = prcBase->left;
57 prc->top = prcBase->bottom - GRIP_SIZE;
58 break;
60 prc->left = (prcBase->left + prcBase->right - GRIP_SIZE) / 2;
61 prc->top = prcBase->bottom - GRIP_SIZE;
62 break;
63 case HIT_LOWER_RIGHT:
64 prc->left = prcBase->right - GRIP_SIZE;
65 prc->top = prcBase->bottom - GRIP_SIZE;
66 break;
67 case HIT_INNER:
68 *prc = *prcBase;
70 return TRUE;
71 default:
73 return FALSE;
74 }
75
78 return TRUE;
79}
@ HIT_LOWER_CENTER
Definition: common.h:49
@ HIT_LOWER_LEFT
Definition: common.h:48
@ HIT_UPPER_CENTER
Definition: common.h:44
@ HIT_UPPER_RIGHT
Definition: common.h:45
@ HIT_MIDDLE_RIGHT
Definition: common.h:47
@ HIT_MIDDLE_LEFT
Definition: common.h:46
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
_Out_ LPRECT prc
Definition: ntgdi.h:1658
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)

Referenced by drawSizeBoxes(), and getSizeBoxHitTest().

◆ setCursorOnSizeBox()

BOOL setCursorOnSizeBox ( CANVAS_HITTEST  hit)

Definition at line 21 of file sizebox.cpp.

22{
23 if (HIT_UPPER_LEFT <= hit && hit <= HIT_LOWER_RIGHT)
24 {
26 return TRUE;
27 }
28 return FALSE;
29}
#define NULL
Definition: types.h:112
static LPCWSTR s_cursor_shapes[]
Definition: sizebox.cpp:12
HCURSOR WINAPI SetCursor(_In_opt_ HCURSOR)
#define LoadCursor
Definition: winuser.h:5802

Referenced by CCanvasWindow::OnSetCursor().

Variable Documentation

◆ s_cursor_shapes

LPCWSTR s_cursor_shapes[]
static
Initial value:
=
{
}
#define IDC_SIZENESW
Definition: winuser.h:688
#define IDC_SIZENWSE
Definition: winuser.h:687
#define IDC_SIZENS
Definition: winuser.h:690
#define IDC_SIZEWE
Definition: winuser.h:689

Definition at line 12 of file sizebox.cpp.

Referenced by setCursorOnSizeBox().