]> git.saurik.com Git - wxWidgets.git/commitdiff
don't lose the alignment flags when setting the column image (replaces patch 1411870...
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 8 Feb 2006 22:15:34 +0000 (22:15 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 8 Feb 2006 22:15:34 +0000 (22:15 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37396 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/listctrl.cpp

index 6b9ef732a65bc86486e6abb9ecb3effffaa112b8..7a365c7a0e94eb9bb43aa49f28376243f08a9a6e 100644 (file)
@@ -78,7 +78,9 @@ static void wxConvertFromMSWListItem(HWND hwndListCtrl,
                                      /* const */ LV_ITEM& lvItem);
 
 // convert our wxListItem to LV_COLUMN
-static void wxConvertToMSWListCol(int col, const wxListItem& item,
+static void wxConvertToMSWListCol(HWND hwndList,
+                                  int col,
+                                  const wxListItem& item,
                                   LV_COLUMN& lvCol);
 
 // ----------------------------------------------------------------------------
@@ -666,7 +668,7 @@ bool wxListCtrl::GetColumn(int col, wxListItem& item) const
 bool wxListCtrl::SetColumn(int col, const wxListItem& item)
 {
     LV_COLUMN lvCol;
-    wxConvertToMSWListCol(col, item, lvCol);
+    wxConvertToMSWListCol(GetHwnd(), col, item, lvCol);
 
     return ListView_SetColumn(GetHwnd(), col, &lvCol) != 0;
 }
@@ -1569,7 +1571,7 @@ long wxListCtrl::InsertItem(long index, const wxString& label, int imageIndex)
 long wxListCtrl::InsertColumn(long col, const wxListItem& item)
 {
     LV_COLUMN lvCol;
-    wxConvertToMSWListCol(col, item, lvCol);
+    wxConvertToMSWListCol(GetHwnd(), col, item, lvCol);
 
     if ( !(lvCol.mask & LVCF_WIDTH) )
     {
@@ -2796,7 +2798,9 @@ static void wxConvertToMSWListItem(const wxListCtrl *ctrl,
         lvItem.mask |= LVIF_IMAGE;
 }
 
-static void wxConvertToMSWListCol(int WXUNUSED(col), const wxListItem& item,
+static void wxConvertToMSWListCol(HWND hwndList,
+                                  int col,
+                                  const wxListItem& item,
                                   LV_COLUMN& lvCol)
 {
     wxZeroMemory(lvCol);
@@ -2836,9 +2840,9 @@ static void wxConvertToMSWListCol(int WXUNUSED(col), const wxListItem& item,
     {
         if ( wxTheApp->GetComCtl32Version() >= 470 )
         {
-            lvCol.mask |= LVCF_IMAGE | LVCF_FMT;
+            lvCol.mask |= LVCF_IMAGE;
 
-            // we use LVCFMT_BITMAP_ON_RIGHT because themages on the right
+            // we use LVCFMT_BITMAP_ON_RIGHT because the images on the right
             // seem to be generally nicer than on the left and the generic
             // version only draws them on the right (we don't have a flag to
             // specify the image location anyhow)
@@ -2846,7 +2850,24 @@ static void wxConvertToMSWListCol(int WXUNUSED(col), const wxListItem& item,
             // we don't use LVCFMT_COL_HAS_IMAGES because it doesn't seem to
             // make any difference in my tests -- but maybe we should?
             if ( item.m_image != -1 )
+            {
+                // as we're going to overwrite the format field, get its
+                // current value first -- unless we want to overwrite it anyhow
+                if ( !(lvCol.mask & LVCF_FMT) )
+                {
+                    LV_COLUMN lvColOld;
+                    wxZeroMemory(lvColOld);
+                    lvColOld.mask = LVCF_FMT;
+                    if ( ListView_GetColumn(hwndList, col, &lvColOld) )
+                    {
+                        lvCol.fmt = lvColOld.fmt;
+                    }
+
+                    lvCol.mask |= LVCF_FMT;
+                }
+
                 lvCol.fmt |= LVCFMT_BITMAP_ON_RIGHT | LVCFMT_IMAGE;
+            }
 
             lvCol.iImage = item.m_image;
         }