]> git.saurik.com Git - wxWidgets.git/commitdiff
added more methods to transparently convert wxTreeItemIdValue to wxTreeItemId to...
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 3 Oct 2005 17:54:09 +0000 (17:54 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 3 Oct 2005 17:54:09 +0000 (17:54 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35780 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/treebase.h
src/msw/treectrl.cpp

index f81ef99a1ea477730e9f6c1a805d25e7a3df23f4..884cd3be014bdd46472a7fc9bcbefd046f7693c7 100644 (file)
@@ -123,11 +123,19 @@ protected:
 
 WX_DEFINE_EXPORTED_ARRAY_PTR(wxTreeItemIdValue, wxArrayTreeItemIdsBase);
 
+// this is a wrapper around the array class defined above which allow to wok
+// with vaue of natural wxTreeItemId type instead of using wxTreeItemIdValue
+// and does it without any loss of efficiency
 class WXDLLEXPORT wxArrayTreeItemIds : public wxArrayTreeItemIdsBase
 {
 public:
     void Add(const wxTreeItemId& id)
         { wxArrayTreeItemIdsBase::Add(id.m_pItem); }
+    void Insert(const wxTreeItemId& id, size_t pos)
+        { wxArrayTreeItemIdsBase::Insert(id.m_pItem, pos); }
+    wxTreeItemId Item(size_t i) const
+        { return wxTreeItemId(wxArrayTreeItemIdsBase::Item(i)); }
+    wxTreeItemId operator[](size_t i) const { return Item(i); }
 };
 
 // ----------------------------------------------------------------------------
index fd12c8c190d942d271ef5ca22e9d54e9c638784a..13edcec7c3d447eee797f7ebded6d8392cf55861 100644 (file)
 // macros to hide the cast ugliness
 // --------------------------------
 
-// ptr is the real item id, i.e. wxTreeItemId::m_pItem
-#define HITEM_PTR(ptr)     (HTREEITEM)(ptr)
-
-// item here is a wxTreeItemId
-#define HITEM(item)     HITEM_PTR((item).m_pItem)
+// get HTREEITEM from wxTreeItemId
+#define HITEM(item)     ((HTREEITEM)(((item).m_pItem)))
 
 // the native control doesn't support multiple selections under MSW and we
 // have 2 ways to emulate them: either using TVS_CHECKBOXES style and let
@@ -1833,7 +1830,7 @@ void wxTreeCtrl::DeleteChildren(const wxTreeItemId& item)
     size_t nCount = children.Count();
     for ( size_t n = 0; n < nCount; n++ )
     {
-        if ( !TreeView_DeleteItem(GetHwnd(), HITEM_PTR(children[n])) )
+        if ( !TreeView_DeleteItem(GetHwnd(), HITEM(children[n])) )
         {
             wxLogLastError(wxT("TreeView_DeleteItem"));
         }
@@ -1945,9 +1942,9 @@ void wxTreeCtrl::UnselectAll()
         for ( size_t n = 0; n < count; n++ )
         {
 #if wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
-            SetItemCheck(HITEM_PTR(selections[n]), false);
+            SetItemCheck(HITEM(selections[n]), false);
 #else // !wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
-            ::UnselectItem(GetHwnd(), HITEM_PTR(selections[n]));
+            ::UnselectItem(GetHwnd(), HITEM(selections[n]));
 #endif // wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE/!wxUSE_CHECKBOXES_IN_MULTI_SEL_TREE
         }
 
@@ -2362,7 +2359,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara
                         size_t count = GetSelections(selections);
                         if ( count == 0 ||
                              count > 1 ||
-                             HITEM_PTR(selections[0]) != htItem )
+                             HITEM(selections[0]) != htItem )
                         {
                             // clear the previously selected items, if the
                             // user clicked outside of the present selection.
@@ -2504,7 +2501,7 @@ WXLRESULT wxTreeCtrl::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lPara
         {
             // TreeView_GetItemRect() will return false if item is not visible,
             // which may happen perfectly well
-            if ( TreeView_GetItemRect(GetHwnd(), HITEM_PTR(selections[n]),
+            if ( TreeView_GetItemRect(GetHwnd(), HITEM(selections[n]),
                                       &rect, TRUE) )
             {
                 ::InvalidateRect(GetHwnd(), &rect, FALSE);