- }
- else return FALSE;
-}
-
-bool wxListCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam)
-{
- wxListEvent event(wxEVT_NULL, m_windowId);
- wxEventType eventType = wxEVT_NULL;
- NMHDR *hdr1 = (NMHDR *) lParam;
- switch ( hdr1->code )
- {
- case LVN_BEGINDRAG:
- {
- eventType = wxEVT_COMMAND_LIST_BEGIN_DRAG;
- NM_LISTVIEW *hdr = (NM_LISTVIEW *)lParam;
- event.m_itemIndex = hdr->iItem;
- event.m_pointDrag.x = hdr->ptAction.x;
- event.m_pointDrag.y = hdr->ptAction.y;
- break;
- }
- case LVN_BEGINLABELEDIT:
- {
- eventType = wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT;
- LV_DISPINFO *info = (LV_DISPINFO *)lParam;
- wxConvertFromMSWListItem(this, event.m_item, info->item, (HWND) GetHWND());
- break;
- }
- case LVN_BEGINRDRAG:
- {
- eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG;
- NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
- event.m_itemIndex = hdr->iItem;
- event.m_pointDrag.x = hdr->ptAction.x;
- event.m_pointDrag.y = hdr->ptAction.y;
- break;
- }
- case LVN_COLUMNCLICK:
- {
- eventType = wxEVT_COMMAND_LIST_COL_CLICK;
- NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
- event.m_itemIndex = -1;
- event.m_col = hdr->iSubItem;
- break;
- }
- case LVN_DELETEALLITEMS:
- {
- eventType = wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
-// NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
- event.m_itemIndex = -1;
- break;
- }
- case LVN_DELETEITEM:
- {
- eventType = wxEVT_COMMAND_LIST_DELETE_ITEM;
- NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
- event.m_itemIndex = hdr->iItem;
- break;
- }
- case LVN_ENDLABELEDIT:
- {
- eventType = wxEVT_COMMAND_LIST_END_LABEL_EDIT;
- LV_DISPINFO *info = (LV_DISPINFO *)lParam;
- wxConvertFromMSWListItem(this, event.m_item, info->item, (HWND) GetHWND());
- if ( info->item.pszText == NULL || info->item.iItem == -1 )
- event.m_cancelled = TRUE;
- break;
- }
- case LVN_GETDISPINFO:
- {
-// return FALSE;
- // TODO: some text buffering here, I think
- // TODO: API for getting Windows to retrieve values
- // on demand.
- eventType = wxEVT_COMMAND_LIST_GET_INFO;
- LV_DISPINFO *info = (LV_DISPINFO *)lParam;
- wxConvertFromMSWListItem(this, event.m_item, info->item, (HWND) GetHWND());
- break;
- }
- case LVN_INSERTITEM:
- {
- eventType = wxEVT_COMMAND_LIST_INSERT_ITEM;
- NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
- event.m_itemIndex = hdr->iItem;
- break;
- }
- case LVN_ITEMCHANGED:
- {
- // This needs to be sent to wxListCtrl as a rather more
- // concrete event. For now, just detect a selection
- // or deselection.
- NM_LISTVIEW* hdr = (NM_LISTVIEW*)lParam;
- if ( (hdr->uNewState & LVIS_SELECTED) && !(hdr->uOldState & LVIS_SELECTED) )
- {
- eventType = wxEVT_COMMAND_LIST_ITEM_SELECTED;
- event.m_itemIndex = hdr->iItem;
- }
- else if ( !(hdr->uNewState & LVIS_SELECTED) && (hdr->uOldState & LVIS_SELECTED) )
- {
- eventType = wxEVT_COMMAND_LIST_ITEM_DESELECTED;
- event.m_itemIndex = hdr->iItem;
- }
- else
- return FALSE;
- break;
- }
- case LVN_KEYDOWN:
- {
- eventType = wxEVT_COMMAND_LIST_KEY_DOWN;
- LV_KEYDOWN *info = (LV_KEYDOWN *)lParam;
- event.m_code = wxCharCodeMSWToWX(info->wVKey);
- break;
- }
- case LVN_SETDISPINFO:
- {
- eventType = wxEVT_COMMAND_LIST_SET_INFO;
- LV_DISPINFO *info = (LV_DISPINFO *)lParam;
- wxConvertFromMSWListItem(this, event.m_item, info->item, (HWND) GetHWND());
- break;
- }
-
- default :
- return wxControl::MSWNotify(wParam, lParam);
- break;
- }
-
- event.SetEventObject( this );
- event.SetEventType(eventType);
-
- if ( !GetEventHandler()->ProcessEvent(event) )
- return FALSE;
-
- if (hdr1->code == LVN_GETDISPINFO)
- {
- LV_DISPINFO *info = (LV_DISPINFO *)lParam;
- if ( info->item.mask & LVIF_TEXT )
- {
- if ( !event.m_item.m_text.IsNull() )
- {
- info->item.pszText = AddPool(event.m_item.m_text);
- info->item.cchTextMax = strlen(info->item.pszText) + 1;
- }
- }
-// wxConvertToMSWListItem(this, event.m_item, info->item);
- }
-
- return TRUE;