Logo ROOT   6.08/07
Reference Guide
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 #ifndef ROOT_TGFrame
16 #include "TGFrame.h"
17 #endif
18 
19 #ifndef ROOT_TBrowserImp
20 #include "TBrowserImp.h"
21 #endif
22 
23 #include <list>
24 #include <map>
25 
26 class TGCanvas;
27 class TGListTree;
28 class TGListTreeItem;
29 class TGPicture;
30 class TGComboBox;
31 class TContextMenu;
32 class TRegexp;
33 class TString;
34 class TRootBrowser;
35 class TSystemDirectory;
36 class TSystemFile;
37 class TGPictureButton;
38 
39 class TGFileBrowser : public TGMainFrame, public TBrowserImp {
40 
41 public:
42  typedef std::list<TGListTreeItem*> sLTI_t;
43  typedef sLTI_t::iterator sLTI_i;
44  typedef sLTI_t::reverse_iterator sLTI_ri;
45  typedef std::map<TGListTreeItem*, const char *> mFiltered_t;
46  typedef mFiltered_t::iterator mFiltered_i;
47 
48 protected:
49  TRootBrowser *fNewBrowser; // Pointer back to the Browser
50  TGHorizontalFrame *fTopFrame; // Top horizontal frame
51  TGHorizontalFrame *fBotFrame; // Bottom horizontal frame
52  TGCanvas *fCanvas; // Canvas for the list tree
53  TGListTree *fListTree; // Main list tree
54  TGListTreeItem *fListLevel; // Current list tree level
55  TGListTreeItem *fCurrentDir; // Current (list tree) directory
56  TGListTreeItem *fRootDir; // Root (list tree) directory
57  TGComboBox *fDrawOption; // Draw options combobox
58  TGComboBox *fFileType; // File type combobox
59  TContextMenu *fContextMenu; // pointer to context menu
60  TGPictureButton *fSortButton; // "Sort" button
61  TGPictureButton *fRefreshButton; // "Refresh" button
62  TGPictureButton *fFilterButton; // "Filter" button
63  const TGPicture *fRootIcon; // Root files icon
64  const TGPicture *fFileIcon; // System files icon
65  const TGPicture *fCachedPic; // Cached picture
66  TString fCachedPicName; // Cached picture name
67  TRegexp *fFilter; // Regular expression used to filter files
68  TSystemDirectory *fDir; // Actual (selected) system directory
69  TSystemFile *fFile; // Actual (selected) system file
70  Int_t fGroupSize; // total number of items when icon box switched to "global view" mode
71  Long_t fNKeys, fCnt; // Counters for keys inside a Root file
72  Bool_t fGrouped; // kTRUE if Root file content (keys) is grouped
73  Bool_t fShowHidden; // kTRUE to display hidden files
74  Bool_t fDblClick; // kTRUE if user double-clicked on a list tree item
75 
76  sLTI_t fSortedItems; // List of sorted list-tree items.
77  mFiltered_t fFilteredItems; // List of filtered list-tree items.
78  TString fFilterStr; // Filter expression string
79 
80  void CreateBrowser();
81 
82 public:
83  TGFileBrowser(const TGWindow *p, TBrowser* b=0, UInt_t w=200, UInt_t h=400);
84  virtual ~TGFileBrowser();
85 
86  virtual void Add(TObject *obj, const char *name = 0, Int_t check = -1);
87  virtual void BrowseObj(TObject *obj);
88  virtual void RecursiveRemove(TObject *obj);
89  virtual void Refresh(Bool_t force = kFALSE);
90  virtual void Show() { MapRaised(); }
91  Option_t *GetDrawOption() const;
92 
93  TRootBrowser *GetNewBrowser() const { return fNewBrowser; }
94  void SetNewBrowser(TRootBrowser* b) { fNewBrowser = b; }
95 
96  void AddFSDirectory(const char* entry, const char* path=0, Option_t *opt="");
97  void AddKey(TGListTreeItem *itm, TObject *obj, const char *name = 0);
98  void AddRemoteFile(TObject *obj);
99  void ApplyFilter(Int_t id);
100  void Chdir(TGListTreeItem *item);
101  void Checked(TObject *obj, Bool_t check);
103  void CheckRemote(TGListTreeItem *item);
105  void Clicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y);
108  void DoubleClicked(TGListTreeItem *item, Int_t btn);
110  char *FormatFileInfo(const char *fname, Long64_t size, Long_t modtime);
111  void GetFilePictures(const TGPicture **pic, Int_t file_type, Bool_t is_link, const char *name);
112  void GetObjPicture(const TGPicture **pic, TObject *obj);
113  void GotoDir(const char *path);
114  void PadModified();
115  void RequestFilter();
116  void Selected(char *);
117  void ToggleSort();
118  void Update();
119 
120  ClassDef(TGFileBrowser, 0) // File browser.
121 };
122 
123 #endif
void RequestFilter()
Open a dialog box asking for a string to be used as filter (regexp), and add an entry in the map of f...
void AddKey(TGListTreeItem *itm, TObject *obj, const char *name=0)
display content of ROOT file
TString fFilterStr
Definition: TGFileBrowser.h:78
Bool_t CheckFiltered(TGListTreeItem *item, Bool_t but=kFALSE)
Check if there is a filter active on the children of the list tree item.
TString fCachedPicName
Definition: TGFileBrowser.h:66
long long Long64_t
Definition: RtypesCore.h:69
sLTI_t::reverse_iterator sLTI_ri
Definition: TGFileBrowser.h:44
virtual void Show()
Definition: TGFileBrowser.h:90
const char Option_t
Definition: RtypesCore.h:62
TGListTreeItem * fCurrentDir
Definition: TGFileBrowser.h:55
TRootBrowser * fNewBrowser
Definition: TGFileBrowser.h:49
TH1 * h
Definition: legend2.C:5
void ApplyFilter(Int_t id)
Apply filter selected in combo box to the file tree view.
Regular expression class.
Definition: TRegexp.h:35
sLTI_t::iterator sLTI_i
Definition: TGFileBrowser.h:43
std::list< TGListTreeItem * > sLTI_t
Definition: TGFileBrowser.h:42
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
TGPictureButton * fFilterButton
Definition: TGFileBrowser.h:62
TGComboBox * fDrawOption
Definition: TGFileBrowser.h:57
const Bool_t kFALSE
Definition: Rtypes.h:92
TGFileBrowser(const TGWindow *p, TBrowser *b=0, UInt_t w=200, UInt_t h=400)
TGFileBrowser constructor.
Bool_t CheckSorted(TGListTreeItem *item, Bool_t but=kFALSE)
Check if the list tree item children are alphabetically sorted.
virtual void MapRaised()
Definition: TGFrame.h:268
void AddFSDirectory(const char *entry, const char *path=0, Option_t *opt="")
Add file system directory in the list tree.
void DoubleClicked(TGListTreeItem *item, Int_t btn)
Process double clicks in TGListTree.
TGPictureButton * fRefreshButton
Definition: TGFileBrowser.h:61
TRegexp * fFilter
Definition: TGFileBrowser.h:67
Double_t x[n]
Definition: legend1.C:17
TGCanvas * fCanvas
Definition: TGFileBrowser.h:52
#define ClassDef(name, id)
Definition: Rtypes.h:254
TGHorizontalFrame * fTopFrame
Definition: TGFileBrowser.h:50
void ToggleSort()
Toggle the sort mode and set the "sort button" state accordingly.
std::map< TGListTreeItem *, const char * > mFiltered_t
Definition: TGFileBrowser.h:45
void AddRemoteFile(TObject *obj)
Add remote file in list tree.
Bool_t fShowHidden
Definition: TGFileBrowser.h:73
void PadModified()
Slot used to switch to the tab containing the current pad/canvas (gPad) used e.g. ...
TString FullPathName(TGListTreeItem *item)
returns an absolute path
char * FormatFileInfo(const char *fname, Long64_t size, Long_t modtime)
Format file information to be displayed in the tooltip.
void Chdir(TGListTreeItem *item)
Make object associated with item the current directory.
Describes an Operating System directory for the browser.
sLTI_t fSortedItems
Definition: TGFileBrowser.h:76
void SetNewBrowser(TRootBrowser *b)
Definition: TGFileBrowser.h:94
TContextMenu * fContextMenu
Definition: TGFileBrowser.h:59
virtual void BrowseObj(TObject *obj)
Browse object.
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
void CreateBrowser()
Create the actual file browser.
TSystemFile * fFile
Definition: TGFileBrowser.h:69
void GetFilePictures(const TGPicture **pic, Int_t file_type, Bool_t is_link, const char *name)
Determine the file picture for the given file type.
virtual void Refresh(Bool_t force=kFALSE)
Refresh content of the list tree.
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:44
TGListTreeItem * fRootDir
Definition: TGFileBrowser.h:56
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void RecursiveRemove(TObject *obj)
Recursively remove object.
void Clicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y)
Process mouse clicks in TGListTree.
TGPictureButton * fSortButton
Definition: TGFileBrowser.h:60
TString DirName(TGListTreeItem *item)
returns the directory path
Option_t * GetDrawOption() const
returns drawing option
mFiltered_t::iterator mFiltered_i
Definition: TGFileBrowser.h:46
mFiltered_t fFilteredItems
Definition: TGFileBrowser.h:77
void Selected(char *)
A ROOT File has been selected in TGHtmlBrowser.
const TGPicture * fRootIcon
Definition: TGFileBrowser.h:63
long Long_t
Definition: RtypesCore.h:50
Long_t XXExecuteDefaultAction(TObject *obj)
Execute default action for selected object (action is specified in the $HOME/.root.mimes or $ROOTSYS/etc/root.mimes file.
TRootBrowser * GetNewBrowser() const
Definition: TGFileBrowser.h:93
void GotoDir(const char *path)
Go to the directory "path" and open all the parent list tree items.
Double_t y[n]
Definition: legend1.C:17
virtual ~TGFileBrowser()
Destructor.
const TGPicture * fCachedPic
Definition: TGFileBrowser.h:65
Mother of all ROOT objects.
Definition: TObject.h:37
Bool_t fDblClick
Definition: TGFileBrowser.h:74
void CheckRemote(TGListTreeItem *item)
Check if the current list tree item points to a remote object.
virtual void Add(TObject *obj, const char *name=0, Int_t check=-1)
Add items to the browser.
A TSystemFile describes an operating system file.
Definition: TSystemFile.h:31
TGListTreeItem * fListLevel
Definition: TGFileBrowser.h:54
const TGPicture * fFileIcon
Definition: TGFileBrowser.h:64
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
TGListTree * fListTree
Definition: TGFileBrowser.h:53
void Checked(TObject *obj, Bool_t check)
Emits signal when double clicking on icon.
TGComboBox * fFileType
Definition: TGFileBrowser.h:58
char name[80]
Definition: TGX11.cxx:109
void Update()
Update content of the list tree.
TSystemDirectory * fDir
Definition: TGFileBrowser.h:68
ABC describing GUI independent browser implementation protocol.
Definition: TBrowserImp.h:31
void GetObjPicture(const TGPicture **pic, TObject *obj)
Retrieve icons associated with class "name".
TGHorizontalFrame * fBotFrame
Definition: TGFileBrowser.h:51