]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/msw/treectrl.h
Added test for sprintf and vsnprintf to fix string.cpp for non-GNU systems.
[wxWidgets.git] / include / wx / msw / treectrl.h
index bb44c4e08b3c2606d03961eb107513abb54496dc..03795479dda2e2b8c4247d21968bad56d8d44b9c 100644 (file)
@@ -131,27 +131,19 @@ protected:
 // Because the objects of this class are deleted by the tree, they should
 // always be allocated on the heap!
 // ----------------------------------------------------------------------------
-class WXDLLEXPORT wxTreeItemData
+class WXDLLEXPORT wxTreeItemData : private wxTreeItemId
 {
-friend class wxTreeCtrl;
 public:
-    // creation/destruction
-    // --------------------
-        // default ctor
-    wxTreeItemData() { }
+    // default ctor/copy ctor/assignment operator are ok
 
-        // default copy ctor/assignment operator are ok
-
-        // dtor is virtual and all the items are deleted by the tree control
-        // when it's deleted, so you normally don't have to care about freeing
-        // memory allocated in your wxTreeItemData-derived class
+    // dtor is virtual and all the items are deleted by the tree control when
+    // it's deleted, so you normally don't have to care about freeing memory
+    // allocated in your wxTreeItemData-derived class
     virtual ~wxTreeItemData() { }
 
-    // accessor: get the item associated with us
-    const wxTreeItemId& GetItemId() const { return m_itemId; }
-
-protected:
-    wxTreeItemId m_itemId;
+    // accessors: set/get the item associated with this node
+    void SetId(const wxTreeItemId& id) { m_itemId = id; }
+    const wxTreeItemId& GetId() const { return (wxTreeItemId&) m_itemId; }
 };
 
 // ----------------------------------------------------------------------------
@@ -240,6 +232,12 @@ public:
         // associate some data with the item
     void SetItemData(const wxTreeItemId& item, wxTreeItemData *data);
 
+        // force appearance of [+] button near the item. This is useful to
+        // allow the user to expand the items which don't have any children now
+        // - but instead add them only when needed, thus minimizing memory
+        // usage and loading time.
+    void SetItemHasChildren(const wxTreeItemId& item, bool has = TRUE);
+
     // item status inquiries
     // ---------------------
 
@@ -252,6 +250,13 @@ public:
         // is this item currently selected (the same as has focus)?
     bool IsSelected(const wxTreeItemId& item) const;
 
+    // number of children
+    // ------------------
+
+        // if 'recursively' is FALSE, only immediate children count, otherwise
+        // the returned number is the number of all items in this branch
+    size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = TRUE);
+
     // navigation
     // ----------
 
@@ -405,8 +410,8 @@ public:
     // implementation
     // --------------
     void Command(wxCommandEvent& event) { ProcessCommand(event); };
-    bool MSWCommand(WXUINT param, WXWORD id);
-    bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam);
+    virtual bool MSWCommand(WXUINT param, WXWORD id);
+    virtual bool MSWNotify(WXWPARAM wParam, WXLPARAM lParam, WXLPARAM *result);
 
 protected:
     // SetImageList helper
@@ -443,7 +448,7 @@ private:
 // NB: note that not all accessors make sense for all events, see the event
 //     descriptions below
 // ----------------------------------------------------------------------------
-class WXDLLEXPORT wxTreeEvent : public wxCommandEvent
+class WXDLLEXPORT wxTreeEvent : public wxNotifyEvent
 {
 friend wxTreeCtrl;
 public:
@@ -465,10 +470,6 @@ public:
         // keyboard code (for wxEVT_COMMAND_TREE_KEY_DOWN only)
     int GetCode() const { return m_code; }
 
-    // set return code for wxEVT_COMMAND_TREE_ITEM_{EXPAND|COLLAPS}ING events
-        // call this to forbid the change in item status
-    void Veto() { m_code = TRUE; }
-
 private:
     // @@ we could save some space by using union here
     int           m_code;