]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
non-recursive destructors
[wxWidgets.git] / src / generic / listctrl.cpp
index 3ca9aa51ac246068d14ce0ea51f89c1c82a66568..b6e7e543c214b0c5ecb8c6a723896c2c1b745a3b 100644 (file)
@@ -2361,6 +2361,8 @@ wxRect wxListMainWindow::GetLineHighlightRect(size_t line) const
 
 long wxListMainWindow::HitTestLine(size_t line, int x, int y) const
 {
+    wxASSERT_MSG( line < GetItemCount(), _T("invalid line in HitTestLine") );
+
     wxListLineData *ld = GetLine(line);
 
     if ( ld->HasImage() && GetLineIconRect(line).Inside(x, y) )
@@ -2554,7 +2556,7 @@ void wxListMainWindow::RefreshSelected()
         to = GetItemCount() - 1;
     }
 
-    if ( HasCurrent() && m_current > from && m_current <= to )
+    if ( HasCurrent() && m_current >= from && m_current <= to )
     {
         RefreshLine(m_current);
     }
@@ -2885,7 +2887,12 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
     if (event.Dragging())
     {
         if (m_dragCount == 0)
-            m_dragStart = wxPoint(x,y);
+        {
+            // we have to report the raw, physical coords as we want to be
+            // able to call HitTest(event.m_pointDrag) from the user code to
+            // get the item being dragged
+            m_dragStart = event.GetPosition();
+        }
 
         m_dragCount++;
 
@@ -3446,6 +3453,9 @@ void wxListMainWindow::SetColumnWidth( int col, int width )
                  _T("SetColumnWidth() can only be called in report mode.") );
 
     m_dirty = TRUE;
+    wxListHeaderWindow *headerWin = GetListCtrl()->m_headerWin;
+    if ( headerWin )
+        headerWin->m_dirty = TRUE;
 
     wxListHeaderDataList::Node *node = m_columns.Item( col );
     wxCHECK_RET( node, _T("no column?") );
@@ -4105,18 +4115,22 @@ long wxListMainWindow::HitTest( int x, int y, int &flags )
 {
     CalcUnscrolledPosition( x, y, &x, &y );
 
+    size_t count = GetItemCount();
+
     if ( HasFlag(wxLC_REPORT) )
     {
         size_t current = y / GetLineHeight();
-        flags = HitTestLine(current, x, y);
-        if ( flags )
-            return current;
+        if ( current < count )
+        {
+            flags = HitTestLine(current, x, y);
+            if ( flags )
+                return current;
+        }
     }
     else // !report
     {
         // TODO: optimize it too! this is less simple than for report view but
         //       enumerating all items is still not a way to do it!!
-        size_t count = GetItemCount();
         for ( size_t current = 0; current < count; current++ )
         {
             flags = HitTestLine(current, x, y);