From e5d3d8ad459facd397afef9f1889f932c8a2f474 Mon Sep 17 00:00:00 2001 From: Kevin Ollivier Date: Fri, 5 Jan 2007 19:45:38 +0000 Subject: [PATCH] Apply patch #1626802, which fixes GetNextItem to return -1 instead of 0 when an item can't be found, and add support for wxLIST_NEXT_ABOVE, wxLIST_NEXT_BELOW, and wxLIST_STATE_DONTCARE. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44100 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/listctrl_mac.cpp | 40 ++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/mac/carbon/listctrl_mac.cpp b/src/mac/carbon/listctrl_mac.cpp index 9cfef3b8d6..b614cf3877 100644 --- a/src/mac/carbon/listctrl_mac.cpp +++ b/src/mac/carbon/listctrl_mac.cpp @@ -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; } -- 2.45.2