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
38class TRegexp;
39class TGPicture;
40class TGFileContainer;
41class TViewUpdateTimer;
42class TGFileIcon;
43class TGFileItem;
44class TTimer;
45class TString;
46class TBufferFile;
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
100 virtual Atom_t HandleDNDEnter(Atom_t *);
101
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
125friend class TGFSFrameElement;
126
127protected:
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
148public:
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
@ kSunkenFrame
Definition: GuiTypes.h:383
@ kVerticalFrame
Definition: GuiTypes.h:381
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:43
unsigned long ULong_t
Definition: RtypesCore.h:53
long Long_t
Definition: RtypesCore.h:52
bool Bool_t
Definition: RtypesCore.h:61
long long Long64_t
Definition: RtypesCore.h:71
const Bool_t kTRUE
Definition: RtypesCore.h:89
const char Option_t
Definition: RtypesCore.h:64
#define ClassDef(name, id)
Definition: Rtypes.h:322
EFSSortMode
Definition: TGFSContainer.h:28
@ kSortByDate
Definition: TGFSContainer.h:32
@ kSortByOwner
Definition: TGFSContainer.h:33
@ kSortByName
Definition: TGFSContainer.h:29
@ kSortByGroup
Definition: TGFSContainer.h:34
@ kSortByType
Definition: TGFSContainer.h:30
@ kSortBySize
Definition: TGFSContainer.h:31
EListViewMode
Definition: TGListView.h:39
@ kLVList
Definition: TGListView.h:42
char name[80]
Definition: TGX11.cxx:109
int type
Definition: TGX11.cxx:120
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition: TBufferFile.h:46
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)
Set drag and drop object.
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.
void SetDNDData(TDNDData *data)
Set drag and drop 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 Atom_t HandleDNDEnter(Atom_t *)
Handle drag and drop enter.
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:693
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:667
Bool_t fActive
Definition: TGListView.h:68
const TGWindow * GetParent() const
Definition: TGWindow.h:84
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