]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
Bring back double border
[wxWidgets.git] / src / generic / listctrl.cpp
index f5dfcd66b0d2b9c0917d833ea4aaa7effe26f89d..67562c04aa3c3c3458f30ae4c3c9e11520db88f2 100644 (file)
@@ -2160,16 +2160,17 @@ bool wxListTextCtrlWrapper::AcceptChanges()
 {
     const wxString value = m_text->GetValue();
 
-    if ( value == m_startValue )
-        // nothing changed, always accept
-        return true;
-
+    // notice that we should always call OnRenameAccept() to generate the "end
+    // label editing" event, even if the user hasn't really changed anything
     if ( !m_owner->OnRenameAccept(m_itemEdited, value) )
+    {
         // vetoed by the user
         return false;
+    }
 
-    // accepted, do rename the item
-    m_owner->SetItemText(m_itemEdited, value);
+    // accepted, do rename the item (unless nothing changed)
+    if ( value != m_startValue )
+        m_owner->SetItemText(m_itemEdited, value);
 
     return true;
 }
@@ -2462,7 +2463,7 @@ wxRect wxListMainWindow::GetLineLabelRect(size_t line) const
             image_x = 3 + ix + IMAGE_MARGIN_IN_REPORT_MODE;
         }
     }
-    
+
     wxRect rect;
     rect.x = HEADER_OFFSET_X;
     rect.y = GetLineY(line);
@@ -3161,7 +3162,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
                     wxRect label = GetLineLabelRect( current );
                     if (label.Contains( x, y ))
                         m_renameTimer->Start( 250, true );
-                        
+
                 }
                 else
                     m_renameTimer->Start( 250, true );
@@ -3332,7 +3333,8 @@ void wxListMainWindow::OnArrowChar(size_t newCurrent, const wxKeyEvent& event)
     else // !shift
     {
         // all previously selected items are unselected unless ctrl is held
-        if ( !event.ControlDown() )
+        // in a multiselection control
+        if ( !event.ControlDown() || IsSingleSel() )
             HighlightAll(false);
 
         ChangeCurrent(newCurrent);
@@ -3340,10 +3342,9 @@ void wxListMainWindow::OnArrowChar(size_t newCurrent, const wxKeyEvent& event)
         // refresh the old focus to remove it
         RefreshLine( oldCurrent );
 
-        if ( !event.ControlDown() )
-        {
+        // in single selection mode we must always have a selected item
+        if ( !event.ControlDown() || IsSingleSel() )
             HighlightLine( m_current, true );
-        }
     }
 
     RefreshLine( m_current );
@@ -3523,17 +3524,19 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
         case WXK_SPACE:
             if ( IsSingleSel() )
             {
-                SendNotify( m_current, wxEVT_COMMAND_LIST_ITEM_ACTIVATED );
-
-                if ( IsHighlighted(m_current) )
+                if ( event.ControlDown() )
+                {
+                    ReverseHighlight(m_current);
+                }
+                else // normal space press
                 {
-                    // don't unselect the item in single selection mode
-                    break;
+                    SendNotify( m_current, wxEVT_COMMAND_LIST_ITEM_ACTIVATED );
                 }
-                //else: select it in ReverseHighlight() below if unselected
             }
-
-            ReverseHighlight(m_current);
+            else // multiple selection
+            {
+                ReverseHighlight(m_current);
+            }
             break;
 
         case WXK_RETURN:
@@ -4808,6 +4811,11 @@ int LINKAGEMODE list_ctrl_compare_func_1( wxListLineData **arg1, wxListLineData
 
 void wxListMainWindow::SortItems( wxListCtrlCompare fn, long data )
 {
+    // selections won't make sense any more after sorting the items so reset
+    // them
+    HighlightAll(false);
+    ResetCurrent();
+
     list_ctrl_compare_func_2 = fn;
     list_ctrl_compare_data = data;
     m_lines.Sort( list_ctrl_compare_func_1 );
@@ -4830,7 +4838,7 @@ void wxListMainWindow::OnScroll(wxScrollWinEvent& event)
     // update our idea of which lines are shown when we redraw the window the
     // next time
     ResetVisibleLinesRange();
-    
+
     if ( event.GetOrientation() == wxHORIZONTAL && HasHeader() )
     {
         wxGenericListCtrl* lc = GetListCtrl();
@@ -4992,6 +5000,9 @@ bool wxGenericListCtrl::Create(wxWindow *parent,
     if ( !wxControl::Create( parent, id, pos, size, style, validator, name ) )
         return false;
 
+    // this window itself shouldn't get the focus, only m_mainWin should
+    SetCanFocus(false);
+
     // don't create the inner window with the border
     style &= ~wxBORDER_MASK;