00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #ifndef __DirectoryTree_h__
00013 #define __DirectoryTree_h__
00014
00015 #include "DirectoryEntryArray.h"
00016 #include "SherpaEvent.h"
00017
00018 class DirectoryTree : public wxTreeCtrl
00019 {
00020
00021 class DirectoryTreeItem : public wxTreeItemData
00022 {
00023
00024 public:
00025 DirectoryTreeItem(const wxString& sNewPath);
00026 ~DirectoryTreeItem()
00027 {}
00028
00029
00030 public:
00031 wxString GetPath() const
00032 { return m_sPath; }
00033 bool IsPopulated() const
00034 { return m_bPopulated; }
00035 void SetIsPopulated()
00036 { m_bPopulated = true; }
00037
00038 private:
00039 wxString m_sPath;
00040 bool m_bPopulated;
00041 };
00042
00043
00044 public:
00045 DirectoryTree
00046 (
00047 wxWindow * wndParent,
00048 const wxWindowID id = wxID_ANY,
00049 const wxPoint& pntPosition = wxDefaultPosition,
00050 const wxSize& siz = wxDefaultSize,
00051 long nStyle = wxNO_BORDER | wxTR_HAS_BUTTONS
00052 );
00053
00054
00055
00056
00057 public:
00058 void OnLeftMouseDown(wxMouseEvent& evt);
00059 void OnItemExpanded(wxTreeEvent& evt);
00060 void OnSetPath(shSetPathEvent& evt);
00061 void OnToWastebin(shToWastebinEvent& evt);
00062 void OnDelete(shDeleteEvent& evt);
00063 void OnCreate(shCreateEvent& evt);
00064
00065
00066 public:
00067 wxString GetPath();
00068 void SetShowHidden(bool bNewShowHidden, bool bUpdate);
00069
00070 private:
00071
00072 void InitTree();
00073 wxTreeItemId PopulatePath(const wxString& sPath);
00074 void AddChildren(const wxTreeItemId& tid);
00075 wxTreeItemId AddChild(const wxTreeItemId& tidParent, const wxString& sPath);
00076 void RemoveItem(const wxString& sPath);
00077
00078
00079 void SetPath(const wxString& sNewPath);
00080 void DoSelection(wxTreeItemId& tid);
00081
00082
00083 wxTreeItemId GetItemFromPath(const wxString& sPath, bool bReturnBestFit = false);
00084 wxTreeItemId GetChildByName(wxTreeItemId& tidParent, const wxString& sName);
00085 bool GetItemPath(wxTreeItemId tid, wxString& sPath);
00086
00087 bool IsAncestorOf(wxTreeItemId tidPutativeAncestor, wxTreeItemId tid);
00088 wxTreeItemId GetRootItem(const wxString& sPath);
00089
00090
00091 private:
00092 wxImageList m_imlButtons;
00093 wxImageList m_iml;
00094 bool m_bShowHidden;
00095
00096
00097
00098 wxWindow * m_wndParent;
00099
00100 DECLARE_EVENT_TABLE()
00101 };
00102
00103 #endif // ndef __DirectoryTree_h__