]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/listctrl.cpp
added Freeze/Thaw implementation for Windows
[wxWidgets.git] / src / msw / listctrl.cpp
index 73a2997beafabda9075187f9da4671a425e4cd6d..52f37500cb4214c9cb82dcae54a5475d097c5a75 100644 (file)
     #define LVS_OWNERDATA 0x1000
 #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
+
 // ----------------------------------------------------------------------------
 // private functions
 // ----------------------------------------------------------------------------
@@ -104,6 +120,7 @@ DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_COL_CLICK)
 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK)
 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK)
 DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_ITEM_ACTIVATED)
+DEFINE_EVENT_TYPE(wxEVT_COMMAND_LIST_CACHE_HINT)
 
 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl, wxControl)
 IMPLEMENT_DYNAMIC_CLASS(wxListItem, wxObject)
@@ -1615,6 +1632,30 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
             return TRUE;
 #endif // _WIN32_IE >= 0x300
 
+        case LVN_ODCACHEHINT:
+            {
+                const NM_CACHEHINT *cacheHint = (NM_CACHEHINT *)lParam;
+
+                eventType = wxEVT_COMMAND_LIST_CACHE_HINT;
+
+                // we get some really stupid cache hints like ones for items in
+                // range 0..0 for an empty control or, after deleting an item,
+                // for items in invalid range - filter this garbage out
+                if ( cacheHint->iFrom < cacheHint->iTo )
+                {
+                    event.m_oldItemIndex = cacheHint->iFrom;
+
+                    long iMax = GetItemCount();
+                    event.m_itemIndex = cacheHint->iTo < iMax ? cacheHint->iTo
+                                                              : iMax - 1;
+                }
+                else
+                {
+                    return FALSE;
+                }
+            }
+            break;
+
         case LVN_GETDISPINFO:
             if ( IsVirtual() )
             {
@@ -1670,10 +1711,10 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
             return TRUE;
 
         case LVN_ENDLABELEDIT:
-            {
-                *result = event.IsAllowed();
-                return TRUE;
-            }
+            // logic here is inversed compared to all the other messages
+            *result = event.IsAllowed();
+
+            return TRUE;
     }
 
     *result = !event.IsAllowed();