]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/treectrl.cpp
Cured some Motif bugs
[wxWidgets.git] / src / msw / treectrl.cpp
index 02f7e0ad92d82c48dc524d2366fab85073dbd1b3..11547d87e62d273e02f0ade3f89a1c41efa766ea 100644 (file)
 #endif
 
 #ifndef WX_PRECOMP
-    #include "wx.h"
+    #include "wx/wx.h"
 #endif
 
 #if defined(__WIN95__)
 
 #include "wx/log.h"
+#include "wx/dynarray.h"
 #include "wx/imaglist.h"
+#include "wx/msw/treectrl.h"
 
 #include "wx/msw/private.h"
 
-#ifndef __GNUWIN32__
+#ifdef __GNUWIN32__
+#include "wx/msw/gnuwin32/extra.h"
+#endif
+
+#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
     #include <commctrl.h>
 #endif
 
@@ -54,7 +60,9 @@
 #undef GetNextSibling
 #endif
 
-#include "wx/msw/treectrl.h"
+#ifdef GetClassInfo
+#undef GetClassInfo
+#endif
 
 // Bug in headers, sometimes
 #ifndef TVIS_FOCUSED
@@ -453,6 +461,22 @@ wxTreeItemId wxTreeCtrl::GetNextChild(const wxTreeItemId& WXUNUSED(item),
     return l;
 }
 
+wxTreeItemId wxTreeCtrl::GetLastChild(const wxTreeItemId& item) const
+{
+    // can this be done more efficiently?
+    long cookie;
+
+    wxTreeItemId childLast,
+    child = GetFirstChild(item, cookie);
+    while ( child.IsOk() )
+    {
+        childLast = child;
+        child = GetNextChild(item, cookie);
+    }
+
+    return childLast;
+}
+
 wxTreeItemId wxTreeCtrl::GetNextSibling(const wxTreeItemId& item) const
 {
     return wxTreeItemId((WXHTREEITEM) TreeView_GetNextSibling(wxhWnd, (HTREEITEM) (WXHTREEITEM) item));
@@ -786,9 +810,29 @@ wxTreeItemId wxTreeCtrl::HitTest(const wxPoint& point, int& flags)
     return wxTreeItemId((WXHTREEITEM) hitTestInfo.hItem);
 }
 
+bool wxTreeCtrl::GetBoundingRect(const wxTreeItemId& item,
+                                 wxRect& rect,
+                                 bool textOnly) const
+{
+    RECT rc;
+    if ( TreeView_GetItemRect(wxhWnd, (HTREEITEM)(WXHTREEITEM)item,
+                              &rc, textOnly) )
+    {
+        rect = wxRect(wxPoint(rc.left, rc.top), wxPoint(rc.right, rc.bottom));
+
+        return TRUE;
+    }
+    else
+    {
+        // couldn't retrieve rect: for example, item isn't visible
+        return FALSE;
+    }
+}
+
 // ----------------------------------------------------------------------------
 // sorting stuff
 // ----------------------------------------------------------------------------
+
 static int CALLBACK TreeView_CompareCallback(wxTreeItemData *pItem1,
                                              wxTreeItemData *pItem2,
                                              wxTreeCtrl *tree)
@@ -813,7 +857,7 @@ void wxTreeCtrl::SortChildren(const wxTreeItemId& item)
     }
     else
     {
-        TVSORTCB tvSort;
+        TV_SORTCB tvSort;
         tvSort.hParent = (HTREEITEM)(WXHTREEITEM)item;
         tvSort.lpfnCompare = (PFNTVCOMPARE)TreeView_CompareCallback;
         tvSort.lParam = (LPARAM)this;