Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGFileBrowser.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Bertrand Bellenot 26/09/2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGFileBrowser
13 #define ROOT_TGFileBrowser
14 
15 #include "TGFrame.h"
16 
17 #include "TBrowserImp.h"
18 
19 #include <list>
20 #include <map>
21 
22 class TGCanvas;
23 class TGListTree;
24 class TGListTreeItem;
25 class TGPicture;
26 class TGComboBox;
27 class TContextMenu;
28 class TRegexp;
29 class TString;
30 class TRootBrowser;
31 class TSystemDirectory;
32 class TSystemFile;
33 class TGPictureButton;
34 
35 class TGFileBrowser : public TGMainFrame, public TBrowserImp {
36 
37 public:
38  typedef std::list<TGListTreeItem*> sLTI_t;
39  typedef sLTI_t::iterator sLTI_i;
40  typedef sLTI_t::reverse_iterator sLTI_ri;
41  typedef std::map<TGListTreeItem*, const char *> mFiltered_t;
42  typedef mFiltered_t::iterator mFiltered_i;
43 
44 protected:
45  TRootBrowser *fNewBrowser; // Pointer back to the Browser
46  TGHorizontalFrame *fTopFrame; // Top horizontal frame
47  TGHorizontalFrame *fBotFrame; // Bottom horizontal frame
48  TGCanvas *fCanvas; // Canvas for the list tree
49  TGListTree *fListTree; // Main list tree
50  TGListTreeItem *fListLevel; // Current list tree level
51  TGListTreeItem *fCurrentDir; // Current (list tree) directory
52  TGListTreeItem *fRootDir; // Root (list tree) directory
53  TGComboBox *fDrawOption; // Draw options combobox
54  TGComboBox *fFileType; // File type combobox
55  TContextMenu *fContextMenu; // pointer to context menu
56  TGPictureButton *fSortButton; // "Sort" button
57  TGPictureButton *fRefreshButton; // "Refresh" button
58  TGPictureButton *fFilterButton; // "Filter" button
59  const TGPicture *fRootIcon; // Root files icon
60  const TGPicture *fFileIcon; // System files icon
61  const TGPicture *fCachedPic; // Cached picture
62  TString fCachedPicName; // Cached picture name
63  TRegexp *fFilter; // Regular expression used to filter files
64  TSystemDirectory *fDir; // Actual (selected) system directory
65  TSystemFile *fFile; // Actual (selected) system file
66  Int_t fGroupSize; // total number of items when icon box switched to "global view" mode
67  Long_t fNKeys, fCnt; // Counters for keys inside a Root file
68  Bool_t fGrouped; // kTRUE if Root file content (keys) is grouped
69  Bool_t fShowHidden; // kTRUE to display hidden files
70  Bool_t fDblClick; // kTRUE if user double-clicked on a list tree item
71 
72  sLTI_t fSortedItems; // List of sorted list-tree items.
73  mFiltered_t fFilteredItems; // List of filtered list-tree items.
74  TString fFilterStr; // Filter expression string
75 
76  void CreateBrowser();
77 
78 public:
79  TGFileBrowser(const TGWindow *p, TBrowser* b=0, UInt_t w=200, UInt_t h=400);
80  virtual ~TGFileBrowser();
81 
82  virtual void Add(TObject *obj, const char *name = 0, Int_t check = -1);
83  virtual void BrowseObj(TObject *obj);
84  virtual void RecursiveRemove(TObject *obj);
85  virtual void Refresh(Bool_t force = kFALSE);
86  virtual void Show() { MapRaised(); }
87  Option_t *GetDrawOption() const;
88 
89  TRootBrowser *GetNewBrowser() const { return fNewBrowser; }
90  void SetNewBrowser(TRootBrowser* b) { fNewBrowser = b; }
91 
92  void AddFSDirectory(const char* entry, const char* path=0, Option_t *opt="");
93  void AddKey(TGListTreeItem *itm, TObject *obj, const char *name = 0);
94  void AddRemoteFile(TObject *obj);
95  void ApplyFilter(Int_t id);
96  void Chdir(TGListTreeItem *item);
97  void Checked(TObject *obj, Bool_t check);
98  Bool_t CheckFiltered(TGListTreeItem *item, Bool_t but = kFALSE);
99  void CheckRemote(TGListTreeItem *item);
100  Bool_t CheckSorted(TGListTreeItem *item, Bool_t but = kFALSE);
101  void Clicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y);
102  TString DirName(TGListTreeItem* item);
103  TString FullPathName(TGListTreeItem* item);
104  void DoubleClicked(TGListTreeItem *item, Int_t btn);
105  Long_t XXExecuteDefaultAction(TObject *obj);
106  char *FormatFileInfo(const char *fname, Long64_t size, Long_t modtime);
107  void GetFilePictures(const TGPicture **pic, Int_t file_type, Bool_t is_link, const char *name);
108  void GetObjPicture(const TGPicture **pic, TObject *obj);
109  void GotoDir(const char *path);
110  void PadModified();
111  void RequestFilter();
112  void Selected(char *);
113  void ToggleSort();
114  void Update();
115 
116  ClassDef(TGFileBrowser, 0) // File browser.
117 };
118 
119 #endif