]> git.saurik.com Git - wxWidgets.git/commitdiff
Blind fixes for FindItem() for the native OS X
authorRobert Roebling <robert@roebling.de>
Wed, 29 Nov 2006 21:34:17 +0000 (21:34 +0000)
committerRobert Roebling <robert@roebling.de>
Wed, 29 Nov 2006 21:34:17 +0000 (21:34 +0000)
    version of wxListCtrk.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43720 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/listctrl_mac.cpp

index 52cf2e32b23e8b628d139de385e31e54500a2670..285376b8d9e5e8acd00660227aefb56d926a5b1c 100644 (file)
@@ -1731,7 +1731,31 @@ long wxListCtrl::FindItem(long start, const wxString& str, bool partial)
     if (m_genericImpl)
         return m_genericImpl->FindItem(start, str, partial);
 
-    return -1;
+    wxString str_upper = str.Upper();
+
+    long idx = start;
+    if (idx < 0)
+        idx = 0;
+    long count = GetItemCount();
+
+    while (idx < count)
+    {
+        wxString line_upper = GetItemText(idx).Upper();
+        if (!partial)
+        {
+            if (line_upper == str_upper )
+                return idx;
+        }
+        else
+        {
+            if (line_upper.find(str_upper) == 0)
+                return idx;
+        }
+        
+        idx++;
+    };
+
+    return wxNOT_FOUND;
 }
 
 // Find an item whose data matches this data, starting from the item after 'start'
@@ -1741,7 +1765,9 @@ long wxListCtrl::FindItem(long start, long data)
     if (m_genericImpl)
         return m_genericImpl->FindItem(start, data);
 
-    long  idx = start + 1;
+    long idx = start;
+    if (idx < 0)
+        idx = 0;
     long count = GetItemCount();
 
     while (idx < count)
@@ -1751,7 +1777,7 @@ long wxListCtrl::FindItem(long start, long data)
         idx++;
     };
 
-    return -1;
+    return wxNOT_FOUND;
 }
 
 // Find an item nearest this position in the specified direction, starting from