Nikolay Sivov : comctl32/header: Implement HDS_NOSIZING style with tests.
Alexandre Julliard
julliard at winehq.org
Tue Sep 8 08:55:32 CDT 2009
Module: wine
Branch: master
Commit: d9ebf1962cda0f3d2799bde8077285841dcd5d1e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=d9ebf1962cda0f3d2799bde8077285841dcd5d1e
Author: Nikolay Sivov <bunglehead at gmail.com>
Date: Sun Sep 6 12:59:43 2009 +0400
comctl32/header: Implement HDS_NOSIZING style with tests.
---
dlls/comctl32/header.c | 17 +++++++---
dlls/comctl32/tests/header.c | 75 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 87 insertions(+), 5 deletions(-)
diff --git a/dlls/comctl32/header.c b/dlls/comctl32/header.c
index 15586c1..d84965c 100644
--- a/dlls/comctl32/header.c
+++ b/dlls/comctl32/header.c
@@ -218,6 +218,14 @@ HEADER_PrevItem(const HEADER_INFO *infoPtr, INT iItem)
return HEADER_OrderToIndex(infoPtr, HEADER_IndexToOrder(infoPtr, iItem)-1);
}
+/* TRUE when item is not resizable with dividers,
+ note that valid index should be supplied */
+static inline BOOL
+HEADER_IsItemFixed(const HEADER_INFO *infoPtr, INT iItem)
+{
+ return (infoPtr->dwStyle & HDS_NOSIZING) || (infoPtr->items[iItem].fmt & HDF_FIXEDWIDTH);
+}
+
static void
HEADER_SetItemBounds (HEADER_INFO *infoPtr)
{
@@ -624,7 +632,7 @@ HEADER_InternalHitTest (const HEADER_INFO *infoPtr, const POINT *lpPt, UINT *pFl
rcTest = rect;
rcTest.right = rcTest.left + DIVIDER_WIDTH;
if (PtInRect (&rcTest, *lpPt)) {
- if (infoPtr->items[HEADER_PrevItem(infoPtr, iCount)].fmt & HDF_FIXEDWIDTH)
+ if (HEADER_IsItemFixed(infoPtr, HEADER_PrevItem(infoPtr, iCount)))
{
*pFlags |= HHT_ONHEADER;
*pItem = iCount;
@@ -647,8 +655,7 @@ HEADER_InternalHitTest (const HEADER_INFO *infoPtr, const POINT *lpPt, UINT *pFl
}
rcTest = rect;
rcTest.left = rcTest.right - DIVIDER_WIDTH;
- if (!(infoPtr->items[iCount].fmt & HDF_FIXEDWIDTH) &&
- PtInRect (&rcTest, *lpPt))
+ if (!HEADER_IsItemFixed(infoPtr, iCount) && PtInRect (&rcTest, *lpPt))
{
*pFlags |= HHT_ONDIVIDER;
*pItem = iCount;
@@ -664,7 +671,7 @@ HEADER_InternalHitTest (const HEADER_INFO *infoPtr, const POINT *lpPt, UINT *pFl
}
/* check for last divider part (on nowhere) */
- if (!(infoPtr->items[infoPtr->uNumItem-1].fmt & HDF_FIXEDWIDTH))
+ if (!HEADER_IsItemFixed(infoPtr, infoPtr->uNumItem - 1))
{
rect = infoPtr->items[infoPtr->uNumItem-1].rect;
rect.left = rect.right;
@@ -678,7 +685,7 @@ HEADER_InternalHitTest (const HEADER_INFO *infoPtr, const POINT *lpPt, UINT *pFl
}
else {
*pFlags |= HHT_ONDIVIDER;
- *pItem = infoPtr->uNumItem-1;
+ *pItem = infoPtr->uNumItem - 1;
TRACE("ON DIVIDER %d\n", *pItem);
return;
}
diff --git a/dlls/comctl32/tests/header.c b/dlls/comctl32/tests/header.c
index 3088a00..d0f3f28 100644
--- a/dlls/comctl32/tests/header.c
+++ b/dlls/comctl32/tests/header.c
@@ -1264,6 +1264,80 @@ static void test_hdf_fixedwidth(HWND hParent)
DestroyWindow(hChild);
}
+static void test_hds_nosizing(HWND hParent)
+{
+ HWND hChild;
+ HDITEM hdItem;
+ DWORD ret;
+ RECT rect;
+ HDHITTESTINFO ht;
+
+ hChild = create_custom_header_control(hParent, FALSE);
+
+ hdItem.mask = HDI_WIDTH;
+ hdItem.cxy = 80;
+
+ ret = SendMessage(hChild, HDM_INSERTITEM, 0, (LPARAM)&hdItem);
+ expect(0, ret);
+
+ /* HDS_NOSIZING only blocks hittesting */
+ ret = GetWindowLong(hChild, GWL_STYLE);
+ SetWindowLong(hChild, GWL_STYLE, ret | HDS_NOSIZING);
+
+ /* try to change width with mouse gestures */
+ rect.right = rect.bottom = 0;
+ SendMessage(hChild, HDM_GETITEMRECT, 0, (LPARAM)&rect);
+ ok(rect.right != 0, "Expected not zero width\n");
+ ok(rect.bottom != 0, "Expected not zero height\n");
+
+ SendMessage(hChild, WM_LBUTTONDOWN, 0, MAKELPARAM(rect.right, rect.bottom / 2));
+ SendMessage(hChild, WM_MOUSEMOVE, 0, MAKELPARAM(rect.right + 20, rect.bottom / 2));
+ SendMessage(hChild, WM_LBUTTONUP, 0, MAKELPARAM(rect.right + 20, rect.bottom / 2));
+
+ SendMessage(hChild, HDM_GETITEMRECT, 0, (LPARAM)&rect);
+
+ if (hdItem.cxy != rect.right)
+ {
+ win_skip("HDS_NOSIZING style not supported\n");
+ DestroyWindow(hChild);
+ return;
+ }
+
+ /* this style doesn't set HDF_FIXEDWIDTH for items */
+ hdItem.mask = HDI_FORMAT;
+ ret = SendMessage(hChild, HDM_GETITEM, 0, (LPARAM)&hdItem);
+ expect(TRUE, ret);
+ ok(!(hdItem.fmt & HDF_FIXEDWIDTH), "Unexpected HDF_FIXEDWIDTH\n");
+
+ /* try to adjust with message */
+ hdItem.mask = HDI_WIDTH;
+ hdItem.cxy = 90;
+
+ ret = SendMessage(hChild, HDM_SETITEM, 0, (LPARAM)&hdItem);
+ expect(TRUE, ret);
+
+ rect.right = 0;
+ SendMessage(hChild, HDM_GETITEMRECT, 0, (LPARAM)&rect);
+ expect(90, rect.right);
+
+ /* hittesting doesn't report ondivider flags for HDS_NOSIZING */
+ ht.pt.x = rect.right - 1;
+ ht.pt.y = rect.bottom / 2;
+ SendMessage(hChild, HDM_HITTEST, 0, (LPARAM)&ht);
+ expect(HHT_ONHEADER, ht.flags);
+
+ /* try to adjust with message */
+ ret = GetWindowLong(hChild, GWL_STYLE);
+ SetWindowLong(hChild, GWL_STYLE, ret & ~HDS_NOSIZING);
+
+ ht.pt.x = 90;
+ ht.pt.y = rect.bottom / 2;
+ SendMessage(hChild, HDM_HITTEST, 0, (LPARAM)&ht);
+ expect(HHT_ONDIVIDER, ht.flags);
+
+ DestroyWindow(hChild);
+}
+
#define TEST_NMCUSTOMDRAW(draw_stage, item_spec, lparam, _left, _top, _right, _bottom) \
ok(nm->dwDrawStage == draw_stage, "Invalid dwDrawStage %d vs %d\n", draw_stage, nm->dwDrawStage); \
if (item_spec != -1) \
@@ -1660,6 +1734,7 @@ START_TEST(header)
/* comctl32 version 6 tests start here */
test_hdf_fixedwidth(parent_hwnd);
+ test_hds_nosizing(parent_hwnd);
unload_v6_module(ctx_cookie);
More information about the wine-cvs
mailing list