Refactored my last change a bit and applied it in another place too.

Added the wx prefix to the other static funcitons for consistency.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@15904 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2002-06-21 03:03:37 +00:00
parent e4ed5de1fe
commit 6149de710a

View File

@@ -171,9 +171,10 @@ public:
}; };
// Get the internal data structure // Get the internal data structure
static wxListItemInternalData *GetInternalData(HWND hwnd, long itemId); static wxListItemInternalData *wxGetInternalData(HWND hwnd, long itemId);
static wxListItemInternalData *GetInternalData(wxListCtrl *ctl, long itemId); static wxListItemInternalData *wxGetInternalData(wxListCtrl *ctl, long itemId);
static wxListItemAttr *GetInternalDataAttr(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; int i = 0;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ wxDeleteInternalData(this, 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);
}
}
m_AnyInternalData = FALSE; m_AnyInternalData = FALSE;
} }
} }
@@ -732,7 +722,7 @@ bool wxListCtrl::SetItem(wxListItem& info)
{ {
// get internal item data // get internal item data
// perhaps a cache here ? // perhaps a cache here ?
wxListItemInternalData *data = GetInternalData(this, info.m_itemId); wxListItemInternalData *data = wxGetInternalData(this, info.m_itemId);
if (! data) if (! data)
{ {
@@ -1205,7 +1195,6 @@ bool wxListCtrl::DeleteItem(long item)
// Deletes all items // Deletes all items
bool wxListCtrl::DeleteAllItems() bool wxListCtrl::DeleteAllItems()
{ {
FreeAllInternalData();
return ListView_DeleteAllItems(GetHwnd()) != 0; return ListView_DeleteAllItems(GetHwnd()) != 0;
} }
@@ -1772,14 +1761,8 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
case LVN_DELETEITEM: case LVN_DELETEITEM:
eventType = wxEVT_COMMAND_LIST_DELETE_ITEM; eventType = wxEVT_COMMAND_LIST_DELETE_ITEM;
event.m_itemIndex = nmLV->iItem; event.m_itemIndex = nmLV->iItem;
// delete the assoicated internal data // delete the assoicated internal data
{ wxDeleteInternalData(this, nmLV->iItem);
wxListItemInternalData *data =
GetInternalData(this, nmLV->iItem);
if (data)
delete data;
};
break; break;
case LVN_SETDISPINFO: case LVN_SETDISPINFO:
@@ -2070,7 +2053,7 @@ WXLPARAM wxListCtrl::OnCustomDraw(WXLPARAM lParam)
wxListItemAttr *attr = wxListItemAttr *attr =
IsVirtual() ? OnGetItemAttr(item) IsVirtual() ? OnGetItemAttr(item)
: GetInternalDataAttr(this, item); : wxGetInternalDataAttr(this, item);
if ( !attr ) if ( !attr )
{ {
@@ -2267,7 +2250,7 @@ void wxListCtrl::RefreshItems(long itemFrom, long itemTo)
RefreshRect(rect); RefreshRect(rect);
} }
static wxListItemInternalData *GetInternalData(HWND hwnd, long itemId) static wxListItemInternalData *wxGetInternalData(HWND hwnd, long itemId)
{ {
LV_ITEM it; LV_ITEM it;
it.mask = LVIF_PARAM; it.mask = LVIF_PARAM;
@@ -2280,20 +2263,34 @@ static wxListItemInternalData *GetInternalData(HWND hwnd, long itemId)
return NULL; 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) if (data)
return data->attr; return data->attr;
else else
return NULL; 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, static void wxConvertFromMSWListItem(HWND hwndListCtrl,
wxListItem& info, wxListItem& info,