Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 19/01/98
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 *************************************************************************/
12#ifndef ROOT_TGFSContainer
13#define ROOT_TGFSContainer
16#include "TGListView.h"
17#include "TGDNDManager.h"
19//----- file sort mode
30class TRegexp;
31class TGPicture;
32class TGFileContainer;
34class TGFileIcon;
35class TGFileItem;
36class TTimer;
37class TString;
38class TBufferFile;
39struct FileStat_t;
42class TGFileItem : public TGLVEntry {
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
56 void Init(const TGPicture *blpic, const TGPicture *slpic,
57 FileStat_t &stat, EListViewMode viewMode);
58 virtual void DoRedraw();
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());
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());
76 virtual ~TGFileItem();
78 virtual void SetViewMode(EListViewMode viewMode);
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; }
89 return &fDNDData;
90 }
92 virtual Atom_t HandleDNDEnter(Atom_t *);
95 return kTRUE;
96 }
98 virtual Atom_t HandleDNDPosition(int, int, Atom_t action, int, int) {
99 if (action == TGDNDManager::GetDNDActionCopy()) return action;
100 return kNone;
101 }
104 return ((TGFrame *)(const_cast<TGWindow*>(GetParent())))->HandleDNDFinished();
105 }
107 void SetDNDData(TDNDData *data);
109 void SetDNDObject(TObject *obj);
111 ClassDef(TGFileItem,0) // Class representing file system object
117friend class TGFSFrameElement;
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
138 void CreateFileList();
141 TGFileContainer(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
142 UInt_t options = kSunkenFrame,
147 virtual ~TGFileContainer();
149 virtual Bool_t HandleTimer(TTimer *t);
150 void StopRefreshTimer();
151 void StartRefreshTimer(ULong_t msec=1000);
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; }
163 const char *GetDirectory() const { return fDirectory.Data(); }
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);
169 virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
171 ClassDef(TGFileContainer,0) // Container containing file system objects
@ kSunkenFrame
Definition: GuiTypes.h:383
@ kVerticalFrame
Definition: GuiTypes.h:381
Handle_t Atom_t
WM token.
Definition: GuiTypes.h:37
const Handle_t kNone
Definition: GuiTypes.h:88
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
#define f(i)
Definition: RSha256.hxx:104
#define h(i)
Definition: RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Definition: RtypesCore.h:45
unsigned int UInt_t
Definition: RtypesCore.h:46
unsigned long ULong_t
Definition: RtypesCore.h:55
long Long_t
Definition: RtypesCore.h:54
bool Bool_t
Definition: RtypesCore.h:63
long long Long64_t
Definition: RtypesCore.h:80
const Bool_t kTRUE
Definition: RtypesCore.h:100
const char Option_t
Definition: RtypesCore.h:66
#define ClassDef(name, id)
Definition: Rtypes.h:325
Definition: TGFSContainer.h:20
@ kSortByDate
Definition: TGFSContainer.h:24
@ kSortByOwner
Definition: TGFSContainer.h:25
@ kSortByName
Definition: TGFSContainer.h:21
@ kSortByGroup
Definition: TGFSContainer.h:26
@ kSortByType
Definition: TGFSContainer.h:22
@ kSortBySize
Definition: TGFSContainer.h:23
Definition: TGListView.h:21
@ kLVList
Definition: TGListView.h:24
char name[80]
Definition: TGX11.cxx:110
int type
Definition: TGX11.cxx:121
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket.
Definition: TBufferFile.h:47
Drag and drop data container.
Definition: TGDNDManager.h:64
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition: TGCanvas.h:192
static Atom_t GetDNDActionCopy()
const TGPicture * fSlink_s
big symbolic link icon
void CreateFileList()
This function creates the file list from current dir.
const TGPicture * fFolder_s
big folder icon
TList * fCleanups
list of pictures to cleanup
TString fDirectory
current directory
TViewUpdateTimer * fRefresh
refresh timer
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
small document icon
const TGPicture * fApp_t
small application icon
const TGPicture * fApp_s
big application icon
virtual void Sort(EFSSortMode sortType)
Sort file system list view container according to sortType.
const TGPicture * fDoc_s
big document icon
Bool_t fCachePictures
kTRUE use caching
virtual void ChangeDirectory(const char *path)
Change current directory.
const TGPicture * fSlink_t
small symbolic link icon
virtual void DisplayDirectory()
Display the contents of the current directory in the container.
ULong_t fMtime
directory modification time
virtual TGFileItem * AddFile(const char *name, const TGPicture *pic=nullptr, const TGPicture *lpic=nullptr)
Add file in container.
virtual TGFileItem * AddRemoteFile(TObject *obj, const TGPicture *ipic=nullptr, const TGPicture *ilpic=nullptr)
Add remote file in 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
small folder icon
TRegexp * fFilter
file filter
Bool_t fDisplayStat
kFALSE to interrupt display directory contents in case of many files inside
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()
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.
EFSSortMode fSortType
sorting mode of contents
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame.
const char * GetDirectory() const
Utility class used by the file selection dialog (TGFSDialog).
Int_t fGid
file uid and gid
Definition: TGFSContainer.h:49
Int_t GetUid() const
Definition: TGFSContainer.h:85
Long64_t fSize
file size
Definition: TGFSContainer.h:52
const TGPicture * fLcurrent
current icon
Definition: TGFSContainer.h:47
Int_t GetGid() const
Definition: TGFSContainer.h:86
TBufferFile * fBuf
buffer used for Drag and Drop
Definition: TGFSContainer.h:53
Bool_t IsActive() const
Definition: TGFSContainer.h:80
const TGPicture * fBlpic
big icon
Definition: TGFSContainer.h:45
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)
Definition: TGFSContainer.h:98
Long_t fModTime
modification time
Definition: TGFSContainer.h:51
const TGPicture * fSlpic
small icon
Definition: TGFSContainer.h:46
Long64_t GetSize() const
Definition: TGFSContainer.h:83
void SetDNDObject(TObject *obj)
Set drag and drop object.
Drag and Drop data.
Definition: TGFSContainer.h:54
Long_t GetModTime() const
Definition: TGFSContainer.h:84
Int_t fType
file type
Definition: TGFSContainer.h:48
Int_t GetType() const
Definition: TGFSContainer.h:82
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:88
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()
Definition: TGFSContainer.h:94
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.
Bool_t IsSymLink() const
Definition: TGFSContainer.h:81
Bool_t fIsLink
true if symbolic link
Definition: TGFSContainer.h:50
virtual ~TGFileItem()
A subclasses of TGWindow, and is used as base class for some simple widgets (buttons,...
Definition: TGFrame.h:80
static Pixel_t GetWhitePixel()
Get white pixel value.
Definition: TGFrame.cxx:709
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:683
Bool_t fActive
true if item is active
Definition: TGListView.h:50
This class describes layout hints used by the layout classes.
Definition: TGLayout.h:50
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition: TGPicture.h:25
TGString wraps a TString and adds some graphics routines like drawing, size of string on screen depen...
Definition: TGString.h:20
ROOT GUI Window base class.
Definition: TGWindow.h:23
const TGWindow * GetParent() const
Definition: TGWindow.h:76
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:136
const char * Data() const
Definition: TString.h:369
Handles synchronous and a-synchronous timer events.
Definition: TTimer.h:51
auto * l
Definition: textangle.C:4