From 88b497c1291889313a82541267dfeac5ab13d06b Mon Sep 17 00:00:00 2001
From: Kevin Ollivier <kevino@theolliviers.com>
Date: Sat, 2 May 2009 18:59:28 +0000
Subject: [PATCH] (Forward port from 2.8) Allow m_current to be used for the
 focused item, and reset the scroll position when removing all items from the
 data browser control.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60486 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 src/osx/carbon/listctrl_mac.cpp | 10 +++++++++-
 src/osx/carbon/utils.cpp        |  1 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/osx/carbon/listctrl_mac.cpp b/src/osx/carbon/listctrl_mac.cpp
index 1f0b594c94..40b6d36198 100644
--- a/src/osx/carbon/listctrl_mac.cpp
+++ b/src/osx/carbon/listctrl_mac.cpp
@@ -616,7 +616,8 @@ void wxListCtrl::OnLeftDown(wxMouseEvent& event)
 
 void wxListCtrl::OnDblClick(wxMouseEvent& event)
 {
-    m_current = -1;
+    if ( m_renameTimer->IsRunning() )
+        m_renameTimer->Stop();
     event.Skip();
 }
 
@@ -1656,6 +1657,9 @@ long wxListCtrl::GetNextItem(long item, int geom, int state) const
                 if ( !IsVirtual() )
                     id = (DataBrowserItemID)m_dbImpl->GetItemFromLine(line);
 
+                if ( (state & wxLIST_STATE_FOCUSED) && (m_current == line)) 
+                    return line;
+
                 if ( (state == wxLIST_STATE_DONTCARE ) )
                     return line;
 
@@ -1676,6 +1680,9 @@ long wxListCtrl::GetNextItem(long item, int geom, int state) const
                 if ( !IsVirtual() )
                     id = (DataBrowserItemID)m_dbImpl->GetItemFromLine(line);
 
+                if ( (state & wxLIST_STATE_FOCUSED) && (m_current == line)) 
+                    return line;
+
                 if ( (state == wxLIST_STATE_DONTCARE ) )
                     return line;
 
@@ -1787,6 +1794,7 @@ bool wxListCtrl::DeleteItem(long item)
 // Deletes all items
 bool wxListCtrl::DeleteAllItems()
 {
+    m_current = -1;
     if (m_genericImpl)
         return m_genericImpl->DeleteAllItems();
 
diff --git a/src/osx/carbon/utils.cpp b/src/osx/carbon/utils.cpp
index 36b792f4f7..dd44627d41 100644
--- a/src/osx/carbon/utils.cpp
+++ b/src/osx/carbon/utils.cpp
@@ -971,6 +971,7 @@ void wxMacDataItemBrowserControl::RemoveItems(wxMacDataItem *container, wxArrayM
 
 void wxMacDataItemBrowserControl::RemoveAllItems(wxMacDataItem *container)
 {
+    SetScrollPosition(0, 0);
     OSStatus err = wxMacDataBrowserControl::RemoveItems( (DataBrowserItemID)container, 0 , NULL , kDataBrowserItemNoProperty );
     verify_noerr( err );
 }
-- 
2.47.2