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