Logo ROOT   6.12/07
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 #include <stdlib.h>
28 
29 //----- file sort mode
37 };
38 
39 
40 class TRegexp;
41 class TGPicture;
42 class TGFileContainer;
43 class TViewUpdateTimer;
44 class TGFileIcon;
45 class TGFileItem;
46 class TTimer;
47 class TString;
48 struct FileStat_t;
49 
50 
51 class TGFileItem : public TGLVEntry {
52 
53 protected:
54  const TGPicture *fBlpic; // big icon
55  const TGPicture *fSlpic; // small icon
56  const TGPicture *fLcurrent; // current icon
57  Int_t fType; // file type
58  Int_t fUid, fGid; // file uid and gid
59  Bool_t fIsLink; // true if symbolic link
60  Long_t fModTime; // modification time
61  Long64_t fSize; // file size
62  TBufferFile *fBuf; // buffer used for Drag and Drop
63  TDNDData fDNDData; // Drag and Drop data
64 
65  void Init(const TGPicture *blpic, const TGPicture *slpic,
66  FileStat_t &stat, EListViewMode viewMode);
67  virtual void DoRedraw();
68 
69 public:
70  TGFileItem(const TGWindow *p = 0,
71  const TGPicture *bpic = 0, const TGPicture *blpic = 0,
72  const TGPicture *spic = 0, const TGPicture *slpic = 0,
73  TGString *name = 0, Int_t type = 0, Long64_t size = 1,
74  Int_t uid = 0, Int_t gid = 0, Long_t modtime = 0,
75  EListViewMode viewMode = kLVList, UInt_t options = kVerticalFrame,
76  Pixel_t back = GetWhitePixel());
77 
78  TGFileItem(const TGWindow *p,
79  const TGPicture *bpic, const TGPicture *blpic,
80  const TGPicture *spic, const TGPicture *slpic,
81  TGString *name, FileStat_t &stat,
82  EListViewMode viewMode = kLVList, UInt_t options = kVerticalFrame,
83  Pixel_t back = GetWhitePixel());
84 
85  virtual ~TGFileItem();
86 
87  virtual void SetViewMode(EListViewMode viewMode);
88 
89  Bool_t IsActive() const { return fActive; }
90  Bool_t IsSymLink() const { return fIsLink; }
91  Int_t GetType() const { return fType; }
92  Long64_t GetSize() const { return fSize; }
93  Long_t GetModTime() const { return fModTime; }
94  Int_t GetUid() const { return fUid; }
95  Int_t GetGid() const { return fGid; }
96 
98  return &fDNDData;
99  }
100 
102  if (!IsDNDTarget()) return kNone;
103  return gVirtualX->InternAtom("application/root", kFALSE);
104  }
105 
106  virtual Bool_t HandleDNDLeave() {
107  return kTRUE;
108  }
109 
110  virtual Atom_t HandleDNDPosition(int, int, Atom_t action, int, int) {
111  if (action == TGDNDManager::GetDNDActionCopy()) return action;
112  return kNone;
113  }
114 
116  return ((TGFrame *)(const_cast<TGWindow*>(GetParent())))->HandleDNDFinished();
117  }
118 
120  if (fDNDData.fDataLength > 0)
121  free(fDNDData.fData);
122  fDNDData.fData = calloc(sizeof(unsigned char), data->fDataLength);
123  if (fDNDData.fData)
124  memcpy(fDNDData.fData, data->fData, data->fDataLength);
125  fDNDData.fDataLength = data->fDataLength;
126  fDNDData.fDataType = data->fDataType;
127  }
128 
129  void SetDNDObject(TObject *obj) {
130  if (fDNDData.fDataLength)
131  free(fDNDData.fData);
132  fBuf->WriteObject(obj);
133  fDNDData.fData = fBuf->Buffer();
134  fDNDData.fDataLength = fBuf->Length();
135  fDNDData.fDataType = gVirtualX->InternAtom("application/root", kFALSE);
136  }
137 
138  ClassDef(TGFileItem,0) // Class representing file system object
139 };
140 
141 
143 
144 friend class TGFSFrameElement;
145 
146 protected:
147  EFSSortMode fSortType; // sorting mode of contents
148  TRegexp *fFilter; // file filter
149  TViewUpdateTimer *fRefresh; // refresh timer
150  ULong_t fMtime; // directory modification time
151  TString fDirectory; // current directory
152  TList *fCleanups; // list of pictures to cleanup
153  const TGPicture *fFolder_t; // small folder icon
154  const TGPicture *fFolder_s; // big folder icon
155  const TGPicture *fApp_t; // small application icon
156  const TGPicture *fApp_s; // big application icon
157  const TGPicture *fDoc_t; // small document icon
158  const TGPicture *fDoc_s; // big document icon
159  const TGPicture *fSlink_t; // small symbolic link icon
160  const TGPicture *fSlink_s; // big symbolic link icon
161  Bool_t fCachePictures; // kTRUE use caching
162  Bool_t fDisplayStat; // kFALSE to interrupt display directory
163  // contents in case of many files inside
164 
165  void CreateFileList();
166 
167 public:
168  TGFileContainer(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
169  UInt_t options = kSunkenFrame,
173 
174  virtual ~TGFileContainer();
175 
176  virtual Bool_t HandleTimer(TTimer *t);
177  void StopRefreshTimer();
178  void StartRefreshTimer(ULong_t msec=1000);
179 
180  virtual TGFileItem *AddFile(const char *name, const TGPicture *pic = 0, const TGPicture *lpic = 0);
181  virtual TGFileItem *AddRemoteFile(TObject *obj, const TGPicture *ipic = 0, const TGPicture *ilpic = 0);
182  virtual void AddFrame(TGFrame *f, TGLayoutHints *l = 0);
183  virtual void Sort(EFSSortMode sortType);
184  virtual void SetFilter(const char *filter);
185  virtual void ChangeDirectory(const char *path);
186  virtual void DisplayDirectory();
187  virtual void SetDisplayStat(Bool_t stat = kTRUE) { fDisplayStat = stat; }
188  Bool_t GetDisplayStat() { return fDisplayStat; }
189 
190  const char *GetDirectory() const { return fDirectory.Data(); }
191 
192  virtual void GetFilePictures(const TGPicture **pic, const TGPicture **lpic,
193  Int_t file_type, Bool_t is_link, const char *ext,
194  Bool_t small);
195 
196  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
197 
198  ClassDef(TGFileContainer,0) // Container containing file system objects
199 };
200 
201 #endif
Int_t GetType() const
Definition: TGFSContainer.h:91
void SetDNDObject(TObject *obj)
Int_t GetGid() const
Definition: TGFSContainer.h:95
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:47
TDNDData fDNDData
Definition: TGFSContainer.h:63
long long Long64_t
Definition: RtypesCore.h:69
const TGPicture * fFolder_s
const TGPicture * fLcurrent
Definition: TGFSContainer.h:56
const TGPicture * fDoc_t
const char Option_t
Definition: RtypesCore.h:62
TH1 * h
Definition: legend2.C:5
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
const TGPicture * fSlpic
Definition: TGFSContainer.h:55
Regular expression class.
Definition: TRegexp.h:31
EListViewMode
Definition: TGListView.h:39
Bool_t IsActive() const
Definition: TGFSContainer.h:89
const TGPicture * fBlpic
Definition: TGFSContainer.h:54
Basic string class.
Definition: TString.h:125
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual TDNDData * GetDNDdata(Atom_t)
Definition: TGFSContainer.h:97
virtual void SetViewMode(EListViewMode viewMode)
Set container item view mode.
EFSSortMode fSortType
static Atom_t GetDNDActionCopy()
virtual Bool_t HandleTimer(TTimer *)
Execute action in response of a timer timing out.
Definition: TGWindow.h:108
TRegexp * fFilter
Int_t Length() const
Definition: TBuffer.h:96
virtual Bool_t HandleDNDFinished()
const TGPicture * fFolder_t
#define ClassDef(name, id)
Definition: Rtypes.h:320
ULong_t Pixel_t
Definition: GuiTypes.h:39
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
Handle_t Atom_t
Definition: GuiTypes.h:36
char * Buffer() const
Definition: TBuffer.h:93
void * fData
Definition: TGDNDManager.h:77
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Definition: TMath.h:1150
Bool_t fActive
Definition: TGListView.h:68
A doubly linked list.
Definition: TList.h:44
const TGPicture * fApp_t
Bool_t IsDNDTarget() const
Definition: TGFrame.h:320
void SetDNDData(TDNDData *data)
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a frame widget as a C++ statement(s) on output stream out.
Definition: TGFrame.cxx:3187
Long_t fModTime
Definition: TGFSContainer.h:60
virtual void SetDisplayStat(Bool_t stat=kTRUE)
virtual Atom_t HandleDNDEnter(Atom_t *)
Long_t GetModTime() const
Definition: TGFSContainer.h:93
Bool_t IsSymLink() const
Definition: TGFSContainer.h:90
TViewUpdateTimer * fRefresh
const char * GetDirectory() const
unsigned int UInt_t
Definition: RtypesCore.h:42
const Handle_t kNone
Definition: GuiTypes.h:87
Int_t GetUid() const
Definition: TGFSContainer.h:94
#define calloc
Definition: civetweb.c:819
EFSSortMode
Definition: TGFSContainer.h:30
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
Atom_t fDataType
Definition: TGDNDManager.h:75
#define gVirtualX
Definition: TVirtualX.h:350
const TGPicture * fSlink_s
const Bool_t kFALSE
Definition: RtypesCore.h:88
virtual Bool_t HandleDNDLeave()
long Long_t
Definition: RtypesCore.h:50
TBufferFile * fBuf
Definition: TGFSContainer.h:62
int type
Definition: TGX11.cxx:120
const TGPicture * fSlink_t
#define free
Definition: civetweb.c:821
unsigned long ULong_t
Definition: RtypesCore.h:51
const TGWindow * GetParent() const
Definition: TGWindow.h:85
Bool_t fIsLink
Definition: TGFSContainer.h:59
Mother of all ROOT objects.
Definition: TObject.h:37
virtual ~TGFileItem()
Destructor.
auto * l
Definition: textangle.C:4
Long64_t fSize
Definition: TGFSContainer.h:61
virtual void DoRedraw()
Draw list view container item.
Long64_t GetSize() const
Definition: TGFSContainer.h:92
Bool_t GetDisplayStat()
virtual Atom_t HandleDNDPosition(int, int, Atom_t action, int, int)
const Bool_t kTRUE
Definition: RtypesCore.h:87
const TGPicture * fDoc_s
const TGPicture * fApp_s
char name[80]
Definition: TGX11.cxx:109
virtual void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE)
Write object to I/O buffer.
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:345