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

DirectoryView.h

Go to the documentation of this file.
00001 
00002 // Name:        DirectoryView.h
00003 // Purpose:     
00004 // Author:      Joe Yates
00005 // Modified by:
00006 // Created:     11/10/2004
00007 // RCS-ID:      $Id: DirectoryView.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 __DirectoryView_h__
00013 #define __DirectoryView_h__
00014 
00015 #include "DirectoryEntryArray.h"
00016 #include "SherpaEvent.h"
00017 
00018 #define SETTING_DIRECTORYVIEW_SORTKEY _T("/DirectoryView/SortKey")
00019 #define SETTING_DIRECTORYVIEW_TEXTSORTFLAGS _T("/DirectoryView/TextSortFlags")
00020 #define SETTING_DIRECTORYVIEW_COLUMNWIDTH_NAME _T("/DirectoryView/Columns/NameWidth")
00021 #define SETTING_DIRECTORYVIEW_COLUMNWIDTH_TYPE _T("/DirectoryView/Columns/TypeWidth")
00022 #define SETTING_DIRECTORYVIEW_COLUMNWIDTH_PERMS _T("/DirectoryView/Columns/PermsWidth")
00023 
00024 /*
00025 We have to sub-class wxListCtrl, in order to use it as virtual
00026 */
00027 
00028 class DirectoryView : public wxListCtrl, public DirectoryEntryArray
00029   {
00030   // friends, classes, enums and types
00031   typedef std::vector<int> ItemArray;
00032 
00033   // Constructors/destructors
00034   public:
00035     DirectoryView(wxWindow * wndParent);
00036     ~DirectoryView();
00037 
00038   // Operators
00039 
00040   // Slots
00041   protected:
00042     // Virtual list Implementation
00043     wxString      OnGetItemText(long item, long column) const;
00044     int           OnGetItemImage(long item) const;
00045     wxListItemAttr * OnGetItemAttr(long item) const;
00046 
00047     // Events
00048     void          OnIdle(wxIdleEvent& evt);
00049 
00050     // Keyboard events
00051     void          OnListKeyDown(wxListEvent& evt);
00052 
00053     // Mouse events
00054     void          OnMouseMove(wxMouseEvent& evt);
00055     void          OnLeftUp(wxMouseEvent& evt);
00056     void          OnRightDown(wxMouseEvent& evt);
00057     void          OnRightUp(wxMouseEvent& evt);
00058     void          OnListItemRightClick(wxListEvent& evt);
00059 
00060     void          OnItemActivated(wxListEvent& evt);
00061     void          OnEndLabelEdit(wxListEvent& evt);
00062   
00063     // Drag'n'drop
00064     void          OnBeginDrag(wxListEvent& evt);
00065 
00066     // Popup menu events
00067     void          popToWastebin_Click(wxCommandEvent& evt);
00068     void          popNewDirectory_Click(wxCommandEvent& evt);
00069     void          popNewFile_Click(wxCommandEvent& evt);
00070 
00071     // Update events from frame
00072     void          OnSetPath(shSetPathEvent& evt);
00073     void          OnRename(shRenameEvent& evt);
00074     void          OnToWastebin(shToWastebinEvent& evt);
00075     void          OnRestore(shRestoreEvent& evt);
00076     void          OnDelete(shDeleteEvent& evt);
00077     void          OnCreate(shCreateEvent& evt);
00078 
00079   // Methods
00080   public:
00081     wxString      GetPath();
00082     void          SetSortKey(DirectoryEntrySortKey des);
00083     void          SetTextSortFlags(int nTextSortFlags);
00084     void          SetShowHidden(bool bShowHidden);
00085 
00086   private:
00087     // Startup
00088     void          CreateMenus();
00089     void          AddColumns();
00090   
00091     // Settings
00092     void          LoadSettings();
00093     void          SaveSettings();
00094   
00095     // Threads
00099     void          SetWantIdleEvents(bool bWantIdleEvents);
00100 
00101     // List display
00102     void          SetPath(const wxString& sNewPath);
00103     void          Refresh(bool bKeepSelection);
00104     void          ClearList();
00105     int           ItemIndexFromPoint(const wxPoint& pnt);
00106 
00107     // Selection
00108     ItemArray     GetSelectedItems();
00109     void          ClearSelection();
00110     void          SetSelected(int nItemIndex);
00111     void          SelectItem(int nItemIndex);
00112     bool          IsItemSelected(int nItemIndex);
00113   
00114     // Item Manipulation
00115     void          ActivateItem(int nItemIndex);
00116     void          DeleteSelected(bool bDeleteFully);
00117     void          RequestItemDeletion(int nItemIndex, bool bDeleteFully);
00118 
00119   // Variables
00120   private:
00121     // List display
00122     int               m_nNextUpdateIndex; // Used by OnIdle directory filling
00123     bool              m_bWantIdleEvents; // When we do a refresh, we say we want idle events
00124     // when we add/remove/etc a file, we say we don't
00125 
00126     // Menus
00127     wxMenu            m_popItem;
00128     wxMenu            m_popFreeSpace;
00129   
00130     // Directory and contents
00131     wxString          m_sPath;
00132     DirectoryEntrySortKey m_des;
00133 
00134     // Settings
00135     bool              m_bDirectoriesFirst;
00136   
00137     // Drag'n'drop
00138     bool              m_bDragging;
00139   
00140     // Sending events
00141     // Keep a copy of the parent, so sending events is more legible
00142     wxWindow *        m_wndParent;
00143 
00144   DECLARE_NO_COPY_CLASS(DirectoryView)
00145   DECLARE_EVENT_TABLE()
00146   };
00147 
00148 #endif // ndef __DirectoryView_h__

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