+ case LVN_BEGINRDRAG:
+ eventType = wxEVT_COMMAND_LIST_BEGIN_RDRAG;
+ // fall through
+
+ case LVN_BEGINDRAG:
+ if ( eventType == wxEVT_NULL )
+ {
+ eventType = wxEVT_COMMAND_LIST_BEGIN_DRAG;
+ }
+
+ event.m_itemIndex = nmLV->iItem;
+ event.m_pointDrag.x = nmLV->ptAction.x;
+ event.m_pointDrag.y = nmLV->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, GetHwnd());
+ }
+ break;
+
+ case LVN_COLUMNCLICK:
+ eventType = wxEVT_COMMAND_LIST_COL_CLICK;
+ event.m_itemIndex = -1;
+ event.m_col = nmLV->iSubItem;
+ break;
+
+ case LVN_DELETEALLITEMS:
+ eventType = wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS;
+ event.m_itemIndex = -1;
+
+ FreeAllAttrs();
+
+ break;
+
+ case LVN_DELETEITEM:
+ eventType = wxEVT_COMMAND_LIST_DELETE_ITEM;
+ event.m_itemIndex = nmLV->iItem;
+
+ if ( m_hasAnyAttr )
+ {
+ delete (wxListItemAttr *)m_attrs.Delete(nmLV->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);
+ if ( info->item.pszText == NULL || info->item.iItem == -1 )
+ return FALSE;
+ }
+ break;
+
+ case LVN_SETDISPINFO:
+ {
+ eventType = wxEVT_COMMAND_LIST_SET_INFO;
+ LV_DISPINFO *info = (LV_DISPINFO *)lParam;
+ wxConvertFromMSWListItem(this, event.m_item, info->item, GetHwnd());
+ }
+ break;
+
+ case LVN_GETDISPINFO:
+ // this provokes stack overflow: indeed, wxConvertFromMSWListItem()
+ // sends us WM_NOTIFY! As it doesn't do anything for now, just leave
+ // it out.
+#if 0
+ {
+ // 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, GetHwnd());
+ break;
+ }
+#endif // 0
+ return FALSE;
+
+
+ case LVN_INSERTITEM:
+ eventType = wxEVT_COMMAND_LIST_INSERT_ITEM;
+ event.m_itemIndex = nmLV->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.
+ if ( (nmLV->uNewState & LVIS_SELECTED) && !(nmLV->uOldState & LVIS_SELECTED) )
+ {
+ eventType = wxEVT_COMMAND_LIST_ITEM_SELECTED;
+ event.m_itemIndex = nmLV->iItem;
+ }
+ else if ( !(nmLV->uNewState & LVIS_SELECTED) && (nmLV->uOldState & LVIS_SELECTED) )
+ {
+ eventType = wxEVT_COMMAND_LIST_ITEM_DESELECTED;
+ event.m_itemIndex = nmLV->iItem;
+ }
+ else
+ {
+ return FALSE;
+ }
+ break;
+
+ case LVN_KEYDOWN:
+ {
+ LV_KEYDOWN *info = (LV_KEYDOWN *)lParam;
+ WORD wVKey = info->wVKey;
+
+ // get the current selection
+ long lItem = GetNextItem(-1,
+ wxLIST_NEXT_ALL,
+ wxLIST_STATE_SELECTED);
+
+ // <Enter> or <Space> activate the selected item if any
+ if ( lItem != -1 && (wVKey == VK_RETURN || wVKey == VK_SPACE) )
+ {
+ // TODO this behaviour probably should be optional
+ eventType = wxEVT_COMMAND_LIST_ITEM_ACTIVATED;
+ event.m_itemIndex = lItem;
+ }
+ else
+ {
+ eventType = wxEVT_COMMAND_LIST_KEY_DOWN;
+ event.m_code = wxCharCodeMSWToWX(wVKey);
+ }
+
+ event.m_item.m_data = GetItemData(lItem);
+ }
+ break;
+
+ case NM_DBLCLK:
+ // if the user processes it in wxEVT_COMMAND_LEFT_CLICK(), don't do
+ // anything else
+ if ( wxControl::MSWOnNotify(idCtrl, lParam, result) )
+ {
+ return TRUE;
+ }
+
+ // else translate it into wxEVT_COMMAND_LIST_ITEM_ACTIVATED event
+ // if it happened on an item (and not on empty place)
+ if ( nmLV->iItem == -1 )
+ {
+ // not on item
+ return FALSE;
+ }
+
+ eventType = wxEVT_COMMAND_LIST_ITEM_ACTIVATED;
+ event.m_itemIndex = nmLV->iItem;
+ event.m_item.m_data = GetItemData(nmLV->iItem);
+ break;
+
+ case NM_RCLICK:
+ /* TECH NOTE: NM_RCLICK isn't really good enough here. We want to
+ subclass and check for the actual WM_RBUTTONDOWN message,
+ because NM_RCLICK waits for the WM_RBUTTONUP message as well
+ before firing off. We want to have notify events for both down
+ -and- up. */
+ {
+ // if the user processes it in wxEVT_COMMAND_RIGHT_CLICK(),
+ // don't do anything else
+ if ( wxControl::MSWOnNotify(idCtrl, lParam, result) )
+ {
+ return TRUE;
+ }
+
+ // else translate it into wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK event
+ LV_HITTESTINFO lvhti;
+ wxZeroMemory(lvhti);
+
+ ::GetCursorPos(&(lvhti.pt));
+ ::ScreenToClient(GetHwnd(),&(lvhti.pt));
+ if ( ListView_HitTest(GetHwnd(),&lvhti) != -1 )
+ {
+ if ( lvhti.flags & LVHT_ONITEM )
+ {
+ eventType = wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK;
+ event.m_itemIndex = lvhti.iItem;
+ }
+ }
+ }
+ break;
+
+#if 0
+ case NM_MCLICK: // ***** THERE IS NO NM_MCLICK. Subclass anyone? ******
+ {
+ // if the user processes it in wxEVT_COMMAND_MIDDLE_CLICK(), don't do
+ // anything else
+ if ( wxControl::MSWOnNotify(idCtrl, lParam, result) )
+ {
+ return TRUE;
+ }
+
+ // else translate it into wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK event
+ eventType = wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK;
+ NMITEMACTIVATE* hdr = (NMITEMACTIVATE*)lParam;
+ event.m_itemIndex = hdr->iItem;
+ }
+ break;
+#endif // 0
+
+#if defined(_WIN32_IE) && _WIN32_IE >= 0x300
+ case NM_CUSTOMDRAW:
+ {
+ LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
+ NMCUSTOMDRAW& nmcd = lplvcd->nmcd;
+ switch( nmcd.dwDrawStage )
+ {
+ case CDDS_PREPAINT:
+ // if we've got any items with non standard attributes,
+ // notify us before painting each item
+ *result = m_hasAnyAttr ? CDRF_NOTIFYITEMDRAW
+ : CDRF_DODEFAULT;
+ return TRUE;
+
+ case CDDS_ITEMPREPAINT:
+ {
+ wxListItemAttr *attr =
+ (wxListItemAttr *)m_attrs.Get(nmcd.dwItemSpec);
+
+ if ( !attr )
+ {
+ // nothing to do for this item
+ return CDRF_DODEFAULT;
+ }
+
+ HFONT hFont;
+ wxColour colText, colBack;
+ if ( attr->HasFont() )
+ {
+ wxFont font = attr->GetFont();
+ hFont = (HFONT)font.GetResourceHandle();
+ }
+ else
+ {
+ hFont = 0;
+ }
+
+ if ( attr->HasTextColour() )
+ {
+ colText = attr->GetTextColour();
+ }
+ else
+ {
+ colText = GetTextColour();
+ }
+
+ if ( attr->HasBackgroundColour() )
+ {
+ colBack = attr->GetBackgroundColour();
+ }
+ else
+ {
+ colBack = GetBackgroundColour();
+ }
+
+ // note that if we wanted to set colours for
+ // individual columns (subitems), we would have
+ // returned CDRF_NOTIFYSUBITEMREDRAW from here
+ if ( hFont )
+ {
+ ::SelectObject(nmcd.hdc, hFont);
+
+ *result = CDRF_NEWFONT;
+ }
+ else
+ {
+ *result = CDRF_DODEFAULT;
+ }
+
+ lplvcd->clrText = wxColourToRGB(colText);
+ lplvcd->clrTextBk = wxColourToRGB(colBack);
+
+ return TRUE;
+ }
+
+ default:
+ *result = CDRF_DODEFAULT;
+ return TRUE;
+ }
+ }
+ break;
+#endif // _WIN32_IE >= 0x300
+
+ default:
+ return wxControl::MSWOnNotify(idCtrl, lParam, result);