]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/listctrl.cpp
remove m_endModalCalled flag, it seems to be unnecessary
[wxWidgets.git] / src / msw / listctrl.cpp
index 17edff1faf9fa9941d7ac266add1eff967b3f82f..d7bac52606a3872eae19737a5a3ec3b667de83ac 100644 (file)
@@ -39,6 +39,7 @@
 #endif
 
 #include "wx/imaglist.h"
 #endif
 
 #include "wx/imaglist.h"
+#include "wx/vector.h"
 
 #include "wx/msw/private.h"
 
 
 #include "wx/msw/private.h"
 
@@ -721,33 +722,32 @@ bool wxListCtrl::SetColumnWidth(int col, int width)
 // columns order
 // ----------------------------------------------------------------------------
 
 // columns order
 // ----------------------------------------------------------------------------
 
-int wxListCtrl::GetColumnOrder(int col) const
+int wxListCtrl::GetColumnIndexFromOrder(int order) const
 {
     const int numCols = GetColumnCount();
 {
     const int numCols = GetColumnCount();
-    wxCHECK_MSG( col >= 0 && col < numCols, -1, _T("Col index out of bounds") );
+    wxCHECK_MSG( order >= 0 && order < numCols, -1,
+                _T("Column position out of bounds") );
 
     wxArrayInt indexArray(numCols);
 
     wxArrayInt indexArray(numCols);
-
     if ( !ListView_GetColumnOrderArray(GetHwnd(), numCols, &indexArray[0]) )
         return -1;
 
     if ( !ListView_GetColumnOrderArray(GetHwnd(), numCols, &indexArray[0]) )
         return -1;
 
-    return indexArray[col];
+    return indexArray[order];
 }
 
 }
 
-int wxListCtrl::GetColumnIndexFromOrder(int order) const
+int wxListCtrl::GetColumnOrder(int col) const
 {
     const int numCols = GetColumnCount();
 {
     const int numCols = GetColumnCount();
-    wxASSERT_MSG( order >= 0 && order < numCols, _T("Col order out of bounds") );
+    wxASSERT_MSG( col >= 0 && col < numCols, _T("Column index out of bounds") );
 
     wxArrayInt indexArray(numCols);
 
     wxArrayInt indexArray(numCols);
-
     if ( !ListView_GetColumnOrderArray(GetHwnd(), numCols, &indexArray[0]) )
         return -1;
 
     if ( !ListView_GetColumnOrderArray(GetHwnd(), numCols, &indexArray[0]) )
         return -1;
 
-    for ( int col = 0; col < numCols; col++ )
+    for ( int pos = 0; pos < numCols; pos++ )
     {
     {
-        if ( indexArray[col] == order )
-            return col;
+        if ( indexArray[pos] == col )
+            return pos;
     }
 
     wxFAIL_MSG( _T("no column with with given order?") );
     }
 
     wxFAIL_MSG( _T("no column with with given order?") );
@@ -802,7 +802,7 @@ wxTextCtrl* wxListCtrl::GetEditControl() const
         HWND hwndEdit = ListView_GetEditControl(GetHwnd());
         if ( hwndEdit )
         {
         HWND hwndEdit = ListView_GetEditControl(GetHwnd());
         if ( hwndEdit )
         {
-            wxListCtrl * const self = wx_const_cast(wxListCtrl *, this);
+            wxListCtrl * const self = const_cast<wxListCtrl *>(this);
 
             if ( !m_textCtrl )
                 self->m_textCtrl = new wxTextCtrl;
 
             if ( !m_textCtrl )
                 self->m_textCtrl = new wxTextCtrl;
@@ -2486,7 +2486,7 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                     if ( lvi.mask & LVIF_TEXT )
                     {
                         wxString text = OnGetItemText(item, lvi.iSubItem);
                     if ( lvi.mask & LVIF_TEXT )
                     {
                         wxString text = OnGetItemText(item, lvi.iSubItem);
-                        wxStrncpy(lvi.pszText, text, lvi.cchTextMax);
+                        wxStrlcpy(lvi.pszText, text.c_str(), lvi.cchTextMax);
                     }
 
                     // see comment at the end of wxListCtrl::GetColumn()
                     }
 
                     // see comment at the end of wxListCtrl::GetColumn()
@@ -2909,11 +2909,14 @@ void wxListCtrl::OnPaint(wxPaintEvent& event)
             dc.SetPen(pen);
             dc.SetBrush(*wxTRANSPARENT_BRUSH);
 
             dc.SetPen(pen);
             dc.SetBrush(*wxTRANSPARENT_BRUSH);
 
-            int numCols = GetColumnCount();
-            int* indexArray = new int[numCols];
-            if ( !ListView_GetColumnOrderArray( GetHwnd(), numCols, indexArray) )
+            const int numCols = GetColumnCount();
+            wxVector<int> indexArray(numCols);
+            if ( !ListView_GetColumnOrderArray(GetHwnd(),
+                                               numCols,
+                                               &indexArray[0]) )
             {
                 wxFAIL_MSG( _T("invalid column index array in OnPaint()") );
             {
                 wxFAIL_MSG( _T("invalid column index array in OnPaint()") );
+                return;
             }
 
             int x = itemRect.GetX();
             }
 
             int x = itemRect.GetX();
@@ -2924,8 +2927,6 @@ void wxListCtrl::OnPaint(wxPaintEvent& event)
                 dc.DrawLine(x-1, firstItemRect.GetY() - gap,
                             x-1, itemRect.GetBottom());
             }
                 dc.DrawLine(x-1, firstItemRect.GetY() - gap,
                             x-1, itemRect.GetBottom());
             }
-
-            delete indexArray;
         }
     }
 }
         }
     }
 }