- enum
- {
- TreeCtrlIcon_Folder,
- TreeCtrlIcon_File
- };
-
- MyTreeCtrl(wxWindow *parent, const wxWindowID id,
- const wxPoint& pos, const wxSize& size,
- long style);
- virtual ~MyTreeCtrl();
-
- void OnBeginDrag(wxTreeEvent& event);
- void OnBeginRDrag(wxTreeEvent& event);
- void OnBeginLabelEdit(wxTreeEvent& event);
- void OnEndLabelEdit(wxTreeEvent& event);
- void OnDeleteItem(wxTreeEvent& event);
- void OnGetInfo(wxTreeEvent& event);
- void OnSetInfo(wxTreeEvent& event);
- void OnItemExpanded(wxTreeEvent& event);
- void OnItemExpanding(wxTreeEvent& event);
- void OnItemCollapsed(wxTreeEvent& event);
- void OnItemCollapsing(wxTreeEvent& event);
- void OnSelChanged(wxTreeEvent& event);
- void OnSelChanging(wxTreeEvent& event);
- void OnKeyDown(wxTreeEvent& event);
-
- void GetItemsRecursively(const wxTreeItemId& idParent, long cookie);
+ enum
+ {
+ TreeCtrlIcon_File,
+ TreeCtrlIcon_FileSelected,
+ TreeCtrlIcon_Folder,
+ TreeCtrlIcon_FolderSelected,
+ TreeCtrlIcon_FolderOpened
+ };
+
+ MyTreeCtrl() { }
+ MyTreeCtrl(wxWindow *parent, const wxWindowID id,
+ const wxPoint& pos, const wxSize& size,
+ long style);
+ virtual ~MyTreeCtrl(){};
+
+ void OnBeginDrag(wxTreeEvent& event);
+ void OnBeginRDrag(wxTreeEvent& event);
+ void OnEndDrag(wxTreeEvent& event);
+ void OnBeginLabelEdit(wxTreeEvent& event);
+ void OnEndLabelEdit(wxTreeEvent& event);
+ void OnDeleteItem(wxTreeEvent& event);
+ void OnContextMenu(wxContextMenuEvent& event);
+ void OnItemMenu(wxTreeEvent& event);
+ void OnGetInfo(wxTreeEvent& event);
+ void OnSetInfo(wxTreeEvent& event);
+ void OnItemExpanded(wxTreeEvent& event);
+ void OnItemExpanding(wxTreeEvent& event);
+ void OnItemCollapsed(wxTreeEvent& event);
+ void OnItemCollapsing(wxTreeEvent& event);
+ void OnSelChanged(wxTreeEvent& event);
+ void OnSelChanging(wxTreeEvent& event);
+ void OnTreeKeyDown(wxTreeEvent& event);
+ void OnItemActivated(wxTreeEvent& event);
+ void OnItemRClick(wxTreeEvent& event);
+
+ void OnRMouseDown(wxMouseEvent& event);
+ void OnRMouseUp(wxMouseEvent& event);
+ void OnRMouseDClick(wxMouseEvent& event);
+
+ void GetItemsRecursively(const wxTreeItemId& idParent,
+ wxTreeItemIdValue cookie = 0);
+
+ void CreateImageList(int size = 16);
+ void CreateButtonsImageList(int size = 11);
+
+ void AddTestItemsToTree(size_t numChildren, size_t depth);
+
+ void DoSortChildren(const wxTreeItemId& item, bool reverse = false)
+ { m_reverseSort = reverse; wxTreeCtrl::SortChildren(item); }
+ void DoEnsureVisible() { if (m_lastItem.IsOk()) EnsureVisible(m_lastItem); }
+
+ void DoToggleIcon(const wxTreeItemId& item);
+
+ void ShowMenu(wxTreeItemId id, const wxPoint& pt);
+
+ int ImageSize(void) const { return m_imageSize; }
+
+ void SetLastItem(wxTreeItemId id) { m_lastItem = id; }
+
+protected:
+ virtual int OnCompareItems(const wxTreeItemId& i1, const wxTreeItemId& i2);
+
+ // is this the test item which we use in several event handlers?
+ bool IsTestItem(const wxTreeItemId& item)
+ {
+ // the test item is the first child folder
+ return GetItemParent(item) == GetRootItem() && !GetPrevSibling(item);
+ }