diff --git a/modules/rostests/apitests/atl/atltest.h b/modules/rostests/apitests/atl/atltest.h index 42740868814..74a30054f1f 100644 --- a/modules/rostests/apitests/atl/atltest.h +++ b/modules/rostests/apitests/atl/atltest.h @@ -2,7 +2,7 @@ * PROJECT: ReactOS api tests * LICENSE: LGPL-2.1-or-later (https://spdx.org/licenses/LGPL-2.1-or-later) * PURPOSE: Testing - * COPYRIGHT: Copyright 2019 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com) + * COPYRIGHT: Copyright 2019-2023 Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com) */ #ifndef ATLTEST_H_ @@ -135,4 +135,44 @@ char *wine_dbgstr_w(const wchar_t *wstr) #define ok_ntstatus(status, expected) ok_hex(status, expected) #define ok_hdl ok_ptr +static inline const char *wine_dbgstr_point(const POINT *ppt) +{ + static char s_asz[4][40]; /* Ring buffer */ + static int s_i = 0; + char *buf; + + if (!ppt) + return "(null)"; + if (IS_INTRESOURCE(ppt)) + return "(invalid ptr)"; + + buf = s_asz[s_i]; + s_i = (s_i + 1) % _countof(s_asz); + sprintf_s(buf, _countof(s_asz[0]), "(%ld, %ld)", ppt->x, ppt->y); + return buf; +} + +static inline const char *wine_dbgstr_size(const SIZE *psize) +{ + return wine_dbgstr_point((const POINT *)psize); +} + +static inline const char *wine_dbgstr_rect(const RECT *prc) +{ + static char s_asz[4][80]; /* Ring buffer */ + static int s_i = 0; + char *buf; + + if (!prc) + return "(null)"; + if (IS_INTRESOURCE(prc)) + return "(invalid ptr)"; + + buf = s_asz[s_i]; + s_i = (s_i + 1) % _countof(s_asz); + sprintf_s(buf, _countof(s_asz[0]), "(%ld, %ld) - (%ld, %ld)", + prc->left, prc->top, prc->right, prc->bottom); + return buf; +} + #endif /* ndef ATLTEST_H_ */ diff --git a/modules/rostests/apitests/atl/atltypes.cpp b/modules/rostests/apitests/atl/atltypes.cpp index 08ee26bce6a..1d074e6787f 100644 --- a/modules/rostests/apitests/atl/atltypes.cpp +++ b/modules/rostests/apitests/atl/atltypes.cpp @@ -7,7 +7,11 @@ * Code based on MSDN samples regarding CPoint, CSize, CRect */ -#include +#ifdef HAVE_APITEST + #include +#else + #include "atltest.h" +#endif #include #include @@ -527,6 +531,46 @@ static void test_CRect() rect2 = rect1 - sz; rectResult = CRect(-100, -50, 200, 250); ok_rect(rectResult, rect2); + + SetRect(&rect2, 10, 20, 300, 120); + rect2.MoveToX(30); + rectResult = CRect(30, 20, 320, 120); + ok_rect(rectResult, rect2); + + SetRect(&rect2, 10, 20, 300, 120); + rect2.MoveToY(40); + rectResult = CRect(10, 40, 300, 140); + ok_rect(rectResult, rect2); + + SetRect(&rect2, 10, 20, 300, 120); + rect2.MoveToXY(30, 40); + rectResult = CRect(30, 40, 320, 140); + ok_rect(rectResult, rect2); + + SetRect(&rect2, 100, 80, -100, -50); + rectResult = CRect(-100, -50, 100, 80); + rect2.NormalizeRect(); + ok_rect(rectResult, rect2); + + rect2.SetRectEmpty(); + rectResult = CRect(0, 0, 0, 0); + ok_rect(rectResult, rect2); + + BOOL ret; + + rect1 = CRect(5, 40, 40, 120); + rect2 = CRect(10, 30, 80, 100); + ret = rect.SubtractRect(rect1, rect2); + rectResult = CRect(10, 30, 80, 100); + ok_int(ret, TRUE); + ok_rect(rectResult, rect2); + + rect1 = CRect(10, 40, 70, 110); + rect2 = CRect(8, 20, 40, 130); + ret = rect.SubtractRect(rect1, rect2); + rectResult = CRect(8, 20, 40, 130); + ok_int(ret, TRUE); + ok_rect(rect2, rectResult); } diff --git a/modules/rostests/apitests/atl/devenv/ATLTest.sln b/modules/rostests/apitests/atl/devenv/ATLTest.sln index 128101222af..68f30447443 100644 --- a/modules/rostests/apitests/atl/devenv/ATLTest.sln +++ b/modules/rostests/apitests/atl/devenv/ATLTest.sln @@ -33,6 +33,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AtlObjMap", "AtlObjMap.vcxp EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "atlconv", "atlconv.vcxproj", "{85194CA3-A828-4270-962A-333743E2BF83}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "atltypes", "atltypes.vcxproj", "{6F9D87BA-0FBD-4A0D-9B11-6363D12ADD1D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -161,6 +163,14 @@ Global {85194CA3-A828-4270-962A-333743E2BF83}.Release|x64.Build.0 = Release|x64 {85194CA3-A828-4270-962A-333743E2BF83}.Release|x86.ActiveCfg = Release|Win32 {85194CA3-A828-4270-962A-333743E2BF83}.Release|x86.Build.0 = Release|Win32 + {6F9D87BA-0FBD-4A0D-9B11-6363D12ADD1D}.Debug|x64.ActiveCfg = Debug|x64 + {6F9D87BA-0FBD-4A0D-9B11-6363D12ADD1D}.Debug|x64.Build.0 = Debug|x64 + {6F9D87BA-0FBD-4A0D-9B11-6363D12ADD1D}.Debug|x86.ActiveCfg = Debug|Win32 + {6F9D87BA-0FBD-4A0D-9B11-6363D12ADD1D}.Debug|x86.Build.0 = Debug|Win32 + {6F9D87BA-0FBD-4A0D-9B11-6363D12ADD1D}.Release|x64.ActiveCfg = Release|x64 + {6F9D87BA-0FBD-4A0D-9B11-6363D12ADD1D}.Release|x64.Build.0 = Release|x64 + {6F9D87BA-0FBD-4A0D-9B11-6363D12ADD1D}.Release|x86.ActiveCfg = Release|Win32 + {6F9D87BA-0FBD-4A0D-9B11-6363D12ADD1D}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/modules/rostests/apitests/atl/devenv/atltypes.vcxproj b/modules/rostests/apitests/atl/devenv/atltypes.vcxproj new file mode 100644 index 00000000000..a935da68534 --- /dev/null +++ b/modules/rostests/apitests/atl/devenv/atltypes.vcxproj @@ -0,0 +1,154 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + + + + {6F9D87BA-0FBD-4A0D-9B11-6363D12ADD1D} + Win32Proj + atltypes + 8.1 + + + + Application + true + v140 + Unicode + + + Application + false + v140 + true + Unicode + + + Application + true + v140_xp + Unicode + false + + + Application + false + v140_xp + true + Unicode + false + + + + + + + + + + + + + + + + + + + + + true + + + true + $(ProjectName)\$(Platform)\$(Configuration)\ + + + false + + + false + $(ProjectName)\$(Platform)\$(Configuration)\ + + + + Use + Level3 + Disabled + WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + + + + + NotUsing + Level3 + Disabled + _DEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Console + true + + + + + Level3 + Use + MaxSpeed + true + true + WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Windows + true + true + true + + + + + Level3 + NotUsing + MaxSpeed + true + true + NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + true + + + Console + true + true + true + + + + + + \ No newline at end of file diff --git a/sdk/lib/atl/atltypes.h b/sdk/lib/atl/atltypes.h index 5d1e9892d3c..76c651eca59 100644 --- a/sdk/lib/atl/atltypes.h +++ b/sdk/lib/atl/atltypes.h @@ -359,11 +359,46 @@ public: top == 0 && bottom == 0); } - //void MoveToX(int x) noexcept - //void MoveToXY(int x, int y) noexcept - //void MoveToXY(POINT point) noexcept - //void MoveToY(int y) noexcept - //void NormalizeRect() noexcept + void MoveToX(int x) noexcept + { + int dx = x - left; + left = x; + right += dx; + } + + void MoveToY(int y) noexcept + { + int dy = y - top; + top = y; + bottom += dy; + } + + void MoveToXY(int x, int y) noexcept + { + MoveToX(x); + MoveToY(y); + } + + void MoveToXY(POINT point) noexcept + { + MoveToXY(point.x, point.y); + } + + void NormalizeRect() noexcept + { + if (left > right) + { + LONG tmp = left; + left = right; + right = tmp; + } + if (top > bottom) + { + LONG tmp = top; + top = bottom; + bottom = tmp; + } + } void OffsetRect(int x, int y) noexcept { @@ -384,10 +419,29 @@ public: { return ::PtInRect(this, point); } - //void SetRect(int x1, int y1, int x2, int y2) noexcept - //void SetRectEmpty() noexcept - //CSize Size() const noexcept - //BOOL SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2) noexcept + + void SetRect(int x1, int y1, int x2, int y2) noexcept + { + left = x1; + top = y1; + right = x2; + bottom = y2; + } + + void SetRectEmpty() noexcept + { + ZeroMemory(this, sizeof(*this)); + } + + CSize Size() const noexcept + { + return CSize(Width(), Height()); + } + + BOOL SubtractRect(LPCRECT lpRectSrc1, LPCRECT lpRectSrc2) noexcept + { + return ::SubtractRect(this, lpRectSrc1, lpRectSrc2); + } CPoint& TopLeft() noexcept {