Public Member Functions | |
TestDirList (const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h) | |
virtual | ~TestDirList () |
void | OnDoubleClick (TGListTreeItem *item, Int_t btn) |
void | CloseWindow () |
Protected Member Functions | |
TString | DirName (TGListTreeItem *item) |
Protected Attributes | |
TGTransientFrame * | fMain |
TGListTree * | fContents |
const TGPicture * | fIcon |
Definition at line 388 of file guitest.C.
TestDirList::TestDirList | ( | const TGWindow * | p, | |
const TGWindow * | main, | |||
UInt_t | w, | |||
UInt_t | h | |||
) |
Definition at line 1888 of file guitest.C.
01890 { 01891 // Create transient frame containing a dirlist widget. 01892 01893 fMain = new TGTransientFrame(p, main, w, h); 01894 fMain->Connect("CloseWindow()", "TestDirList", this, "CloseWindow()"); 01895 fMain->DontCallClose(); // to avoid double deletions. 01896 01897 fIcon = gClient->GetPicture("rootdb_t.xpm"); 01898 TGLayoutHints *lo; 01899 01900 // use hierarchical cleaning 01901 fMain->SetCleanup(kDeepCleanup); 01902 01903 TGCanvas* canvas = new TGCanvas(fMain, 500, 300); 01904 fContents = new TGListTree(canvas, kHorizontalFrame); 01905 lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY | kLHintsBottom); 01906 fMain->AddFrame(canvas,lo); 01907 fContents->Connect("DoubleClicked(TGListTreeItem*,Int_t)","TestDirList",this, 01908 "OnDoubleClick(TGListTreeItem*,Int_t)"); 01909 fContents->Connect("Clicked(TGListTreeItem*,Int_t)","TestDirList",this, 01910 "OnDoubleClick(TGListTreeItem*,Int_t)"); 01911 #ifdef G__WIN32 01912 fContents->AddItem(0,"c:\\"); // browse the upper directory 01913 #else 01914 fContents->AddItem(0,"/"); // browse the upper directory 01915 #endif 01916 01917 // position relative to the parent's window 01918 fMain->CenterOnParent(); 01919 01920 fMain->SetWindowName("List Dir Test"); 01921 01922 fMain->MapSubwindows(); 01923 fMain->Resize(); 01924 fMain->MapWindow(); 01925 }
TestDirList::~TestDirList | ( | ) | [virtual] |
TString TestDirList::DirName | ( | TGListTreeItem * | item | ) | [protected] |
Definition at line 1941 of file guitest.C.
Referenced by OnDoubleClick().
01942 { 01943 // Returns an absolute path. 01944 01945 TGListTreeItem* parent; 01946 TString dirname = item->GetText(); 01947 01948 while ((parent=item->GetParent())) { 01949 dirname = gSystem->ConcatFileName(parent->GetText(),dirname); 01950 item = parent; 01951 } 01952 01953 return dirname; 01954 }
void TestDirList::OnDoubleClick | ( | TGListTreeItem * | item, | |
Int_t | btn | |||
) |
Definition at line 1956 of file guitest.C.
01957 { 01958 // Show contents of directory. 01959 01960 if ((btn!=kButton1) || !item || (Bool_t)item->GetUserData()) return; 01961 01962 // use UserData to indicate that item was already browsed 01963 item->SetUserData((void*)1); 01964 01965 TSystemDirectory dir(item->GetText(),DirName(item)); 01966 01967 TList *files = dir.GetListOfFiles(); 01968 01969 if (files) { 01970 TIter next(files); 01971 TSystemFile *file; 01972 TString fname; 01973 01974 while ((file=(TSystemFile*)next())) { 01975 fname = file->GetName(); 01976 if (file->IsDirectory()) { 01977 if ((fname!="..") && (fname!=".")) { // skip it 01978 fContents->AddItem(item,fname); 01979 } 01980 } else if (fname.EndsWith(".root")) { // add root files 01981 fContents->AddItem(item,fname,fIcon,fIcon); 01982 } 01983 } 01984 delete files; 01985 } 01986 }
void TestDirList::CloseWindow | ( | ) |
TGTransientFrame* TestDirList::fMain [protected] |
TGListTree* TestDirList::fContents [protected] |
Definition at line 394 of file guitest.C.
Referenced by OnDoubleClick(), TestDirList(), and ~TestDirList().
const TGPicture* TestDirList::fIcon [protected] |
Definition at line 395 of file guitest.C.
Referenced by OnDoubleClick(), TestDirList(), and ~TestDirList().