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-2021, 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 #include "TGListView.h"
17 #include "TGDNDManager.h"
18 
19 //----- file sort mode
27 };
28 
29 
30 class TRegexp;
31 class TGPicture;
32 class TGFileContainer;
33 class TViewUpdateTimer;
34 class TGFileIcon;
35 class TGFileItem;
36 class TTimer;
37 class TString;
38 class TBufferFile;
39 struct FileStat_t;
40 
41 
42 class TGFileItem : public TGLVEntry {
43 
44 protected:
45  const TGPicture *fBlpic; // big icon
46  const TGPicture *fSlpic; // small icon
47  const TGPicture *fLcurrent; // current icon
48  Int_t fType; // file type
49  Int_t fUid, fGid; // file uid and gid
50  Bool_t fIsLink; // true if symbolic link
51  Long_t fModTime; // modification time
52  Long64_t fSize; // file size
53  TBufferFile *fBuf; // buffer used for Drag and Drop
54  TDNDData fDNDData; // Drag and Drop data
55 
56  void Init(const TGPicture *blpic, const TGPicture *slpic,
57  FileStat_t &stat, EListViewMode viewMode);
58  virtual void DoRedraw();
59 
60 public:
61  TGFileItem(const TGWindow *p = nullptr,
62  const TGPicture *bpic = nullptr, const TGPicture *blpic = nullptr,
63  const TGPicture *spic = nullptr, const TGPicture *slpic = nullptr,
64  TGString *name = nullptr, Int_t type = 0, Long64_t size = 1,
65  Int_t uid = 0, Int_t gid = 0, Long_t modtime = 0,
66  EListViewMode viewMode = kLVList, UInt_t options = kVerticalFrame,
67  Pixel_t back = GetWhitePixel());
68 
69  TGFileItem(const TGWindow *p,
70  const TGPicture *bpic, const TGPicture *blpic,
71  const TGPicture *spic, const TGPicture *slpic,
72  TGString *name, FileStat_t &stat,
73  EListViewMode viewMode = kLVList, UInt_t options = kVerticalFrame,
74  Pixel_t back = GetWhitePixel());
75 
76  virtual ~TGFileItem();
77 
78  virtual void SetViewMode(EListViewMode viewMode);
79 
80  Bool_t IsActive() const { return fActive; }
81  Bool_t IsSymLink() const { return fIsLink; }
82  Int_t GetType() const { return fType; }
83  Long64_t GetSize() const { return fSize; }
84  Long_t GetModTime() const { return fModTime; }
85  Int_t GetUid() const { return fUid; }
86  Int_t GetGid() const { return fGid; }
87 
89  return &fDNDData;
90  }
91 
92  virtual Atom_t HandleDNDEnter(Atom_t *);
93 
94  virtual Bool_t HandleDNDLeave() {
95  return kTRUE;
96  }
97 
98  virtual Atom_t HandleDNDPosition(int, int, Atom_t action, int, int) {
99  if (action == TGDNDManager::GetDNDActionCopy()) return action;
100  return kNone;
101  }
102 
104  return ((TGFrame *)(const_cast<TGWindow*>(GetParent())))->HandleDNDFinished();
105  }
106 
107  void SetDNDData(TDNDData *data);
108 
109  void SetDNDObject(TObject *obj);
110 
111  ClassDef(TGFileItem,0) // Class representing file system object
112 };
113 
114 
116 
117 friend class TGFSFrameElement;
118 
119 protected:
120  EFSSortMode fSortType; // sorting mode of contents
121  TRegexp *fFilter; // file filter
122  TViewUpdateTimer *fRefresh; // refresh timer
123  ULong_t fMtime; // directory modification time
124  TString fDirectory; // current directory
125  TList *fCleanups; // list of pictures to cleanup
126  const TGPicture *fFolder_t; // small folder icon
127  const TGPicture *fFolder_s; // big folder icon
128  const TGPicture *fApp_t; // small application icon
129  const TGPicture *fApp_s; // big application icon
130  const TGPicture *fDoc_t; // small document icon
131  const TGPicture *fDoc_s; // big document icon
132  const TGPicture *fSlink_t; // small symbolic link icon
133  const TGPicture *fSlink_s; // big symbolic link icon
134  Bool_t fCachePictures; // kTRUE use caching
135  Bool_t fDisplayStat; // kFALSE to interrupt display directory
136  // contents in case of many files inside
137 
138  void CreateFileList();
139 
140 public:
141  TGFileContainer(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
142  UInt_t options = kSunkenFrame,
146 
147  virtual ~TGFileContainer();
148 
149  virtual Bool_t HandleTimer(TTimer *t);
150  void StopRefreshTimer();
151  void StartRefreshTimer(ULong_t msec=1000);
152 
153  virtual TGFileItem *AddFile(const char *name, const TGPicture *pic = nullptr, const TGPicture *lpic = nullptr);
154  virtual TGFileItem *AddRemoteFile(TObject *obj, const TGPicture *ipic = nullptr, const TGPicture *ilpic = nullptr);
155  virtual void AddFrame(TGFrame *f, TGLayoutHints *l = nullptr);
156  virtual void Sort(EFSSortMode sortType);
157  virtual void SetFilter(const char *filter);
158  virtual void ChangeDirectory(const char *path);
159  virtual void DisplayDirectory();
160  virtual void SetDisplayStat(Bool_t stat = kTRUE) { fDisplayStat = stat; }
162 
163  const char *GetDirectory() const { return fDirectory.Data(); }
164 
165  virtual void GetFilePictures(const TGPicture **pic, const TGPicture **lpic,
166  Int_t file_type, Bool_t is_link, const char *ext,
167  Bool_t small);
168 
169  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
170 
171  ClassDef(TGFileContainer,0) // Container containing file system objects
172 };
173 
174 #endif
l
auto * l
Definition: textangle.C:4
EListViewMode
EListViewMode
Definition: TGListView.h:21
TGFileItem::GetModTime
Long_t GetModTime() const
Definition: TGFSContainer.h:84
TGFileItem::IsSymLink
Bool_t IsSymLink() const
Definition: TGFSContainer.h:81
TGWindow
ROOT GUI Window base class.
Definition: TGWindow.h:23
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:95
TGFileContainer::fCachePictures
Bool_t fCachePictures
Definition: TGFSContainer.h:134
TGLVEntry::fActive
Bool_t fActive
Definition: TGListView.h:50
TGFileContainer::fFilter
TRegexp * fFilter
Definition: TGFSContainer.h:121
TGFileContainer
Definition: TGFSContainer.h:115
TGFileContainer::fDirectory
TString fDirectory
Definition: TGFSContainer.h:124
TGPicture
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition: TGPicture.h:25
TGFileItem
Definition: TGFSContainer.h:42
f
#define f(i)
Definition: RSha256.hxx:104
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGFileContainer::fFolder_t
const TGPicture * fFolder_t
Definition: TGFSContainer.h:126
TGFileContainer::DisplayDirectory
virtual void DisplayDirectory()
Display the contents of the current directory in the container.
Definition: TGFSContainer.cxx:743
TGFileItem::HandleDNDLeave
virtual Bool_t HandleDNDLeave()
Definition: TGFSContainer.h:94
TGFileContainer::ChangeDirectory
virtual void ChangeDirectory(const char *path)
Change current directory.
Definition: TGFSContainer.cxx:726
TGFileContainer::CreateFileList
void CreateFileList()
This function creates the file list from current dir.
Definition: TGFSContainer.cxx:761
TGFileItem::GetUid
Int_t GetUid() const
Definition: TGFSContainer.h:85
TString::Data
const char * Data() const
Definition: TString.h:369
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
TGFileItem::SetDNDData
void SetDNDData(TDNDData *data)
Set drag and drop data.
Definition: TGFSContainer.cxx:451
TGFileContainer::fRefresh
TViewUpdateTimer * fRefresh
Definition: TGFSContainer.h:122
FileStat_t
Definition: TSystem.h:124
kVerticalFrame
@ kVerticalFrame
Definition: GuiTypes.h:381
TGFileItem::~TGFileItem
virtual ~TGFileItem()
Destructor.
Definition: TGFSContainer.cxx:398
TGFileContainer::TGFSFrameElement
friend class TGFSFrameElement
Definition: TGFSContainer.h:117
Long64_t
long long Long64_t
Definition: RtypesCore.h:75
TGFileItem::fSize
Long64_t fSize
Definition: TGFSContainer.h:52
TGFileItem::DoRedraw
virtual void DoRedraw()
Draw list view container item.
Definition: TGFSContainer.cxx:421
TGFileContainer::fApp_s
const TGPicture * fApp_s
Definition: TGFSContainer.h:129
kSortByDate
@ kSortByDate
Definition: TGFSContainer.h:24
TGFileContainer::fDisplayStat
Bool_t fDisplayStat
Definition: TGFSContainer.h:135
TGFileContainer::AddFile
virtual TGFileItem * AddFile(const char *name, const TGPicture *pic=nullptr, const TGPicture *lpic=nullptr)
Add file in container.
Definition: TGFSContainer.cxx:790
TGFileItem::fUid
Int_t fUid
Definition: TGFSContainer.h:49
TGFileItem::fIsLink
Bool_t fIsLink
Definition: TGFSContainer.h:50
TGFileContainer::GetDisplayStat
Bool_t GetDisplayStat()
Definition: TGFSContainer.h:161
TGLVEntry
Definition: TGListView.h:36
Int_t
int Int_t
Definition: RtypesCore.h:45
TGFileItem::HandleDNDEnter
virtual Atom_t HandleDNDEnter(Atom_t *)
Handle drag and drop enter.
Definition: TGFSContainer.cxx:442
TGFileContainer::fDoc_s
const TGPicture * fDoc_s
Definition: TGFSContainer.h:131
TGFrame::GetDefaultFrameBackground
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:683
TGFileItem::GetSize
Long64_t GetSize() const
Definition: TGFSContainer.h:83
TGFileContainer::GetFilePictures
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.
Definition: TGFSContainer.cxx:628
TGFileItem::fBuf
TBufferFile * fBuf
Definition: TGFSContainer.h:53
TGDNDManager.h
TGFileContainer::fSlink_s
const TGPicture * fSlink_s
Definition: TGFSContainer.h:133
TString
Basic string class.
Definition: TString.h:136
TGFrame
Definition: TGFrame.h:80
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
TGFileContainer::~TGFileContainer
virtual ~TGFileContainer()
Delete list view file container.
Definition: TGFSContainer.cxx:551
bool
TGFileItem::GetGid
Int_t GetGid() const
Definition: TGFSContainer.h:86
kSortByOwner
@ kSortByOwner
Definition: TGFSContainer.h:25
TGFileItem::Init
void Init(const TGPicture *blpic, const TGPicture *slpic, FileStat_t &stat, EListViewMode viewMode)
Common initializer for file list view item.
Definition: TGFSContainer.cxx:287
TGFileContainer::SetDisplayStat
virtual void SetDisplayStat(Bool_t stat=kTRUE)
Definition: TGFSContainer.h:160
kNone
const Handle_t kNone
Definition: GuiTypes.h:88
TGFileContainer::GetDirectory
const char * GetDirectory() const
Definition: TGFSContainer.h:163
TGDNDManager::GetDNDActionCopy
static Atom_t GetDNDActionCopy()
Definition: TGDNDManager.cxx:283
TTimer
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
kSortByType
@ kSortByType
Definition: TGFSContainer.h:22
kSunkenFrame
@ kSunkenFrame
Definition: GuiTypes.h:383
TGFileItem::GetType
Int_t GetType() const
Definition: TGFSContainer.h:82
TGFileItem::fType
Int_t fType
Definition: TGFSContainer.h:48
TGFileContainer::SetFilter
virtual void SetFilter(const char *filter)
Set file selection filter.
Definition: TGFSContainer.cxx:606
h
#define h(i)
Definition: RSha256.hxx:106
size
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
kSortByName
@ kSortByName
Definition: TGFSContainer.h:21
Atom_t
Handle_t Atom_t
WM token.
Definition: GuiTypes.h:37
TGFileItem::HandleDNDPosition
virtual Atom_t HandleDNDPosition(int, int, Atom_t action, int, int)
Definition: TGFSContainer.h:98
TGFileContainer::AddRemoteFile
virtual TGFileItem * AddRemoteFile(TObject *obj, const TGPicture *ipic=nullptr, const TGPicture *ilpic=nullptr)
Add remote file in container.
Definition: TGFSContainer.cxx:839
TGFileItem::IsActive
Bool_t IsActive() const
Definition: TGFSContainer.h:80
TGFileItem::SetDNDObject
void SetDNDObject(TObject *obj)
Set drag and drop object.
Definition: TGFSContainer.cxx:465
Long_t
long Long_t
Definition: RtypesCore.h:54
TGFileContainer::StartRefreshTimer
void StartRefreshTimer(ULong_t msec=1000)
start refreshing
Definition: TGFSContainer.cxx:886
TGLayoutHints
This class describes layout hints used by the layout classes.
Definition: TGLayout.h:50
TGFileContainer::fCleanups
TList * fCleanups
Definition: TGFSContainer.h:125
TGFileItem::fDNDData
TDNDData fDNDData
Definition: TGFSContainer.h:54
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
TDNDData
Drag and drop data container.
Definition: TGDNDManager.h:64
TGFileContainer::fApp_t
const TGPicture * fApp_t
Definition: TGFSContainer.h:128
TGFileItem::fSlpic
const TGPicture * fSlpic
Definition: TGFSContainer.h:46
unsigned int
TGFileItem::HandleDNDFinished
virtual Bool_t HandleDNDFinished()
Definition: TGFSContainer.h:103
TRegexp
Regular expression class.
Definition: TRegexp.h:31
TGWindow::GetParent
const TGWindow * GetParent() const
Definition: TGWindow.h:76
TGFileContainer::AddFrame
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame.
Definition: TGFSContainer.cxx:577
TGFileItem::fLcurrent
const TGPicture * fLcurrent
Definition: TGFSContainer.h:47
TGFileContainer::fFolder_s
const TGPicture * fFolder_s
Definition: TGFSContainer.h:127
TGLVContainer
Definition: TGListView.h:178
TGFileContainer::Sort
virtual void Sort(EFSSortMode sortType)
Sort file system list view container according to sortType.
Definition: TGFSContainer.cxx:615
kSortByGroup
@ kSortByGroup
Definition: TGFSContainer.h:26
TGFileItem::GetDNDdata
virtual TDNDData * GetDNDdata(Atom_t)
Definition: TGFSContainer.h:88
TGFileContainer::TGFileContainer
TGFileContainer(const TGWindow *p=nullptr, 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.
Definition: TGFSContainer.cxx:481
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGFileItem::TGFileItem
TGFileItem(const TGWindow *p=nullptr, const TGPicture *bpic=nullptr, const TGPicture *blpic=nullptr, const TGPicture *spic=nullptr, const TGPicture *slpic=nullptr, TGString *name=nullptr, 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.
Definition: TGFSContainer.cxx:251
name
char name[80]
Definition: TGX11.cxx:110
TGFrame::GetWhitePixel
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:709
TGFileItem::SetViewMode
virtual void SetViewMode(EListViewMode viewMode)
Set container item view mode.
Definition: TGFSContainer.cxx:406
TGFileItem::fBlpic
const TGPicture * fBlpic
Definition: TGFSContainer.h:45
TGFileContainer::fSortType
EFSSortMode fSortType
Definition: TGFSContainer.h:120
EFSSortMode
EFSSortMode
Definition: TGFSContainer.h:20
TGFileContainer::fDoc_t
const TGPicture * fDoc_t
Definition: TGFSContainer.h:130
kSortBySize
@ kSortBySize
Definition: TGFSContainer.h:23
TGFileContainer::fMtime
ULong_t fMtime
Definition: TGFSContainer.h:123
TGFileContainer::HandleTimer
virtual Bool_t HandleTimer(TTimer *t)
Refresh container contents.
Definition: TGFSContainer.cxx:593
type
int type
Definition: TGX11.cxx:121
TGFileContainer::SavePrimitive
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save a file container widget as a C++ statement(s) on output stream out.
Definition: TGFSContainer.cxx:895
TGListView.h
kLVList
@ kLVList
Definition: TGListView.h:24
TGCanvas
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition: TGCanvas.h:192
TGString
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition: TGString.h:20
TBufferFile
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition: TBufferFile.h:47
TGFileItem::fGid
Int_t fGid
Definition: TGFSContainer.h:49
TGFileContainer::StopRefreshTimer
void StopRefreshTimer()
stop refresh timer
Definition: TGFSContainer.cxx:877
TList
A doubly linked list.
Definition: TList.h:44
TGFileContainer::fSlink_t
const TGPicture * fSlink_t
Definition: TGFSContainer.h:132
TGFileItem::fModTime
Long_t fModTime
Definition: TGFSContainer.h:51
int