]> git.saurik.com Git - wxWidgets.git/commitdiff
added stubs for wxTreeCtrl functions not yet implemented under MSW
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 18 Dec 1998 15:47:08 +0000 (15:47 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 18 Dec 1998 15:47:08 +0000 (15:47 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1238 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

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

index a67bd488510357df86bffca1f984bd2e9f688cdb..4bae54274352e84253a93ec3d78a4bc2e760fd10 100644 (file)
@@ -43,7 +43,6 @@ struct WXDLLEXPORT wxTreeViewItem;
 // first item precedes the second, +1 if the second precedes the first or 0 if
 // they're equivalent
 class wxTreeItemData;
-typedef int (*wxTreeItemCmpFunc)(wxTreeItemData *item1, wxTreeItemData *item2);
 
 // ----------------------------------------------------------------------------
 // constants
@@ -377,13 +376,17 @@ public:
         // end editing and accept or discard the changes to item label
     void EndEditLabel(const wxTreeItemId& item, bool discardChanges = FALSE);
 
-        // sort the children of this item using the specified callback function
-        // (it should return -1, 0 or +1 as usual), if it's not specified
-        // alphabetical comparaison is performed.
+    // sorting
+        // this function is called to compare 2 items and should return -1, 0
+        // or +1 if the first item is less than, equal to or greater than the
+        // second one. The base class version performs alphabetic comparaison
+        // of item labels (GetText)
+    virtual int OnCompareItems(const wxTreeItemId& item1,
+                               const wxTreeItemId& item2);
+        // sort the children of this item using OnCompareItems
         //
-        // NB: this function is not reentrant!
-    void SortChildren(const wxTreeItemId& item,
-                      wxTreeItemCmpFunc *cmpFunction = NULL);
+        // NB: this function is not reentrant and not MT-safe (FIXME)!
+    void SortChildren(const wxTreeItemId& item);
 
     // helpers
     // -------
index 2d8791a9be659843faaf07fb5fb04ed799b5f49d..42dd352347710e1b9859aaea4150c941228a140e 100644 (file)
@@ -736,10 +736,17 @@ wxTreeItemId wxTreeCtrl::HitTest(const wxPoint& point, int& flags)
     return wxTreeItemId((WXHTREEITEM) hitTestInfo.hItem);
 }
 
-void wxTreeCtrl::SortChildren(const wxTreeItemId& item,
-                              wxTreeItemCmpFunc *cmpFunction)
+int wxTreeCtrl::OnCompareItems(const wxTreeItemId& item1,
+                               const wxTreeItemId& item2)
 {
-    if ( cmpFunction == NULL )
+    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
+    if ( wxIS_KIND_OF(this, wxTreeCtrl) )
     {
         TreeView_SortChildren(wxhWnd, (HTREEITEM) (WXHTREEITEM) item, 0);
     }
@@ -750,9 +757,11 @@ void wxTreeCtrl::SortChildren(const wxTreeItemId& item,
     }
 }
 
-// TODO
 size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item, bool recursively)
 {
+    // TODO
+    wxFAIL_MSG("wxTreeCtrl::GetChildrenCount not implemented");
+
     return 0;
 }
 
@@ -761,6 +770,7 @@ size_t wxTreeCtrl::GetChildrenCount(const wxTreeItemId& item, bool recursively)
 void wxTreeCtrl::DeleteChildren(const wxTreeItemId& item)
 {
     // TODO
+    wxFAIL_MSG("wxTreeCtrl::DeleteChildren not implemented");
 }
 
 // ----------------------------------------------------------------------------