]> git.saurik.com Git - wxWidgets.git/commitdiff
Apply patch #1626802, which fixes GetNextItem to return -1 instead of 0 when an item...
authorKevin Ollivier <kevino@theolliviers.com>
Fri, 5 Jan 2007 19:45:38 +0000 (19:45 +0000)
committerKevin Ollivier <kevino@theolliviers.com>
Fri, 5 Jan 2007 19:45:38 +0000 (19:45 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44100 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/listctrl_mac.cpp

index 9cfef3b8d6445fb27d6c4faa8711a3ed8e71b8eb..b614cf38773ff450f10165538fd459bff18b0f5d 100644 (file)
@@ -1560,19 +1560,43 @@ long wxListCtrl::GetNextItem(long item, int geom, int state) const
     if (m_genericImpl)
         return m_genericImpl->GetNextItem(item, geom, state);
 
-    if (m_dbImpl && geom == wxLIST_NEXT_ALL && state == wxLIST_STATE_SELECTED )
+    // TODO: implement all geometry and state options?
+    if ( m_dbImpl )
     {
-        long count = m_dbImpl->MacGetCount() ;
-        for ( long line = item + 1 ; line < count; line++ )
+        if ( geom == wxLIST_NEXT_ALL || geom == wxLIST_NEXT_BELOW )
         {
-            wxMacDataItem* id = m_dbImpl->GetItemFromLine(line);
-            if ( m_dbImpl->IsItemSelected(id ) )
-                return line;
+            long count = m_dbImpl->MacGetCount() ;
+            for ( long line = item + 1 ; line < count; line++ )
+            {
+                wxMacDataItem* id = m_dbImpl->GetItemFromLine(line);
+                
+                if ( (state == wxLIST_STATE_DONTCARE ) )
+                    return line;
+                
+                if ( (state & wxLIST_STATE_SELECTED) && m_dbImpl->IsItemSelected( id ) )
+                    return line;
+            }
+        }
+        else if ( geom == wxLIST_NEXT_ABOVE )
+        {
+            int item2 = item;
+            if ( item2 == -1 )
+                item2 = m_dbImpl->MacGetCount();
+                
+            for ( long line = item2 - 1 ; line >= 0; line-- )
+            {
+                wxMacDataItem* id = m_dbImpl->GetItemFromLine(line);
+                
+                if ( (state == wxLIST_STATE_DONTCARE ) )
+                    return line;
+                
+                if ( (state & wxLIST_STATE_SELECTED) && m_dbImpl->IsItemSelected( id ) )
+                    return line;
+            }
         }
-        return -1;
     }
 
-    return 0;
+    return -1;
 }