- /*
- * Public interface
- */
-
- // creation
- // --------
- wxTreeCtrl();
-
- inline wxTreeCtrl(wxWindow *parent, wxWindowID id = -1,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = "wxTreeCtrl") {
- Create(parent, id, pos, size, style, validator, name);
- }
- ~wxTreeCtrl();
-
- bool Create(wxWindow *parent, wxWindowID id = -1,
- const wxPoint& pos = wxDefaultPosition,
- const wxSize& size = wxDefaultSize,
- long style = wxTR_HAS_BUTTONS|wxTR_LINES_AT_ROOT,
- const wxValidator& validator = wxDefaultValidator,
- const wxString& name = "wxTreeCtrl");
-
- // accessors
- // ---------
- //
- int GetCount() const;
-
- // indent
- int GetIndent() const;
- void SetIndent(int indent);
- // image list
- wxImageList *GetImageList(int which = wxIMAGE_LIST_NORMAL) const;
- void SetImageList(wxImageList *imageList, int which = wxIMAGE_LIST_NORMAL);
-
- // navigation inside the tree
- long GetNextItem(long item, int code) const;
- bool ItemHasChildren(long item) const;
- long GetChild(long item) const;
- long GetParent(long item) const;
- long GetFirstVisibleItem() const;
- long GetNextVisibleItem(long item) const;
- long GetSelection() const;
- long GetRootItem() const;
-
- // generic function for (g|s)etting item attributes
- bool GetItem(wxTreeItem& info) const;
- bool SetItem(wxTreeItem& info);
- // item state
- int GetItemState(long item, long stateMask) const;
- bool SetItemState(long item, long state, long stateMask);
- // item image
- bool SetItemImage(long item, int image, int selImage);
- // item text
- wxString GetItemText(long item) const;
- void SetItemText(long item, const wxString& str);
- // custom data associated with the item
- long GetItemData(long item) const;
- bool SetItemData(long item, long data);
- // convenience function
- bool IsItemExpanded(long item) {
- return (GetItemState(item, wxTREE_STATE_EXPANDED) &
- wxTREE_STATE_EXPANDED) != 0;
- }
-
- // bounding rect
- bool GetItemRect(long item, wxRectangle& rect, bool textOnly = FALSE) const;
- //
- wxTextCtrl* GetEditControl() const;
-
+ // creation
+ // --------
+ wxTreeCtrl() { Init(); }
+
+ wxTreeCtrl(wxWindow *parent, wxWindowID id = wxID_ANY,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
+ const wxValidator& validator = wxDefaultValidator,
+ const wxString& name = "wxTreeCtrl")
+ {
+ Create(parent, id, pos, size, style, validator, name);
+ }
+
+ virtual ~wxTreeCtrl();
+
+ bool Create(wxWindow *parent, wxWindowID id = wxID_ANY,
+ const wxPoint& pos = wxDefaultPosition,
+ const wxSize& size = wxDefaultSize,
+ long style = wxTR_HAS_BUTTONS | wxTR_LINES_AT_ROOT,
+ const wxValidator& validator = wxDefaultValidator,
+ const wxString& name = "wxTreeCtrl");
+
+ // accessors
+ // ---------
+
+ // get the total number of items in the control
+ virtual unsigned int GetCount() const;
+
+ // indent is the number of pixels the children are indented relative to
+ // the parents position. SetIndent() also redraws the control
+ // immediately.
+ unsigned int GetIndent() const;
+ void SetIndent(unsigned int indent);
+
+ // image list: these functions allow to associate an image list with
+ // the control and retrieve it. Note that the control does _not_ delete
+ // the associated image list when it's deleted in order to allow image
+ // lists to be shared between different controls.
+ //
+ // The normal image list is for the icons which correspond to the
+ // normal tree item state (whether it is selected or not).
+ // Additionally, the application might choose to show a state icon
+ // which corresponds to an app-defined item state (for example,
+ // checked/unchecked) which are taken from the state image list.
+ wxImageList *GetImageList() const;
+ wxImageList *GetStateImageList() const;
+
+ void SetImageList(wxImageList *imageList);
+ void SetStateImageList(wxImageList *imageList);
+
+ // Functions to work with tree ctrl items. Unfortunately, they can _not_ be
+ // member functions of wxTreeItem because they must know the tree the item
+ // belongs to for Windows implementation and storing the pointer to
+ // wxTreeCtrl in each wxTreeItem is just too much waste.
+
+ // accessors
+ // ---------
+
+ // retrieve items label
+ wxString GetItemText(const wxTreeItemId& item) const;
+ // get the normal item image
+ int GetItemImage(const wxTreeItemId& item) const;
+ // get the data associated with the item
+ wxTreeItemData *GetItemData(const wxTreeItemId& item) const;
+
+ // modifiers
+ // ---------
+
+ // set items label
+ void SetItemText(const wxTreeItemId& item, const wxString& text);
+ // set the normal item image
+ void SetItemImage(const wxTreeItemId& item, int image);
+ // associate some data with the item
+ void SetItemData(const wxTreeItemId& item, wxTreeItemData *data);
+
+ // item status inquiries
+ // ---------------------
+
+ // is the item visible (it might be outside the view or not expanded)?
+ bool IsVisible(const wxTreeItemId& item) const;
+ // does the item has any children?
+ bool ItemHasChildren(const wxTreeItemId& item) const;
+ // is the item expanded (only makes sense if HasChildren())?
+ bool IsExpanded(const wxTreeItemId& item) const;
+ // 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
+ // ----------
+
+ // wxTreeItemId.IsOk() will return false if there is no such item
+
+ // get the root tree item
+ wxTreeItemId GetRootItem() const;
+
+ // get the item currently selected (may return NULL if no selection)
+ wxTreeItemId GetSelection() const;
+
+ // get the parent of this item (may return NULL if root)
+ wxTreeItemId GetItemParent(const wxTreeItemId& item) const;
+
+ // for this enumeration function you must pass in a "cookie" parameter
+ // which is opaque for the application but is necessary for the library
+ // to make these functions reentrant (i.e. allow more than one
+ // enumeration on one and the same object simultaneously). Of course,
+ // the "cookie" passed to GetFirstChild() and GetNextChild() should be
+ // the same!
+
+ // get the last child of this item - this method doesn't use cookies
+ wxTreeItemId GetLastChild(const wxTreeItemId& item) const;
+
+ // get the next sibling of this item
+ wxTreeItemId GetNextSibling(const wxTreeItemId& item) const;
+ // get the previous sibling
+ wxTreeItemId GetPrevSibling(const wxTreeItemId& item) const;
+
+ // get first visible item
+ wxTreeItemId GetFirstVisibleItem() const;
+ // get the next visible item: item must be visible itself!
+ // see IsVisible() and wxTreeCtrl::GetFirstVisibleItem()
+ wxTreeItemId GetNextVisible(const wxTreeItemId& item) const;
+ // get the previous visible item: item must be visible itself!
+ wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const;
+