X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/57c208c5759da71a637f0f0f5b7d3dc3eda09c02..f33396842a7bdecef5c1de6f80b145a096bbeabc:/src/msw/treectrl.cpp diff --git a/src/msw/treectrl.cpp b/src/msw/treectrl.cpp index 7673df85ed..eb6dfc4977 100644 --- a/src/msw/treectrl.cpp +++ b/src/msw/treectrl.cpp @@ -40,6 +40,10 @@ #include "wx/msw/private.h" +#ifdef __GNUWIN32__ +#include "wx/msw/gnuwin32/extra.h" +#endif + #if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__) #include #endif @@ -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) ; @@ -372,6 +377,13 @@ void wxTreeCtrl::SetItemBold(const wxTreeItemId& item, bool bold) DoSetItem(&tvItem); } +void wxTreeCtrl::SetItemDropHighlight(const wxTreeItemId& item, bool highlight) +{ + wxTreeViewItem tvItem(item, TVIF_STATE, TVIS_DROPHILITED); + tvItem.state = highlight ? TVIS_DROPHILITED : 0; + DoSetItem(&tvItem); +} + // ---------------------------------------------------------------------------- // Item status // ---------------------------------------------------------------------------- @@ -457,6 +469,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)); @@ -501,6 +529,13 @@ wxTreeItemId wxTreeCtrl::DoInsertItem(const wxTreeItemId& parent, TV_INSERTSTRUCT tvIns; tvIns.hParent = (HTREEITEM) (WXHTREEITEM)parent; tvIns.hInsertAfter = (HTREEITEM) (WXHTREEITEM) hInsertAfter; + + // This is how we insert the item as the first child: supply a NULL hInsertAfter + if (tvIns.hInsertAfter == (HTREEITEM) 0) + { + tvIns.hInsertAfter = TVI_FIRST; + } + UINT mask = 0; if ( !text.IsEmpty() ) { @@ -636,8 +671,10 @@ void wxTreeCtrl::DeleteAllItems() void wxTreeCtrl::DoExpand(const wxTreeItemId& item, int flag) { - wxASSERT_MSG( flag == TVE_COLLAPSE || flag == TVE_COLLAPSERESET || - flag == TVE_EXPAND || flag == TVE_TOGGLE, + wxASSERT_MSG( flag == TVE_COLLAPSE || + flag == (TVE_COLLAPSE | TVE_COLLAPSERESET) || + flag == TVE_EXPAND || + flag == TVE_TOGGLE, "Unknown flag in wxTreeCtrl::DoExpand" ); // TreeView_Expand doesn't send TVN_ITEMEXPAND(ING) messages, so we must @@ -677,7 +714,7 @@ void wxTreeCtrl::Collapse(const wxTreeItemId& item) void wxTreeCtrl::CollapseAndReset(const wxTreeItemId& item) { - DoExpand(item, TVE_COLLAPSERESET); + DoExpand(item, TVE_COLLAPSE | TVE_COLLAPSERESET); } void wxTreeCtrl::Toggle(const wxTreeItemId& item) @@ -790,9 +827,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 +1064,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();