+// convert our state and mask flags to LV_ITEM constants
+static void wxConvertToMSWFlags(long state, long mask, LV_ITEM& lvItem);
+
+// convert wxListItem to LV_ITEM
+static void wxConvertToMSWListItem(const wxListCtrl *ctrl,
+ const wxListItem& info, LV_ITEM& lvItem);
+
+// convert LV_ITEM to wxListItem
+static void wxConvertFromMSWListItem(HWND hwndListCtrl,
+ wxListItem& info,
+ /* const */ LV_ITEM& lvItem);
+
+// convert our wxListItem to LV_COLUMN
+static void wxConvertToMSWListCol(int col, const wxListItem& item,
+ LV_COLUMN& lvCol);
+
+// ----------------------------------------------------------------------------
+// private helper classes
+// ----------------------------------------------------------------------------
+
+// We have to handle both fooW and fooA notifications in several cases
+// because of broken commctl.dll and/or unicows.dll. This class is used to
+// convert LV_ITEMA and LV_ITEMW to LV_ITEM (which is either LV_ITEMA or
+// LV_ITEMW depending on wxUSE_UNICODE setting), so that it can be processed
+// by wxConvertToMSWListItem().
+class wxLV_ITEM
+{
+public:
+ ~wxLV_ITEM() { delete m_buf; }
+ operator LV_ITEM&() const { return *m_item; }
+
+#if wxUSE_UNICODE
+ wxLV_ITEM(LV_ITEMW &item) : m_buf(NULL), m_item(&item) {}
+ wxLV_ITEM(LV_ITEMA &item)
+ {
+ m_item = new LV_ITEM((LV_ITEM&)item);
+ if ( (item.mask & LVIF_TEXT) && item.pszText )
+ {
+ m_buf = new wxMB2WXbuf(wxConvLocal.cMB2WX(item.pszText));
+ m_item->pszText = (wxChar*)m_buf->data();
+ }
+ else
+ m_buf = NULL;
+ }
+private:
+ wxMB2WXbuf *m_buf;
+
+#else // !wxUSE_UNICODE
+ wxLV_ITEM(LV_ITEMW &item)
+ {
+ m_item = new LV_ITEM((LV_ITEM&)item);
+
+ // the code below doesn't compile without wxUSE_WCHAR_T and as I don't
+ // know if it's useful to have it at all (do we ever get Unicode
+ // notifications in ANSI mode? I don't think so...) I'm not going to
+ // write alternative implementation right now
+ //
+ // but if it is indeed used, we should simply directly use
+ // ::WideCharToMultiByte() here
+#if wxUSE_WCHAR_T
+ if ( (item.mask & LVIF_TEXT) && item.pszText )
+ {
+ m_buf = new wxWC2WXbuf(wxConvLocal.cWC2WX(item.pszText));
+ m_item->pszText = (wxChar*)m_buf->data();
+ }
+ else
+#endif // wxUSE_WCHAR_T
+ m_buf = NULL;
+ }
+ wxLV_ITEM(LV_ITEMA &item) : m_buf(NULL), m_item(&item) {}
+private:
+ wxWC2WXbuf *m_buf;
+#endif // wxUSE_UNICODE/!wxUSE_UNICODE
+
+ LV_ITEM *m_item;
+
+ DECLARE_NO_COPY_CLASS(wxLV_ITEM)
+};
+
+///////////////////////////////////////////////////////
+// Problem:
+// The MSW version had problems with SetTextColour() et
+// al as the wxListItemAttr's were stored keyed on the
+// item index. If a item was inserted anywhere but the end
+// of the list the the text attributes (colour etc) for
+// the following items were out of sync.
+//
+// Solution:
+// Under MSW the only way to associate data with a List
+// item independant of its position in the list is to
+// store a pointer to it in its lParam attribute. However
+// user programs are already using this (via the
+// SetItemData() GetItemData() calls).
+//
+// However what we can do is store a pointer to a
+// structure which contains the attributes we want *and*
+// a lParam for the users data, e.g.
+//
+// class wxListItemInternalData
+// {
+// public:
+// wxListItemAttr *attr;
+// long lParam; // user data
+// };
+//
+// To conserve memory, a wxListItemInternalData is
+// only allocated for a LV_ITEM if text attributes or
+// user data(lparam) are being set.
+
+
+// class wxListItemInternalData
+class wxListItemInternalData
+{
+public:
+ wxListItemAttr *attr;
+ LPARAM lParam; // user data
+
+ wxListItemInternalData() : attr(NULL), lParam(0) {}
+ ~wxListItemInternalData()
+ {
+ if (attr)
+ delete attr;
+ };
+
+ DECLARE_NO_COPY_CLASS(wxListItemInternalData)
+};
+
+// Get the internal data structure
+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);
+