TestFileList Class Reference

Collaboration diagram for TestFileList:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TestFileList (const TGWindow *p, const TGWindow *main, UInt_t w, UInt_t h)
virtual ~TestFileList ()
void OnDoubleClick (TGLVEntry *, Int_t)
void DoMenu (Int_t)
void CloseWindow ()

Protected Member Functions

void DisplayFile (const TString &fname)
void DisplayDirectory (const TString &fname)
void DisplayObject (const TString &fname, const TString &name)

Protected Attributes

TGTransientFrame * fMain
TGFileContainer * fContents
TGPopupMenu * fMenu

Detailed Description

Definition at line 408 of file guitest.C.


Constructor & Destructor Documentation

TestFileList::TestFileList ( const TGWindow *  p,
const TGWindow *  main,
UInt_t  w,
UInt_t  h 
)

Definition at line 1989 of file guitest.C.

01990 {
01991    // Create transient frame containing a filelist widget.
01992 
01993    TGLayoutHints *lo;
01994 
01995    fMain = new TGTransientFrame(p, main, w, h);
01996    fMain->Connect("CloseWindow()", "TestDirList", this, "CloseWindow()");
01997    fMain->DontCallClose(); // to avoid double deletions.
01998 
01999    // use hierarchical cleaning
02000    fMain->SetCleanup(kDeepCleanup);
02001 
02002    TGMenuBar* mb = new TGMenuBar(fMain);
02003    lo = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX, 0, 0, 1, 1);
02004    fMain->AddFrame(mb, lo);
02005 
02006    fMenu = mb->AddPopup("&View");
02007    fMenu->AddEntry("Lar&ge Icons",kLVLargeIcons);
02008    fMenu->AddEntry("S&mall Icons",kLVSmallIcons);
02009    fMenu->AddEntry("&List",       kLVList);
02010    fMenu->AddEntry("&Details",    kLVDetails);
02011    fMenu->AddSeparator();
02012    fMenu->AddEntry("&Close",      10);
02013    fMenu->Connect("Activated(Int_t)","TestFileList",this,"DoMenu(Int_t)");
02014 
02015    TGListView* lv = new TGListView(fMain, w, h);
02016    lo = new TGLayoutHints(kLHintsExpandX | kLHintsExpandY);
02017    fMain->AddFrame(lv,lo);
02018 
02019    Pixel_t white;
02020    gClient->GetColorByName("white", white);
02021    fContents = new TGFileContainer(lv, kSunkenFrame,white);
02022    fContents->Connect("DoubleClicked(TGFrame*,Int_t)", "TestFileList", this,
02023                       "OnDoubleClick(TGLVEntry*,Int_t)");
02024 
02025    // position relative to the parent's window
02026    fMain->CenterOnParent();
02027 
02028    fMain->SetWindowName("File List Test");
02029    fMain->MapSubwindows();
02030    fMain->MapWindow();
02031    fContents->SetDefaultHeaders();
02032    fContents->DisplayDirectory();
02033    fContents->AddFile("..");        // up level directory
02034    fContents->Resize();
02035    fContents->StopRefreshTimer();   // stop refreshing
02036    fMain->Resize();
02037 }

TestFileList::~TestFileList (  )  [virtual]

Definition at line 2039 of file guitest.C.

02040 {
02041    // Cleanup.
02042 
02043    delete fContents;
02044    fMain->DeleteWindow();  // deletes fMain
02045 }


Member Function Documentation

void TestFileList::DisplayFile ( const TString &  fname  )  [protected]

Definition at line 2058 of file guitest.C.

Referenced by OnDoubleClick().

