- iSelected should be -1 if no item selected (Gerard Patel)

- some of the checks for invalid items where > when they should have been >=
  (Marcus Meissner)
- made InsertItem behave similarly to DeleteItem, ie, if the current item is
  after where the item is inserted, increment the selected item (David Luyer)
This commit is contained in:
David Luyer 1999-09-19 12:12:34 +00:00 committed by Alexandre Julliard
parent dc6f327a8d
commit b1f173da52
1 changed files with 14 additions and 6 deletions

View File

@ -125,7 +125,7 @@ TAB_SetCurFocus (HWND hwnd,WPARAM wParam)
TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
INT iItem=(INT) wParam; INT iItem=(INT) wParam;
if ((iItem < 0) || (iItem > infoPtr->uNumItem)) return 0; if ((iItem < 0) || (iItem >= infoPtr->uNumItem)) return 0;
infoPtr->uFocus=iItem; infoPtr->uFocus=iItem;
if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) { if (GetWindowLongA(hwnd, GWL_STYLE) & TCS_BUTTONS) {
@ -1296,6 +1296,7 @@ TAB_InsertItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
if (infoPtr->uNumItem == 0) { if (infoPtr->uNumItem == 0) {
infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM)); infoPtr->items = COMCTL32_Alloc (sizeof (TAB_ITEM));
infoPtr->uNumItem++; infoPtr->uNumItem++;
infoPtr->iSelected = 0;
} }
else { else {
TAB_ITEM *oldItems = infoPtr->items; TAB_ITEM *oldItems = infoPtr->items;
@ -1316,6 +1317,9 @@ TAB_InsertItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
} }
if (iItem <= infoPtr->iSelected)
infoPtr->iSelected++;
COMCTL32_Free (oldItems); COMCTL32_Free (oldItems);
} }
@ -1370,7 +1374,7 @@ TAB_SetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
iItem=(INT) wParam; iItem=(INT) wParam;
tabItem=(LPTCITEMA ) lParam; tabItem=(LPTCITEMA ) lParam;
TRACE("%d %p\n",iItem, tabItem); TRACE("%d %p\n",iItem, tabItem);
if ((iItem<0) || (iItem>infoPtr->uNumItem)) return FALSE; if ((iItem<0) || (iItem>=infoPtr->uNumItem)) return FALSE;
wineItem=& infoPtr->items[iItem]; wineItem=& infoPtr->items[iItem];
@ -1422,7 +1426,7 @@ TAB_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam)
iItem=(INT) wParam; iItem=(INT) wParam;
tabItem=(LPTCITEMA) lParam; tabItem=(LPTCITEMA) lParam;
TRACE("\n"); TRACE("\n");
if ((iItem<0) || (iItem>infoPtr->uNumItem)) return FALSE; if ((iItem<0) || (iItem>=infoPtr->uNumItem)) return FALSE;
wineItem=& infoPtr->items[iItem]; wineItem=& infoPtr->items[iItem];
@ -1476,6 +1480,9 @@ TAB_DeleteItem (HWND hwnd, WPARAM wParam, LPARAM lParam)
if (iItem < infoPtr->iSelected) if (iItem < infoPtr->iSelected)
infoPtr->iSelected--; infoPtr->iSelected--;
if (infoPtr->uNumItem == 0)
infoPtr->iSelected = -1;
/* /*
* Reposition and repaint tabs. * Reposition and repaint tabs.
*/ */
@ -1494,7 +1501,8 @@ TAB_DeleteAllItems (HWND hwnd, WPARAM wParam, LPARAM lParam)
TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd);
COMCTL32_Free (infoPtr->items); COMCTL32_Free (infoPtr->items);
infoPtr->uNumItem=0; infoPtr->uNumItem = 0;
infoPtr->iSelected = -1;
return TRUE; return TRUE;
} }
@ -1607,7 +1615,7 @@ TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
infoPtr->hFont = 0; infoPtr->hFont = 0;
infoPtr->items = 0; infoPtr->items = 0;
infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA); infoPtr->hcurArrow = LoadCursorA (0, IDC_ARROWA);
infoPtr->iSelected = 0; infoPtr->iSelected = -1;
infoPtr->uFocus = 0; infoPtr->uFocus = 0;
infoPtr->hwndToolTip = 0; infoPtr->hwndToolTip = 0;
infoPtr->DoRedraw = TRUE; infoPtr->DoRedraw = TRUE;