#pragma hdrstop
#endif
+#include "wx/window.h"
+#include "wx/msw/private.h"
+
#ifndef WX_PRECOMP
- #include "wx/wx.h"
+ #include "wx/settings.h"
+#endif
+
+// Mingw32 is a bit mental even though this is done in winundef
+#ifdef GetFirstChild
+#undef GetFirstChild
+#endif
+#ifdef GetNextSibling
+#undef GetNextSibling
#endif
#if defined(__WIN95__)
#include "wx/imaglist.h"
#include "wx/msw/treectrl.h"
-#include "wx/msw/private.h"
+#ifdef __GNUWIN32__
+#include "wx/msw/gnuwin32/extra.h"
+#endif
#if (defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__)
#include <commctrl.h>
#endif
-#ifdef GetFirstChild
-#undef GetFirstChild
-#endif
-
-#ifdef GetNextChild
-#undef GetNextChild
-#endif
-
-#ifdef GetNextSibling
-#undef GetNextSibling
-#endif
-
-#ifdef GetClassInfo
-#undef GetClassInfo
-#endif
-
// Bug in headers, sometimes
#ifndef TVIS_FOCUSED
#define TVIS_FOCUSED 0x0001
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) ;
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
// ----------------------------------------------------------------------------
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() )
{
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
void wxTreeCtrl::CollapseAndReset(const wxTreeItemId& item)
{
- DoExpand(item, TVE_COLLAPSERESET);
+ DoExpand(item, TVE_COLLAPSE | TVE_COLLAPSERESET);
}
void wxTreeCtrl::Toggle(const wxTreeItemId& item)
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)
{
+ wxCHECK_MSG( pItem1 && pItem2, 0,
+ _T("sorting tree without data doesn't make sense") );
+
return tree->OnCompareItems(pItem1->GetId(), pItem2->GetId());
}
}
// process WM_NOTIFY Windows message
-bool wxTreeCtrl::MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result)
+bool wxTreeCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
{
wxTreeEvent event(wxEVT_NULL, m_windowId);
wxEventType eventType = wxEVT_NULL;
}
default:
- return wxControl::MSWNotify(wParam, lParam, result);
+ return wxControl::MSWOnNotify(idCtrl, lParam, result);
}
event.SetEventObject(this);
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();