02059 {
02060    // Display content of ROOT file.
02061 
02062    TFile file(fname);
02063    fContents->RemoveAll();
02064    fContents->AddFile(gSystem->WorkingDirectory());
02065    fContents->SetPagePosition(0,0);
02066    fContents->SetColHeaders("Name","Title");
02067 
02068    TIter next(file.GetListOfKeys());
02069    TKey *key;
02070 
02071    while ((key=(TKey*)next())) {
02072       TString cname = key->GetClassName();
02073       TString name = key->GetName();
02074       TGLVEntry *entry = new TGLVEntry(fContents,name,cname);
02075       entry->SetSubnames(key->GetTitle());
02076       fContents->AddItem(entry);
02077 
02078       // user data is a filename
02079       entry->SetUserData((void*)StrDup(fname));
02080    }
02081    fMain->Resize();
02082 }

void TestFileList::DisplayDirectory ( const TString &  fname  )  [protected]

Definition at line 2084 of file guitest.C.

Referenced by OnDoubleClick().

02085 {
02086    // Display content of directory.
02087 
02088    fContents->SetDefaultHeaders();
02089    gSystem->ChangeDirectory(fname);
02090    fContents->ChangeDirectory(fname);
02091    fContents->DisplayDirectory();
02092    fContents->AddFile("..");  // up level directory
02093    fMain->Resize();
02094 }

void TestFileList::DisplayObject ( const TString &  fname,
const TString &  name 
) [protected]

Definition at line 2096 of file guitest.C.

Referenced by OnDoubleClick().

02097 {
02098    // Browse object located in file.
02099 
02100    TDirectory *sav = gDirectory;
02101 
02102    static TFile *file = 0;
02103    if (file) delete file;     // close
02104    file = new TFile(fname);   // reopen
02105 
02106    TObject* obj = file->Get(name);
02107    if (obj) {
02108       if (!obj->IsFolder()) {
02109          obj->Browse(0);
02110       } else obj->Print();
02111    }
02112    gDirectory = sav;
02113 }

void TestFileList::OnDoubleClick ( TGLVEntry *  ,
Int_t   
)

Definition at line 2115 of file guitest.C.

02116 {
02117    // Handle double click.
02118 
02119    if (btn != kButton1) return;
02120 
02121    // set kWatch cursor
02122    ULong_t cur = gVirtualX->CreateCursor(kWatch);
02123    gVirtualX->SetCursor(fContents->GetId(), cur);
02124 
02125    TString name(f->GetTitle());
02126    const char* fname = (const char*)f->GetUserData();
02127 
02128    if (fname) {
02129       DisplayObject(fname, name);
02130    } else if (name.EndsWith(".root")) {
02131       DisplayFile(name);
02132    } else {
02133       DisplayDirectory(name);
02134    }
02135    // set kPointer cursor
02136    cur = gVirtualX->CreateCursor(kPointer);
02137    gVirtualX->SetCursor(fContents->GetId(), cur);
02138 }

void TestFileList::DoMenu ( Int_t   ) 

Definition at line 2047 of file guitest.C.

02048 {
02049    // Switch view mode.
02050 
02051    if (mode<10) {
02052       fContents->SetViewMode((EListViewMode)mode);
02053    } else {
02054       delete this;
02055    }
02056 }

void TestFileList::CloseWindow (  ) 

Definition at line 2140 of file guitest.C.

02141 {
02142    delete this;
02143 }


Member Data Documentation

TGTransientFrame* TestFileList::fMain [protected]

Definition at line 413 of file guitest.C.

Referenced by DisplayDirectory(), DisplayFile(), TestFileList(), and ~TestFileList().

TGFileContainer* TestFileList::fContents [protected]

Definition at line 414 of file guitest.C.

Referenced by DisplayDirectory(), DisplayFile(), DoMenu(), OnDoubleClick(), TestFileList(), and ~TestFileList().

TGPopupMenu* TestFileList::fMenu [protected]

Definition at line 415 of file guitest.C.

Referenced by TestFileList().


The documentation for this class was generated from the following file:
Generated on Mon Jan 7 13:19:04 2013 for MicromegasFramework by  doxygen 1.4.7