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#include "TBufferFile.h"
27
28//----- file sort mode
36};
37
38
39class TRegexp;
40class TGPicture;
41class TGFileContainer;
42class TViewUpdateTimer;
43class TGFileIcon;
44class TGFileItem;
45class TTimer;
46class TString;
47struct FileStat_t;
48
49
50class TGFileItem : public TGLVEntry {
51
52protected:
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
68public:
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
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);
126 }
127
131 fBuf->WriteObject(obj);
134 fDNDData.fDataType = gVirtualX->InternAtom("application/root", kFALSE);
135 }
136
137 ClassDef(TGFileItem,0) // Class representing file system object
138};
139
140
142
143friend class TGFSFrameElement;
144
145protected:
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
166public:
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
Handle_t Atom_t
Definition: GuiTypes.h:36
const Handle_t kNone
Definition: GuiTypes.h:87
ULong_t Pixel_t
Definition: GuiTypes.h:39
#define f(i)
Definition: RSha256.hxx:104
#define h(i)
Definition: RSha256.hxx:106
int Int_t
Definition: RtypesCore.h:41
unsigned int UInt_t
Definition: RtypesCore.h:42
const Bool_t kFALSE
Definition: RtypesCore.h:88
unsigned long ULong_t
Definition: RtypesCore.h:51
long Long_t
Definition: RtypesCore.h:50
bool Bool_t
Definition: RtypesCore.h:59
long long Long64_t
Definition: RtypesCore.h:69
const Bool_t kTRUE
Definition: RtypesCore.h:87
const char Option_t
Definition: RtypesCore.h:62
#define ClassDef(name, id)
Definition: Rtypes.h:326
EFSSortMode
Definition: TGFSContainer.h:29
@ kSortByDate
Definition: TGFSContainer.h:33
@ kSortByOwner
Definition: TGFSContainer.h:34
@ kSortByName
Definition: TGFSContainer.h:30
@ kSortByGroup
Definition: TGFSContainer.h:35
@ kSortByType
Definition: TGFSContainer.h:31
@ kSortBySize
Definition: TGFSContainer.h:32
@ kSunkenFrame
Definition: TGFrame.h:61
@ kVerticalFrame
Definition: TGFrame.h:59
EListViewMode
Definition: TGListView.h:39
@ kLVList
Definition: TGListView.h:42
char name[80]
Definition: TGX11.cxx:109
int type
Definition: TGX11.cxx:120
#define gVirtualX
Definition: TVirtualX.h:345
#define free
Definition: civetweb.c:1539
#define calloc
Definition: civetweb.c:1537
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition: TBufferFile.h:46
void WriteObject(const TObject *obj, Bool_t cacheReuse=kTRUE) override
Write object to I/O buffer.
Definition: TBufferIO.cxx:530
Int_t Length() const
Definition: TBuffer.h:99
char * Buffer() const
Definition: TBuffer.h:95
Atom_t fDataType
Definition: TGDNDManager.h:75
Int_t fDataLength
Definition: TGDNDManager.h:78
void * fData
Definition: TGDNDManager.h:77
static Atom_t GetDNDActionCopy()
const TGPicture * fSlink_s
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.
virtual TGFileItem * AddFile(const char *name, const TGPicture *pic=0, const TGPicture *lpic=0)
Add file in container.
void CreateFileList()
This function creates the file list from current dir.
const TGPicture * fFolder_s
TViewUpdateTimer * fRefresh
void StopRefreshTimer()
stop refresh timer
virtual Bool_t HandleTimer(TTimer *t)
Refresh container contents.
virtual void SetDisplayStat(Bool_t stat=kTRUE)
const TGPicture * fDoc_t
const TGPicture * fApp_t
const TGPicture * fApp_s
virtual void Sort(EFSSortMode sortType)
Sort file system list view container according to sortType.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame.
const TGPicture * fDoc_s
virtual void ChangeDirectory(const char *path)
Change current directory.
const TGPicture * fSlink_t
virtual void DisplayDirectory()
Display the contents of the current directory in the container.
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a file container widget as a C++ statement(s) on output stream out.
void StartRefreshTimer(ULong_t msec=1000)
start refreshing
const TGPicture * fFolder_t
TRegexp * fFilter
friend class TGFSFrameElement
virtual ~TGFileContainer()
Delete list view file container.
virtual void SetFilter(const char *filter)
Set file selection filter.
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.
Bool_t GetDisplayStat()
EFSSortMode fSortType
virtual TGFileItem * AddRemoteFile(TObject *obj, const TGPicture *ipic=0, const TGPicture *ilpic=0)
Add remote file in container.
const char * GetDirectory() const
Int_t GetUid() const
Definition: TGFSContainer.h:93
Long64_t fSize
Definition: TGFSContainer.h:60
const TGPicture * fLcurrent
Definition: TGFSContainer.h:55
Int_t GetGid() const
Definition: TGFSContainer.h:94
TBufferFile * fBuf
Definition: TGFSContainer.h:61
Bool_t IsActive() const
Definition: TGFSContainer.h:88
const TGPicture * fBlpic
Definition: TGFSContainer.h:53
void Init(const TGPicture *blpic, const TGPicture *slpic, FileStat_t &stat, EListViewMode viewMode)
Common initializer for file list view item.
virtual Atom_t HandleDNDPosition(int, int, Atom_t action, int, int)
Long_t fModTime
Definition: TGFSContainer.h:59
const TGPicture * fSlpic
Definition: TGFSContainer.h:54
Long64_t GetSize() const
Definition: TGFSContainer.h:91
void SetDNDObject(TObject *obj)
TDNDData fDNDData
Definition: TGFSContainer.h:62
Long_t GetModTime() const
Definition: TGFSContainer.h:92
Int_t GetType() const
Definition: TGFSContainer.h:90
virtual void DoRedraw()
Draw list view container item.
virtual Atom_t HandleDNDEnter(Atom_t *)
void SetDNDData(TDNDData *data)
virtual TDNDData * GetDNDdata(Atom_t)
Definition: TGFSContainer.h:96
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.
virtual void SetViewMode(EListViewMode viewMode)
Set container item view mode.
virtual Bool_t HandleDNDFinished()
virtual Bool_t HandleDNDLeave()
Bool_t IsSymLink() const
Definition: TGFSContainer.h:89
Bool_t fIsLink
Definition: TGFSContainer.h:58
virtual ~TGFileItem()
Destructor.
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:691
Bool_t IsDNDTarget() const
Definition: TGFrame.h:320
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
Bool_t fActive
Definition: TGListView.h:68
const TGWindow * GetParent() const
Definition: TGWindow.h:85
A doubly linked list.
Definition: TList.h:44
Mother of all ROOT objects.
Definition: TObject.h:37
Regular expression class.
Definition: TRegexp.h:31
Basic string class.
Definition: TString.h:131
const char * Data() const
Definition: TString.h:364
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
auto * l
Definition: textangle.C:4