File indexing completed on 2025-01-18 10:11:57
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef ROOT_TGFSContainer
0013 #define ROOT_TGFSContainer
0014
0015
0016 #include "TGListView.h"
0017 #include "TGDNDManager.h"
0018
0019
0020 enum EFSSortMode {
0021 kSortByName,
0022 kSortByType,
0023 kSortBySize,
0024 kSortByDate,
0025 kSortByOwner,
0026 kSortByGroup
0027 };
0028
0029
0030 class TRegexp;
0031 class TGPicture;
0032 class TGFileContainer;
0033 class TViewUpdateTimer;
0034 class TGFileIcon;
0035 class TGFileItem;
0036 class TTimer;
0037 class TString;
0038 class TBufferFile;
0039 struct FileStat_t;
0040
0041
0042 class TGFileItem : public TGLVEntry {
0043
0044 protected:
0045 const TGPicture *fBlpic;
0046 const TGPicture *fSlpic;
0047 const TGPicture *fLcurrent;
0048 Int_t fType;
0049 Int_t fUid, fGid;
0050 Bool_t fIsLink;
0051 Long_t fModTime;
0052 Long64_t fSize;
0053 TBufferFile *fBuf;
0054 TDNDData fDNDData;
0055
0056 void Init(const TGPicture *blpic, const TGPicture *slpic,
0057 FileStat_t &stat, EListViewMode viewMode);
0058 void DoRedraw() override;
0059
0060 public:
0061 TGFileItem(const TGWindow *p = nullptr,
0062 const TGPicture *bpic = nullptr, const TGPicture *blpic = nullptr,
0063 const TGPicture *spic = nullptr, const TGPicture *slpic = nullptr,
0064 TGString *name = nullptr, Int_t type = 0, Long64_t size = 1,
0065 Int_t uid = 0, Int_t gid = 0, Long_t modtime = 0,
0066 EListViewMode viewMode = kLVList, UInt_t options = kVerticalFrame,
0067 Pixel_t back = GetWhitePixel());
0068
0069 TGFileItem(const TGWindow *p,
0070 const TGPicture *bpic, const TGPicture *blpic,
0071 const TGPicture *spic, const TGPicture *slpic,
0072 TGString *name, FileStat_t &stat,
0073 EListViewMode viewMode = kLVList, UInt_t options = kVerticalFrame,
0074 Pixel_t back = GetWhitePixel());
0075
0076 ~TGFileItem() override;
0077
0078 void SetViewMode(EListViewMode viewMode) override;
0079
0080 Bool_t IsActive() const override { return fActive; }
0081 Bool_t IsSymLink() const { return fIsLink; }
0082 Int_t GetType() const { return fType; }
0083 Long64_t GetSize() const { return fSize; }
0084 Long_t GetModTime() const { return fModTime; }
0085 Int_t GetUid() const { return fUid; }
0086 Int_t GetGid() const { return fGid; }
0087
0088 virtual TDNDData *GetDNDdata(Atom_t) {
0089 return &fDNDData;
0090 }
0091
0092 Atom_t HandleDNDEnter(Atom_t *) override;
0093
0094 Bool_t HandleDNDLeave() override {
0095 return kTRUE;
0096 }
0097
0098 Atom_t HandleDNDPosition(int, int, Atom_t action, int, int) override {
0099 if (action == TGDNDManager::GetDNDActionCopy()) return action;
0100 return kNone;
0101 }
0102
0103 Bool_t HandleDNDFinished() override {
0104 return ((TGFrame *)(const_cast<TGWindow*>(GetParent())))->HandleDNDFinished();
0105 }
0106
0107 void SetDNDData(TDNDData *data);
0108
0109 void SetDNDObject(TObject *obj);
0110
0111 ClassDefOverride(TGFileItem,0)
0112 };
0113
0114
0115 class TGFileContainer : public TGLVContainer {
0116
0117 friend class TGFSFrameElement;
0118
0119 protected:
0120 EFSSortMode fSortType;
0121 TRegexp *fFilter;
0122 TViewUpdateTimer *fRefresh;
0123 ULong_t fMtime;
0124 TString fDirectory;
0125 TList *fCleanups;
0126 const TGPicture *fFolder_t;
0127 const TGPicture *fFolder_s;
0128 const TGPicture *fApp_t;
0129 const TGPicture *fApp_s;
0130 const TGPicture *fDoc_t;
0131 const TGPicture *fDoc_s;
0132 const TGPicture *fSlink_t;
0133 const TGPicture *fSlink_s;
0134 Bool_t fCachePictures;
0135 Bool_t fDisplayStat;
0136
0137
0138 void CreateFileList();
0139
0140 public:
0141 TGFileContainer(const TGWindow *p = nullptr, UInt_t w = 1, UInt_t h = 1,
0142 UInt_t options = kSunkenFrame,
0143 Pixel_t back = GetDefaultFrameBackground());
0144 TGFileContainer(TGCanvas *p, UInt_t options = kSunkenFrame,
0145 Pixel_t back = GetDefaultFrameBackground());
0146
0147 ~TGFileContainer() override;
0148
0149 Bool_t HandleTimer(TTimer *t) override;
0150 void StopRefreshTimer();
0151 void StartRefreshTimer(ULong_t msec=1000);
0152
0153 virtual TGFileItem *AddFile(const char *name, const TGPicture *pic = nullptr, const TGPicture *lpic = nullptr);
0154 virtual TGFileItem *AddRemoteFile(TObject *obj, const TGPicture *ipic = nullptr, const TGPicture *ilpic = nullptr);
0155 void AddFrame(TGFrame *f, TGLayoutHints *l = nullptr) override;
0156 virtual void Sort(EFSSortMode sortType);
0157 virtual void SetFilter(const char *filter);
0158 virtual void ChangeDirectory(const char *path);
0159 virtual void DisplayDirectory();
0160 virtual void SetDisplayStat(Bool_t stat = kTRUE) { fDisplayStat = stat; }
0161 Bool_t GetDisplayStat() { return fDisplayStat; }
0162
0163 const char *GetDirectory() const { return fDirectory.Data(); }
0164
0165 virtual void GetFilePictures(const TGPicture **pic, const TGPicture **lpic,
0166 Int_t file_type, Bool_t is_link, const char *ext,
0167 Bool_t small);
0168
0169 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0170
0171 ClassDefOverride(TGFileContainer,0)
0172 };
0173
0174 #endif