/********************************************************************* * * _OnTouch */ static void _OnTouch(LISTBOX_Handle hObj, WM_MESSAGE* pMsg) { const GUI_PID_STATE* pState = (const GUI_PID_STATE*)pMsg->Data.p; if (pMsg->Data.p) { /* Something happened in our area (pressed or released) */ if (pState->Pressed == 0) { _NotifyOwner(hObj, WM_NOTIFICATION_RELEASED); } } else { /* Mouse moved out */ _NotifyOwner(hObj, WM_NOTIFICATION_MOVED_OUT); } }
/********************************************************************* * * _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); } } } }
/********************************************************************* * * _OnTouch */ static void _OnTouch(LISTVIEW_Handle hObj, LISTVIEW_Obj* pObj, WM_MESSAGE*pMsg) { int Notification; const GUI_PID_STATE* pState = (const GUI_PID_STATE*)pMsg->Data.p; GUI_USE_PARA(pObj); if (pMsg->Data.p) { /* Something happened in our area (pressed or released) */ if (pState->Pressed) { _SetSelFromPos(hObj, pObj, pState); Notification = WM_NOTIFICATION_CLICKED; WM_SetFocus(hObj); } else { Notification = WM_NOTIFICATION_RELEASED; } } else { Notification = WM_NOTIFICATION_MOVED_OUT; } _NotifyOwner(hObj, Notification); }
/********************************************************************* * * 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(); } }
/********************************************************************* * * _LISTVIEW_Callback */ static void _LISTVIEW_Callback (WM_MESSAGE *pMsg) { LISTVIEW_Handle hObj; LISTVIEW_Obj* pObj; WM_SCROLL_STATE ScrollState; hObj = pMsg->hWin; /* Let widget handle the standard messages */ if (WIDGET_HandleActive(hObj, pMsg) == 0) { return; } pObj = LISTVIEW_H2P(hObj); switch (pMsg->MsgId) { case WM_NOTIFY_CLIENTCHANGE: case WM_SIZE: LISTVIEW__UpdateScrollParas(hObj, pObj); return; case WM_NOTIFY_PARENT: switch (pMsg->Data.v) { case WM_NOTIFICATION_CHILD_DELETED: /* make sure we do not send any messages to the header child once it has been deleted */ if (pMsg->hWinSrc == pObj->hHeader) { pObj->hHeader = 0; } break; case WM_NOTIFICATION_VALUE_CHANGED: if (pMsg->hWinSrc == WM_GetScrollbarV(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateV.v = ScrollState.v; LISTVIEW__InvalidateInsideArea(hObj, pObj); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } else if (pMsg->hWinSrc == WM_GetScrollbarH(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateH.v = ScrollState.v; LISTVIEW__UpdateScrollParas(hObj, pObj); HEADER_SetScrollPos(pObj->hHeader, pObj->ScrollStateH.v); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } break; case WM_NOTIFICATION_SCROLLBAR_ADDED: LISTVIEW__UpdateScrollParas(hObj, pObj); break; } return; case WM_PAINT: _Paint(hObj, pObj, pMsg); return; case WM_TOUCH: _OnTouch(hObj, pObj, pMsg); return; /* Important: message handled ! */ case WM_KEY: if (((const WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt > 0) { int Key; Key = ((const WM_KEY_INFO*)(pMsg->Data.p))->Key; if (_AddKey(hObj, Key)) { return; } } break; /* No return here ... WM_DefaultProc needs to be called */ case WM_DELETE: _FreeAttached(pObj); break; /* No return here ... WM_DefaultProc needs to be called */ } WM_DefaultProc(pMsg); }
/********************************************************************* * * _LISTBOX_Callback */ static void _LISTBOX_Callback(WM_MESSAGE*pMsg) { LISTBOX_Handle hObj = pMsg->hWin; LISTBOX_Obj* pObj = LISTBOX_H2P(hObj); WM_SCROLL_STATE ScrollState; /* Let widget handle the standard messages */ if (WIDGET_HandleActive(hObj, pMsg) == 0) { /* Owner needs to be informed about focus change */ if (pMsg->MsgId == WM_SET_FOCUS) { if (pMsg->Data.v == 0) { /* Lost focus ? */ _NotifyOwner(hObj, LISTBOX_NOTIFICATION_LOST_FOCUS); } } return; } switch (pMsg->MsgId) { case WM_NOTIFY_PARENT: switch (pMsg->Data.v) { case WM_NOTIFICATION_VALUE_CHANGED: if (pMsg->hWinSrc == WM_GetScrollbarV(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateV.v = ScrollState.v; LISTBOX__InvalidateInsideArea(hObj); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } else if (pMsg->hWinSrc == WM_GetScrollbarH(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateH.v = ScrollState.v; LISTBOX__InvalidateInsideArea(hObj); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } break; case WM_NOTIFICATION_SCROLLBAR_ADDED: LISTBOX_UpdateScrollers(hObj); break; } break; case WM_PAINT: _OnPaint(hObj, pObj, pMsg); break; case WM_PID_STATE_CHANGED: { const WM_PID_STATE_CHANGED_INFO* pInfo = (const WM_PID_STATE_CHANGED_INFO*)pMsg->Data.p; if (pInfo->State) { int Sel; Sel = _GetItemFromPos(hObj, pObj, pInfo->x, pInfo->y); if (Sel >= 0) { _ToggleMultiSel(hObj, pObj, Sel); LISTBOX_SetSel(hObj, Sel); } _NotifyOwner(hObj, WM_NOTIFICATION_CLICKED); return; } } break; case WM_TOUCH: _OnTouch(hObj, pMsg); return; #if GUI_SUPPORT_MOUSE case WM_MOUSEOVER: if (_OnMouseOver(hObj, pObj, pMsg) == 0) return; break; #endif case WM_DELETE: _FreeAttached(pObj); break; /* No return here ... WM_DefaultProc needs to be called */ case WM_KEY: if (((const WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt > 0) { int Key; Key = ((const WM_KEY_INFO*)(pMsg->Data.p))->Key; if (LISTBOX_AddKey(hObj, Key)) { return; } } break; case WM_SIZE: LISTBOX_UpdateScrollers(hObj); WM_InvalidateWindow(hObj); break; } WM_DefaultProc(pMsg); }
/********************************************************************* * * LISTVIEW_Callback */ void LISTVIEW_Callback (WM_MESSAGE *pMsg) { LISTVIEW_Handle hObj; LISTVIEW_Obj* pObj; WM_SCROLL_STATE ScrollState; hObj = pMsg->hWin; /* Let widget handle the standard messages */ if (WIDGET_HandleActive(hObj, pMsg) == 0) { return; } pObj = (LISTVIEW_Obj *)GUI_ALLOC_h2p(hObj); /* Don't use use WIDGET_H2P because WIDGET_INIT_ID() has not be called at this point */ switch (pMsg->MsgId) { case WM_NOTIFY_CLIENTCHANGE: case WM_SIZE: if (pMsg->hWinSrc && (pMsg->hWinSrc == pObj->hHeader)) { LISTVIEW__UpdateScrollParas(hObj, pObj); } return; case WM_NOTIFY_PARENT: switch (pMsg->Data.v) { case WM_NOTIFICATION_CHILD_DELETED: /* make sure we do not send any messages to the header child once it has been deleted */ if (pMsg->hWinSrc == pObj->hHeader) { pObj->hHeader = 0; } break; case WM_NOTIFICATION_VALUE_CHANGED: if (pMsg->hWinSrc == WM_GetScrollbarV(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateV.v = ScrollState.v; LISTVIEW__InvalidateInsideArea(hObj, pObj); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } else if (pMsg->hWinSrc == WM_GetScrollbarH(hObj)) { WM_GetScrollState(pMsg->hWinSrc, &ScrollState); pObj->ScrollStateH.v = ScrollState.v; LISTVIEW__UpdateScrollParas(hObj, pObj); HEADER_SetScrollPos(pObj->hHeader, pObj->ScrollStateH.v); _NotifyOwner(hObj, WM_NOTIFICATION_SCROLL_CHANGED); } break; case WM_NOTIFICATION_SCROLLBAR_ADDED: #if WIDGET_USE_PARENT_EFFECT WIDGET_SetEffect(pMsg->hWinSrc, pObj->Widget.pEffect); #endif LISTVIEW__UpdateScrollParas(hObj, pObj); break; case WM_NOTIFICATION_RELEASED: if ((pMsg->hWinSrc == pObj->hHeader) && (pObj->hSort)) { int Column; LISTVIEW_SORT * pSort; LISTVIEW_COLUMN * pColumn; WM_SetFocus(hObj); Column = HEADER_GetSel(pObj->hHeader); if (Column >= 0) { pColumn = (LISTVIEW_COLUMN *)GUI_ARRAY_GetpItem(&pObj->ColumnArray, Column); if (pColumn->fpCompare) { pSort = (LISTVIEW_SORT *)GUI_ALLOC_h2p(pObj->hSort); if (pSort) { // ReverseSort if (pObj->SortIndex == Column) { pSort->Reverse ^= 1; pObj->ReverseSort = 1; pObj->IsSorted = 0; } else { pSort->Reverse = 0; pObj->SortIndex = Column; pObj->IsPresorted = 0; } /* if (pObj->SortIndex == Column) { pSort->Reverse ^= 1; } else { pSort->Reverse = 0; pObj->SortIndex = Column; } pObj->IsPresorted = 0; */ LISTVIEW__InvalidateInsideArea(hObj, pObj); } } } } break; } return; case WM_PAINT: _Paint(hObj, pObj, pMsg); return; case WM_TOUCH: _OnTouch(hObj, pObj, pMsg); return; /* Important: message handled ! */ case WM_KEY: if (((const WM_KEY_INFO*)(pMsg->Data.p))->PressedCnt > 0) { int Key; Key = ((const WM_KEY_INFO*)(pMsg->Data.p))->Key; if (_AddKey(hObj, pObj, Key)) { return; } } break; /* No return here ... WM_DefaultProc needs to be called */ case WM_DELETE: _FreeAttached(pObj); break; /* No return here ... WM_DefaultProc needs to be called */ } WM_DefaultProc(pMsg); }