#ifndef ROOT_TGFSContainer
#define ROOT_TGFSContainer
#ifndef ROOT_TGListView
#include "TGListView.h"
#endif
#ifndef ROOT_TDNDManager
#include "TGDNDManager.h"
#endif
#ifndef ROOT_TBufferFile
#include "TBufferFile.h"
#endif
#include <stdlib.h>
enum EFSSortMode {
kSortByName,
kSortByType,
kSortBySize,
kSortByDate,
kSortByOwner,
kSortByGroup
};
class TRegexp;
class TGPicture;
class TGFileContainer;
class TViewUpdateTimer;
class TGFileIcon;
class TGFileItem;
class TTimer;
class TString;
struct FileStat_t;
class TGFileItem : public TGLVEntry {
protected:
const TGPicture *fBlpic;
const TGPicture *fSlpic;
const TGPicture *fLcurrent;
Int_t fType;
Int_t fUid, fGid;
Bool_t fIsLink;
Long_t fModTime;
Long64_t fSize;
TBufferFile *fBuf;
TDNDData fDNDData;
void Init(const TGPicture *blpic, const TGPicture *slpic,
FileStat_t &stat, EListViewMode viewMode);
virtual void DoRedraw();
public:
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());
TGFileItem(const TGWindow *p,
const TGPicture *bpic, const TGPicture *blpic,
const TGPicture *spic, const TGPicture *slpic,
TGString *name, FileStat_t &stat,
EListViewMode viewMode = kLVList, UInt_t options = kVerticalFrame,
Pixel_t back = GetWhitePixel());
virtual ~TGFileItem();
virtual void SetViewMode(EListViewMode viewMode);
Bool_t IsActive() const { return fActive; }
Bool_t IsSymLink() const { return fIsLink; }
Int_t GetType() const { return fType; }
Long64_t GetSize() const { return fSize; }
Long_t GetModTime() const { return fModTime; }
Int_t GetUid() const { return fUid; }
Int_t GetGid() const { return fGid; }
virtual TDNDData *GetDNDdata(Atom_t) {
return &fDNDData;
}
virtual Atom_t HandleDNDEnter(Atom_t *) {
if (!IsDNDTarget()) return kNone;
return gVirtualX->InternAtom("application/root", kFALSE);
}
virtual Bool_t HandleDNDLeave() {
return kTRUE;
}
virtual Atom_t HandleDNDPosition(int, int, Atom_t action, int, int) {
if (action == TGDNDManager::GetDNDActionCopy()) return action;
return kNone;
}
virtual Bool_t HandleDNDFinished() {
return ((TGFrame *)(const_cast<TGWindow*>(GetParent())))->HandleDNDFinished();
}
void SetDNDData(TDNDData *data) {
if (fDNDData.fDataLength > 0)
free(fDNDData.fData);
fDNDData.fData = calloc(sizeof(unsigned char), data->fDataLength);
memcpy(fDNDData.fData, data->fData, data->fDataLength);
fDNDData.fDataLength = data->fDataLength;
fDNDData.fDataType = data->fDataType;
}
void SetDNDObject(TObject *obj) {
if (fDNDData.fDataLength)
free(fDNDData.fData);
fBuf->WriteObject(obj);
fDNDData.fData = fBuf->Buffer();
fDNDData.fDataLength = fBuf->Length();
fDNDData.fDataType = gVirtualX->InternAtom("application/root", kFALSE);
}
ClassDef(TGFileItem,0)
};
class TGFileContainer : public TGLVContainer {
friend class TGFSFrameElement;
protected:
EFSSortMode fSortType;
TRegexp *fFilter;
TViewUpdateTimer *fRefresh;
ULong_t fMtime;
TString fDirectory;
TList *fCleanups;
const TGPicture *fFolder_t;
const TGPicture *fFolder_s;
const TGPicture *fApp_t;
const TGPicture *fApp_s;
const TGPicture *fDoc_t;
const TGPicture *fDoc_s;
const TGPicture *fSlink_t;
const TGPicture *fSlink_s;
Bool_t fCachePictures;
Bool_t fDisplayStat;
void CreateFileList();
public:
TGFileContainer(const TGWindow *p = 0, UInt_t w = 1, UInt_t h = 1,
UInt_t options = kSunkenFrame,
Pixel_t back = GetDefaultFrameBackground());
TGFileContainer(TGCanvas *p, UInt_t options = kSunkenFrame,
Pixel_t back = GetDefaultFrameBackground());
virtual ~TGFileContainer();
virtual Bool_t HandleTimer(TTimer *t);
void StopRefreshTimer();
void StartRefreshTimer(ULong_t msec=1000);
virtual TGFileItem *AddFile(const char *name, const TGPicture *pic = 0, const TGPicture *lpic = 0);
virtual TGFileItem *AddRemoteFile(TObject *obj, const TGPicture *ipic = 0, const TGPicture *ilpic = 0);
virtual void AddFrame(TGFrame *f, TGLayoutHints *l = 0);
virtual void Sort(EFSSortMode sortType);
virtual void SetFilter(const char *filter);
virtual void ChangeDirectory(const char *path);
virtual void DisplayDirectory();
virtual void SetDisplayStat(Bool_t stat = kTRUE) { fDisplayStat = stat; }
Bool_t GetDisplayStat() { return fDisplayStat; }
const char *GetDirectory() const { return fDirectory.Data(); }
virtual void GetFilePictures(const TGPicture **pic, const TGPicture **lpic,
Int_t file_type, Bool_t is_link, const char *ext,
Bool_t small);
virtual void SavePrimitive(ostream &out, Option_t *option = "");
ClassDef(TGFileContainer,0)
};
#endif