X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/73d8c5fd7620fd5eea3bc37de587473e14cff01e..2ad99bc1398db5a619b3682e90ad7a99485ae4c9:/src/msw/listctrl.cpp diff --git a/src/msw/listctrl.cpp b/src/msw/listctrl.cpp index cae8ad8d26..9ea8e389a1 100644 --- a/src/msw/listctrl.cpp +++ b/src/msw/listctrl.cpp @@ -171,9 +171,10 @@ public: }; // Get the internal data structure -static wxListItemInternalData *GetInternalData(HWND hwnd, long itemId); -static wxListItemInternalData *GetInternalData(wxListCtrl *ctl, long itemId); -static wxListItemAttr *GetInternalDataAttr(wxListCtrl *ctl, long itemId); +static wxListItemInternalData *wxGetInternalData(HWND hwnd, long itemId); +static wxListItemInternalData *wxGetInternalData(wxListCtrl *ctl, long itemId); +static wxListItemAttr *wxGetInternalDataAttr(wxListCtrl *ctl, long itemId); +static void wxDeleteInternalData(wxListCtrl* ctl, long itemId); // ---------------------------------------------------------------------------- @@ -364,19 +365,8 @@ void wxListCtrl::FreeAllInternalData() int i = 0; for (i = 0; i < n; i++) - { - wxListItemInternalData *data = GetInternalData(this, i); - if (data) - { - delete data; - LV_ITEM item; - memset(&item, 0, sizeof(item)); - item.iItem = i; - item.mask = LVIF_PARAM; - item.lParam = (LPARAM) 0; - BOOL result = ListView_SetItem(GetHwnd(), &item); - } - } + wxDeleteInternalData(this, i); + m_AnyInternalData = FALSE; } } @@ -589,6 +579,8 @@ bool wxListCtrl::GetColumn(int col, wxListItem& item) const LV_COLUMN lvCol; wxZeroMemory(lvCol); + lvCol.mask = LVCF_WIDTH; + if ( item.m_mask & wxLIST_MASK_TEXT ) { lvCol.mask |= LVCF_TEXT; @@ -596,6 +588,16 @@ bool wxListCtrl::GetColumn(int col, wxListItem& item) const lvCol.cchTextMax = 512; } + if ( item.m_mask & wxLIST_MASK_FORMAT ) + { + lvCol.mask |= LVCF_FMT; + } + + if ( item.m_mask & wxLIST_MASK_IMAGE ) + { + lvCol.mask |= LVCF_IMAGE; + } + bool success = ListView_GetColumn(GetHwnd(), col, & lvCol) != 0; // item.m_subItem = lvCol.iSubItem; @@ -617,6 +619,13 @@ bool wxListCtrl::GetColumn(int col, wxListItem& item) const item.m_format = wxLIST_FORMAT_CENTRE; } +#if _WIN32_IE >= 0x0300 + if ( item.m_mask & wxLIST_MASK_IMAGE ) + { + item.m_image = lvCol.iImage; + } +#endif + return success; } @@ -732,7 +741,7 @@ bool wxListCtrl::SetItem(wxListItem& info) { // get internal item data // perhaps a cache here ? - wxListItemInternalData *data = GetInternalData(this, info.m_itemId); + wxListItemInternalData *data = wxGetInternalData(this, info.m_itemId); if (! data) { @@ -1205,7 +1214,6 @@ bool wxListCtrl::DeleteItem(long item) // Deletes all items bool wxListCtrl::DeleteAllItems() { - FreeAllInternalData(); return ListView_DeleteAllItems(GetHwnd()) != 0; } @@ -1305,14 +1313,22 @@ long wxListCtrl::FindItem(long start, const wxString& str, bool partial) // Find an item whose data matches this data, starting from the item after 'start' // or the beginning if 'start' is -1. +// NOTE : Lindsay Mathieson - 14-July-2002 +// No longer use ListView_FindItem as the data attribute is now stored +// in a wxListItemInternalData structure refernced by the actual lParam long wxListCtrl::FindItem(long start, long data) { - LV_FINDINFO findInfo; + long idx = start + 1; + long count = GetItemCount(); - findInfo.flags = LVFI_PARAM; - findInfo.lParam = data; + while (idx < count) + { + if (GetItemData(idx) == data) + return idx; + idx++; + }; - return ListView_FindItem(GetHwnd(), (int) start, & findInfo); + return -1; } // Find an item nearest this position in the specified direction, starting from @@ -1772,14 +1788,8 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) case LVN_DELETEITEM: eventType = wxEVT_COMMAND_LIST_DELETE_ITEM; event.m_itemIndex = nmLV->iItem; - // delete the assoicated internal data - { - wxListItemInternalData *data = - GetInternalData(this, nmLV->iItem); - if (data) - delete data; - }; + wxDeleteInternalData(this, nmLV->iItem); break; case LVN_SETDISPINFO: @@ -2070,7 +2080,7 @@ WXLPARAM wxListCtrl::OnCustomDraw(WXLPARAM lParam) wxListItemAttr *attr = IsVirtual() ? OnGetItemAttr(item) - : GetInternalDataAttr(this, item); + : wxGetInternalDataAttr(this, item); if ( !attr ) { @@ -2267,7 +2277,7 @@ void wxListCtrl::RefreshItems(long itemFrom, long itemTo) RefreshRect(rect); } -static wxListItemInternalData *GetInternalData(HWND hwnd, long itemId) +static wxListItemInternalData *wxGetInternalData(HWND hwnd, long itemId) { LV_ITEM it; it.mask = LVIF_PARAM; @@ -2280,20 +2290,34 @@ static wxListItemInternalData *GetInternalData(HWND hwnd, long itemId) return NULL; }; -static wxListItemInternalData *GetInternalData(wxListCtrl *ctl, long itemId) +static wxListItemInternalData *wxGetInternalData(wxListCtrl *ctl, long itemId) { - return GetInternalData((HWND) ctl->GetHWND(), itemId); + return wxGetInternalData((HWND) ctl->GetHWND(), itemId); }; -static wxListItemAttr *GetInternalDataAttr(wxListCtrl *ctl, long itemId) +static wxListItemAttr *wxGetInternalDataAttr(wxListCtrl *ctl, long itemId) { - wxListItemInternalData *data = GetInternalData(ctl, itemId); + wxListItemInternalData *data = wxGetInternalData(ctl, itemId); if (data) return data->attr; else return NULL; }; +static void wxDeleteInternalData(wxListCtrl* ctl, long itemId) +{ + wxListItemInternalData *data = wxGetInternalData(ctl, itemId); + if (data) + { + delete data; + LV_ITEM item; + memset(&item, 0, sizeof(item)); + item.iItem = itemId; + item.mask = LVIF_PARAM; + item.lParam = (LPARAM) 0; + ListView_SetItem((HWND)ctl->GetHWND(), &item); + } +} static void wxConvertFromMSWListItem(HWND hwndListCtrl, wxListItem& info,