]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
Fixed a bug so wxLC_VRULES works by itself.
[wxWidgets.git] / src / generic / listctrl.cpp
index e4fc11143e1ee8011ff2ac0df0f0c8c64e08766b..5609fdd9973ee6417e57353be534e64d6cdaecf6 100644 (file)
@@ -9,9 +9,10 @@
 /////////////////////////////////////////////////////////////////////////////
 
 /*
 /////////////////////////////////////////////////////////////////////////////
 
 /*
-   TODO for better virtual list control support:
+   TODO
 
 
-   1. we need to implement searching/sorting somehow
+   1. we need to implement searching/sorting for virtual controls somehow
+   2. when changing selection the lines are refreshed twice
  */
 
 // ============================================================================
  */
 
 // ============================================================================
@@ -3172,11 +3173,16 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
                 le.m_itemIndex = m_current;
                 GetLine(m_current)->GetItem( 0, le.m_item );
                 GetParent()->GetEventHandler()->ProcessEvent( le );
                 le.m_itemIndex = m_current;
                 GetLine(m_current)->GetItem( 0, le.m_item );
                 GetParent()->GetEventHandler()->ProcessEvent( le );
+
+                if ( IsHighlighted(m_current) )
+                {
+                    // don't unselect the item in single selection mode
+                    break;
+                }
+                //else: select it in ReverseHighlight() below if unselected
             }
             }
-            else
-            {
-                ReverseHighlight(m_current);
-            }
+
+            ReverseHighlight(m_current);
             break;
 
         case WXK_RETURN:
             break;
 
         case WXK_RETURN:
@@ -3497,8 +3503,9 @@ void wxListMainWindow::SetItemState( long litem, long state, long stateMask )
                   _T("invalid list ctrl item index in SetItem") );
 
     size_t oldCurrent = m_current;
                   _T("invalid list ctrl item index in SetItem") );
 
     size_t oldCurrent = m_current;
-    size_t item = (size_t)litem;    // sdafe because of the check above
+    size_t item = (size_t)litem;    // safe because of the check above
 
 
+    // do we need to change the focus?
     if ( stateMask & wxLIST_STATE_FOCUSED )
     {
         if ( state & wxLIST_STATE_FOCUSED )
     if ( stateMask & wxLIST_STATE_FOCUSED )
     {
         if ( state & wxLIST_STATE_FOCUSED )
@@ -3510,9 +3517,13 @@ void wxListMainWindow::SetItemState( long litem, long state, long stateMask )
                 m_current = item;
                 OnFocusLine( m_current );
 
                 m_current = item;
                 OnFocusLine( m_current );
 
-                if ( IsSingleSel() && (oldCurrent != (size_t)-1) )
+                if ( oldCurrent != (size_t)-1 )
                 {
                 {
-                    HighlightLine(oldCurrent, FALSE);
+                    if ( IsSingleSel() )
+                    {
+                        HighlightLine(oldCurrent, FALSE);
+                    }
+
                     RefreshLine(oldCurrent);
                 }
 
                     RefreshLine(oldCurrent);
                 }
 
@@ -3526,10 +3537,13 @@ void wxListMainWindow::SetItemState( long litem, long state, long stateMask )
             {
                 OnUnfocusLine( m_current );
                 m_current = (size_t)-1;
             {
                 OnUnfocusLine( m_current );
                 m_current = (size_t)-1;
+
+                RefreshLine( oldCurrent );
             }
         }
     }
 
             }
         }
     }
 
+    // do we need to change the selection state?
     if ( stateMask & wxLIST_STATE_SELECTED )
     {
         bool on = (state & wxLIST_STATE_SELECTED) != 0;
     if ( stateMask & wxLIST_STATE_SELECTED )
     {
         bool on = (state & wxLIST_STATE_SELECTED) != 0;
@@ -3790,7 +3804,7 @@ void wxListMainWindow::RefreshAll()
     Refresh();
 
     wxListHeaderWindow *headerWin = GetListCtrl()->m_headerWin;
     Refresh();
 
     wxListHeaderWindow *headerWin = GetListCtrl()->m_headerWin;
-    if ( headerWin )
+    if ( headerWin && headerWin->m_dirty )
     {
         headerWin->m_dirty = FALSE;
         headerWin->Refresh();
     {
         headerWin->m_dirty = FALSE;
         headerWin->Refresh();
@@ -3890,6 +3904,7 @@ void wxListMainWindow::DeleteItem( long lindex )
         m_lines.RemoveAt( index );
     }
 
         m_lines.RemoveAt( index );
     }
 
+    // we need to refresh the (vert) scrollbar as the number of items changed
     m_dirty = TRUE;
 
     SendNotify( index, wxEVT_COMMAND_LIST_DELETE_ITEM );
     m_dirty = TRUE;
 
     SendNotify( index, wxEVT_COMMAND_LIST_DELETE_ITEM );