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