Commit f644c787 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

Update ordering on insertion of an item.

parent 88090b47
...@@ -845,7 +845,7 @@ HEADER_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -845,7 +845,7 @@ HEADER_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
HDITEMA *phdi = (HDITEMA*)lParam; HDITEMA *phdi = (HDITEMA*)lParam;
INT nItem = (INT)wParam; INT nItem = (INT)wParam;
HEADER_ITEM *lpItem; HEADER_ITEM *lpItem;
INT len; INT len, i, iOrder;
if ((phdi == NULL) || (nItem < 0)) if ((phdi == NULL) || (nItem < 0))
return -1; return -1;
...@@ -853,6 +853,8 @@ HEADER_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -853,6 +853,8 @@ HEADER_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
if (nItem > infoPtr->uNumItem) if (nItem > infoPtr->uNumItem)
nItem = infoPtr->uNumItem; nItem = infoPtr->uNumItem;
iOrder = (phdi->mask & HDI_ORDER) ? phdi->iOrder : nItem;
if (infoPtr->uNumItem == 0) { if (infoPtr->uNumItem == 0) {
infoPtr->items = COMCTL32_Alloc (sizeof (HEADER_ITEM)); infoPtr->items = COMCTL32_Alloc (sizeof (HEADER_ITEM));
infoPtr->uNumItem++; infoPtr->uNumItem++;
...@@ -884,6 +886,12 @@ HEADER_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -884,6 +886,12 @@ HEADER_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
COMCTL32_Free (oldItems); COMCTL32_Free (oldItems);
} }
for (i=0; i < infoPtr->uNumItem; i++)
{
if (infoPtr->items[i].iOrder >= iOrder)
infoPtr->items[i].iOrder++;
}
lpItem = &infoPtr->items[nItem]; lpItem = &infoPtr->items[nItem];
lpItem->bDown = FALSE; lpItem->bDown = FALSE;
...@@ -921,13 +929,7 @@ HEADER_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -921,13 +929,7 @@ HEADER_InsertItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
if (phdi->mask & HDI_IMAGE) if (phdi->mask & HDI_IMAGE)
lpItem->iImage = phdi->iImage; lpItem->iImage = phdi->iImage;
if (phdi->mask & HDI_ORDER) lpItem->iOrder = iOrder;
{
lpItem->iOrder = phdi->iOrder;
}
else
lpItem->iOrder=nItem;
HEADER_SetItemBounds (hwnd); HEADER_SetItemBounds (hwnd);
...@@ -944,7 +946,7 @@ HEADER_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -944,7 +946,7 @@ HEADER_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
HDITEMW *phdi = (HDITEMW*)lParam; HDITEMW *phdi = (HDITEMW*)lParam;
INT nItem = (INT)wParam; INT nItem = (INT)wParam;
HEADER_ITEM *lpItem; HEADER_ITEM *lpItem;
INT len; INT len, i, iOrder;
if ((phdi == NULL) || (nItem < 0)) if ((phdi == NULL) || (nItem < 0))
return -1; return -1;
...@@ -952,6 +954,8 @@ HEADER_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -952,6 +954,8 @@ HEADER_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
if (nItem > infoPtr->uNumItem) if (nItem > infoPtr->uNumItem)
nItem = infoPtr->uNumItem; nItem = infoPtr->uNumItem;
iOrder = (phdi->mask & HDI_ORDER) ? phdi->iOrder : nItem;
if (infoPtr->uNumItem == 0) { if (infoPtr->uNumItem == 0) {
infoPtr->items = COMCTL32_Alloc (sizeof (HEADER_ITEM)); infoPtr->items = COMCTL32_Alloc (sizeof (HEADER_ITEM));
infoPtr->uNumItem++; infoPtr->uNumItem++;
...@@ -983,6 +987,12 @@ HEADER_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -983,6 +987,12 @@ HEADER_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
COMCTL32_Free (oldItems); COMCTL32_Free (oldItems);
} }
for (i=0; i < infoPtr->uNumItem; i++)
{
if (infoPtr->items[i].iOrder >= iOrder)
infoPtr->items[i].iOrder++;
}
lpItem = &infoPtr->items[nItem]; lpItem = &infoPtr->items[nItem];
lpItem->bDown = FALSE; lpItem->bDown = FALSE;
...@@ -1021,12 +1031,7 @@ HEADER_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) ...@@ -1021,12 +1031,7 @@ HEADER_InsertItemW (HWND hwnd, WPARAM wParam, LPARAM lParam)
if (phdi->mask & HDI_IMAGE) if (phdi->mask & HDI_IMAGE)
lpItem->iImage = phdi->iImage; lpItem->iImage = phdi->iImage;
if (phdi->mask & HDI_ORDER) lpItem->iOrder = iOrder;
{
lpItem->iOrder = phdi->iOrder;
}
else
lpItem->iOrder = nItem;
HEADER_SetItemBounds (hwnd); HEADER_SetItemBounds (hwnd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment