]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/treectrl.cpp
Various compilation fixes.
[wxWidgets.git] / src / msw / treectrl.cpp
index 46a215d3ba926a1b0d201a76defeada6b7fcb49d..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);
 };
 
 // ----------------------------------------------------------------------------
@@ -1213,6 +1214,12 @@ 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);
     DoGetItem(&tvItem);
 
@@ -2699,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;
@@ -2713,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;
 
@@ -2858,11 +2890,12 @@ bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
     switch ( hdr->code )
     {
         case NM_DBLCLK:
-            // we translate NM_DBLCLK into ACTIVATED event, so don't interpret
-            // the return code of this event handler as the return value for
-            // NM_DBLCLK - otherwise, double clicking the item to toggle its
-            // expanded status would never work
-            *result = false;
+            // we translate NM_DBLCLK into ACTIVATED event and if the user
+            // handled the activation of the item we shouldn't proceed with
+            // also using the same double click for toggling the item expanded
+            // state -- but OTOH do let the user to expand/collapse the item by
+            // double clicking on it if the activation is not handled specially
+            *result = processed;
             break;
 
         case NM_RCLICK: