34#error OPAQUE should not be defined!?
62 { offsetof(
RECT,
left), offsetof(
RECT,
top), 0, 0, 0, 0, 1, 3 },
63 { offsetof(
RECT,
right), offsetof(
RECT,
top), 0, 0, -1, 0, 0, 2 },
64 { offsetof(
RECT,
right), offsetof(
RECT,
bottom), 0, 0, -1, -1, 3, 1 },
65 { offsetof(
RECT,
left), offsetof(
RECT,
bottom), 0, 0, 0, -1, 2, 0 },
68 { offsetof(
RECT,
left), offsetof(
RECT,
top), 1, 0, 0, 0, 4, 6 },
69 { offsetof(
RECT,
right), offsetof(
RECT,
top), 0, 1, -1, 0, 7, 5 },
70 { offsetof(
RECT,
left), offsetof(
RECT,
bottom), 1, 0, 0, -1, 6, 4 },
101 for (
int i = 0;
i < 8;
i++)
102 grayPattern[
i] =
static_cast<WORD>(0x5555 << (
i & 1));
103 HBITMAP grayBitmap = CreateBitmap(8, 8, 1, 1, &grayPattern);
104 if (grayBitmap !=
nullptr)
107 DeleteObject(grayBitmap);
115 HDC hDC,LPRECT lpRect,SIZE size,
116 LPRECT lpRectLast,SIZE sizeLast,
117 HBRUSH hBrush =
nullptr,HBRUSH hBrushLast =
nullptr)
121 HRGN rgnOutside,rgnInside;
122 rgnOutside = CreateRectRgnIndirect(lpRect);
124 InflateRect(&rect,-
size.cx, -
size.cy);
125 IntersectRect(&rect,&rect,lpRect);
126 rgnInside = CreateRectRgnIndirect(&rect);
127 rgnNew = CreateRectRgn(0, 0, 0, 0);
128 CombineRgn(rgnNew,rgnOutside,rgnInside,
RGN_XOR);
130 HBRUSH hBrushOld =
nullptr;
131 if (hBrush ==
nullptr)
133 if (hBrushLast ==
nullptr)
136 HRGN rgnLast(
nullptr);
137 HRGN rgnUpdate(
nullptr);
138 if (lpRectLast !=
nullptr)
141 rgnLast = CreateRectRgn(0, 0, 0, 0);
149 InflateRect(&rect,-sizeLast.cx, -sizeLast.cy);
150 IntersectRect(&rect,&rect, lpRectLast);
151 SetRectRgn(rgnInside,rect.left,rect.top,rect.right,rect.bottom);
152 CombineRgn(rgnLast,rgnOutside,rgnInside,
RGN_XOR);
155 if (hBrush == hBrushLast)
157 rgnUpdate = CreateRectRgn(0, 0, 0, 0);
158 CombineRgn(rgnUpdate,rgnLast,rgnNew,
RGN_XOR);
161 if (hBrush != hBrushLast && lpRectLast !=
nullptr)
164 SelectClipRgn(hDC,rgnLast);
165 GetClipBox(hDC,&rect);
166 hBrushOld =
static_cast<HBRUSH
>(SelectObject(hDC,
static_cast<HGDIOBJ
>(hBrushLast)));
167 PatBlt(hDC,rect.left,rect.top,(rect.right-rect.left),(rect.bottom-rect.top),
PATINVERT);
169 SelectObject(hDC,
static_cast<HGDIOBJ
>(hBrushOld));
174 SelectClipRgn(hDC,rgnUpdate);
176 GetClipBox(hDC,&rect);
177 hBrushOld =
static_cast<HBRUSH
>(SelectObject(hDC,
static_cast<HGDIOBJ
>(hBrush)));
178 PatBlt(hDC,rect.left, rect.top,(rect.right-rect.left),(rect.bottom-rect.top),
PATINVERT);
181 if (hBrushOld !=
nullptr)
182 SelectObject(hDC,
static_cast<HGDIOBJ
>(hBrushOld));
183 SelectClipRgn(hDC,
nullptr);
190 pt.x = rect->left;
pt.y = rect->top;
191 ClientToScreen(pWnd,&
pt);
192 ScreenToClient(pWndClipTo,&
pt);
193 rect->left =
pt.x; rect->top =
pt.y;
195 pt.x = rect->right;
pt.y = rect->bottom;
196 ClientToScreen(pWnd,&
pt);
197 ScreenToClient(pWndClipTo,&
pt);
198 rect->right =
pt.x; rect->bottom =
pt.y;
204 if(rp->left > rp->right) {
206 rp->left = rp->right;
210 if(rp->top > rp->bottom) {
212 rp->top = rp->bottom;
229 CopyRect(&
m_rect,lpSrcRect);
240 static bool bInitialized =
false;
246 WORD hatchPattern[8];
247 WORD wPattern = 0x1111;
248 for (
int i = 0;
i < 4;
i++)
250 hatchPattern[
i] = wPattern;
251 hatchPattern[
i+4] = wPattern;
254 HBITMAP hatchBitmap = CreateBitmap(8, 8, 1, 1,&hatchPattern);
258 DeleteObject(hatchBitmap);
268 static const WCHAR szWindows[] = L
"windows";
269 static const WCHAR szInplaceBorderWidth[] = L
"oleinplaceborderwidth";
270 afxHandleSize = GetProfileIntW(szWindows, szInplaceBorderWidth, 4);
277 afxCursors[8] = LoadCursor(
nullptr,IDC_SIZEALL);
302 if (PtInRect(&rectTrue,
point))
316 if (nHitTest != HTCLIENT)
321 GetCursorPos(&
point);
322 ScreenToClient(pWnd,&
point);
367 if (GetCapture() !=
nullptr)
377 if (hWndClipTo !=
nullptr)
378 UpdateWindow(hWndClipTo);
385 xDiff =
point.x - xDiff;
386 yDiff =
point.y - yDiff;
390 if (hWndClipTo !=
nullptr)
393 hDrawDC = GetDCEx(hWndClipTo,
nullptr, DCX_CACHE);
398 hDrawDC =
GetDC(hWnd);
408 int const bRet = GetMessageW(&msg,
nullptr, 0, 0);
409 SAL_WARN_IF(-1 == bRet,
"embedserv",
"GetMessageW failed: " << WindowsErrorString(GetLastError()));
410 if (-1 == bRet || 0 == bRet)
413 if (GetCapture() != hWnd)
424 *
px =
static_cast<int>(
static_cast<short>(LOWORD(msg.lParam))) - xDiff;
426 *py =
static_cast<int>(
static_cast<short>(HIWORD(msg.lParam))) - yDiff;
447 if (msg.message != WM_LBUTTONUP)
453 if (!EqualRect(&rectOld,&
m_rect))
462 if (msg.wParam != VK_ESCAPE)
476 DispatchMessageW(&msg);
482 if (hWndClipTo !=
nullptr)
483 ReleaseDC(hWndClipTo,hDrawDC);
485 ReleaseDC(hWnd,hDrawDC);
495 return !EqualRect(&rectSave,&
m_rect);
518 nNewWidth = nAbsWidth != 0 ? nNewWidth / nAbsWidth : 1;
519 const AFX_RECTINFO* pRectInfo =
521 *
px = *
reinterpret_cast<int*
>(
reinterpret_cast<BYTE*
>(&
m_rect) + pRectInfo->nOffsetAcross) +
522 nNewWidth *
m_sizeMin.cx * -pRectInfo->nSignAcross;
528 if (py !=
nullptr && nAbsHeight <
m_sizeMin.cy)
530 nNewHeight = nAbsHeight != 0 ? nNewHeight / nAbsHeight : 1;
531 const AFX_RECTINFO* pRectInfo =
533 *py = *
reinterpret_cast<int*
>(
reinterpret_cast<BYTE*
>(&
m_rect) + pRectInfo->nOffsetAcross) +
534 nNewHeight *
m_sizeMin.cy * -pRectInfo->nSignAcross;
540 LPRECT lpRect,HWND pWndClipTo,HDC pDC,HWND pWnd)
547 if (pWndClipTo !=
nullptr)
581 SetViewportOrgEx(hDC,0, 0,
nullptr);
582 SetWindowOrgEx(hDC,0, 0,
nullptr);
588 HPEN pOldPen =
nullptr;
589 HBRUSH pOldBrush =
nullptr;
599 pOldPen =
static_cast<HPEN
>(SelectObject(hDC,
reinterpret_cast<HGDIOBJ
>(
BLACK_PEN)));
600 pOldBrush =
static_cast<HBRUSH
>(SelectObject(hDC,
reinterpret_cast<HGDIOBJ
>(
NULL_BRUSH)));
601 nOldROP = SetROP2(hDC,R2_COPYPEN);
602 InflateRect(&rect,+1, +1);
603 Rectangle(hDC,rect.left, rect.top, rect.right, rect.bottom);
604 SetROP2(hDC,nOldROP);
614 pTemp = SelectObject(hDC,
reinterpret_cast<HGDIOBJ
>(
NULL_PEN));
615 if (pOldPen ==
nullptr)
616 pOldPen =
static_cast<HPEN
>(pTemp);
617 pTemp = SelectObject(hDC,
static_cast<HGDIOBJ
>(
afxHatchBrush));
618 if (pOldBrush ==
nullptr)
619 pOldBrush =
static_cast<HBRUSH
>(pTemp);
620 SetBkMode(hDC,TRANSPARENT);
621 nOldROP = SetROP2(hDC,R2_MASKNOTPEN);
622 Rectangle(hDC,rect.left+1, rect.top+1, rect.right, rect.bottom);
623 SetROP2(hDC,nOldROP);
629 pTemp = SelectObject(hDC,
static_cast<HGDIOBJ
>(
afxHatchBrush));
630 if (pOldBrush ==
nullptr)
631 pOldBrush =
static_cast<HBRUSH
>(pTemp);
635 PatBlt(hDC,rectTrue.left, rectTrue.top, rectTrue.right-rectTrue.left,
636 rect.top-rectTrue.top, 0x000F0001 );
637 PatBlt(hDC,rectTrue.left, rect.bottom,
638 rectTrue.right-rectTrue.left,
639 rectTrue.bottom-rect.bottom, 0x000F0001 );
640 PatBlt(hDC,rectTrue.left, rect.top, rect.left-rectTrue.left,
641 rect.bottom-rect.top, 0x000F0001 );
642 PatBlt(hDC,rect.right, rect.top, rectTrue.right-rect.right,
643 rect.bottom-rect.top, 0x000F0001 );
650 HBRUSH hbrush = CreateSolidBrush(
RGB(0,0,0));
651 for (
int i = 0;
i < 8; ++
i)
657 FillRect(hDC,&rect,hbrush);
660 DeleteObject(hbrush);
664 if (pOldPen !=
nullptr)
665 SelectObject(hDC,pOldPen);
666 if (pOldBrush !=
nullptr)
667 SelectObject(hDC,pOldBrush);
678 InflateRect(&rectT,+1, +1);
690 int nWidth = rectT.right - rectT.left;
691 int nHeight = rectT.bottom - rectT.top;
694 rect.left = *
reinterpret_cast<int*
>(
reinterpret_cast<BYTE*
>(&rectT) + pHandleInfo->nOffsetX);
695 rect.top = *
reinterpret_cast<int*
>(
reinterpret_cast<BYTE*
>(&rectT) + pHandleInfo->nOffsetY);
696 rect.left +=
size * pHandleInfo->nHandleX;
697 rect.top +=
size * pHandleInfo->nHandleY;
698 rect.left += pHandleInfo->nCenterX * (nWidth -
size) / 2;
699 rect.top += pHandleInfo->nCenterY * (nHeight -
size) / 2;
700 rect.right = rect.left +
size;
701 rect.bottom = rect.top +
size;
709 LPCRECT rect = lpRect ==
nullptr ? &
m_rect : lpRect;
715 int sizeMax = std::min(
abs(rect->right - rect->left),
716 abs(rect->bottom - rect->top));
717 if (
size * 2 > sizeMax)
745 InflateRect(&rect,nInflateBy, nInflateBy);
773 if (!PtInRect(&rect,
point))
777 for (
int i = 0;
i < 8; ++
i)
782 if (PtInRect(&rect,
point))
793 InflateRect(&rect,+1, +1);
794 if (!PtInRect(&rect,
point))
802 int nHandle,
int** ppx,
int** ppy,
int* px,
int* py)
815 if (pHandleInfo->nInvertX !=
nHandle)
817 *ppx =
reinterpret_cast<int*
>(
reinterpret_cast<BYTE*
>(&
m_rect) + pHandleInfo->nOffsetX);
827 if (pHandleInfo->nInvertY !=
nHandle)
829 *ppy =
reinterpret_cast<int*
>(
reinterpret_cast<BYTE*
>(&
m_rect) + pHandleInfo->nOffsetY);
BOOL SetCursor(HWND hWnd, UINT nHitTest) const
void GetTrueRect(LPRECT lpTrueRect) const
virtual void DrawTrackerRect(LPRECT lpRect, HWND hWndClipTo, HDC hDC, HWND hWnd)
virtual UINT GetHandleMask() const
void GetModifyPointers(int nHandle, int **ppx, int **ppy, int *px, int *py)
int NormalizeHit(int nHandle) const
BOOL Track(HWND hWnd, POINT point, BOOL bAllowInvert=FALSE, HWND hWndClipTo=nullptr)
int HitTest(POINT point) const
BOOL TrackHandle(int nHandle, HWND hWnd, POINT point, HWND hWndClipTo)
void GetHandleRect(int nHandle, RECT *pHandleRect) const
virtual void AdjustRect(int nHandle, LPRECT lpRect)
int HitTestHandles(POINT point) const
virtual int GetHandleSize(LPRECT lpRect=nullptr) const
virtual void OnChangedRect(const RECT &rectOld)
#define SAL_WARN_IF(condition, area, stream)
constexpr tools::Long SIZE
void TransformRect(LPRECT rect, HWND pWnd, HWND pWndClipTo)
SwNodeOffset abs(const SwNodeOffset &a)
const wchar_t *typedef BOOL
static void DrawDragRect(HDC hDC, LPRECT lpRect, SIZE size, LPRECT lpRectLast, SIZE sizeLast, HBRUSH hBrush=nullptr, HBRUSH hBrushLast=nullptr)
static HBRUSH HalftoneBrush()
static HPEN afxBlackDottedPen
static void NormalizeRect(LPRECT rp)
static HCURSOR afxCursors[10]
const AFX_HANDLEINFO afxHandleInfo[]
const AFX_RECTINFO afxRectInfo[]
static HBRUSH afxHatchBrush
static HBRUSH afxHalftoneBrush