[GUI] Embedded browser?

Hi,

I’m currently writing a GUI where I need to embed a browser in a frame. I found nothing in the root documentation that can fit my needs.
Is there something that can works in this way ? :

TGMainFrame *pMainFrame = new TGMainFrame(gClient->GetRoot());
TEmbeddedBrowser *pBrowser = new TEmbeddedBrowser(pMainFrame);
TDirectory *pRootDir = new TDirectory("root","/");
pBrowser->Add(pRootDir, "/");
TH1D *pH = new TH1D("h","h",10, 0, 9);
pRootDirectory->Add(pH,"My histogram");

pMainFrame->MapSubwindows();
pMainFrame->Resize(pMainFrame->GetDefaultSize());
pMainFrame->MapWindow();

I need a tree list view for a set of objects. I know that there is the TGListTree and its TGListTreeItem but i just wonder if there is an existing class that already wraps this TGListTree as the TBrowser does and that can be embedded in a frame.

Cheers,

RE

Hi,

You can take a look at the $ROOTSYS/tutorials/gui/guitest.C tutorial, the “File List…” entry in the “Test” menu.

Cheers, Bertrand.

Hi,

Thanks for your answer and redirecting me to this example. I took a look to the latter but its class for browsing the file list provide a raw implementation of the browser. Even worst, it is for file system browsing and I want to create my own directories locally.

Maybe, is there a way to draw a TDirectory in a frame ? This should works for me since the TDirectory implements at least the storage of directories and objects. Then I will just need to find a way to draw it somewhere.

Cheers,

RE

Hi,

[quote=“rete”]Even worst, it is for file system browsing and I want to create my own directories locally[/quote]I’m not sure I understand your point. What is the difference between “file system” and “your own directories locally”?

And BTW, you can also embed a pair of TGListView/TGFileContainer:

fFileView = new TGListView(fC2,600,200); fFileCont = new TGFileContainer(fFileView->GetViewPort(),100,102, kVerticalFrame,GetWhitePixel()); fFileView->GetViewPort()->SetBackgroundColor(GetWhitePixel()); fFileView->SetContainer(fFileCont); fFileCont->SetFilter("*.root"); fFileCont->ChangeDirectory("data"); fFileView->SetViewMode(kLVDetails); fFileCont->Sort(kSortByName); fFileCont->GetListView()->ResizeColumns(); fC2->AddFrame(fFileView, new TGLayoutHints(kLHintsLeft|kLHintsTop,5,2,2,2)); Where FC2 is a TGCompositeFrame

Cheers, Bertrand.

Sorry, I think I’m not clear. :confused:

The left frame of the TBrowser is doing exactly what I want. It contains by default “root” , “PROOF Sessions” , “ROOT Files” and “/”. I would only this container but an empty one, embedded in my frame so that user can create its own folders and sub-folders and put TObjects inside.

Tell me if not clear again. Sorry if it’s again the case.

RE

The left part of the ROOT browser if a TGFileBrowser, and it inherits from TBrowser. You can try to use it, but if you want a very customized version, you will need to do it yourself…

Cheers, Bertrand.

Thank you a lot.

I finally find the way to do what I want from the TGFileBrowser.
It looks like this :


// Embed the browser in my frame
TGMainFrame *pMyMainFrame = new TGMainFrame(gClient->GetRoot());
TGFileBrowser *pBrowser = new TGFileBrowser(pMyMainFrame);
pBrowser->ReparentWindow(pMyMainFrame->GetParent());

// following code is just an example of what I wanted to display ...
TDirectory *pRunDir = new TDirectory("run", "Run");
pBrowser->Add(pRunDir, pRunDir->GetTitle());
TDirectory *pSubRunDir = pRunDir->mkdir("SubRun");
pBrowser->Add(pSubRunDir, pSubRunDir->GetTitle());
TH1D *pH = new TH1D("h", "h", 10, 0, 9);
pH->Fill(1);
pSubRunDir->Add(pH);
pBrowser->Add(pH, pH->GetTitle())

Thanks again. I set the post as resolved.

RE