+ // 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)
+{
+ return tree->OnCompareItems(pItem1->GetId(), pItem2->GetId());
+}
+
+int wxTreeCtrl::OnCompareItems(const wxTreeItemId& item1,
+ const wxTreeItemId& item2)
+{
+ return strcmp(GetItemText(item1), GetItemText(item2));
+}
+
+void wxTreeCtrl::SortChildren(const wxTreeItemId& item)
+{
+ // rely on the fact that TreeView_SortChildren does the same thing as our
+ // default behaviour, i.e. sorts items alphabetically and so call it
+ // directly if we're not in derived class (much more efficient!)
+ if ( GetClassInfo() == CLASSINFO(wxTreeCtrl) )
+ {
+ TreeView_SortChildren(wxhWnd, (HTREEITEM)(WXHTREEITEM)item, 0);
+ }
+ else
+ {
+ TV_SORTCB tvSort;
+ tvSort.hParent = (HTREEITEM)(WXHTREEITEM)item;
+ tvSort.lpfnCompare = (PFNTVCOMPARE)TreeView_CompareCallback;
+ tvSort.lParam = (LPARAM)this;
+ TreeView_SortChildrenCB(wxhWnd, &tvSort, 0 /* reserved */);