]> git.saurik.com Git - wxWidgets.git/commitdiff
keep selected image in sync with the normal one if it hasn't been changed (patch...
authorVadim Zeitlin <vadim@wxwidgets.org>
Thu, 10 Jul 2003 11:04:37 +0000 (11:04 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Thu, 10 Jul 2003 11:04:37 +0000 (11:04 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21851 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/msw/treectrl.cpp

index 5dcb0867c0c8e4c112dedaae6107c402c21efa02..d49421936040278e84e6797b8e1beacd50b4f1e2 100644 (file)
@@ -1012,15 +1012,28 @@ void wxTreeCtrl::SetItemImage(const wxTreeItemId& item, int image,
         return;
     }
 
-    int imageNormal, imageSel;
+    int imageNormal,
+        imageSel;
+
     switch ( which )
     {
         default:
             wxFAIL_MSG( wxT("unknown tree item image type") );
+            // fall through
 
         case wxTreeItemIcon_Normal:
-            imageNormal = image;
-            imageSel = GetItemSelectedImage(item);
+            {
+                const int imageNormalOld = GetItemImage(item);
+                const int imageSelOld = GetItemSelectedImage(item);
+
+                // always set the normal image
+                imageNormal = image;
+
+                // if the selected and normal images were the same, they should
+                // be the same after the update, otherwise leave the selected
+                // image as it was
+                imageSel = imageNormalOld == imageSelOld ? image : imageSelOld;
+            }
             break;
 
         case wxTreeItemIcon_Selected: