]> git.saurik.com Git - wxWidgets.git/commitdiff
Rename wxDataViewMainWindow::OnArrowChar to OnVerticalNavigation.
authorVáclav Slavík <vslavik@fastmail.fm>
Sat, 3 Sep 2011 13:14:25 +0000 (13:14 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Sat, 3 Sep 2011 13:14:25 +0000 (13:14 +0000)
The method handled much more than just arrow characters and it didn't
handle all arrow characters.

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

src/generic/datavgen.cpp

index a69ac5b4bcab692a412e3b57219617e4b6bc910c..a164680f6974c651117d0534da718e3b7102306b 100644 (file)
@@ -545,8 +545,8 @@ public:
     wxBitmap CreateItemBitmap( unsigned int row, int &indent );
 #endif // wxUSE_DRAG_AND_DROP
     void OnPaint( wxPaintEvent &event );
     wxBitmap CreateItemBitmap( unsigned int row, int &indent );
 #endif // wxUSE_DRAG_AND_DROP
     void OnPaint( wxPaintEvent &event );
-    void OnArrowChar(unsigned int newCurrent, const wxKeyEvent& event);
     void OnChar( wxKeyEvent &event );
     void OnChar( wxKeyEvent &event );
+    void OnVerticalNavigation(unsigned int newCurrent, const wxKeyEvent& event);
     void OnMouse( wxMouseEvent &event );
     void OnSetFocus( wxFocusEvent &event );
     void OnKillFocus( wxFocusEvent &event );
     void OnMouse( wxMouseEvent &event );
     void OnSetFocus( wxFocusEvent &event );
     void OnKillFocus( wxFocusEvent &event );
@@ -2552,58 +2552,6 @@ void wxDataViewMainWindow::RefreshRowsAfter( unsigned int firstRow )
     Refresh( true, &rect );
 }
 
     Refresh( true, &rect );
 }
 
-void wxDataViewMainWindow::OnArrowChar(unsigned int newCurrent, const wxKeyEvent& event)
-{
-    wxCHECK_RET( newCurrent < GetRowCount(),
-                wxT("invalid item index in OnArrowChar()") );
-
-    // if there is no selection, we cannot move it anywhere
-    if (!HasCurrentRow())
-        return;
-
-    unsigned int oldCurrent = m_currentRow;
-
-    // in single selection we just ignore Shift as we can't select several
-    // items anyhow
-    if ( event.ShiftDown() && !IsSingleSel() )
-    {
-        RefreshRow( oldCurrent );
-
-        ChangeCurrentRow( newCurrent );
-
-        // select all the items between the old and the new one
-        if ( oldCurrent > newCurrent )
-        {
-            newCurrent = oldCurrent;
-            oldCurrent = m_currentRow;
-        }
-
-        SelectRows( oldCurrent, newCurrent, true );
-        if (oldCurrent!=newCurrent)
-            SendSelectionChangedEvent(GetItemByRow(m_selection[0]));
-    }
-    else // !shift
-    {
-        RefreshRow( oldCurrent );
-
-        // all previously selected items are unselected unless ctrl is held
-        if ( !event.ControlDown() )
-            SelectAllRows(false);
-
-        ChangeCurrentRow( newCurrent );
-
-        if ( !event.ControlDown() )
-        {
-            SelectRow( m_currentRow, true );
-            SendSelectionChangedEvent(GetItemByRow(m_currentRow));
-        }
-        else
-            RefreshRow( m_currentRow );
-    }
-
-    GetOwner()->EnsureVisible( m_currentRow, -1 );
-}
-
 wxRect wxDataViewMainWindow::GetLineRect( unsigned int row ) const
 {
     wxRect rect;
 wxRect wxDataViewMainWindow::GetLineRect( unsigned int row ) const
 {
     wxRect rect;
@@ -3377,12 +3325,12 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
 
         case WXK_UP:
             if ( m_currentRow > 0 )
 
         case WXK_UP:
             if ( m_currentRow > 0 )
-                OnArrowChar( m_currentRow - 1, event );
+                OnVerticalNavigation( m_currentRow - 1, event );
             break;
 
         case WXK_DOWN:
             if ( m_currentRow + 1 < GetRowCount() )
             break;
 
         case WXK_DOWN:
             if ( m_currentRow + 1 < GetRowCount() )
-                OnArrowChar( m_currentRow + 1, event );
+                OnVerticalNavigation( m_currentRow + 1, event );
             break;
         // Add the process for tree expanding/collapsing
         case WXK_LEFT:
             break;
         // Add the process for tree expanding/collapsing
         case WXK_LEFT:
@@ -3436,12 +3384,12 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
         case WXK_END:
         {
             if (!IsEmpty())
         case WXK_END:
         {
             if (!IsEmpty())
-                OnArrowChar( GetRowCount() - 1, event );
+                OnVerticalNavigation( GetRowCount() - 1, event );
             break;
         }
         case WXK_HOME:
             if (!IsEmpty())
             break;
         }
         case WXK_HOME:
             if (!IsEmpty())
-                OnArrowChar( 0, event );
+                OnVerticalNavigation( 0, event );
             break;
 
         case WXK_PAGEUP:
             break;
 
         case WXK_PAGEUP:
@@ -3451,7 +3399,7 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
                 if (index < 0)
                     index = 0;
 
                 if (index < 0)
                     index = 0;
 
-                OnArrowChar( index, event );
+                OnVerticalNavigation( index, event );
             }
             break;
 
             }
             break;
 
