Logo ROOT   6.21/01
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 #include "TBufferFile.h"
27 
28 //----- file sort mode
36 };
37 
38 
39 class TRegexp;
40 class TGPicture;
41 class TGFileContainer;
42 class TViewUpdateTimer;
43 class TGFileIcon;
44 class TGFileItem;
45 class TTimer;
46 class TString;
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 
101  if (!IsDNDTarget()) return kNone;
102  return gVirtualX->InternAtom("application/root", kFALSE);
103  }
104 
105  virtual Bool_t HandleDNDLeave() {
106  return kTRUE;
107  }
108 
109  virtual Atom_t HandleDNDPosition(int, int, Atom_t action, int, int) {
110  if (action == TGDNDManager::GetDNDActionCopy()) return action;
111  return kNone;
112  }
113 
115  return ((TGFrame *)(const_cast<TGWindow*>(GetParent())))->HandleDNDFinished();
116  }
117 
118  void SetDNDData(TDNDData *data) {
119  if (fDNDData.fDataLength > 0)
121  fDNDData.fData = calloc(sizeof(unsigned char), data->fDataLength);
122  if (fDNDData.fData)
123  memcpy(fDNDData.fData, data->fData, data->fDataLength);
125  fDNDData.fDataType = data->fDataType;
126  }
127 
128  void SetDNDObject(TObject *obj) {
129  if (fDNDData.fDataLength)
131  fBuf->WriteObject(obj);
132  fDNDData.fData = fBuf->Buffer();
134  fDNDData.fDataType = gVirtualX->InternAtom("application/root", kFALSE);
135  }
136 
137  ClassDef(TGFileItem,0) // Class representing file system object
138 };
139 
140 
142 
143 friend class TGFSFrameElement;
144 
145 protected:
146  EFSSortMode fSortType; // sorting mode of contents
147  TRegexp *fFilter; // file filter
148  TViewUpdateTimer *fRefresh; // refresh timer
149  ULong_t fMtime; // directory modification time
150  TString fDirectory; // current directory
151  TList *fCleanups; // list of pictures to cleanup
152  const TGPicture *fFolder_t; // small folder icon
153  const TGPicture *fFolder_s; // big folder icon
154  const TGPicture *fApp_t; // small application icon
155  const TGPicture *fApp_s; // big application icon
156  const TGPicture *fDoc_t; // small document icon
157  const TGPicture *fDoc_s; // big document icon
158  const TGPicture *fSlink_t; // small symbolic link icon
159  const TGPicture *fSlink_s; // big symbolic link icon
160  Bool_t fCachePictures; // kTRUE use caching
161  Bool_t fDisplayStat; // kFALSE to interrupt display directory
162  // contents in case of many files inside
163 
164  void CreateFileList();
165 
166 public:
167  TGFileContainer(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
168  UInt_t options = kSunkenFrame,
172 
173  virtual ~TGFileContainer();
174 
175  virtual Bool_t HandleTimer(TTimer *t);
176  void StopRefreshTimer();
177  void StartRefreshTimer(ULong_t msec=1000);
178 
179  virtual TGFileItem *AddFile(const char *name, const TGPicture *pic = 0, const TGPicture *lpic = 0);
180  virtual TGFileItem *AddRemoteFile(TObject *obj, const TGPicture *ipic = 0, const TGPicture *ilpic = 0);
181  virtual void AddFrame(TGFrame *f, TGLayoutHints *l = 0);
182  virtual void Sort(EFSSortMode sortType);
183  virtual void SetFilter(const char *filter);
184  virtual void ChangeDirectory(const char *path);
185  virtual void DisplayDirectory();
186  virtual void SetDisplayStat(Bool_t stat = kTRUE) { fDisplayStat = stat; }
188 
189  const char *GetDirectory() const { return fDirectory.Data(); }
190 
191  virtual void GetFilePictures(const TGPicture **pic, const TGPicture **lpic,
192  Int_t file_type, Bool_t is_link, const char *ext,
193  Bool_t small);
194 
195  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
196 
197  ClassDef(TGFileContainer,0) // Container containing file system objects
198 };
199 
200 #endif
Int_t GetType() const
Definition: TGFSContainer.h:90
void SetDNDObject(TObject *obj)
Int_t GetGid() const
Definition: TGFSContainer.h:94
void Init(const TGPicture *blpic, const TGPicture *slpic, FileStat_t &stat, EListViewMode viewMode)
Common initializer for file list view item.
Int_t fDataLength
Definition: TGDNDManager.h:78
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
Definition: TBufferFile.h:46
TDNDData fDNDData
Definition: TGFSContainer.h:62
long long Long64_t
Definition: RtypesCore.h:69
const TGPicture * fFolder_s
const TGPicture * fLcurrent
Definition: TGFSContainer.h:55
void StopRefreshTimer()
stop refresh timer
const TGPicture * fDoc_t
const char Option_t
Definition: RtypesCore.h:62
void StartRefreshTimer(ULong_t msec=1000)
start refreshing
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
const TGPicture * fSlpic
Definition: TGFSContainer.h:54
Regular expression class.
Definition: TRegexp.h:31
EListViewMode
Definition: TGListView.h:39
Bool_t IsActive() const
Definition: TGFSContainer.h:88
const TGPicture * fBlpic
Definition: TGFSContainer.h:53
Basic string class.
Definition: TString.h:131
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual TDNDData * GetDNDdata(Atom_t)
Definition: TGFSContainer.h:96
virtual TGFileItem * AddRemoteFile(TObject *obj, const TGPicture *ipic=0, const TGPicture *ilpic=0)
Add remote file in container.
virtual void SetViewMode(EListViewMode viewMode)
Set container item view mode.
EFSSortMode fSortType
static Atom_t GetDNDActionCopy()
TRegexp * fFilter
Int_t Length() const
Definition: TBuffer.h:99
virtual Bool_t HandleDNDFinished()
friend class TGFSFrameElement
const TGPicture * fFolder_t
#define ClassDef(name, id)
Definition: Rtypes.h:326
ULong_t Pixel_t
Definition: GuiTypes.h:39
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
virtual void ChangeDirectory(const char *path)
Change current directory.
void CreateFileList()
This function creates the file list from current dir.
Handle_t Atom_t
Definition: GuiTypes.h:36
char * Buffer() const
Definition: TBuffer.h:95
void * fData
Definition: TGDNDManager.h:77
virtual void Sort(EFSSortMode sortType)
Sort file system list view container according to sortType.
Bool_t fActive
Definition: TGListView.h:68
virtual Bool_t HandleTimer(TTimer *t)
Refresh container contents.
void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
Definition: TBufferIO.cxx:530
A doubly linked list.
Definition: TList.h:44
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.
const TGPicture * fApp_t
Bool_t IsDNDTarget() const
Definition: TGFrame.h:320
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame.
void SetDNDData(TDNDData *data)
Long_t fModTime
Definition: TGFSContainer.h:59
virtual void SetDisplayStat(Bool_t stat=kTRUE)
virtual Atom_t HandleDNDEnter(Atom_t *)
Long_t GetModTime() const
Definition: TGFSContainer.h:92
Bool_t IsSymLink() const
Definition: TGFSContainer.h:89
TViewUpdateTimer * fRefresh
const char * GetDirectory() const
virtual TGFileItem * AddFile(const char *name, const TGPicture *pic=0, const TGPicture *lpic=0)
Add file in container.
unsigned int UInt_t
Definition: RtypesCore.h:42
const Handle_t kNone
Definition: GuiTypes.h:87
Int_t GetUid() const
Definition: TGFSContainer.h:93
#define calloc
Definition: civetweb.c:1537
EFSSortMode
Definition: TGFSContainer.h:29
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
Atom_t fDataType
Definition: TGDNDManager.h:75
#define gVirtualX
Definition: TVirtualX.h:345
const TGPicture * fSlink_s
#define h(i)
Definition: RSha256.hxx:106
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a file container widget as a C++ statement(s) on output stream out.
virtual Bool_t HandleDNDLeave()
long Long_t
Definition: RtypesCore.h:50
TBufferFile * fBuf
Definition: TGFSContainer.h:61
int type
Definition: TGX11.cxx:120
const TGPicture * fSlink_t
#define free
Definition: civetweb.c:1539
unsigned long ULong_t
Definition: RtypesCore.h:51
const TGWindow * GetParent() const
Definition: TGWindow.h:85
Bool_t fIsLink
Definition: TGFSContainer.h:58
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void SetFilter(const char *filter)
Set file selection filter.
virtual ~TGFileItem()
Destructor.
auto * l
Definition: textangle.C:4
Long64_t fSize
Definition: TGFSContainer.h:60
virtual void DoRedraw()
Draw list view container item.
Long64_t GetSize() const
Definition: TGFSContainer.h:91
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.
virtual void DisplayDirectory()
Display the contents of the current directory in the container.
Bool_t GetDisplayStat()
virtual Atom_t HandleDNDPosition(int, int, Atom_t action, int, int)
virtual ~TGFileContainer()
Delete list view file container.
const Bool_t kTRUE
Definition: RtypesCore.h:87
const TGPicture * fDoc_s
const TGPicture * fApp_s
char name[80]
Definition: TGX11.cxx:109
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.
const char * Data() const
Definition: TString.h:364