]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/treectrl.cpp
typos in error messages corrected
[wxWidgets.git] / src / msw / treectrl.cpp
index 07b86000b98f931efb22862e57083c3673950e25..7f8fd2847b116da370b24b15dff00ef63a6348f2 100644 (file)
 #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
 
@@ -58,8 +64,6 @@
 #undef GetClassInfo
 #endif
 
-#include "wx/msw/treectrl.h"
-
 // Bug in headers, sometimes
 #ifndef TVIS_FOCUSED
     #define TVIS_FOCUSED            0x0001
@@ -136,7 +140,8 @@ bool wxTreeCtrl::Create(wxWindow *parent, wxWindowID id,
 
     m_windowId = (id == -1) ? NewControlId() : id;
 
-    DWORD wstyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_HASLINES;
+    DWORD wstyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP | TVS_HASLINES | TVS_SHOWSELALWAYS ;
+
 
     bool want3D;
     WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D) ;
@@ -457,6 +462,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));
@@ -790,9 +811,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)
@@ -1007,6 +1048,7 @@ bool wxTreeCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result)
         NM_TREEVIEW* tv = (NM_TREEVIEW *)lParam;
         wxTreeItemData *data = (wxTreeItemData *)tv->itemOld.lParam;
         delete data; // may be NULL, ok
+        processed = TRUE; // Make sure we don't get called twice
     }
 
     *result = !event.IsAllowed();