]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
* Added serialization code to the repository
[wxWidgets.git] / src / generic / listctrl.cpp
index 8e158cfaedee7cbee9940051238fbd2a9a40f71f..67d086dc724220d187be56c59f71ef23c9e23e69 100644 (file)
@@ -1098,15 +1098,67 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
   {
     m_usedKeys = FALSE;
     wxListLineData *oldCurrent = m_current;
-    m_current = line;
-    if (!event.ShiftDown() || (m_mode & wxLC_SINGLE_SEL)) HilightAll( FALSE );
-    m_current->ReverseHilight();
-    RefreshLine( m_current );
+    if (m_mode & wxLC_SINGLE_SEL)
+    {
+      m_current = line;
+      HilightAll( FALSE );
+      m_current->ReverseHilight();
+      RefreshLine( m_current );
+    }
+    else
+    {
+      if (event.ShiftDown())
+      {
+        m_current = line;
+        m_current->ReverseHilight();
+        RefreshLine( m_current );
+      }
+      else if (event.ControlDown())
+      {
+        m_current = line;
+        int numOfCurrent = -1;
+        node = m_lines.First();
+        while (node)
+        {
+          wxListLineData *test_line = (wxListLineData*)node->Data();
+         numOfCurrent++;
+         if (test_line == oldCurrent) break;
+          node = node->Next();
+        };
+        int numOfLine = -1;
+        node = m_lines.First();
+        while (node)
+        {
+          wxListLineData *test_line = (wxListLineData*)node->Data();
+         numOfLine++;
+         if (test_line == line) break;
+          node = node->Next();
+        };
+       
+       if (numOfLine < numOfCurrent) 
+         { int i = numOfLine; numOfLine = numOfCurrent; numOfCurrent = i; }
+       wxNode *node = m_lines.Nth( numOfCurrent );
+       for (int i = 0; i <= numOfLine-numOfCurrent; i++)
+       {
+         wxListLineData *test_line= (wxListLineData*)node->Data();
+         test_line->Hilight(TRUE);
+         RefreshLine( test_line );
+         node = node->Next();
+       }
+      }
+      else 
+      {
+        m_current = line;
+        HilightAll( FALSE );
+        m_current->ReverseHilight();
+        RefreshLine( m_current );
+      }
+    }
     if (m_current != oldCurrent)
     {
+      RefreshLine( oldCurrent );
       UnfocusLine( oldCurrent );
       FocusLine( m_current );
-      RefreshLine( oldCurrent );
     };
     m_lastOnSame = (m_current == oldCurrent);
     return;
@@ -1147,15 +1199,15 @@ void wxListMainWindow::MoveToFocus( void )
 
 void wxListMainWindow::OnArrowChar( wxListLineData *newCurrent, bool shiftDown )
 {
-  UnfocusLine( m_current );
   if ((m_mode & wxLC_SINGLE_SEL) || (m_usedKeys == FALSE)) m_current->Hilight( FALSE );
   wxListLineData *oldCurrent = m_current;
   m_current = newCurrent;
   MoveToFocus();
   if (shiftDown || (m_mode & wxLC_SINGLE_SEL)) m_current->Hilight( TRUE );
-  FocusLine( m_current );
   RefreshLine( m_current );
   RefreshLine( oldCurrent );
+  FocusLine( m_current );
+  UnfocusLine( oldCurrent );
 };
 
 void wxListMainWindow::OnChar( wxKeyEvent &event )
@@ -1248,19 +1300,25 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
       };
       break;
     };
+    case WXK_SPACE:
+    {
+      m_current->ReverseHilight();
+      RefreshLine( m_current );
+    };
+    break;
     case WXK_INSERT:
     {
       if (!(m_mode & wxLC_SINGLE_SEL))
       {
         wxListLineData *oldCurrent = m_current;
-        UnfocusLine( m_current );
         m_current->ReverseHilight();
         wxNode *node = m_lines.Member( m_current )->Next();       
         if (node) m_current = (wxListLineData*)node->Data();
         MoveToFocus();
-        FocusLine( m_current );
-       RefreshLine( m_current );
        RefreshLine( oldCurrent );
+       RefreshLine( m_current );
+        UnfocusLine( oldCurrent );
+        FocusLine( m_current );
       };
     };
     break;
@@ -1755,6 +1813,7 @@ void wxListMainWindow::DeleteItem( long index )
   if (node)
   {
     wxListLineData *line = (wxListLineData*)node->Data();
+    if (m_current == line) m_current = NULL;
     DeleteLine( line );
     m_lines.DeleteNode( node );
   };
@@ -1770,6 +1829,7 @@ void wxListMainWindow::DeleteColumn( int col )
 void wxListMainWindow::DeleteAllItems( void )
 {
   m_dirty = TRUE;
+  m_current = NULL;
   wxNode *node = m_lines.First();
   while (node)
   {
@@ -1778,12 +1838,12 @@ void wxListMainWindow::DeleteAllItems( void )
     node = node->Next();
   };
   m_lines.Clear();
-  m_current = NULL;
 };
 
 void wxListMainWindow::DeleteEverything( void )
 {
   m_dirty = TRUE;
+  m_current = NULL;
   wxNode *node = m_lines.First();
   while (node)
   {