Logo ROOT  
Reference Guide
TGFSContainer.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 19/01/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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_TGFSContainer
13 #define ROOT_TGFSContainer
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGFileIcon, TGFileEntry, TGFSContainer //
19 // //
20 // Utility classes used by the file selection dialog (TGFileDialog). //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "TGListView.h"
25 #include "TGDNDManager.h"
26 
27 //----- file sort mode
35 };
36 
37 
38 class TRegexp;
39 class TGPicture;
40 class TGFileContainer;
41 class TViewUpdateTimer;
42 class TGFileIcon;
43 class TGFileItem;
44 class TTimer;
45 class TString;
46 class TBufferFile;
47 struct FileStat_t;
48 
49 
50 class TGFileItem : public TGLVEntry {
51 
52 protected:
53  const TGPicture *fBlpic; // big icon
54  const TGPicture *fSlpic; // small icon
55  const TGPicture *fLcurrent; // current icon
56  Int_t fType; // file type
57  Int_t fUid, fGid; // file uid and gid
58  Bool_t fIsLink; // true if symbolic link
59  Long_t fModTime; // modification time
60  Long64_t fSize; // file size
61  TBufferFile *fBuf; // buffer used for Drag and Drop
62  TDNDData fDNDData; // Drag and Drop data
63 
64  void Init(const TGPicture *blpic, const TGPicture *slpic,
65  FileStat_t &stat, EListViewMode viewMode);
66  virtual void DoRedraw();
67 
68 public:
69  TGFileItem(const TGWindow *p = 0,
70  const TGPicture *bpic = 0, const TGPicture *blpic = 0,
71  const TGPicture *spic = 0, const TGPicture *slpic = 0,
72  TGString *name = 0, Int_t type = 0, Long64_t size = 1,
73  Int_t uid = 0, Int_t gid = 0, Long_t modtime = 0,
74  EListViewMode viewMode = kLVList, UInt_t options = kVerticalFrame,
75  Pixel_t back = GetWhitePixel());
76 
77  TGFileItem(const TGWindow *p,
78  const TGPicture *bpic, const TGPicture *blpic,
79  const TGPicture *spic, const TGPicture *slpic,
80  TGString *name, FileStat_t &stat,
81  EListViewMode viewMode = kLVList, UInt_t options = kVerticalFrame,
82  Pixel_t back = GetWhitePixel());
83 
84  virtual ~TGFileItem();
85 
86  virtual void SetViewMode(EListViewMode viewMode);
87 
88  Bool_t IsActive() const { return fActive; }
89  Bool_t IsSymLink() const { return fIsLink; }
90  Int_t GetType() const { return fType; }
91  Long64_t GetSize() const { return fSize; }
92  Long_t GetModTime() const { return fModTime; }
93  Int_t GetUid() const { return fUid; }
94  Int_t GetGid() const { return fGid; }
95 
97  return &fDNDData;
98  }
99 
100  virtual Atom_t HandleDNDEnter(Atom_t *);
101 
102  virtual Bool_t HandleDNDLeave() {
103  return kTRUE;
104  }
105 
106  virtual Atom_t HandleDNDPosition(int, int, Atom_t action, int, int) {
107  if (action == TGDNDManager::GetDNDActionCopy()) return action;
108  return kNone;
109  }
110 
112  return ((TGFrame *)(const_cast<TGWindow*>(GetParent())))->HandleDNDFinished();
113  }
114 
115  void SetDNDData(TDNDData *data);
116 
117  void SetDNDObject(TObject *obj);
118 
119  ClassDef(TGFileItem,0) // Class representing file system object
120 };
121 
122 
124 
125 friend class TGFSFrameElement;
126 
127 protected:
128  EFSSortMode fSortType; // sorting mode of contents
129  TRegexp *fFilter; // file filter
130  TViewUpdateTimer *fRefresh; // refresh timer
131  ULong_t fMtime; // directory modification time
132  TString fDirectory; // current directory
133  TList *fCleanups; // list of pictures to cleanup
134  const TGPicture *fFolder_t; // small folder icon
135  const TGPicture *fFolder_s; // big folder icon
136  const TGPicture *fApp_t; // small application icon
137  const TGPicture *fApp_s; // big application icon
138  const TGPicture *fDoc_t; // small document icon
139  const TGPicture *fDoc_s; // big document icon
140  const TGPicture *fSlink_t; // small symbolic link icon
141  const TGPicture *fSlink_s; // big symbolic link icon
142  Bool_t fCachePictures; // kTRUE use caching
143  Bool_t fDisplayStat; // kFALSE to interrupt display directory
144  // contents in case of many files inside
145 
146  void CreateFileList();
147 
148 public:
149  TGFileContainer(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
150  UInt_t options = kSunkenFrame,
154 
155  virtual ~TGFileContainer();
156 
157  virtual Bool_t HandleTimer(TTimer *t);
158  void StopRefreshTimer();
159  void StartRefreshTimer(ULong_t msec=1000);
160 
161  virtual TGFileItem *AddFile(const char *name, const TGPicture *pic = 0, const TGPicture *lpic = 0);
162  virtual TGFileItem *AddRemoteFile(TObject *obj, const TGPicture *ipic = 0, const TGPicture *ilpic = 0);
163  virtual void AddFrame(TGFrame *f, TGLayoutHints *l = 0);
164  virtual void Sort(EFSSortMode sortType);
165  virtual void SetFilter(const char *filter);
166  virtual void ChangeDirectory(const char *path);
167  virtual void DisplayDirectory();
168  virtual void SetDisplayStat(Bool_t stat = kTRUE) { fDisplayStat = stat; }
170 
171  const char *GetDirectory() const { return fDirectory.Data(); }
172 
173  virtual void GetFilePictures(const TGPicture **pic, const TGPicture **lpic,
174  Int_t file_type, Bool_t is_link, const char *ext,
175  Bool_t small);
176 
177  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
178 
179  ClassDef(TGFileContainer,0) // Container containing file system objects
180 };
181 
182 #endif
l
auto * l
Definition: textangle.C:4
EListViewMode
EListViewMode
Definition: TGListView.h:39
TGFileItem::GetModTime
Long_t GetModTime() const
Definition: TGFSContainer.h:92
TGFileItem::IsSymLink
Bool_t IsSymLink() const
Definition: TGFSContainer.h:89
TGWindow
Definition: TGWindow.h:31
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
TGFileContainer::fCachePictures
Bool_t fCachePictures
Definition: TGFSContainer.h:142
TGLVEntry::fActive
Bool_t fActive
Definition: TGListView.h:68
TGFileContainer::fFilter
TRegexp * fFilter
Definition: TGFSContainer.h:129
TGFileContainer
Definition: TGFSContainer.h:123
TGFileContainer::fDirectory
TString fDirectory
Definition: TGFSContainer.h:132
TGPicture
Definition: TGPicture.h:36
TGFileItem
Definition: TGFSContainer.h:50
f
#define f(i)
Definition: RSha256.hxx:104
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGFileContainer::fFolder_t
const TGPicture * fFolder_t
Definition: TGFSContainer.h:134
TGFileContainer::DisplayDirectory
virtual void DisplayDirectory()
Display the contents of the current directory in the container.
Definition: TGFSContainer.cxx:742
TGFileItem::HandleDNDLeave
virtual Bool_t HandleDNDLeave()
Definition: TGFSContainer.h:102
TGFileContainer::ChangeDirectory
virtual void ChangeDirectory(const char *path)
Change current directory.
Definition: TGFSContainer.cxx:725
TGFileContainer::CreateFileList
void CreateFileList()
This function creates the file list from current dir.
Definition: TGFSContainer.cxx:760
TGFileItem::GetUid
Int_t GetUid() const
Definition: TGFSContainer.h:93
TString::Data
const char * Data() const
Definition: TString.h:369
Pixel_t
ULong_t Pixel_t
Definition: GuiTypes.h:39
TGFileItem::SetDNDData
void SetDNDData(TDNDData *data)
Set drag and drop data.
Definition: TGFSContainer.cxx:450
TGFileContainer::fRefresh
TViewUpdateTimer * fRefresh
Definition: TGFSContainer.h:130
TGFileContainer::AddFile
virtual TGFileItem * AddFile(const char *name, const TGPicture *pic=0, const TGPicture *lpic=0)
Add file in container.
Definition: TGFSContainer.cxx:789
FileStat_t
Definition: TSystem.h:124
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGFileItem::~TGFileItem
virtual ~TGFileItem()
Destructor.
Definition: TGFSContainer.cxx:397
TGFileContainer::TGFSFrameElement
friend class TGFSFrameElement
Definition: TGFSContainer.h:125
Long64_t
long long Long64_t
Definition: RtypesCore.h:73
TGFileItem::fSize
Long64_t fSize
Definition: TGFSContainer.h:60
TGFileItem::DoRedraw
virtual void DoRedraw()
Draw list view container item.
Definition: TGFSContainer.cxx:420
TGFileContainer::fApp_s
const TGPicture * fApp_s
Definition: TGFSContainer.h:137
kSortByDate
@ kSortByDate
Definition: TGFSContainer.h:32
TGFileContainer::fDisplayStat
Bool_t fDisplayStat
Definition: TGFSContainer.h:143
TGFileItem::fUid
Int_t fUid
Definition: TGFSContainer.h:57
TGFileItem::fIsLink
Bool_t fIsLink
Definition: TGFSContainer.h:58
TGFileContainer::GetDisplayStat
Bool_t GetDisplayStat()
Definition: TGFSContainer.h:169
TGLVEntry
Definition: TGListView.h:54
Int_t
int Int_t
Definition: RtypesCore.h:45
TGFileItem::HandleDNDEnter
virtual Atom_t HandleDNDEnter(Atom_t *)
Handle drag and drop enter.
Definition: TGFSContainer.cxx:441
TGFileContainer::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame.
Definition: TGFSContainer.cxx:576
TGFileContainer::fDoc_s
const TGPicture * fDoc_s
Definition: TGFSContainer.h:139
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:668
TGFileItem::GetSize
Long64_t GetSize() const
Definition: TGFSContainer.h:91
TGFileContainer::GetFilePictures
virtual void GetFilePictures(const TGPicture **pic, const TGPicture **lpic, Int_t file_type, Bool_t is_link, const char *ext, Bool_t small)
Determine the file picture for the given file type.
Definition: TGFSContainer.cxx:627
TGFileItem::fBuf
TBufferFile * fBuf
Definition: TGFSContainer.h:61
TGDNDManager.h
TGFileContainer::fSlink_s
const TGPicture * fSlink_s
Definition: TGFSContainer.h:141
TString
Basic string class.
Definition: TString.h:136
TGFrame
Definition: TGFrame.h:105
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGFileContainer::TGFileContainer
TGFileContainer(const TGWindow *p=0, UInt_t w=1, UInt_t h=1, UInt_t options=kSunkenFrame, Pixel_t back=GetDefaultFrameBackground())
Create a list view container which will hold the contents of the current directory.
Definition: TGFSContainer.cxx:480
TGFileContainer::~TGFileContainer
virtual ~TGFileContainer()
Delete list view file container.
Definition: TGFSContainer.cxx:550
bool
TGFileItem::GetGid
Int_t GetGid() const
Definition: TGFSContainer.h:94
kSortByOwner
@ kSortByOwner
Definition: TGFSContainer.h:33
TGFileItem::Init
void Init(const TGPicture *blpic, const TGPicture *slpic, FileStat_t &stat, EListViewMode viewMode)
Common initializer for file list view item.
Definition: TGFSContainer.cxx:286
TGFileContainer::SetDisplayStat
virtual void SetDisplayStat(Bool_t stat=kTRUE)
Definition: TGFSContainer.h:168
kNone
const Handle_t kNone
Definition: GuiTypes.h:87
TGFileContainer::GetDirectory
const char * GetDirectory() const
Definition: TGFSContainer.h:171
TGDNDManager::GetDNDActionCopy
static Atom_t GetDNDActionCopy()
Definition: TGDNDManager.cxx:281
TTimer
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
kSortByType
@ kSortByType
Definition: TGFSContainer.h:30
kSunkenFrame
@ kSunkenFrame
Definition: GuiTypes.h:383
TGFileItem::GetType
Int_t GetType() const
Definition: TGFSContainer.h:90
TGFileItem::fType
Int_t fType
Definition: TGFSContainer.h:56
TGFileContainer::SetFilter
virtual void SetFilter(const char *filter)
Set file selection filter.
Definition: TGFSContainer.cxx:605
h
#define h(i)
Definition: RSha256.hxx:106
kSortByName
@ kSortByName
Definition: TGFSContainer.h:29
Atom_t
Handle_t Atom_t
Definition: GuiTypes.h:36
TGFileItem::HandleDNDPosition
virtual Atom_t HandleDNDPosition(int, int, Atom_t action, int, int)
Definition: TGFSContainer.h:106
TGFileItem::IsActive
Bool_t IsActive() const
Definition: TGFSContainer.h:88
TGFileItem::SetDNDObject
void SetDNDObject(TObject *obj)
Set drag and drop object.
Definition: TGFSContainer.cxx:464
Long_t
long Long_t
Definition: RtypesCore.h:54
TGFileContainer::StartRefreshTimer
void StartRefreshTimer(ULong_t msec=1000)
start refreshing
Definition: TGFSContainer.cxx:885
TGLayoutHints
Definition: TGLayout.h:57
TGFileContainer::fCleanups
TList * fCleanups
Definition: TGFSContainer.h:133
TGFileItem::TGFileItem
TGFileItem(const TGWindow *p=0, const TGPicture *bpic=0, const TGPicture *blpic=0, const TGPicture *spic=0, const TGPicture *slpic=0, TGString *name=0, Int_t type=0, Long64_t size=1, Int_t uid=0, Int_t gid=0, Long_t modtime=0, EListViewMode viewMode=kLVList, UInt_t options=kVerticalFrame, Pixel_t back=GetWhitePixel())
Create a list view item.
Definition: TGFSContainer.cxx:250
TGFileItem::fDNDData
TDNDData fDNDData
Definition: TGFSContainer.h:62
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
TDNDData
Definition: TGDNDManager.h:65
TGFileContainer::fApp_t
const TGPicture * fApp_t
Definition: TGFSContainer.h:136
TGFileItem::fSlpic
const TGPicture * fSlpic
Definition: TGFSContainer.h:54
TGFileContainer::AddRemoteFile
virtual TGFileItem * AddRemoteFile(TObject *obj, const TGPicture *ipic=0, const TGPicture *ilpic=0)
Add remote file in container.
Definition: TGFSContainer.cxx:838
unsigned int
TGFileItem::HandleDNDFinished
virtual Bool_t HandleDNDFinished()
Definition: TGFSContainer.h:111
TRegexp
Regular expression class.
Definition: TRegexp.h:31
TGWindow::GetParent
const TGWindow * GetParent() const
Definition: TGWindow.h:84
TGFileItem::fLcurrent
const TGPicture * fLcurrent
Definition: TGFSContainer.h:55
TGFileContainer::fFolder_s
const TGPicture * fFolder_s
Definition: TGFSContainer.h:135
TGLVContainer
Definition: TGListView.h:196
TGFileContainer::Sort
virtual void Sort(EFSSortMode sortType)
Sort file system list view container according to sortType.
Definition: TGFSContainer.cxx:614
kSortByGroup
@ kSortByGroup
Definition: TGFSContainer.h:34
TGFileItem::GetDNDdata
virtual TDNDData * GetDNDdata(Atom_t)
Definition: TGFSContainer.h:96
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
name
char name[80]
Definition: TGX11.cxx:110
TGFrame::GetWhitePixel
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:694
TGFileItem::SetViewMode
virtual void SetViewMode(EListViewMode viewMode)
Set container item view mode.
Definition: TGFSContainer.cxx:405
TGFileItem::fBlpic
const TGPicture * fBlpic
Definition: TGFSContainer.h:53
TGFileContainer::fSortType
EFSSortMode fSortType
Definition: TGFSContainer.h:128
EFSSortMode
EFSSortMode
Definition: TGFSContainer.h:28
TGFileContainer::fDoc_t
const TGPicture * fDoc_t
Definition: TGFSContainer.h:138
kSortBySize
@ kSortBySize
Definition: TGFSContainer.h:31
TGFileContainer::fMtime
ULong_t fMtime
Definition: TGFSContainer.h:131
TGFileContainer::HandleTimer
virtual Bool_t HandleTimer(TTimer *t)
Refresh container contents.
Definition: TGFSContainer.cxx:592
type
int type
Definition: TGX11.cxx:121
TGFileContainer::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a file container widget as a C++ statement(s) on output stream out.
Definition: TGFSContainer.cxx:894
TGListView.h
kLVList
@ kLVList
Definition: TGListView.h:42
TGCanvas
Definition: TGCanvas.h:202
TGString
Definition: TGString.h:30
TBufferFile
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition: TBufferFile.h:47
TGFileItem::fGid
Int_t fGid
Definition: TGFSContainer.h:57
TGFileContainer::StopRefreshTimer
void StopRefreshTimer()
stop refresh timer
Definition: TGFSContainer.cxx:876
TList
A doubly linked list.
Definition: TList.h:44
TGFileContainer::fSlink_t
const TGPicture * fSlink_t
Definition: TGFSContainer.h:140
TGFileItem::fModTime
Long_t fModTime
Definition: TGFSContainer.h:59
int