@@ -3463,7 +3411,7 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
                 if ( index >= count )
                     index = count - 1;
 
                 if ( index >= count )
                     index = count - 1;
 
-                OnArrowChar( index, event );
+                OnVerticalNavigation( index, event );
             }
             break;
 
             }
             break;
 
@@ -3482,6 +3430,58 @@ void wxDataViewMainWindow::OnChar( wxKeyEvent &event )
     }
 }
 
     }
 }
 
+void wxDataViewMainWindow::OnVerticalNavigation(unsigned int newCurrent, const wxKeyEvent& event)
+{
+    wxCHECK_RET( newCurrent < GetRowCount(),
+                wxT("invalid item index in OnVerticalNavigation()") );
+
+    // if there is no selection, we cannot move it anywhere
+    if (!HasCurrentRow())
+        return;
+
+    unsigned int oldCurrent = m_currentRow;
+
+    // in single selection we just ignore Shift as we can't select several
+    // items anyhow
+    if ( event.ShiftDown() && !IsSingleSel() )
+    {
+        RefreshRow( oldCurrent );
+
+        ChangeCurrentRow( newCurrent );
+
+        // select all the items between the old and the new one
+        if ( oldCurrent > newCurrent )
+        {
+            newCurrent = oldCurrent;
+            oldCurrent = m_currentRow;
+        }
+
+        SelectRows( oldCurrent, newCurrent, true );
+        if (oldCurrent!=newCurrent)
+            SendSelectionChangedEvent(GetItemByRow(m_selection[0]));
+    }
+    else // !shift
+    {
+        RefreshRow( oldCurrent );
+
+        // all previously selected items are unselected unless ctrl is held
+        if ( !event.ControlDown() )
+            SelectAllRows(false);
+
+        ChangeCurrentRow( newCurrent );
+
+        if ( !event.ControlDown() )
+        {
+            SelectRow( m_currentRow, true );
+            SendSelectionChangedEvent(GetItemByRow(m_currentRow));
+        }
+        else
+            RefreshRow( m_currentRow );
+    }
+
+    GetOwner()->EnsureVisible( m_currentRow, -1 );
+}
+
 void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
 {
     if (event.GetEventType() == wxEVT_MOUSEWHEEL)
 void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
 {
     if (event.GetEventType() == wxEVT_MOUSEWHEEL)