Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGFileBrowser.cxx
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Bertrand Bellenot 26/09/2007
3
4/*************************************************************************
5 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
6 * All rights reserved. *
7 * *
8 * For the licensing terms see $ROOTSYS/LICENSE. *
9 * For the list of contributors see $ROOTSYS/README/CREDITS. *
10 *************************************************************************/
11
12#include "TROOT.h"
13#include "TSystem.h"
14#include "TApplication.h"
15#include "TGClient.h"
16#include "TGListTree.h"
17#include "TGLayout.h"
18#include "TGComboBox.h"
19#include "TContextMenu.h"
20#include "TGTextEntry.h"
21#include "TGTab.h"
22#include "TGLabel.h"
23#include "TSystemDirectory.h"
24#include "TGMimeTypes.h"
25#include "TClass.h"
26#include "TQClass.h"
27#include "TObjString.h"
28#include "TObjArray.h"
29#include "TInterpreter.h"
30#include "TRegexp.h"
31#include "TEnv.h"
32#include "TImage.h"
33#include "TBrowser.h"
34#include "TRemoteObject.h"
35#include "TKey.h"
36#include "TKeyMapFile.h"
37#include "TVirtualPad.h"
38#include "Getline.h"
39#include "snprintf.h"
40#include <ctime>
41#include <cstring>
42#include <cstdlib>
43
44#include "TGFileBrowser.h"
45#include "TRootBrowser.h"
46#include "TGInputDialog.h"
47
48#include "TVirtualPadEditor.h"
49#include "TGedEditor.h"
50#include "TBaseClass.h"
51#include "TVirtualX.h"
52
53#include "RConfigure.h"
54
55#ifdef WIN32
56const char rootdir[] = "\\";
57#else
58const char rootdir[] = "/";
59#endif
60
61const char *filters[] = {
62 "",
63 "*.*",
64 "*.[C|c|h]*",
65 "*.root",
66 "*.txt"
67};
68
69
70/** \class TCursorSwitcher
71 \ingroup guiwidgets
72
73Helper class used to change the cursor in a method and restore the
74original one when going out of the method scope.
75
76*/
77
78
79///////////////////////////////////////////////////////////////////////////////
81private:
84public:
86 if (w1) gVirtualX->SetCursor(w1->GetId(), gVirtualX->CreateCursor(kWatch));
87 if (w2) gVirtualX->SetCursor(w2->GetId(), gVirtualX->CreateCursor(kWatch));
88 }
90 if (fW1) gVirtualX->SetCursor(fW1->GetId(), gVirtualX->CreateCursor(kPointer));
91 if (fW2) gVirtualX->SetCursor(fW2->GetId(), gVirtualX->CreateCursor(kPointer));
92 }
93};
94
95
96/** \class TGFileBrowser
97 \ingroup guiwidgets
98
99System file browser, used as TRootBrowser plug-in.
100This class is the real core of the ROOT browser.
101
102*/
103
104
105
106////////////////////////////////////////////////////////////////////////////////
107/// TGFileBrowser constructor.
108
110 : TGMainFrame(p, w, h), TBrowserImp(b), fNewBrowser(0)
111{
112 if (p && p != gClient->GetDefaultRoot())
113 fNewBrowser = (TRootBrowser *)p->GetMainFrame();
114 if (fNewBrowser)
117 Resize(w, h);
118 if (fBrowser) Show();
119}
120
121////////////////////////////////////////////////////////////////////////////////
122/// Create the actual file browser.
123
125{
126 fCachedPic = 0;
128
129 fTopFrame = new TGHorizontalFrame(this, 100, 30);
132 dropt_entry->SetToolTipText("Object Draw Option", 300);
133 fDrawOption->Resize(80, 20);
135 lb->Resize(lb->GetWidth(), 120);
136 Int_t dropt = 1;
137 fDrawOption->AddEntry("", dropt++);
138 fDrawOption->AddEntry("box", dropt++);
139 fDrawOption->AddEntry("colz", dropt++);
140 fDrawOption->AddEntry("lego", dropt++);
141 fDrawOption->AddEntry("lego1", dropt++);
142 fDrawOption->AddEntry("lego2", dropt++);
143 fDrawOption->AddEntry("same", dropt++);
144 fDrawOption->AddEntry("surf", dropt++);
145 fDrawOption->AddEntry("surf1", dropt++);
146 fDrawOption->AddEntry("surf2", dropt++);
147 fDrawOption->AddEntry("surf3", dropt++);
148 fDrawOption->AddEntry("surf4", dropt++);
149 fDrawOption->AddEntry("surf5", dropt++);
150 fDrawOption->AddEntry("text", dropt++);
152 kLHintsRight, 2, 2, 2, 2));
153 fTopFrame->AddFrame(new TGLabel(fTopFrame, "Draw Option:"),
155 5, 2, 2, 2));
156
157 fSortButton = new TGPictureButton(fTopFrame, "bld_sortup.png");
158 fSortButton->SetStyle(gClient->GetStyle());
159 fSortButton->SetToolTipText("Sort Alphabetically\n(Current folder only)");
161 kLHintsLeft, 2, 2, 2, 2));
162 fSortButton->Connect("Clicked()", "TGFileBrowser", this, "ToggleSort()");
163
164 fFilterButton = new TGPictureButton(fTopFrame, "filter.png");
165 fFilterButton->SetStyle(gClient->GetStyle());
166 fFilterButton->SetToolTipText("Filter Content");
168 kLHintsLeft, 2, 2, 2, 2));
169 fFilterButton->Connect("Clicked()", "TGFileBrowser", this, "RequestFilter()");
170
171 fRefreshButton = new TGPictureButton(fTopFrame, "refresh.png");
172 fRefreshButton->SetStyle(gClient->GetStyle());
173 fRefreshButton->SetToolTipText("Refresh Current Folder");
175 kLHintsLeft, 2, 5, 2, 2));
176 fRefreshButton->Connect("Clicked()", "TGFileBrowser", this, "Refresh()");
177
179 kLHintsExpandX, 2, 2, 2, 2));
180 fCanvas = new TGCanvas(this, 100, 100);
184 fListTree->Connect("DoubleClicked(TGListTreeItem *, Int_t)",
185 "TGFileBrowser", this, "DoubleClicked(TGListTreeItem *, Int_t)");
186 fListTree->Connect("Clicked(TGListTreeItem *, Int_t, Int_t, Int_t)",
187 "TGFileBrowser", this, "Clicked(TGListTreeItem *, Int_t, Int_t, Int_t)");
188 fListTree->Connect("Checked(TObject*, Bool_t)", "TGFileBrowser",
189 this, "Checked(TObject*, Bool_t)");
190
191 fRootIcon = gClient->GetPicture("rootdb_t.xpm");
192 fFileIcon = gClient->GetPicture("doc_t.xpm");
193
194 fBotFrame = new TGHorizontalFrame(this, 100, 30);
195 fBotFrame->AddFrame(new TGLabel(fBotFrame, "Filter: "),
197 2, 2, 2, 2));
198 fFileType = new TGComboBox(fBotFrame, " All Files (*.*)");
199 Int_t ftype = 1;
200 fFileType->AddEntry(" All Files (*.*)", ftype++);
201 fFileType->AddEntry(" C/C++ Files (*.c;*.cxx;*.h;...)", ftype++);
202 fFileType->AddEntry(" ROOT Files (*.root)", ftype++);
203 fFileType->AddEntry(" Text Files (*.txt)", ftype++);
204 fFileType->Resize(200, 20);
206 kLHintsExpandX, 2, 2, 2, 2));
207 fFileType->Connect("Selected(Int_t)", "TGFileBrowser", this,
208 "ApplyFilter(Int_t)");
209 fFileType->GetTextEntry()->Connect("ReturnPressed()", "TGFileBrowser",
210 this, "ApplyFilter(Int_t = -1)");
212 kLHintsExpandX, 2, 2, 2, 2));
213
214 fContextMenu = new TContextMenu("FileBrowserContextMenu");
215 fFilter = nullptr;
216 fGroupSize = 1000;
217 fListLevel = 0;
218 fCurrentDir = 0;
219 fRootDir = 0;
220 fDir = nullptr;
221 fFile = nullptr;
222 fNKeys = 0;
223 fCnt = 0;
224 fFilterStr = "*";
225
226 TString gv = gEnv->GetValue("Browser.GroupView", "1000");
227 Int_t igv = atoi(gv.Data());
228 if (igv > 10)
229 fGroupSize = igv;
230
231 if (gEnv->GetValue("Browser.ShowHidden", 0))
233 else
235
237
238 TQObject::Connect("TPad", "Modified()",
239 "TGFileBrowser", this, "PadModified()");
240
241 fListLevel = 0;
244 MapWindow();
245}
246
247////////////////////////////////////////////////////////////////////////////////
248/// Destructor.
249
251{
252 TQObject::Disconnect("TPad", "Modified()");
253
254 delete fContextMenu;
255 delete fListTree;
256 delete fFilter;
257 delete fDir;
258 delete fFile;
260 if (fCachedPic && (fCachedPic != fFileIcon))
263 Cleanup();
264}
265
266////////////////////////////////////////////////////////////////////////////////
267/// Helper function checking if a class has a graphic properties editor.
268
270{
271 TBaseClass *base;
272 TList* bcl = cl->GetListOfBases();
273 TIter next(bcl);
274 while ((base = (TBaseClass*) next())) {
275 cl = base->GetClassPointer();
276 if (cl && TClass::GetClass(Form("%sEditor", cl->GetName())))
277 return kTRUE;
278 if (cl && IsObjectEditable(cl))
279 return kTRUE;
280 }
281 return kFALSE;
282}
283
284////////////////////////////////////////////////////////////////////////////////
285/// Format the tooltip information, based on the object passed in argument.
286
287static const char *FormatToolTip(TObject *obj, Int_t maxlen=0)
288{
289 static TString infos;
290 if (!obj) {
291 infos.Clear();
292 return 0;
293 }
294 infos = obj->GetName();
295 if (obj->GetTitle()) {
296 infos += "\n";
297 infos += obj->GetTitle();
298 }
299 if (maxlen > 0 && infos.Length() > maxlen) {
300 infos.Remove(maxlen - 3);
301 infos += "...";
302 }
303 TString objinfo = obj->GetObjectInfo(1, 1);
304 if (!objinfo.IsNull() && !objinfo.BeginsWith("x=")) {
305 Long64_t bsize, fsize, objsize;
306 objsize = objinfo.Atoll();
307 if (objsize > 0) {
308 infos += "\n";
309 bsize = fsize = objsize;
310 if (fsize > 1024) {
311 fsize /= 1024;
312 if (fsize > 1024) {
313 // 3.7MB is more informative than just 3MB
314 infos += TString::Format("Size: %lld.%lldM", fsize/1024,
315 (fsize%1024)/103);
316 } else {
317 infos += TString::Format("Size: %lld.%lldK", bsize/1024,
318 (bsize%1024)/103);
319 }
320 } else {
321 infos += TString::Format("Size: %lld bytes", bsize);
322 }
323 }
324 }
325 return infos.Data();
326}
327
328/**************************************************************************/
329// TBrowserImp virtuals
330/**************************************************************************/
331
332////////////////////////////////////////////////////////////////////////////////
333/// Add items to the browser. This function has to be called
334/// by the Browse() member function of objects when they are
335/// called by a browser. If check < 0 (default) no check box is drawn,
336/// if 0 then unchecked checkbox is added, if 1 checked checkbox is added.
337
338void TGFileBrowser::Add(TObject *obj, const char *name, Int_t check)
339{
340 if (fListLevel && !strcmp(fListLevel->GetText(), "Classes") &&
342 !strcmp(fListLevel->GetParent()->GetText(), "root")) {
343 // Browsing list of root classes...
344 }
345 else {
346 if (obj && obj->InheritsFrom("TApplication"))
347 fListLevel = 0;
348 if (obj && obj->InheritsFrom("TSystemDirectory"))
349 return;
350 }
351 if (fListLevel) {
352 TString oname = "";
353 if (name)
354 oname = name;
355 else if (obj)
356 oname = obj->GetName();
357 // check if the current item is filtered
358 auto it = fFilteredItems.find(fListLevel);
359 if (it != fFilteredItems.end()) {
360 // check if the item (object) name match the filter
361 const char *filter = it->second.c_str();
362 TRegexp re(filter, kTRUE);
363 // if not, simply return, so no item will be added
364 if (oname.Index(re) == kNPOS) return;
365 }
366 }
367 const TGPicture *pic = nullptr;
368 if (obj && obj->InheritsFrom("TKey") && (obj->IsA() != TClass::Class()))
369 AddKey(fListLevel, obj, name);
370 else if (obj) {
371 GetObjPicture(&pic, obj);
372 if (!name) name = obj->GetName();
373 if (check > -1) {
376 pic, pic, kTRUE);
377 if ((pic != fFileIcon) && (pic != fCachedPic))
381 }
382 }
383 else {
384 // special case for remote object
386 if (obj->InheritsFrom("TRemoteObject"))
387 isRemote = kTRUE;
388 else if (fListLevel) {
389 // check also if one of its parents is a remote object
391 while (top->GetParent()) {
392 TObject *tobj = (TObject *) top->GetUserData();
393 if (tobj && (tobj->InheritsFrom("TRemoteObject") ||
394 tobj->InheritsFrom("TApplicationRemote"))) {
395 isRemote = kTRUE;
396 break;
397 }
398 top = top->GetParent();
399 }
400 }
401 if (isRemote) {
403 if (!strcmp(robj->GetClassName(), "TKey")) {
404 AddKey(fListLevel, obj, name);
405 }
406 else {
408 // add the remote object only if not already in the list
409 if (!fShowHidden && fname.BeginsWith("."))
410 return;
411 AddRemoteFile(obj);
412 }
413 }
414 else {
417 if ((pic != fFileIcon) && (pic != fCachedPic))
419 if (item && obj && obj->InheritsFrom("TObject"))
420 item->SetDNDSource(kTRUE);
422 }
423 }
424 }
425 }
426}
427
428////////////////////////////////////////////////////////////////////////////////
429/// Add remote file in list tree.
430
432{
434 Int_t type;
436 const TGPicture *spic;
437 TGPicture *pic;
438
440
442
443 robj->GetFileStat(&sbuf);
444 is_link = sbuf.fIsLink;
445 type = sbuf.fMode;
446 filename = robj->GetName();
447 if (R_ISDIR(type) || fFilter == 0 ||
448 (fFilter && filename.Index(*fFilter) != kNPOS)) {
449
451
452 pic = (TGPicture*)spic; pic->AddReference();
453
457 }
458}
459
460////////////////////////////////////////////////////////////////////////////////
461/// Browse object. This, in turn, will trigger the calling of
462/// TBrowser::Add() which will fill the IconBox and the tree.
463/// Emits signal "BrowseObj(TObject*)".
464
466{
467 if (fNewBrowser)
469 if (obj != gROOT) {
471 fListLevel = 0;
472 Add(obj);
475 if (obj->IsFolder())
479 }
480 }
481 if (fBrowser) obj->Browse(fBrowser);
482 if (obj == gROOT) {
483 TList *volumes = gSystem->GetVolumes("all");
484 TList *curvol = gSystem->GetVolumes("cur");
485 if (volumes && curvol) {
486 const char *curdrive;
487 TNamed *named = (TNamed *)curvol->At(0);
488 if (named)
489 curdrive = named->GetName();
490 else
491 curdrive = "C:";
492 TIter next(volumes);
493 TNamed *drive;
494 while ((drive = (TNamed *)next())) {
495 AddFSDirectory(TString::Format("%s\\", drive->GetName()), drive->GetTitle(),
496 (strcmp(drive->GetName(), curdrive) == 0) ?
497 "SetRootDir" : "Add");
498 }
499 delete volumes;
500 delete curvol;
501 }
502 else {
503 AddFSDirectory("/");
504 }
506 if (gROOT->GetListOfFiles() && !gROOT->GetListOfFiles()->IsEmpty())
507 Selected(0);
508 }
509}
510
511////////////////////////////////////////////////////////////////////////////////
512/// Emits signal when double clicking on icon.
513
515{
516 if (fNewBrowser)
517 fNewBrowser->Checked(obj, checked);
518}
519
520////////////////////////////////////////////////////////////////////////////////
521/// returns drawing option
522
524{
525 return fDrawOption->GetTextEntry()->GetText();
526}
527
528////////////////////////////////////////////////////////////////////////////////
529/// Determine the file picture for the given file type.
530
532 Bool_t is_link, const char *name)
533{
534 static TString cached_ext;
535 static const TGPicture *cached_spic = 0;
536 const char *ext = name ? strrchr(name, '.') : 0;
537 TString sname = name ? name : " ";
538 *pic = 0;
539
540 if (ext && cached_spic && (cached_ext == ext)) {
541 *pic = cached_spic;
542 return;
543 }
544
545 if (R_ISREG(file_type)) {
546 *pic = gClient->GetMimeTypeList()->GetIcon(name, kTRUE);
547
548 if (*pic) {
549 if (ext) {
550 cached_ext = ext;
551 cached_spic = *pic;
552 return;
553 }
554 }
555 } else {
556 *pic = 0;
557 }
558
559 if (*pic == 0) {
560 *pic = gClient->GetPicture("doc_t.xpm");
561
562 if (R_ISREG(file_type) && (file_type) & kS_IXUSR) {
563 *pic = gClient->GetPicture("app_t.xpm");
564 }
565 if (R_ISDIR(file_type)) {
566 *pic = gClient->GetPicture("folder_t.xpm");
567 }
568 if(sname.EndsWith(".root")) {
569 *pic = gClient->GetPicture("rootdb_t.xpm");
570 }
571
572 }
573 if (is_link) {
574 *pic = gClient->GetPicture("slink_t.xpm");
575 }
576
577 cached_spic = 0;
578 cached_ext = "";
579}
580
581////////////////////////////////////////////////////////////////////////////////
582/// Recursively remove object.
583
585{
586 TGListTreeItem *itm = nullptr, *item = nullptr;
587 if (obj->InheritsFrom("TFile")) {
588 itm = fListTree->FindChildByData(0, gROOT->GetListOfFiles());
589 if (itm)
591 if (item) {
592 // if the item to be deleted has a filter,
593 // delete its entry in the map
594 if (CheckFiltered(item))
595 fFilteredItems.erase(item);
597 }
598 itm = fRootDir ? fRootDir->GetFirstChild() : nullptr;
599 while (itm) {
601 if (item) {
603 item->SetUserData(0);
604 }
605 itm = itm->GetNextSibling();
606 }
607 }
608 if (!obj->InheritsFrom("TFile") && fRootDir) {
610 // if the item to be deleted has a filter, delete its entry in the map
611 if (item && CheckFiltered(item))
612 fFilteredItems.erase(item);
614 }
615 //fListTree->ClearViewPort();
616}
617
618////////////////////////////////////////////////////////////////////////////////
619/// Refresh content of the list tree.
620
622{
623 TTimer::SingleShot(200, "TGFileBrowser", this, "Update()");
624}
625
626////////////////////////////////////////////////////////////////////////////////
627/// Update content of the list tree.
628
630{
631 Long64_t size = 0;
632 Long_t id = 0, flags = 0, modtime = 0;
633 char path[1024];
635 if (!item) item = fRootDir;
636 if (!item) return;
637 //fListTree->DeleteChildren(item);
638 TGListTreeItem *curr = fListTree->GetSelected(); // GetCurrent() ??
639 if (curr) {
640 TObject *obj = (TObject *) curr->GetUserData();
641 if (obj && ROOT::Detail::HasBeenDeleted(obj)) {
642 // if the item to be deleted has a filter,
643 // delete its entry in the map
644 if (CheckFiltered(curr))
645 fFilteredItems.erase(curr);
647 curr = 0;
648 obj = 0;
649 }
650 else if (obj && !ROOT::Detail::HasBeenDeleted(obj) &&
651 obj->InheritsFrom("TObjString") && curr->GetParent()) {
652 fListTree->GetPathnameFromItem(curr->GetParent(), path);
653 if (strlen(path) > 1) {
654 TString dirpath = FullPathName(curr->GetParent());
655 Int_t res = gSystem->GetPathInfo(dirpath.Data(), &id, &size,
656 &flags, &modtime);
657 if ((res == 0) && (flags & 2)) {
659 if (gSystem->AccessPathName(fullpath.Data())) {
660 // if the item to be deleted has a filter,
661 // delete its entry in the map
662 if (CheckFiltered(curr))
663 fFilteredItems.erase(curr);
665 curr = 0;
666 obj = 0;
667 }
668 }
669 }
670 }
671 }
673 flags = id = size = modtime = 0;
674 if (gSystem->GetPathInfo(actpath.Data(), &id, &size, &flags, &modtime) == 0) {
675 Int_t isdir = (Int_t)flags & 2;
676
678 if (isdir) {
679 TGListTreeItem *del = 0, *itm = item->GetFirstChild();
680 while (itm) {
682 if (strlen(path) > 1) {
684 if (gSystem->AccessPathName(recpath.Data())) {
685 del = itm;
686 itm = itm->GetNextSibling();
687 // if the item to be deleted has a filter,
688 // delete its entry in the map
689 if (CheckFiltered(del))
690 fFilteredItems.erase(del);
692 }
693 }
694 if (del)
695 del = 0;
696 else
697 itm = itm->GetNextSibling();
698 }
699 }
700 }
703 fListLevel = sav;
705}
706
707/**************************************************************************/
708// Other
709/**************************************************************************/
710
711////////////////////////////////////////////////////////////////////////////////
712/// Add file system directory in the list tree.
713
714void TGFileBrowser::AddFSDirectory(const char *entry, const char *path,
715 Option_t *opt)
716{
717 TGListTreeItem *item = 0;
718 if ((opt == 0) || (!opt[0])) {
719 if (fRootDir == 0 && !fListTree->FindChildByName(0, rootdir))
721 return;
722 }
723 if (strstr(opt, "SetRootDir")) {
726 }
727 else if (strstr(opt, "Add")) {
728 // MT: i give up! wanted to place entries for selected
729 // directories like home, pwd, alice-macros.
730 // TGListTreeItem *lti = fListTree->AddItem(0, entry);
731 //
734 }
735 if (item && path) {
736 TString infos = path;
737 item->SetTipText(path);
738 TGPicture *pic = 0;
739 if (infos.Contains("Removable"))
740 pic = (TGPicture *)gClient->GetPicture("fdisk_t.xpm");
741 else if (infos.Contains("Local"))
742 pic = (TGPicture *)gClient->GetPicture("hdisk_t.xpm");
743 else if (infos.Contains("CD"))
744 pic = (TGPicture *)gClient->GetPicture("cdrom_t.xpm");
745 else if (infos.Contains("Network"))
746 pic = (TGPicture *)gClient->GetPicture("netdisk_t.xpm");
747 if (pic) {
748 item->SetPictures(pic, pic);
749 gClient->FreePicture(pic);
750 }
751 }
752}
753
754////////////////////////////////////////////////////////////////////////////////
755/// display content of ROOT file
756
758{
759 // Int_t from, to;
761 static TGListTreeItem *olditem = itm;
762 static TGListTreeItem *item = itm;
763 const TGPicture *pic;
764
765 if (itm == 0) return;
766
767 if ((fCnt == 0) || (olditem != itm)) {
768 olditem = item = itm;
769 }
770 if (!name) name = obj->GetName();
771 if (fNKeys > fGroupSize) {
772 where = itm->GetFirstChild();
773 while (where) {
774 if (fListTree->FindItemByObj(where, obj))
775 return;
776 where = where->GetNextSibling();
777 }
778 }
779 if ((fNKeys > fGroupSize) && (fCnt % fGroupSize == 0)) {
780 if (item != itm) {
781 TString newname = TString::Format("%s-%s", item->GetText(), name);
782 item->Rename(newname.Data());
783 }
785 item->SetDNDSource(kTRUE);
786 }
787 if ((fCnt > fGroupSize) && (fCnt >= fNKeys-1)) {
788 TString newname = TString::Format("%s-%s", item->GetText(), name);
789 item->Rename(newname.Data());
790 }
791 GetObjPicture(&pic, obj);
794 if (pic && (pic != fFileIcon) && (pic != fCachedPic))
796 it->SetDNDSource(kTRUE);
797 it->SetTipText(FormatToolTip(obj, 32));
798 }
799 fCnt++;
800}
801
802////////////////////////////////////////////////////////////////////////////////
803/// Apply filter selected in combo box to the file tree view.
804
806{
807 // Long64_t size;
808 // Long_t fid, flags, modtime;
809
810 if (fFilter)
811 delete fFilter;
812 fFilter = nullptr;
813 if ((id > 1) && (id < 5))
814 fFilter = new TRegexp(filters[id], kTRUE);
815 else if ((id < 0) || (id > 4)) {
817 if (lbe) {
818 const char *text = lbe->GetTitle();
819 fFilter = new TRegexp(text, kTRUE);
820 }
821 }
823 if (!item)
824 item = fRootDir;
825 if (!item) return;
828 //fListTree->AdjustPosition(item);
830}
831
832////////////////////////////////////////////////////////////////////////////////
833/// Make object associated with item the current directory.
834
836{
837 if (item) {
838 TGListTreeItem *i = item;
839 while (i) {
840 TObject *obj = (TObject*) i->GetUserData();
841 if ((obj) && obj->InheritsFrom("TDirectory")) {
842 ((TDirectory *)obj)->cd();
843 break;
844 }
845 i = i->GetParent();
846 }
847 }
848}
849
850////////////////////////////////////////////////////////////////////////////////
851/// Check if the current list tree item points to a remote object.
852
854{
855 if (!item) return;
856 TObject *obj = (TObject *) item->GetUserData();
857 if (obj) {
858 if (obj->InheritsFrom("TApplicationRemote")) {
859 if (!gApplication->GetAppRemote()) {
860 gROOT->ProcessLine(TString::Format(".R %s", item->GetText()));
861 if (gApplication->GetAppRemote()) {
862 Getlinem(kInit, TString::Format("\n%s:root [0]",
864 }
865 }
866 }
867 if (item->GetParent() && item->GetParent()->GetUserData() &&
868 ((TObject *)item->GetParent()->GetUserData())->InheritsFrom("TApplicationRemote")) {
869 // switch to remote session
870 if (!gApplication->GetAppRemote()) {
871 gROOT->ProcessLine(TString::Format(".R %s", item->GetParent()->GetText()));
872 if (gApplication->GetAppRemote()) {
873 Getlinem(kInit, TString::Format("\n%s:root [0]",
875 }
876 }
877 else if (!strcmp(item->GetText(), "ROOT Files")) {
878 // update list of files opened in the remote session
880 gApplication->ProcessLine("((TApplicationServer *)gApplication)->BrowseFile(0);");
881 }
882 }
883 else {
884 // check if the listtree item is from a local session or
885 // from a remote session, then switch to the session it belongs to
886 TGListTreeItem *top = item;
887 while (top->GetParent()) {
888 top = top->GetParent();
889 }
890 TObject *topobj = (TObject *) top->GetUserData();
891 if (topobj && topobj->InheritsFrom("TApplicationRemote")) {
892 // it belongs to a remote session
893 if (!gApplication->GetAppRemote()) {
894 // switch to remote session if not already in
895 gROOT->ProcessLine(TString::Format(".R %s", top->GetText()));
896 if (gApplication->GetAppRemote()) {
897 Getlinem(kInit, TString::Format("\n%s:root [0]",
899 }
900 }
901 }
902 else if (gApplication->GetAppRemote()) {
903 // switch back to local session if not already in
905 Getlinem(kInit, "\nroot [0]");
906 }
907 }
908 }
909 else if (gApplication->GetAppRemote()) {
910 // switch back to local session if not already in
912 Getlinem(kInit, "\nroot [0]");
913 }
914}
915
916////////////////////////////////////////////////////////////////////////////////
917/// Check if there is a filter active on the children of the list tree item.
918/// If the but argument is true, the "filter" button state is set accordingly,
919/// and its tooltip will show the filter used.
920
922{
923 Bool_t found = kFALSE;
924 TString filter;
925 // if there is no filter (the map is empty) then just return
926 if (fFilteredItems.empty())
927 return kFALSE;
928 auto it = fFilteredItems.find(item);
929 if (it != fFilteredItems.end()) {
930 // if the item is in the map, take the filter regexp string
931 filter = it->second.c_str();
932 fFilterStr = filter;
933 found = kTRUE;
934 }
935 if (but) {
936 // if the but argument is true, change the button state
937 // to reflect the filtering state
939 if (found) {
940 // format the tooltip to display the regexp used as filter
941 filter.Prepend("Showing only \'");
942 filter += "\'";
944 }
945 else {
946 // reset the tooltip text
947 fFilterButton->SetToolTipText("Filter Content...");
948 }
949 }
950 return found;
951}
952
953////////////////////////////////////////////////////////////////////////////////
954/// Check if the list tree item children are alphabetically sorted.
955/// If the but argument is true, the "sort" button state is set accordingly.
956
958{
959 Bool_t found = kFALSE;
960 TGListTreeItem *i, *itm;
961 if (item->GetFirstChild())
962 itm = item;
963 else
964 itm = item->GetParent();
965 for (sLTI_i p=fSortedItems.begin(); p!=fSortedItems.end(); ++p) {
966 i = (TGListTreeItem *)(*p);
967 if (itm == i) {
968 found = kTRUE;
969 break;
970 }
971 }
973 return found;
974}
975
976////////////////////////////////////////////////////////////////////////////////
977/// Process mouse clicks in TGListTree.
978
980{
981 char path[1024];
982 Long64_t size = 0;
983 Long_t id = 0, flags = 0, modtime = 0;
985 if (!item) return;
989 TObject *selected = 0;
991 TObject *obj = (TObject *) item->GetUserData();
992 if (obj && (!obj->InheritsFrom("TObjString") ||
993 gSystem->AccessPathName(fullpath.Data()))) {
994 if (obj->InheritsFrom("TKey") && (obj->IsA() != TClass::Class())) {
995 Chdir(item);
996 const char *clname = ((TKey *)obj)->GetClassName();
997 if (clname && strcmp(clname, "TGeoManager")) {
999 TString name = ((TKey *)obj)->GetName();
1000 name += ";";
1001 name += ((TKey *)obj)->GetCycle();
1002 void *add = gDirectory->FindObjectAny((char *) name.Data());
1003 if (add && cl->IsTObject()) {
1004 obj = (TObject*)add;
1005 // don't change the user data, to avoid deletion of the
1006 // list tree item by RecursiveRemove()
1007 // it is better to read the object each time anyway,
1008 // as it may have changed in the file
1009 if (obj->InheritsFrom("TDirectory") || obj->InheritsFrom("TList"))
1010 item->SetUserData(obj);
1011 }
1012 }
1013 }
1014 if (obj->InheritsFrom("TLeaf") ||
1015 obj->InheritsFrom("TBranch")) {
1016 Chdir(item);
1017 }
1018 if (btn == kButton3)
1019 fContextMenu->Popup(x, y, obj, fBrowser);
1020 selected = obj;
1021 }
1022 else {
1024 if (strlen(path) > 3) {
1025 if (gSystem->GetPathInfo(fullpath.Data(), &id, &size, &flags, &modtime) == 0) {
1026 if (flags & 2) {
1027 fCurrentDir = item;
1028 if (btn == kButton3) {
1029 if (fDir) delete fDir;
1030 fDir = new TSystemDirectory(item->GetText(), fullpath.Data());
1032 }
1033 }
1034 else {
1035 fCurrentDir = item->GetParent();
1036 if (btn == kButton3) {
1037 if (fFile) delete fFile;
1038 fFile = new TSystemFile(item->GetText(), fullpath.Data());
1040 }
1041 }
1042 }
1043 }
1044 }
1046 if (selected && (selected->IsA() != TClass::Class())) {
1047 if (selected->InheritsFrom("TLeaf"))
1048 selected = (TObject *)gROOT->ProcessLine(TString::Format("((TLeaf *)0x%zx)->GetBranch()->GetTree();", (size_t)selected));
1049 if (selected->InheritsFrom("TBranch"))
1050 selected = (TObject *)gROOT->ProcessLine(TString::Format("((TBranch *)0x%zx)->GetTree();", (size_t)selected));
1051 if (selected->InheritsFrom("TTree")) {
1052 // if a tree not attached to any directory (e.g. in a TFolder)
1053 // then attach it to the current directory (gDirectory)
1054 TDirectory *tdir = (TDirectory *)gROOT->ProcessLine(TString::Format("((TTree *)0x%zx)->GetDirectory();", (size_t)selected));
1055 if (!tdir) {
1056 gROOT->ProcessLine(TString::Format("((TTree *)0x%zx)->SetDirectory(gDirectory);", (size_t)selected));
1057 }
1058 }
1059 }
1060 if (selected && gPad && IsObjectEditable(selected->IsA())) {
1062 if (ved) {
1063 TGedEditor *ged = (TGedEditor *)ved;
1064 ged->SetModel(gPad, selected, kButton1Down);
1065 }
1066 }
1067}
1068
1069////////////////////////////////////////////////////////////////////////////////
1070/// returns an absolute path
1071
1073{
1074 TGListTreeItem *parent, *itm = item;
1075 TString dirname = itm->GetText();
1076
1077 while ((parent=itm->GetParent())) {
1079 itm = parent;
1080 }
1082#ifdef R__WIN32
1083 // only handle .lnk files on Windows
1084 while (dirname.Contains(".lnk")) {
1085 Ssiz_t idx = dirname.Index(".lnk") + 4;
1087 resolved.Remove(idx);
1089 dirname = resolved.Append(dirname.Remove(0, idx));
1090 }
1091#endif
1092 return dirname;
1093}
1094
1095////////////////////////////////////////////////////////////////////////////////
1096/// returns the directory path
1097
1099{
1102
1103#ifdef WIN32
1104 char winDrive[256];
1105 char winDir[256];
1106 char winName[256];
1107 char winExt[256];
1110#else
1112#endif
1113 return dirname;
1114}
1115
1116////////////////////////////////////////////////////////////////////////////////
1117/// Returns true if given a text file
1118/// Uses the specification given on p86 of the Camel book
1119/// - Text files have no NULLs in the first block
1120/// - and less than 30% of characters with high bit set
1121
1122static Bool_t IsTextFile(const char *candidate)
1123{
1124 Int_t i;
1125 Int_t nchars;
1126 Int_t weirdcount = 0;
1127 char buffer[512];
1128 FILE *infile;
1129 FileStat_t buf;
1130
1131 if (gSystem->GetPathInfo(candidate, buf) || !(buf.fMode & kS_IFREG))
1132 return kFALSE;
1133
1134 infile = fopen(candidate, "r");
1135 if (infile) {
1136 // Read a block
1137 nchars = fread(buffer, 1, 512, infile);
1138 fclose (infile);
1139 // Examine the block
1140 for (i = 0; i < nchars; i++) {
1141 if (buffer[i] & 128)
1142 weirdcount++;
1143 if (buffer[i] == '\0')
1144 // No NULLs in text files
1145 return kFALSE;
1146 }
1147 if ((nchars > 0) && ((weirdcount * 100 / nchars) > 30))
1148 return kFALSE;
1149 } else {
1150 // Couldn't open it. Not a text file then
1151 return kFALSE;
1152 }
1153 return kTRUE;
1154}
1155
1156////////////////////////////////////////////////////////////////////////////////
1157/// Create a symlink (shortcut on Windows) icon by merging the picture
1158/// passed as argument and the slink_t.xpm icon (small arrow)
1159
1160static const TGPicture *MakeLinkPic(const TGPicture *pic)
1161{
1162 const TGPicture *merged;
1163 TImage *img1, *img2;
1164 if (pic) {
1165 img1 = TImage::Create();
1166 if (img1 == 0) return pic;
1167 img1->SetImage(((const TGPicture *)pic)->GetPicture(),
1168 ((const TGPicture *)pic)->GetMask());
1169 img2 = TImage::Open("slink_t.xpm");
1170 if (img2) img1->Merge(img2);
1171 TString lnk_name = ((const TGPicture *)pic)->GetName();
1172 lnk_name.Prepend("lnk_");
1173 merged = gClient->GetPicturePool()->GetPicture(lnk_name.Data(),
1174 img1->GetPixmap(), img1->GetMask());
1175 if (img2) delete img2;
1176 delete img1;
1177 return merged;
1178 }
1179 return pic;
1180}
1181
1182////////////////////////////////////////////////////////////////////////////////
1183/// Process double clicks in TGListTree.
1184
1186{
1187 const TGPicture *pic=0;
1192 Long64_t size;
1193 Long_t id, flags, modtime;
1194 char action[512];
1195 TString act;
1197 if (!gSystem->GetPathInfo(item->GetText(), sbuf) && sbuf.fIsLink) {
1198 is_link = kTRUE;
1199 fullpath = item->GetText();
1201 }
1202
1203 if (fNewBrowser)
1206 fListLevel = item;
1210 TGListTreeItem *pitem = item->GetParent();
1211 TObject *obj = (TObject *) item->GetUserData();
1212 if (obj && !obj->InheritsFrom("TSystemFile")) {
1213 TString ext = obj->GetName();
1214 if (obj->InheritsFrom("TDirectory") && (obj->IsA() != TClass::Class())) {
1215 if (((TDirectory *)obj)->GetListOfKeys())
1216 fNKeys = ((TDirectory *)obj)->GetListOfKeys()->GetEntries();
1217 else
1218 fNKeys = 0;
1219 }
1220 else if (obj->InheritsFrom("TKey") && (obj->IsA() != TClass::Class())) {
1221 Chdir(item);
1222 const char *clname = ((TKey *)obj)->GetClassName();
1223 if (clname) {
1225 TString name = ((TKey *)obj)->GetName();
1226 name += ";";
1227 name += ((TKey *)obj)->GetCycle();
1228 void *add = gDirectory->FindObjectAny((char *) name.Data());
1229 if (add && cl->IsTObject()) {
1230 obj = (TObject*)add;
1231 // don't change the user data, to avoid deletion of the
1232 // list tree item by RecursiveRemove()
1233 // it is better to read the object each time anyway,
1234 // as it may have changed in the file
1235 if (obj->InheritsFrom("TDirectory") || obj->InheritsFrom("TList"))
1236 item->SetUserData(obj);
1237 }
1238 }
1239 }
1240 else if (obj->InheritsFrom("TLeaf") || obj->InheritsFrom("TBranch")) {
1241 Chdir(item);
1242 }
1243 else if (obj->InheritsFrom("TRemoteObject")) {
1244 // the real object is a TKey
1246 if (!strcmp(robj->GetClassName(), "TKey")) {
1247 TGListTreeItem *parent = item;
1249 // find the TFile remote object containing the TKey
1250 while ( probj && strcmp(probj->GetClassName(), "TFile")) {
1251 parent = parent->GetParent();
1252 probj = (TRemoteObject *)parent->GetUserData();
1253 }
1254 if (probj && !strcmp(probj->GetClassName(), "TFile")) {
1255 // remotely browse file (remotely call TFile::cd())
1258 TString::Format("((TApplicationServer *)gApplication)->BrowseFile(\"%s\");",
1259 probj->GetName()));
1260 gSystem->Sleep(250);
1261 }
1262 }
1263 if (gClient->GetMimeTypeList()->GetAction(obj->GetName(), action)) {
1264 act = action;
1265 act.ReplaceAll("%s", obj->GetName());
1266 if ((act[0] != '!') && (strcmp(pitem->GetText(), "ROOT Files"))) {
1267 // special case for remote object: remote process
1269 gApplication->ProcessLine(act.Data());
1270 }
1271 }
1272 if ((ext.EndsWith(".root")) && (strcmp(pitem->GetText(), "ROOT Files"))) {
1274 gApplication->ProcessLine("((TApplicationServer *)gApplication)->BrowseFile(0);");
1275 }
1276 }
1277 if (!obj->InheritsFrom("TObjString") ||
1278 gSystem->AccessPathName(fullpath.Data())) {
1280 fDblClick = kTRUE;
1281 if (gClient->GetMimeTypeList()->GetAction(obj->IsA()->GetName(), action)) {
1282 act = action;
1283 if (fBrowser && act.Contains("->Browse()")) obj->Browse(fBrowser);
1284 else if (act.Contains("->Draw()")) obj->Draw(GetDrawOption());
1285 else {
1286 if (act.Contains("%s")) act.ReplaceAll("%s", obj->GetName());
1287 else act.Prepend(obj->GetName());
1288 gInterpreter->SaveGlobalsContext();
1289 if (act[0] == '!') {
1290 act.Remove(0, 1);
1291 gSystem->Exec(act.Data());
1292 } else {
1293 // special case for remote object: remote process
1294 if (obj->InheritsFrom("TRemoteObject"))
1296 gApplication->ProcessLine(act.Data());
1297 }
1298 }
1299 }
1300 else if (obj->InheritsFrom("TCanvas") && fNewBrowser &&
1303 // avoid potential crash when drawing a canvas with the same name
1304 // than a canvas already embedded in one of the browser's tab
1305 obj->DrawClone();
1306 } else if (fBrowser && !obj->InheritsFrom("TFormula"))
1307 obj->Browse(fBrowser);
1308 fDblClick = kFALSE;
1309 fNKeys = 0;
1310 fCnt = 0;
1312 if (gPad) gPad->Update();
1313 return;
1314 }
1315 }
1316 flags = id = size = modtime = 0;
1317 if (gSystem->GetPathInfo(fullpath.Data(), &id, &size, &flags, &modtime) != 0)
1318 return;
1319 Int_t isdir = (Int_t)flags & 2;
1320
1322 if (isdir) {
1323 fCurrentDir = item;
1324 //fListTree->DeleteChildren(item);
1325 TSystemDirectory dir(item->GetText(),FullPathName(item));
1326 TList *files = dir.GetListOfFiles();
1327 if (files) {
1328 files->Sort();
1329 TIter next(files);
1330 TSystemFile *file;
1332 // directories first
1333 //fListTree->DeleteChildren(item);
1334 while ((file=(TSystemFile*)next())) {
1335 fname = file->GetName();
1336 if (file->IsDirectory()) {
1337 if (!fShowHidden && fname.BeginsWith("."))
1338 continue;
1339 if ((fname!="..") && (fname!=".")) { // skip it
1342 if (!gSystem->GetPathInfo(fname, sbuf) &&
1343 sbuf.fIsLink) {
1344 // change the pictures if it is a symlink
1345 // (shortcut on Windows)
1346 const TGPicture *opened = 0, *l_opened = 0;
1347 const TGPicture *closed = 0, *l_closed = 0;
1348 opened = fClient->GetPicture("ofolder_t.xpm");
1350 closed = fClient->GetPicture("folder_t.xpm");
1352 if (l_opened && l_closed)
1353 itm->SetPictures(l_opened, l_closed);
1358 }
1359 // uncomment line below to set directories as
1360 // DND targets
1361 //itm->SetDNDTarget(kTRUE);
1362 itm->SetUserData(0);
1363 }
1364 }
1365 }
1366 }
1367 // then files...
1368 TIter nextf(files);
1369 while ((file=(TSystemFile*)nextf())) {
1370 fname = pname = file->GetName();
1371 if (!file->IsDirectory() && (fFilter == 0 ||
1372 (fFilter && fname.Index(*fFilter) != kNPOS))) {
1373 if (!fShowHidden && fname.BeginsWith("."))
1374 continue;
1375 size = modtime = 0;
1376 if (gSystem->GetPathInfo(fname, sbuf) == 0) {
1377 size = sbuf.fSize;
1378 modtime = sbuf.fMtime;
1379 }
1380 if (sbuf.fIsLink && pname.EndsWith(".lnk"))
1381 pname.Remove(pname.Length()-4);
1382 pic = gClient->GetMimeTypeList()->GetIcon(pname, kTRUE);
1383 if (!pic)
1384 pic = fFileIcon;
1385 if (sbuf.fIsLink)
1386 pic = MakeLinkPic(pic);
1389 if (pic != fFileIcon)
1391 if (sbuf.fIsLink) {
1392 TString fullname = file->GetName();
1393 gSystem->ExpandPathName(fullname);
1394 itm->SetUserData(new TObjString(TString::Format("file://%s\r\n",fullname.Data())), kTRUE);
1395 } else {
1396 itm->SetUserData(new TObjString(TString::Format("file://%s/%s\r\n",
1397 gSystem->UnixPathName(file->GetTitle()),
1398 file->GetName())), kTRUE);
1399 }
1400 itm->SetDNDSource(kTRUE);
1401 if (size && modtime) {
1402 char *tiptext = FormatFileInfo(fname.Data(), size, modtime);
1403 itm->SetTipText(tiptext);
1404 delete [] tiptext;
1405 }
1406 }
1407 }
1408 }
1409 files->Delete();
1410 delete files;
1411 }
1412 }
1413 else {
1414 TString lnkname = item->GetText();
1415 if (is_link && lnkname.EndsWith(".lnk"))
1416 lnkname.Remove(lnkname.Length()-4);
1417 fCurrentDir = item->GetParent();
1418 TSystemFile f(lnkname.Data(), fullpath.Data());
1419 TString fname = f.GetName();
1420 if (fname.EndsWith(".root")) {
1421 TDirectory *rfile = 0;
1423 rfile = (TDirectory *)gROOT->GetListOfFiles()->FindObject(obj);
1424 if (!rfile) {
1425 rfile = (TDirectory *)gROOT->ProcessLine(TString::Format("new TFile(\"%s\")",fname.Data()));
1426 }
1427 if (rfile) {
1428 // replace actual user data (TObjString) by the TDirectory...
1429 if (item->GetUserData()) {
1430 // first delete the data to avoid memory leaks
1431 TObject *obj2 = static_cast<TObject *>(item->GetUserData());
1432 // only delete TObjString as they are the only objects
1433 // created who have to be deleted
1434 TObjString *ostr = dynamic_cast<TObjString *>(obj2);
1435 if (ostr) delete ostr;
1436 }
1437 item->SetUserData(rfile);
1438 fNKeys = rfile->GetListOfKeys()->GetEntries();
1439 fCnt = 0;
1440 if (fBrowser) rfile->Browse(fBrowser);
1441 fNKeys = 0;
1442 fCnt = 0;
1443 }
1444 }
1445 else if (fname.EndsWith(".png")) {
1449 }
1450 else if (IsTextFile(fullpath.Data())) {
1452 if (fNewBrowser) {
1453 TGFrameElement *fe = 0;
1455 TGCompositeFrame *frame = tabRight->GetCurrentContainer();
1456 if (frame)
1457 fe = (TGFrameElement *)frame->GetList()->First();
1458 if (fe) {
1460 TString fullname = f.GetTitle();
1461 fullname.ReplaceAll("\\", "\\\\");
1462 if (embed->InheritsFrom("TGTextEditor")) {
1463 gROOT->ProcessLine(TString::Format("((TGTextEditor *)0x%zx)->LoadFile(\"%s\");",
1464 (size_t)embed, fullname.Data()));
1465 }
1466 else if (embed->InheritsFrom("TGTextEdit")) {
1467 gROOT->ProcessLine(TString::Format("((TGTextEdit *)0x%zx)->LoadFile(\"%s\");",
1468 (size_t)embed, fullname.Data()));
1469 }
1470 else {
1472 }
1473 }
1474 else {
1476 }
1477 }
1479 }
1480 else {
1484 }
1485 }
1486 //gSystem->ChangeDirectory(savdir.Data());
1488}
1489
1490////////////////////////////////////////////////////////////////////////////////
1491/// Execute default action for selected object (action is specified
1492/// in the $HOME/.root.mimes or $ROOTSYS/etc/root.mimes file.
1493
1495{
1496 char action[512];
1497 TString act;
1498 TString ext = obj->GetName();
1500
1501 if (gClient->GetMimeTypeList()->GetAction(obj->GetName(), action)) {
1502 act = action;
1503 act.ReplaceAll("%s", obj->GetName());
1504 gInterpreter->SaveGlobalsContext();
1505
1506 if (act[0] == '!') {
1507 act.Remove(0, 1);
1508 gSystem->Exec(act.Data());
1509 return 0;
1510 } else {
1511 // special case for remote object: remote process
1512 if (obj->InheritsFrom("TRemoteObject"))
1514
1515 const Long_t res = gApplication->ProcessLine(act.Data());
1516#ifdef R__HAS_COCOA
1517 if (act.Contains(".x") || act.Contains(".X")) {
1518 if (gPad) gPad->Update();
1519 }
1520#endif
1521 return res;
1522 }
1523 }
1524 return 0;
1525}
1526
1527////////////////////////////////////////////////////////////////////////////////
1528/// Format file information to be displayed in the tooltip.
1529
1531{
1532 Long64_t fsize, bsize;
1534 infos += "\n";
1535
1536 fsize = bsize = size;
1537 if (fsize > 1024) {
1538 fsize /= 1024;
1539 if (fsize > 1024) {
1540 // 3.7MB is more informative than just 3MB
1541 infos += TString::Format("Size: %lld.%lldM", fsize/1024, (fsize%1024)/103);
1542 } else {
1543 infos += TString::Format("Size: %lld.%lldK", bsize/1024, (bsize%1024)/103);
1544 }
1545 } else {
1546 infos += TString::Format("Size: %lld", bsize);
1547 }
1548 struct tm *newtime;
1549 time_t loctime = (time_t) modtime;
1551 if (newtime) {
1552 infos += "\n";
1553 infos += TString::Format("%d-%02d-%02d %02d:%02d",
1554 newtime->tm_year + 1900,
1555 newtime->tm_mon+1, newtime->tm_mday,
1556 newtime->tm_hour, newtime->tm_min);
1557 }
1558 return StrDup(infos.Data());
1559}
1560
1561////////////////////////////////////////////////////////////////////////////////
1562/// Retrieve icons associated with class "name". Association is made
1563/// via the user's ~/.root.mimes file or via $ROOTSYS/etc/root.mimes.
1564
1566{
1567 const char *clname = 0;
1568 TClass *objClass = 0;
1569 static TImage *im = 0;
1570 if (!im) {
1571 im = TImage::Create();
1572 }
1573
1574 if (obj->IsA() == TClass::Class()) {
1575 objClass = obj->IsA();
1576 if (objClass)
1577 clname = objClass->GetName();
1578 }
1579 else if (obj->InheritsFrom("TKey")) {
1580 clname = ((TKey *)obj)->GetClassName();
1581 }
1582 else if (obj->InheritsFrom("TKeyMapFile")) {
1583 clname = ((TKeyMapFile *)obj)->GetTitle();
1584 }
1585 else if (obj->InheritsFrom("TRemoteObject")) {
1586 // special case for remote object: get real object class
1588 if (!strcmp(robj->GetClassName(), "TKey"))
1589 clname = robj->GetKeyClassName();
1590 else
1591 clname = robj->GetClassName();
1592 }
1593 else {
1594 objClass = obj->IsA();
1595 if (objClass)
1596 clname = objClass->GetName();
1597 }
1598 if (!clname) {
1599 clname = "Unknown";
1600 }
1601 const char *name = obj->GetIconName() ? obj->GetIconName() : clname;
1603 Bool_t xpm = xpm_magic == "/* ";
1604 const char *iconname = xpm ? obj->GetName() : name;
1605
1606 if (obj->IsA()->InheritsFrom("TGeoVolume")) {
1607 iconname = obj->GetIconName() ? obj->GetIconName() : obj->IsA()->GetName();
1608 }
1609
1610 if (fCachedPicName == iconname) {
1611 *pic = fCachedPic;
1612 return;
1613 }
1614 *pic = gClient->GetMimeTypeList()->GetIcon(iconname, kTRUE);
1615 if (!(*pic) && xpm) {
1616 if (im && im->SetImageBuffer((char**)&name, TImage::kXpm)) {
1617 im->Scale(im->GetWidth()/4, im->GetHeight()/4);
1618 *pic = gClient->GetPicturePool()->GetPicture(iconname, im->GetPixmap(),
1619 im->GetMask());
1620 }
1621 gClient->GetMimeTypeList()->AddType("[thumbnail]", iconname, iconname, iconname, "->Browse()");
1622 return;
1623 }
1624 if (fCachedPic && (fCachedPic != fFileIcon))
1626 if (*pic == 0) {
1627 if (!obj->IsFolder())
1628 *pic = fFileIcon;
1629 }
1630 fCachedPic = *pic;
1631 fCachedPicName = iconname;
1632}
1633
1634////////////////////////////////////////////////////////////////////////////////
1635/// Go to the directory "path" and open all the parent list tree items.
1636
1637void TGFileBrowser::GotoDir(const char *path)
1638{
1640 ULong_t id;
1644 item = fRootDir;
1645 if (item == 0) return;
1647 TObjArray *tokens = sPath.Tokenize("/");
1648 if (tokens->IsEmpty()) {
1650 DoubleClicked(item, 1);
1651 delete tokens;
1654 return;
1655 }
1656 // if the Browser.ExpandDirectories option is set to "no", then don't
1657 // expand the parent directory tree (for example on nfs)
1658 TString str = gEnv->GetValue("Browser.ExpandDirectories", "yes");
1659 str.ToLower();
1660 expand = (str == "yes") ? kTRUE : kFALSE;
1661 TString first = ((TObjString*)tokens->At(0))->GetName();
1662 // always prevent expanding the parent directory tree on afs
1663 if (first == "afs")
1664 expand = kFALSE;
1665 // check also AFS_SUPER_MAGIC, NFS_SUPER_MAGIC, FUSE_SUPER_MAGIC,
1666 // CIFS_MAGIC_NUMBER and SMB_SUPER_MAGIC
1667 if (!gSystem->GetFsInfo(path, (Long_t *)&id, &bsize, &blocks, &bfree))
1668 if (id == 0x5346414f || id == 0x6969 || id == 0x65735546 || id == 0xff534d42 || id == 0x517b)
1669 expand = kFALSE;
1670 if (first.Length() == 2 && first.EndsWith(":")) {
1671 TList *curvol = gSystem->GetVolumes("cur");
1672 if (curvol) {
1673 TNamed *drive = (TNamed *)curvol->At(0);
1674 if (first == drive->GetName()) {
1675 TString infos = drive->GetTitle();
1676 if (infos.Contains("Network"))
1677 expand = kFALSE;
1678 }
1679 delete curvol;
1680 }
1681 }
1682 for (Int_t i = 0; i < tokens->GetEntriesFast(); ++i) {
1683 TString token = ((TObjString*)tokens->At(i))->GetName();
1684 if (token.Length() == 2 && token.EndsWith(":")) {
1685 token.Append("\\");
1686 itm = fListTree->FindChildByName(0, token);
1687 if (itm) {
1688 item = itm;
1690 if (expand)
1691 DoubleClicked(item, 1);
1692 }
1693 continue;
1694 }
1695 itm = fListTree->FindChildByName(item, token);
1696 if (itm) {
1697 item = itm;
1699 if (expand)
1700 DoubleClicked(item, 1);
1701 }
1702 else {
1703 itm = fListTree->AddItem(item, token);
1704 item = itm;
1706 if (expand)
1707 DoubleClicked(item, 1);
1708 }
1709 }
1711 DoubleClicked(item, 1);
1712 delete tokens;
1715}
1716
1717////////////////////////////////////////////////////////////////////////////////
1718/// Slot used to switch to the tab containing the current pad/canvas (gPad)
1719/// used e.g. when drawing a histogram by double-clicking on its list tree
1720/// item in a root file.
1721
1723{
1724 if (fDblClick && fNewBrowser) {
1725 Int_t i;
1727 for (i=0;i<tabRight->GetNumberOfTabs();++i) {
1728 TGFrameElement *fe = 0;
1730 TGCompositeFrame *frame = tabRight->GetTabContainer(i);
1731 if (frame)
1732 fe = (TGFrameElement *)frame->GetList()->First();
1733 if (fe)
1734 embed = (TGCompositeFrame *)fe->fFrame;
1735 if (embed && embed->InheritsFrom("TRootCanvas")) {
1736 ULongptr_t canvas = gROOT->ProcessLine(TString::Format("((TRootCanvas *)0x%zx)->Canvas();",
1737 (size_t)embed));
1738 if ((canvas) && (canvas == (ULongptr_t)gPad ||
1739 canvas == (ULongptr_t)gPad->GetCanvas())) {
1740 tabRight->SetTab(i, kTRUE);
1741 break;
1742 }
1743 }
1744 }
1745 }
1746}
1747
1748////////////////////////////////////////////////////////////////////////////////
1749/// Open a dialog box asking for a string to be used as filter (regexp), and
1750/// add an entry in the map of filtered entries. Entering "*" or empty string
1751/// ("") will disable filtering on the current list tree item.
1752
1754{
1755 char filter[1024];
1756 if (!fListLevel)
1757 return;
1758 // initialize with previous (active) filter string
1759 snprintf(filter, sizeof(filter), "%s", fFilterStr.Data());
1760 new TGInputDialog(gClient->GetRoot(), this,
1761 "Enter filter expression:\n(empty string \"\" or \"*\" to remove filter)",
1762 filter, filter);
1763 // if user pressed cancel, update the status of the current list tree
1764 // item and return
1765 if ((filter[0] == 0) && (filter[1] == 0)) {
1767 return;
1768 }
1769 else if (((filter[0] == 0) && (filter[1] == 1)) || !strcmp(filter, "*")) {
1770 // if user entered "*" or "", just disable filtering for the current
1771 // list tree item
1774 } else {
1775 // if user entered a string different from "*", use it to create an
1776 // entry in the filter map
1777 fFilterStr = filter;
1779 // if there is already a filter on this item, delete it
1782 // insert a new entry for the current list tree item
1783 fFilteredItems.emplace(fListLevel, filter);
1784 }
1785 // finally update the list tree
1790}
1791
1792////////////////////////////////////////////////////////////////////////////////
1793/// A ROOT File has been selected in TGFileBrowser.
1794
1796{
1797 TGListTreeItem *itm = fListTree->FindChildByData(0, gROOT->GetListOfFiles());
1798 if (itm) {
1800 fListLevel = itm;
1803 BrowseObj(gROOT->GetListOfFiles());
1806 }
1807}
1808
1809////////////////////////////////////////////////////////////////////////////////
1810/// Toggle the sort mode and set the "sort button" state accordingly.
1811
1813{
1814 if (!fListLevel) return;
1817 if (!fListLevel->GetFirstChild()) {
1820 }
1821 if (!item)
1822 return;
1824 if (!is_sorted) {
1825 //alphabetical sorting
1827 fSortedItems.push_back(item);
1829 } else {
1831 DoubleClicked(item, 1);
1832 fSortedItems.remove(item);
1834 gClient->NeedRedraw(fListTree, kTRUE);
1835 gClient->HandleInput();
1836 if (itemname.Length() > 0) {
1838 if (itm) {
1840 Clicked(itm, 1, 0, 0);
1841 itm->SetActive(kTRUE);
1844 }
1845 }
1846 }
1849}
1850
1851
@ kButton1Down
Definition Buttons.h:17
@ kWatch
Definition GuiTypes.h:376
@ kPointer
Definition GuiTypes.h:376
@ kHorizontalFrame
Definition GuiTypes.h:383
@ kButton3
Definition GuiTypes.h:215
#define b(i)
Definition RSha256.hxx:100
#define f(i)
Definition RSha256.hxx:104
#define h(i)
Definition RSha256.hxx:106
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
Definition RtypesCore.h:68
unsigned long ULongptr_t
Unsigned integer large enough to hold a pointer (platform-dependent)
Definition RtypesCore.h:90
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
constexpr Ssiz_t kNPOS
The equivalent of std::string::npos for the ROOT class TString.
Definition RtypesCore.h:131
long long Long64_t
Portable signed long integer 8 bytes.
Definition RtypesCore.h:83
constexpr Bool_t kTRUE
Definition RtypesCore.h:107
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
R__EXTERN TApplication * gApplication
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define gDirectory
Definition TDirectory.h:385
R__EXTERN TEnv * gEnv
Definition TEnv.h:126
@ kButtonUp
Definition TGButton.h:53
@ kButtonEngaged
Definition TGButton.h:55
#define gClient
Definition TGClient.h:157
const char * filters[]
static Bool_t IsObjectEditable(TClass *cl)
Helper function checking if a class has a graphic properties editor.
static const TGPicture * MakeLinkPic(const TGPicture *pic)
Create a symlink (shortcut on Windows) icon by merging the picture passed as argument and the slink_t...
static const char * FormatToolTip(TObject *obj, Int_t maxlen=0)
Format the tooltip information, based on the object passed in argument.
const char rootdir[]
static Bool_t IsTextFile(const char *candidate)
Returns true if given a text file Uses the specification given on p86 of the Camel book.
@ kDeepCleanup
Definition TGFrame.h:42
@ kLHintsRight
Definition TGLayout.h:26
@ kLHintsExpandY
Definition TGLayout.h:31
@ kLHintsLeft
Definition TGLayout.h:24
@ kLHintsCenterY
Definition TGLayout.h:28
@ kLHintsTop
Definition TGLayout.h:27
@ kLHintsExpandX
Definition TGLayout.h:30
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t del
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize id
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char text
char name[80]
Definition TGX11.cxx:148
#define gInterpreter
#define gROOT
Definition TROOT.h:417
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2570
char * StrDup(const char *str)
Duplicate the string str.
Definition TString.cxx:2638
Bool_t R_ISREG(Int_t mode)
Definition TSystem.h:126
Bool_t R_ISDIR(Int_t mode)
Definition TSystem.h:123
R__EXTERN TSystem * gSystem
Definition TSystem.h:582
@ kS_IXUSR
Definition TSystem.h:112
@ kS_IFREG
Definition TSystem.h:101
#define gPad
#define gVirtualX
Definition TVirtualX.h:377
#define snprintf
Definition civetweb.c:1579
virtual Longptr_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=nullptr)
Process a single command line, either a C++ statement or an interpreter command starting with a "....
TApplication * GetAppRemote() const
virtual const char * ApplicationName() const
Each class (see TClass) has a linked list of its base class(es).
Definition TBaseClass.h:33
TClass * GetClassPointer(Bool_t load=kTRUE)
Get pointer to the base class TClass.
ABC describing GUI independent browser implementation protocol.
Definition TBrowserImp.h:29
TBrowser * fBrowser
TBrowser associated with this implementation.
Definition TBrowserImp.h:32
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
void SetDrawOption(Option_t *option="") override
Set drawing option for object.
Definition TBrowser.h:106
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:84
static TClass * Class()
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Definition TClass.cxx:3694
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition TClass.cxx:6043
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition TClass.cxx:2994
This class provides an interface to context sensitive popup menus.
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=nullptr, TVirtualPad *p=nullptr)
Popup context menu at given location in canvas c and pad p for selected object.
Helper class used to change the cursor in a method and restore the original one when going out of the...
TCursorSwitcher(TGWindow *w1, TGWindow *w2)
Describe directory structure in memory.
Definition TDirectory.h:45
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition TEnv.cxx:511
virtual void SetToolTipText(const char *text, Long_t delayms=400)
Set tool tip text associated with this button.
Definition TGButton.cxx:439
virtual void SetStyle(UInt_t newstyle)
Set the button style (modern or classic).
Definition TGButton.cxx:265
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition TGButton.cxx:229
A frame containing two scrollbars (a horizontal and a vertical) and a viewport.
Definition TGCanvas.h:192
const TGPicture * GetPicture(const char *name)
Get picture from the picture pool.
Definition TGClient.cxx:288
void FreePicture(const TGPicture *pic)
Free picture resource.
Definition TGClient.cxx:316
A combobox (also known as a drop down listbox) allows the selection of one item out of a list of item...
Definition TGComboBox.h:47
virtual TGLBEntry * GetSelectedEntry() const
Definition TGComboBox.h:115
virtual TGTextEntry * GetTextEntry() const
Definition TGComboBox.h:111
virtual void AddEntry(TGString *s, Int_t id)
Definition TGComboBox.h:86
virtual TGListBox * GetListBox() const
Definition TGComboBox.h:110
The base class for composite widgets (menu bars, list boxes, etc.).
Definition TGFrame.h:289
TGDimension GetDefaultSize() const override
std::cout << fWidth << "x" << fHeight << std::endl;
Definition TGFrame.h:318
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=nullptr)
Add frame to the composite frame using the specified layout hints.
Definition TGFrame.cxx:1110
virtual TList * GetList() const
Definition TGFrame.h:312
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition TGFrame.cxx:960
void MapSubwindows() override
Map all sub windows that are part of the composite frame.
Definition TGFrame.cxx:1157
void SetCleanup(Int_t mode=kLocalCleanup) override
Turn on automatic cleanup of child frames in dtor.
Definition TGFrame.cxx:1065
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition TGCanvas.cxx:888
TGListTreeItem * fRootDir
Root (list tree) directory.
Int_t fGroupSize
total number of items when icon box switched to "global view" mode
Bool_t CheckFiltered(TGListTreeItem *item, Bool_t but=kFALSE)
Check if there is a filter active on the children of the list tree item.
TString DirName(TGListTreeItem *item)
returns the directory path
TSystemFile * fFile
Actual (selected) system file.
TGHorizontalFrame * fBotFrame
Bottom horizontal frame.
void GetObjPicture(const TGPicture **pic, TObject *obj)
Retrieve icons associated with class "name".
TGListTree * fListTree
Main list tree.
void AddKey(TGListTreeItem *itm, TObject *obj, const char *name=nullptr)
display content of ROOT file
TGFileBrowser(const TGWindow *p, TBrowser *b=nullptr, UInt_t w=200, UInt_t h=400)
TGFileBrowser constructor.
void CreateBrowser()
Create the actual file browser.
Bool_t fShowHidden
kTRUE to display hidden files
Bool_t fDblClick
kTRUE if user double-clicked on a list tree item
TGListTreeItem * fCurrentDir
Current (list tree) directory.
Bool_t CheckSorted(TGListTreeItem *item, Bool_t but=kFALSE)
Check if the list tree item children are alphabetically sorted.
void Clicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y)
Process mouse clicks in TGListTree.
void DoubleClicked(TGListTreeItem *item, Int_t btn)
Process double clicks in TGListTree.
void BrowseObj(TObject *obj) override
Browse object.
void ApplyFilter(Int_t id)
Apply filter selected in combo box to the file tree view.
TGPictureButton * fFilterButton
"Filter" button
void PadModified()
Slot used to switch to the tab containing the current pad/canvas (gPad) used e.g.
void GotoDir(const char *path)
Go to the directory "path" and open all the parent list tree items.
void RecursiveRemove(TObject *obj) override
Recursively remove object.
void ToggleSort()
Toggle the sort mode and set the "sort button" state accordingly.
TGListTreeItem * fListLevel
Current list tree level.
void AddRemoteFile(TObject *obj)
Add remote file in list tree.
TString fFilterStr
Filter expression string.
TRegexp * fFilter
Regular expression used to filter files.
void GetFilePictures(const TGPicture **pic, Int_t file_type, Bool_t is_link, const char *name)
Determine the file picture for the given file type.
TSystemDirectory * fDir
Actual (selected) system directory.
Long_t fCnt
Counters for keys inside a Root file.
void Add(TObject *obj, const char *name=nullptr, Int_t check=-1) override
Add items to the browser.
sLTI_t fSortedItems
List of sorted list-tree items.
~TGFileBrowser() override
Destructor.
const TGPicture * fCachedPic
Cached picture.
void RequestFilter()
Open a dialog box asking for a string to be used as filter (regexp), and add an entry in the map of f...
TGComboBox * fFileType
File type combobox.
TGCanvas * fCanvas
Canvas for the list tree.
TContextMenu * fContextMenu
pointer to context menu
TRootBrowser * fNewBrowser
Pointer back to the Browser.
char * FormatFileInfo(const char *fname, Long64_t size, Long_t modtime)
Format file information to be displayed in the tooltip.
TString FullPathName(TGListTreeItem *item)
returns an absolute path
TGPictureButton * fSortButton
"Sort" button
TGComboBox * fDrawOption
Draw options combobox.
void Checked(TObject *obj, Bool_t check)
Emits signal when double clicking on icon.
const TGPicture * fFileIcon
System files icon.
Option_t * GetDrawOption() const override
returns drawing option
TGPictureButton * fRefreshButton
"Refresh" button
void CheckRemote(TGListTreeItem *item)
Check if the current list tree item points to a remote object.
void Update()
Update content of the list tree.
const TGPicture * fRootIcon
Root files icon.
void Selected(char *)
A ROOT File has been selected in TGFileBrowser.
void Show() override
void AddFSDirectory(const char *entry, const char *path=nullptr, Option_t *opt="")
Add file system directory in the list tree.
void Refresh(Bool_t force=kFALSE) override
Refresh content of the list tree.
TString fCachedPicName
Cached picture name.
mFiltered_t fFilteredItems
List of filtered list-tree items.
Long_t XXExecuteDefaultAction(TObject *obj)
Execute default action for selected object (action is specified in the $HOME/.root....
void Chdir(TGListTreeItem *item)
Make object associated with item the current directory.
sLTI_t::iterator sLTI_i
TGHorizontalFrame * fTopFrame
Top horizontal frame.
void Resize(UInt_t w=0, UInt_t h=0) override
Resize the frame.
Definition TGFrame.cxx:598
void MapWindow() override
map window
Definition TGFrame.h:206
A composite frame that layout their children in horizontal way.
Definition TGFrame.h:387
Input Dialog Widget.
This class handles GUI labels.
Definition TGLabel.h:24
This class describes layout hints used by the layout classes.
Definition TGLayout.h:50
A listbox is a box, possibly with scrollbar, containing entries.
Definition TGListBox.h:221
TGListTreeItem * GetFirstChild() const
Definition TGListTree.h:61
virtual const char * GetText() const =0
TGListTreeItem * GetParent() const
Definition TGListTree.h:60
virtual void SetTipText(const char *)
Definition TGListTree.h:79
void SetDNDSource(Bool_t onoff)
Definition TGListTree.h:110
virtual void * GetUserData() const =0
A list tree is a widget that can contain a number of items arranged in a tree structure.
Definition TGListTree.h:197
TGListTreeItem * FindItemByObj(TGListTreeItem *item, void *ptr)
Find item with fUserData == ptr.
void ClearHighlighted()
Un highlight items.
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
Int_t DeleteChildren(TGListTreeItem *item)
Delete children of item from list.
void CheckItem(TGListTreeItem *item, Bool_t check=kTRUE)
Set check button state for the node 'item'.
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
TGListTreeItem * GetSelected() const
Definition TGListTree.h:392
Int_t RecursiveDeleteItem(TGListTreeItem *item, void *userData)
Delete item with fUserData == ptr.
Int_t DeleteItem(TGListTreeItem *item)
Delete item from list tree.
void SetSelected(TGListTreeItem *item)
Definition TGListTree.h:363
TGListTreeItem * GetFirstItem() const
Definition TGListTree.h:391
TGListTreeItem * FindChildByName(TGListTreeItem *item, const char *name)
Find child of item by name.
Int_t SortChildren(TGListTreeItem *item)
Sort children of item.
void AdjustPosition(TGListTreeItem *item)
Move content to position of item.
void HighlightItem(TGListTreeItem *item)
Highlight item.
TGListTreeItem * FindChildByData(TGListTreeItem *item, void *userData)
Find child of item by userData.
void SetToolTipItem(TGListTreeItem *item, const char *string)
Set tooltip text for this item.
void GetPathnameFromItem(TGListTreeItem *item, char *path, Int_t depth=0)
Get pathname from item.
Defines top level windows that interact with the system Window Manager.
Definition TGFrame.h:399
TGClient * fClient
Connection to display server.
Definition TGObject.h:25
Handle_t GetId() const
Definition TGObject.h:41
Yield an action as soon as it is clicked.
Definition TGButton.h:228
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition TGPicture.h:25
A tab widget contains a set of composite frames each with a little tab with a name (like a set of fol...
Definition TGTab.h:46
TGTabElement * GetTabTab(Int_t tabIndex) const
Return the tab element of tab with index tabIndex.
Definition TGTab.cxx:660
A TGTextEntry is a one line text input widget.
Definition TGTextEntry.h:24
Text string listbox entries.
Definition TGListBox.h:48
ROOT GUI Window base class.
Definition TGWindow.h:23
const char * GetName() const override
Return unique name, used in SavePrimitive methods.
Definition TGWindow.cxx:334
virtual void SetModel(TVirtualPad *pad, TObject *obj, Int_t event, Bool_t force=kFALSE)
Activate object editors according to the selected object.
An abstract interface to image processing library.
Definition TImage.h:29
static TImage * Open(const char *file, EImageFileTypes type=kUnknown)
Open a specified image file.
Definition TImage.cxx:117
@ kXpm
Definition TImage.h:37
static TImage * Create()
Create an image.
Definition TImage.cxx:34
Utility class for browsing TMapFile objects.
Definition TKeyMapFile.h:20
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition TKey.h:28
A doubly linked list.
Definition TList.h:38
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:49
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:50
An array of TObjects.
Definition TObjArray.h:31
Collectable string class.
Definition TObjString.h:28
Mother of all ROOT objects.
Definition TObject.h:42
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
Definition TObject.cxx:579
virtual const char * GetName() const
Returns name of object.
Definition TObject.cxx:462
virtual void Browse(TBrowser *b)
Browse object. May be overridden for another default action.
Definition TObject.cxx:218
virtual const char * GetIconName() const
Returns mime type name of object.
Definition TObject.cxx:472
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
Definition TObject.cxx:319
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Returns string containing info about the object at position (px,py).
Definition TObject.cxx:491
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:888
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition TObject.cxx:549
virtual const char * GetTitle() const
Returns title of object.
Definition TObject.cxx:507
virtual TClass * IsA() const
Definition TObject.h:248
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:293
Bool_t Connect(const char *signal, const char *receiver_class, void *receiver, const char *slot)
Non-static method is used to connect from the signal of this object to the receiver slot.
Definition TQObject.cxx:865
Bool_t Disconnect(const char *signal=nullptr, void *receiver=nullptr, const char *slot=nullptr)
Disconnects signal of this object from slot of receiver.
Regular expression class.
Definition TRegexp.h:31
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session.
This class creates a ROOT object browser, constituted by three main tabs.
void SetActBrowser(TBrowserImp *b)
virtual void Checked(TObject *obj, Bool_t check)
Emits signal when double clicking on icon.
TGTab * GetTabRight() const
Basic string class.
Definition TString.h:138
Ssiz_t Length() const
Definition TString.h:427
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition TString.cxx:2324
const char * Data() const
Definition TString.h:386
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:715
TString & Prepend(const char *cs)
Definition TString.h:684
TString & Append(const char *cs)
Definition TString.h:583
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2459
Describes an Operating System directory for the browser.
virtual TList * GetListOfFiles() const
Returns a TList of TSystemFile objects representing the contents of the directory.
A TSystemFile describes an operating system file.
Definition TSystemFile.h:29
virtual Bool_t IsDirectory(const char *dir=nullptr) const
Check if object is a directory.
virtual int GetFsInfo(const char *path, Long_t *id, Long_t *bsize, Long_t *blocks, Long_t *bfree)
Get info about a file system: fs type, block size, number of blocks, number of free blocks.
Definition TSystem.cxx:1487
virtual Bool_t ExpandPathName(TString &path)
Expand a pathname getting rid of special shell characters like ~.
Definition TSystem.cxx:1289
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition TSystem.cxx:655
int GetPathInfo(const char *path, Long_t *id, Long_t *size, Long_t *flags, Long_t *modtime)
Get info about a file: id, size, flags, modification time.
Definition TSystem.cxx:1413
virtual TList * GetVolumes(Option_t *) const
Definition TSystem.h:475
virtual const char * PrependPathName(const char *dir, TString &name)
Concatenate a directory and a file name.
Definition TSystem.cxx:1096
virtual Bool_t AccessPathName(const char *path, EAccessMode mode=kFileExists)
Returns FALSE if one can access a file using the specified access mode.
Definition TSystem.cxx:1311
virtual Bool_t ChangeDirectory(const char *path)
Change directory.
Definition TSystem.cxx:876
virtual const char * UnixPathName(const char *unixpathname)
Convert from a local pathname to a Unix pathname.
Definition TSystem.cxx:1077
virtual void Sleep(UInt_t milliSec)
Sleep milliSec milli seconds.
Definition TSystem.cxx:439
virtual const char * WorkingDirectory()
Return working directory.
Definition TSystem.cxx:885
virtual TString GetDirName(const char *pathname)
Return the directory name in pathname.
Definition TSystem.cxx:1046
static void SingleShot(Int_t milliSec, const char *receiver_class, void *receiver, const char *method)
This static function calls a slot after a given time interval.
Definition TTimer.cxx:261
Abstract base class used by ROOT graphics editor.
static TVirtualPadEditor * GetPadEditor(Bool_t load=kTRUE)
Returns the pad editor dialog. Static method.
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17
R__ALWAYS_INLINE bool HasBeenDeleted(const TObject *obj)
Check if the TObject's memory has been deleted.
Definition TObject.h:409
Int_t fMode
Definition TSystem.h:135