/********************************************************************* * * LISTBOX_SetItemDisabled */ void LISTBOX_SetItemDisabled(LISTBOX_Handle hObj, unsigned Index, int OnOff) { if (hObj) { unsigned NumItems; LISTBOX_Obj* pObj; WM_LOCK(); pObj = LISTBOX_H2P(hObj); NumItems = LISTBOX__GetNumItems(pObj); if (Index < NumItems) { WM_HMEM hItem = GUI_ARRAY_GethItem(&pObj->ItemArray, Index); if (hItem) { LISTBOX_ITEM * pItem = (LISTBOX_ITEM *)GUI_ALLOC_h2p(hItem); if (OnOff) { if (!(pItem->Status & LISTBOX_ITEM_DISABLED)) { pItem->Status |= LISTBOX_ITEM_DISABLED; LISTBOX__InvalidateItem(hObj, pObj, Index); } } else { if (pItem->Status & LISTBOX_ITEM_DISABLED) { pItem->Status &= ~LISTBOX_ITEM_DISABLED; LISTBOX__InvalidateItem(hObj, pObj, Index); } } } } WM_UNLOCK(); } }
/********************************************************************* * * _ToggleMultiSel */ static void _ToggleMultiSel(LISTBOX_Handle hObj, LISTBOX_Obj* pObj, int Sel) { if (pObj->Flags & LISTBOX_SF_MULTISEL) { WM_HMEM hItem = GUI_ARRAY_GethItem(&pObj->ItemArray, Sel); if (hItem) { LISTBOX_ITEM * pItem = (LISTBOX_ITEM *)GUI_ALLOC_h2p(hItem); if (!(pItem->Status & LISTBOX_ITEM_DISABLED)) { pItem->Status ^= LISTBOX_ITEM_SELECTED; _NotifyOwner(hObj, WM_NOTIFICATION_SEL_CHANGED); LISTBOX__InvalidateItem(hObj, pObj, Sel); } } } }
/********************************************************************* * * LISTBOX_SetSel */ void LISTBOX_SetSel (LISTBOX_Handle hObj, int NewSel) { if (hObj) { LISTBOX_Obj* pObj; int MaxSel; WM_LOCK(); pObj = LISTBOX_H2P(hObj); MaxSel = LISTBOX__GetNumItems(pObj); MaxSel = MaxSel ? MaxSel - 1 : 0; if (NewSel > MaxSel) { NewSel = MaxSel; } if (NewSel < 0) { NewSel = -1; } else { WM_HMEM hItem = GUI_ARRAY_GethItem(&pObj->ItemArray, NewSel); if (hItem) { LISTBOX_ITEM* pItem = (LISTBOX_ITEM*)GUI_ALLOC_h2p(hItem); if (pItem->Status & LISTBOX_ITEM_DISABLED) { NewSel = -1; } } } if (NewSel != pObj->Sel) { int OldSel; OldSel = pObj->Sel; pObj->Sel = NewSel; if (_UpdateScrollPos(hObj, pObj)) { LISTBOX__InvalidateInsideArea(hObj); } else { LISTBOX__InvalidateItem(hObj, pObj, OldSel); LISTBOX__InvalidateItem(hObj, pObj, NewSel); } _NotifyOwner(hObj, WM_NOTIFICATION_SEL_CHANGED); } WM_UNLOCK(); } }
/********************************************************************* * * LISTBOX_AddString */ void LISTBOX_AddString(LISTBOX_Handle hObj, const char* s) { if (hObj && s) { LISTBOX_Obj* pObj; LISTBOX_ITEM Item = {0, 0}; WM_LOCK(); pObj = LISTBOX_H2P(hObj); if (GUI_ARRAY_AddItem(&pObj->ItemArray, &Item, sizeof(LISTBOX_ITEM) + strlen(s)) == 0) { unsigned ItemIndex = GUI_ARRAY_GetNumItems(&pObj->ItemArray) - 1; LISTBOX_ITEM* pItem= (LISTBOX_ITEM*)GUI_ARRAY_GetpItem(&pObj->ItemArray, ItemIndex); strcpy(pItem->acText, s); LISTBOX__InvalidateItemSize(pObj, ItemIndex); LISTBOX_UpdateScrollers(hObj); LISTBOX__InvalidateItem(hObj, pObj, ItemIndex); } WM_UNLOCK(); } }
/********************************************************************* * * LISTBOX_SetString */ void LISTBOX_SetString(LISTBOX_Handle hObj, const char* s, unsigned int Index) { if (hObj) { LISTBOX_Obj* pObj; WM_LOCK(); pObj = LISTBOX_H2P(hObj); if (Index < (unsigned int)LISTBOX__GetNumItems(pObj)) { LISTBOX_ITEM* pItem; pItem = (LISTBOX_ITEM*)GUI_ARRAY_ResizeItem(&pObj->ItemArray, Index, sizeof(LISTBOX_ITEM) + strlen(s)); if (pItem) { strcpy(pItem->acText, s); LISTBOX__InvalidateItemSize(pObj, Index); LISTBOX_UpdateScrollers(hObj); LISTBOX__InvalidateItem(hObj, pObj, Index); } } WM_UNLOCK(); } }