+#ifndef LVHT_ONITEM
+ #define LVHT_ONITEM \
+ (LVHT_ONITEMICON | LVHT_ONITEMLABEL | LVHT_ONITEMSTATEICON)
+#endif
+
+#ifndef LVM_SETEXTENDEDLISTVIEWSTYLE
+ #define LVM_SETEXTENDEDLISTVIEWSTYLE (0x1000 + 54)
+#endif
+
+#ifndef LVS_EX_FULLROWSELECT
+ #define LVS_EX_FULLROWSELECT 0x00000020
+#endif
+
+#ifndef LVS_OWNERDATA
+ #define LVS_OWNERDATA 0x1000
+#endif
+
+#ifndef LVM_FIRST
+ #define LVM_FIRST 0x1000
+#endif
+
+#ifndef HDM_FIRST
+ #define HDM_FIRST 0x1200
+#endif
+
+// mingw32/cygwin don't have declarations for comctl32.dll 4.70+ stuff
+#ifndef NM_CACHEHINT
+ typedef struct tagNMLVCACHEHINT
+ {
+ NMHDR hdr;
+ int iFrom;
+ int iTo;
+ } NMLVCACHEHINT;
+
+ #define NM_CACHEHINT NMLVCACHEHINT
+#endif
+
+#ifndef LVN_ODCACHEHINT
+ #define LVN_ODCACHEHINT (-113)
+#endif
+
+#ifndef ListView_GetHeader
+ #define ListView_GetHeader(w) (HWND)SendMessage((w),LVM_GETHEADER,0,0)
+#endif
+
+#ifndef LVM_GETHEADER
+ #define LVM_GETHEADER (LVM_FIRST+31)
+#endif
+
+#ifndef Header_GetItemRect
+ #define Header_GetItemRect(w,i,r) \
+ (BOOL)SendMessage((w),HDM_GETITEMRECT,(WPARAM)(i),(LPARAM)(r))
+#endif
+
+#ifndef HDM_GETITEMRECT
+ #define HDM_GETITEMRECT (HDM_FIRST+7)
+#endif
+
+#ifndef LVCF_IMAGE
+ #define LVCF_IMAGE 0x0010
+#endif
+
+#ifndef LVCFMT_BITMAP_ON_RIGHT
+ #define LVCFMT_BITMAP_ON_RIGHT 0x1000
+#endif
+
+#if defined(__GNUWIN32__) && !defined(LV_ITEM) \
+ && !wxCHECK_W32API_VERSION( 0, 5 )
+typedef struct _LVITEMW {
+ UINT mask;
+ int iItem;
+ int iSubItem;
+ UINT state;
+ UINT stateMask;
+ LPWSTR pszText;
+ int cchTextMax;
+ int iImage;
+ LPARAM lParam;
+#if (_WIN32_IE >= 0x0300)
+ int iIndent;
+#endif
+} LV_ITEMW;
+typedef LV_ITEM LV_ITEMA;
+#endif
+
+#if defined(__GNUWIN32__) && !wxCHECK_W32API_VERSION( 0, 5 )
+#ifndef LV_DISPINFOA
+typedef struct tagNMLVDISPINFOA {
+ NMHDR hdr;
+ LV_ITEMA item;
+} NMLVDISPINFOA, FAR *LPNMLVDISPINFOA;
+#define _LV_DISPINFOA tagNMLVDISPINFOA
+#define LV_DISPINFOA NMLVDISPINFOA
+#endif
+#ifndef LV_DISPINFOW
+typedef struct tagNMLVDISPINFOW {
+ NMHDR hdr;
+ LV_ITEMW item;
+} NMLVDISPINFOW, FAR *LPNMLVDISPINFOW;
+#define _LV_DISPINFOW tagNMLVDISPINFOW
+#define LV_DISPINFOW NMLVDISPINFOW
+#endif
+#endif
+
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+// 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
+ wxLV_ITEM(LV_ITEMW &item)
+ {
+ m_item = new LV_ITEM((LV_ITEM&)item);
+ if ( (item.mask & LVIF_TEXT) && item.pszText )
+ {
+ m_buf = new wxWC2WXbuf(wxConvLocal.cWC2WX(item.pszText));
+ m_item->pszText = (wxChar*)m_buf->data();
+ }
+ else
+ m_buf = NULL;
+ }
+ wxLV_ITEM(LV_ITEMA &item) : m_buf(NULL), m_item(&item) {}
+private:
+ wxWC2WXbuf *m_buf;