]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
don't crash trying to dereference NULL m_selection (happens when showing a grid witho...
[wxWidgets.git] / src / generic / listctrl.cpp
index 2fee597386e3d1c462f448747de644673204b663..22cf70aa383df6eb9140c1b4e4831db20d0ab42a 100644 (file)
@@ -1449,8 +1449,8 @@ void wxListLineData::SetPosition( int x, int y,
 
             if ( item->HasImage() )
             {
-                m_gi->m_rectIcon.x = m_gi->m_rectAll.x + 4
-                                    + (spacing - m_gi->m_rectIcon.width)/2;
+                m_gi->m_rectIcon.x = m_gi->m_rectAll.x + 4 +
+                    (m_gi->m_rectAll.width - m_gi->m_rectIcon.width) / 2;
                 m_gi->m_rectIcon.y = m_gi->m_rectAll.y + 4;
             }
 
@@ -3772,6 +3772,14 @@ void wxListMainWindow::SetItemState( long litem, long state, long stateMask )
             {
                 ResetCurrent();
 
+                if ( IsSingleSel() )
+                {
+                    // we must unselect the old current item as well or we
+                    // might end up with more than one selected item in a
+                    // single selection control
+                    HighlightLine(oldCurrent, FALSE);
+                }
+
                 RefreshLine( oldCurrent );
             }
         }
@@ -4948,6 +4956,13 @@ void wxListCtrl::ClearAll()
 bool wxListCtrl::DeleteColumn( int col )
 {
     m_mainWin->DeleteColumn( col );
+
+    // if we don't have the header any longer, we need to relayout the window
+    if ( !GetColumnCount() )
+    {
+        ResizeReportView(FALSE /* no header */);
+    }
+
     return TRUE;
 }
 
@@ -5019,8 +5034,17 @@ long wxListCtrl::InsertItem( long index, const wxString &label, int imageIndex )
 
 long wxListCtrl::InsertColumn( long col, wxListItem &item )
 {
-    wxASSERT( m_headerWin );
+    wxCHECK_MSG( m_headerWin, -1, _T("can't add column in non report mode") );
+
     m_mainWin->InsertColumn( col, item );
+
+    // if we hadn't had header before and have it now we need to relayout the
+    // window
+    if ( GetColumnCount() == 1 )
+    {
+        ResizeReportView(TRUE /* have header */);
+    }
+
     m_headerWin->Refresh();
 
     return 0;