Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

DirectoryTree.h

Go to the documentation of this file.
00001 
00002 // Name:        DirectoryTree.h
00003 // Purpose:     
00004 // Author:      Joe Yates
00005 // Modified by:
00006 // Created:     11/10/2004
00007 // RCS-ID:      $Id: DirectoryTree.h,v 1.1.1.1 2006/01/24 22:13:19 titusd Exp $
00008 // Copyright:   (c) BID Snc
00009 // License:     BSD license (see the file 'LICENSE.txt')
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   // friends, classes, enums and types
00021   class DirectoryTreeItem : public wxTreeItemData
00022     {
00023     // Constructors/destructors
00024     public:
00025       DirectoryTreeItem(const wxString& sNewPath);
00026       ~DirectoryTreeItem()
00027         {}
00028 
00029     // Methods
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   // Constructors/destructors
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   // Operators
00055 
00056   // Slots
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   // Methods
00066   public:
00067     wxString      GetPath();
00068     void          SetShowHidden(bool bNewShowHidden, bool bUpdate);
00069 
00070   private:
00071     // Tree modification
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     // Selection
00079     void          SetPath(const wxString& sNewPath);
00080     void          DoSelection(wxTreeItemId& tid);
00081 
00082     // Accessors
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   // Members
00091   private:
00092     wxImageList   m_imlButtons;
00093     wxImageList   m_iml;
00094     bool          m_bShowHidden;
00095   
00096     // Sending events
00097     // Keep a copy of the frame, so sending events is more legible
00098     wxWindow *    m_wndParent;
00099 
00100   DECLARE_EVENT_TABLE()
00101   };
00102 
00103 #endif // ndef __DirectoryTree_h__

Generated on Wed Jan 25 08:14:45 2006 for Sherpa by doxygen 1.3.6