Logo ROOT  
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 #include "TGFrame.h"
16 
17 #include "TBrowserImp.h"
18 
19 #include <list>
20 #include <map>
21 #include <string>
22 
23 class TGCanvas;
24 class TGListTree;
25 class TGListTreeItem;
26 class TGPicture;
27 class TGComboBox;
28 class TContextMenu;
29 class TRegexp;
30 class TString;
31 class TRootBrowser;
32 class TSystemDirectory;
33 class TSystemFile;
34 class TGPictureButton;
35 
36 class TGFileBrowser : public TGMainFrame, public TBrowserImp {
37 
38 public:
39  typedef std::list<TGListTreeItem*> sLTI_t;
40  typedef sLTI_t::iterator sLTI_i;
41  typedef sLTI_t::reverse_iterator sLTI_ri;
42  typedef std::map<TGListTreeItem*, std::string> mFiltered_t;
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; }
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);
99  void CheckRemote(TGListTreeItem *item);
101  void Clicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y);
104  void DoubleClicked(TGListTreeItem *item, Int_t btn);
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
TGFileBrowser::GetNewBrowser
TRootBrowser * GetNewBrowser() const
Definition: TGFileBrowser.h:89
TGFileBrowser
Definition: TGFileBrowser.h:36
TGFileBrowser::ToggleSort
void ToggleSort()
Toggle the sort mode and set the "sort button" state accordingly.
Definition: TGFileBrowser.cxx:1830
TGFileBrowser::mFiltered_t
std::map< TGListTreeItem *, std::string > mFiltered_t
Definition: TGFileBrowser.h:42
TGFileBrowser::ApplyFilter
void ApplyFilter(Int_t id)
Apply filter selected in combo box to the file tree view.
Definition: TGFileBrowser.cxx:820
TBrowser
Definition: TBrowser.h:37
TGWindow
Definition: TGWindow.h:31
TGFileBrowser::CreateBrowser
void CreateBrowser()
Create the actual file browser.
Definition: TGFileBrowser.cxx:121
TGMainFrame
Definition: TGFrame.h:444
TGPicture
Definition: TGPicture.h:36
TGFileBrowser::PadModified
void PadModified()
Slot used to switch to the tab containing the current pad/canvas (gPad) used e.g.
Definition: TGFileBrowser.cxx:1740
TGFileBrowser::AddKey
void AddKey(TGListTreeItem *itm, TObject *obj, const char *name=0)
display content of ROOT file
Definition: TGFileBrowser.cxx:772
TGFileBrowser::TGFileBrowser
TGFileBrowser(const TGWindow *p, TBrowser *b=0, UInt_t w=200, UInt_t h=400)
TGFileBrowser constructor.
Definition: TGFileBrowser.cxx:106
TGFileBrowser::fBotFrame
TGHorizontalFrame * fBotFrame
Definition: TGFileBrowser.h:47
TGFileBrowser::SetNewBrowser
void SetNewBrowser(TRootBrowser *b)
Definition: TGFileBrowser.h:90
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TGFileBrowser::fRootIcon
const TGPicture * fRootIcon
Definition: TGFileBrowser.h:59
TGFileBrowser::Checked
void Checked(TObject *obj, Bool_t check)
Emits signal when double clicking on icon.
Definition: TGFileBrowser.cxx:517
TSystemDirectory
Definition: TSystemDirectory.h:32
TGFileBrowser::fRefreshButton
TGPictureButton * fRefreshButton
Definition: TGFileBrowser.h:57
TGFileBrowser::fTopFrame
TGHorizontalFrame * fTopFrame
Definition: TGFileBrowser.h:46
Int_t
int Int_t
Definition: RtypesCore.h:45
TGFileBrowser::Refresh
virtual void Refresh(Bool_t force=kFALSE)
Refresh content of the list tree.
Definition: TGFileBrowser.cxx:624
TGFileBrowser::fFile
TSystemFile * fFile
Definition: TGFileBrowser.h:65
TGListTree
Definition: TGListTree.h:210
x
Double_t x[n]
Definition: legend1.C:17
TGFileBrowser::fShowHidden
Bool_t fShowHidden
Definition: TGFileBrowser.h:69
TGFileBrowser::RecursiveRemove
virtual void RecursiveRemove(TObject *obj)
Recursively remove object.
Definition: TGFileBrowser.cxx:587
TGFileBrowser::~TGFileBrowser
virtual ~TGFileBrowser()
Destructor.
Definition: TGFileBrowser.cxx:251
TGFileBrowser::GetDrawOption
Option_t * GetDrawOption() const
returns drawing option
Definition: TGFileBrowser.cxx:526
TGHorizontalFrame
Definition: TGFrame.h:423
TGFileBrowser::fSortButton
TGPictureButton * fSortButton
Definition: TGFileBrowser.h:56
TGFileBrowser::AddRemoteFile
void AddRemoteFile(TObject *obj)
Add remote file in list tree.
Definition: TGFileBrowser.cxx:431
TGFileBrowser::fGroupSize
Int_t fGroupSize
Definition: TGFileBrowser.h:66
TGFileBrowser::FormatFileInfo
char * FormatFileInfo(const char *fname, Long64_t size, Long_t modtime)
Format file information to be displayed in the tooltip.
Definition: TGFileBrowser.cxx:1548
TString
Definition: TString.h:136
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
b
#define b(i)
Definition: RSha256.hxx:118
bool
TGFileBrowser::BrowseObj
virtual void BrowseObj(TObject *obj)
Browse object.
Definition: TGFileBrowser.cxx:468
TGFileBrowser::Show
virtual void Show()
Definition: TGFileBrowser.h:86
TBrowserImp.h
TContextMenu
Definition: TContextMenu.h:44
TGFileBrowser::fCanvas
TGCanvas * fCanvas
Definition: TGFileBrowser.h:48
Option_t
const typedef char Option_t
Definition: RtypesCore.h:66
TGFileBrowser::fCnt
Long_t fCnt
Definition: TGFileBrowser.h:67
TGFileBrowser::fGrouped
Bool_t fGrouped
Definition: TGFileBrowser.h:68
TGFileBrowser::Clicked
void Clicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y)
Process mouse clicks in TGListTree.
Definition: TGFileBrowser.cxx:993
TBrowserImp
Definition: TBrowserImp.h:29
TGFileBrowser::fDblClick
Bool_t fDblClick
Definition: TGFileBrowser.h:70
TSystemFile
Definition: TSystemFile.h:29
h
#define h(i)
Definition: RSha256.hxx:124
TGFileBrowser::RequestFilter
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...
Definition: TGFileBrowser.cxx:1771
TGFileBrowser::fCachedPicName
TString fCachedPicName
Definition: TGFileBrowser.h:62
TGFileBrowser::sLTI_ri
sLTI_t::reverse_iterator sLTI_ri
Definition: TGFileBrowser.h:41
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:92
TGFrame.h
TGFileBrowser::fListTree
TGListTree * fListTree
Definition: TGFileBrowser.h:49
Long_t
long Long_t
Definition: RtypesCore.h:54
TGFrame::MapRaised
virtual void MapRaised()
map raised
Definition: TGFrame.h:230
TGFileBrowser::fSortedItems
sLTI_t fSortedItems
Definition: TGFileBrowser.h:72
TGFileBrowser::fContextMenu
TContextMenu * fContextMenu
Definition: TGFileBrowser.h:55
y
Double_t y[n]
Definition: legend1.C:17
TGFileBrowser::GetFilePictures
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.
Definition: TGFileBrowser.cxx:534
TGFileBrowser::Update
void Update()
Update content of the list tree.
Definition: TGFileBrowser.cxx:646
TGFileBrowser::GotoDir
void GotoDir(const char *path)
Go to the directory "path" and open all the parent list tree items.
Definition: TGFileBrowser.cxx:1655
unsigned int
TGFileBrowser::Add
virtual void Add(TObject *obj, const char *name=0, Int_t check=-1)
Add items to the browser.
Definition: TGFileBrowser.cxx:338
TGComboBox
Definition: TGComboBox.h:67
TRegexp
Definition: TRegexp.h:31
TGFileBrowser::CheckRemote
void CheckRemote(TGListTreeItem *item)
Check if the current list tree item points to a remote object.
Definition: TGFileBrowser.cxx:867
TGFileBrowser::GetObjPicture
void GetObjPicture(const TGPicture **pic, TObject *obj)
Retrieve icons associated with class "name".
Definition: TGFileBrowser.cxx:1583
TGFileBrowser::fFilterButton
TGPictureButton * fFilterButton
Definition: TGFileBrowser.h:58
TGFileBrowser::fCachedPic
const TGPicture * fCachedPic
Definition: TGFileBrowser.h:61
TGFileBrowser::fDrawOption
TGComboBox * fDrawOption
Definition: TGFileBrowser.h:53
TGFileBrowser::CheckSorted
Bool_t CheckSorted(TGListTreeItem *item, Bool_t but=kFALSE)
Check if the list tree item children are alphabetically sorted.
Definition: TGFileBrowser.cxx:971
TGFileBrowser::fFileIcon
const TGPicture * fFileIcon
Definition: TGFileBrowser.h:60
TGFileBrowser::AddFSDirectory
void AddFSDirectory(const char *entry, const char *path=0, Option_t *opt="")
Add file system directory in the list tree.
Definition: TGFileBrowser.cxx:731
TGPictureButton
Definition: TGButton.h:228
TGFileBrowser::fFilterStr
TString fFilterStr
Definition: TGFileBrowser.h:74
TGFileBrowser::DoubleClicked
void DoubleClicked(TGListTreeItem *item, Int_t btn)
Process double clicks in TGListTree.
Definition: TGFileBrowser.cxx:1201
TGFileBrowser::fFilteredItems
mFiltered_t fFilteredItems
Definition: TGFileBrowser.h:73
TGFileBrowser::fListLevel
TGListTreeItem * fListLevel
Definition: TGFileBrowser.h:50
TGFileBrowser::Selected
void Selected(char *)
A ROOT File has been selected in TGHtmlBrowser.
Definition: TGFileBrowser.cxx:1813
TObject
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGFileBrowser::fNewBrowser
TRootBrowser * fNewBrowser
Definition: TGFileBrowser.h:45
TGFileBrowser::fFilter
TRegexp * fFilter
Definition: TGFileBrowser.h:63
name
char name[80]
Definition: TGX11.cxx:110
TGFileBrowser::fCurrentDir
TGListTreeItem * fCurrentDir
Definition: TGFileBrowser.h:51
TGFileBrowser::XXExecuteDefaultAction
Long_t XXExecuteDefaultAction(TObject *obj)
Execute default action for selected object (action is specified in the $HOME/.root....
Definition: TGFileBrowser.cxx:1512
TGFileBrowser::fFileType
TGComboBox * fFileType
Definition: TGFileBrowser.h:54
TGFileBrowser::fNKeys
Long_t fNKeys
Definition: TGFileBrowser.h:67
TGFileBrowser::sLTI_t
std::list< TGListTreeItem * > sLTI_t
Definition: TGFileBrowser.h:39
TGFileBrowser::sLTI_i
sLTI_t::iterator sLTI_i
Definition: TGFileBrowser.h:40
TGFileBrowser::fRootDir
TGListTreeItem * fRootDir
Definition: TGFileBrowser.h:52
TGFileBrowser::DirName
TString DirName(TGListTreeItem *item)
returns the directory path
Definition: TGFileBrowser.cxx:1114
TGCanvas
Definition: TGCanvas.h:202
TGListTreeItem
Definition: TGListTree.h:43
TGFileBrowser::fDir
TSystemDirectory * fDir
Definition: TGFileBrowser.h:64
TGFileBrowser::Chdir
void Chdir(TGListTreeItem *item)
Make object associated with item the current directory.
Definition: TGFileBrowser.cxx:849
TGFileBrowser::FullPathName
TString FullPathName(TGListTreeItem *item)
returns an absolute path
Definition: TGFileBrowser.cxx:1086
int
TRootBrowser
Definition: TRootBrowser.h:53
TGFileBrowser::CheckFiltered
Bool_t CheckFiltered(TGListTreeItem *item, Bool_t but=kFALSE)
Check if there is a filter active on the children of the list tree item.
Definition: TGFileBrowser.cxx:935