]> git.saurik.com Git - wxWidgets.git/commitdiff
Simpler version of [ 1604590 ] wxListCtrl::FindItem & wxString
authorRobert Roebling <robert@roebling.de>
Wed, 29 Nov 2006 21:10:21 +0000 (21:10 +0000)
committerRobert Roebling <robert@roebling.de>
Wed, 29 Nov 2006 21:10:21 +0000 (21:10 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43719 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/listctrl.tex
src/generic/listctrl.cpp

index 05aa3c6578afedb8ef25d0f68415a993dfd5a10d..538cc1942a0ad7e7539aa20991496aa995b43a38 100644 (file)
@@ -253,7 +253,9 @@ Ensures this item is visible.
 \func{long}{FindItem}{\param{long }{start}, \param{const wxString\& }{str}, \param{const bool }{partial = false}}
 
 Find an item whose label matches this string, starting from {\it start} or
-the beginning if {\it start} is -1.
+the beginning if {\it start} is -1. The string comparison is case
+insensitive. If {\it partial} is true then this method will look for
+items which begin with {\it str}.
 
 \func{long}{FindItem}{\param{long }{start}, \param{long }{data}}
 
index 40a79102d5a9defeaaacebcd9cf5965bfe4a9fc6..152e4400369b8bb2485a13a768c18f988a6425ba 100644 (file)
@@ -4501,10 +4501,13 @@ void wxListMainWindow::EnsureVisible( long index )
     MoveToItem((size_t)index);
 }
 
-long wxListMainWindow::FindItem(long start, const wxString& str, bool WXUNUSED(partial) )
+long wxListMainWindow::FindItem(long start, const wxString& str, bool partial )
 {
+    if (str.empty())
+        return wxNOT_FOUND;
+        
     long pos = start;
-    wxString tmp = str;
+    wxString str_upper = str.Upper();
     if (pos < 0)
         pos = 0;
 
@@ -4512,8 +4515,17 @@ long wxListMainWindow::FindItem(long start, const wxString& str, bool WXUNUSED(p
     for ( size_t i = (size_t)pos; i < count; i++ )
     {
         wxListLineData *line = GetLine(i);
-        if ( line->GetText(0) == tmp )
-            return i;
+        wxString line_upper = line->GetText(0).Upper();
+        if (!partial)
+        {
+            if (line_upper == str_upper )
+                return i;
+        }
+        else
+        {
+            if (line_upper.find(str_upper) == 0)
+                return i;
+        }
     }
 
     return wxNOT_FOUND;