]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/treectrl.cpp
Uncomment code accidentally left commented
[wxWidgets.git] / src / msw / treectrl.cpp
index 9cf8532ae622247551b50c09af1d06766dfa19a5..88a0016e3efc23243036bbc426336308c6da7331 100644 (file)
@@ -37,6 +37,7 @@
     #include "wx/settings.h"
 #endif
 
+#include "wx/dynlib.h"
 #include "wx/msw/private.h"
 
 // Set this to 1 to be _absolutely_ sure that repainting will work for all
@@ -388,7 +389,7 @@ protected:
     // the real client data
     wxTreeItemData *m_data;
 
-    DECLARE_NO_COPY_CLASS(wxTreeItemParam)
+    wxDECLARE_NO_COPY_CLASS(wxTreeItemParam);
 };
 
 // wxVirutalNode is used in place of a single root when 'hidden' root is
@@ -413,7 +414,7 @@ public:
 private:
     wxTreeItemParam *m_param;
 
-    DECLARE_NO_COPY_CLASS(wxVirtualNode)
+    wxDECLARE_NO_COPY_CLASS(wxVirtualNode);
 };
 
 #ifdef __VISUALC__
@@ -458,7 +459,7 @@ private:
 
     const wxTreeCtrl *m_tree;
 
-    DECLARE_NO_COPY_CLASS(wxTreeTraversal)
+    wxDECLARE_NO_COPY_CLASS(wxTreeTraversal);
 };
 
 // internal class for getting the selected items
@@ -498,7 +499,7 @@ public:
 private:
     wxArrayTreeItemIds& m_selections;
 
-    DECLARE_NO_COPY_CLASS(TraverseSelections)
+    wxDECLARE_NO_COPY_CLASS(TraverseSelections);
 };
 
 // internal class for counting tree items
@@ -527,7 +528,7 @@ public:
 private:
     size_t m_count;
 
-    DECLARE_NO_COPY_CLASS(TraverseCounter)
+    wxDECLARE_NO_COPY_CLASS(TraverseCounter);
 };
 
 // ----------------------------------------------------------------------------
@@ -797,11 +798,6 @@ bool wxTreeCtrl::DoGetItem(wxTreeViewItem *tvItem) const
     wxCHECK_MSG( tvItem->hItem != TVI_ROOT, false,
                  _T("can't retrieve virtual root item") );
 
-    return DoGetPossiblyRootItem(tvItem);
-}
-
-bool wxTreeCtrl::DoGetPossiblyRootItem(wxTreeViewItem *tvItem) const
-{
     if ( !TreeView_GetItem(GetHwnd(), tvItem) )
     {
         wxLogLastError(wxT("TreeView_GetItem"));
@@ -997,7 +993,14 @@ wxTreeItemParam *wxTreeCtrl::GetItemParam(const wxTreeItemId& item) const
 
     wxTreeViewItem tvItem(item, TVIF_PARAM);
 
-    if ( !DoGetPossiblyRootItem(&tvItem) )
+    // hidden root may still have data.
+    if ( IS_VIRTUAL_ROOT(item) )
+    {
+        return GET_VIRTUAL_ROOT()->GetParam();
+    }
+
+    // visible node.
+    if ( !DoGetItem(&tvItem) )
     {
         return NULL;
     }
@@ -1211,8 +1214,14 @@ bool wxTreeCtrl::ItemHasChildren(const wxTreeItemId& item) const
 {
     wxCHECK_MSG( item.IsOk(), false, wxT("invalid tree item") );
 
+    if ( IS_VIRTUAL_ROOT(item) )
+    {
+        wxTreeItemIdValue cookie;
+        return GetFirstChild(item, cookie).IsOk();
+    }
+
     wxTreeViewItem tvItem(item, TVIF_CHILDREN);
-    DoGetPossiblyRootItem(&tvItem);
+    DoGetItem(&tvItem);
 
     return tvItem.cChildren != 0;
 }
@@ -2697,7 +2706,30 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                         // delete it (in POSTPAINT notify)
                         if (m_imageListState && m_imageListState->GetImageCount() > 0)
                         {
-                            #define hImageList (HIMAGELIST)m_imageListState->GetHIMAGELIST()
+                            typedef BOOL (wxSTDCALL *ImageList_Copy_t)
+                                (HIMAGELIST, int, HIMAGELIST, int, UINT);
+                            static ImageList_Copy_t s_pfnImageList_Copy = NULL;
+                            static bool loaded = false;
+
+                            if ( !loaded )
+                            {
+                                wxLoadedDLL dllComCtl32(_T("comctl32.dll"));
+                                if ( dllComCtl32.IsLoaded() )
+                                    wxDL_INIT_FUNC(s_pfn, ImageList_Copy, dllComCtl32);
+                            }
+
+                            if ( !s_pfnImageList_Copy )
+                            {
+                                // this code is broken with ImageList_Copy()
+                                // but I don't care enough about Win95 support
+                                // to write it now -- if anybody does, please
+                                // do it
+                                wxFAIL_MSG("TODO: implement this for Win95");
+                                break;
+                            }
+
+                            const HIMAGELIST
+                                hImageList = GetHimagelistOf(m_imageListState);
 
                             // add temporary image
                             int width, height;
@@ -2711,13 +2743,15 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
                             {
                                 // move images to right
                                 for ( int i = index; i > 0; i-- )
-                                    ::ImageList_Copy(hImageList, i, hImageList, i-1, 0);
+                                {
+                                    (*s_pfnImageList_Copy)(hImageList, i,
+                                                           hImageList, i-1,
+                                                           ILCF_MOVE);
+                                }
 
                                 // we must remove the image in POSTPAINT notify
                                 *result |= CDRF_NOTIFYPOSTPAINT;
                             }
-
-                            #undef hImageList
                         }
                         break;