Logo ROOT   6.12/07
Reference Guide
TRootBrowserLite.cxx
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 27/02/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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 //////////////////////////////////////////////////////////////////////////
13 // //
14 // TRootBrowserLite //
15 // //
16 // This class creates a ROOT object browser (looking like Windows //
17 // Explorer). The widgets used are the new native ROOT GUI widgets. //
18 // //
19 //////////////////////////////////////////////////////////////////////////
20 
21 #include "RConfigure.h"
22 
23 #include "TRootBrowserLite.h"
24 #include "TRootApplication.h"
25 #include "TGCanvas.h"
26 #include "TGMenu.h"
27 #include "TGFileDialog.h"
28 #include "TGStatusBar.h"
29 #include "TGFSComboBox.h"
30 #include "TGLabel.h"
31 #include "TGButton.h"
32 #include "TGListView.h"
33 #include "TGListTree.h"
34 #include "TGToolBar.h"
35 #include "TGSplitter.h"
36 #include "TG3DLine.h"
37 #include "TGFSContainer.h"
38 #include "TGMimeTypes.h"
39 #include "TRootHelpDialog.h"
40 #include "TGTextEntry.h"
41 #include "TGTextEdit.h"
42 #include "TGTextEditDialogs.h"
43 
44 #include "TROOT.h"
45 #include "TEnv.h"
46 #include "TBrowser.h"
47 #include "TApplication.h"
48 #include "TFile.h"
49 #include "TKey.h"
50 #include "TKeyMapFile.h"
51 #include "TClass.h"
52 #include "TContextMenu.h"
53 #include "TSystem.h"
54 #include "TSystemDirectory.h"
55 #include "TSystemFile.h"
56 #include "TRemoteObject.h"
57 #include "TInterpreter.h"
58 #include "TGuiBuilder.h"
59 #include "TImage.h"
60 #include "TVirtualPad.h"
61 #include "KeySymbols.h"
62 #include "THashTable.h"
63 #include "TMethod.h"
64 #include "TColor.h"
65 #include "TObjString.h"
66 #include "TGDNDManager.h"
67 #include "TBufferFile.h"
68 #include "TFolder.h"
69 #include "Getline.h"
70 
71 #include "HelpText.h"
72 
73 #ifdef WIN32
74 #include "TWin32SplashThread.h"
75 #endif
76 
77 // Browser menu command ids
89 
103 
104  kViewArrangeByName, // Arrange submenu
110 
113 
116 
117  kOneLevelUp, // One level up toolbar button
118  kFSComboBox, // File system combobox in toolbar
119 
128 };
129 
130 
131 //----- Struct for default icons
132 
133 struct DefaultIcon_t {
134  const char *fPicnamePrefix;
135  const TGPicture *fIcon[2];
136 };
137 
138 #if 0
139 static DefaultIcon_t gDefaultIcon[] = {
140  { "folder", { 0, 0 } },
141  { "app", { 0, 0 } },
142  { "doc", { 0, 0 } },
143  { "slink", { 0, 0 } },
144  { "histo", { 0, 0 } },
145  { "object", { 0, 0 } }
146 };
147 #endif
148 
149 
150 //----- Toolbar stuff...
151 
153  { "tb_uplevel.xpm", "Up One Level", kFALSE, kOneLevelUp, 0 },
154  { "", "", kFALSE, -1, 0 },
155  { "tb_bigicons.xpm", "Large Icons", kTRUE, kViewLargeIcons, 0 },
156  { "tb_smicons.xpm", "Small Icons", kTRUE, kViewSmallIcons, 0 },
157  { "tb_list.xpm", "List", kTRUE, kViewList, 0 },
158  { "tb_details.xpm", "Details", kTRUE, kViewDetails, 0 },
159  { "", "", kFALSE, -1, 0 },
160  { "tb_back.xpm", "Back", kFALSE, kHistoryBack, 0 },
161  { "tb_forw.xpm", "Forward", kFALSE, kHistoryForw, 0 },
162  { "tb_refresh.xpm", "Refresh (F5)", kFALSE, kViewRefresh, 0 },
163  { "", "", kFALSE, -1, 0 },
164  { "tb_find.xpm", "Find (Ctrl-F)", kFALSE, kViewFind, 0 },
165  { "", "", kFALSE, -1, 0 },
166  { "macro_t.xpm", "Execute Macro", kFALSE, kViewExec, 0 },
167  { "interrupt.xpm", "Interrupt Macro",kFALSE, kViewInterrupt, 0 },
168  { "filesaveas.xpm", "Save Macro", kFALSE, kViewSave, 0 },
169  { 0, 0, kFALSE, 0, 0 }
170 };
171 
172 
173 //----- TGFileDialog file types
174 
175 static const char *gOpenTypes[] = { "ROOT files", "*.root",
176  "All files", "*",
177  0, 0 };
178 
179 ////////////////////////////////////////////////////////////////////////////////////
180 class TRootBrowserHistoryCursor : public TObject {
181 public:
182  TGListTreeItem *fItem;
183 
184  TRootBrowserHistoryCursor(TGListTreeItem *item) : fItem(item) {}
185  void Print(Option_t *) const { if (fItem) printf("%s\n", fItem->GetText()); }
186 };
187 
188 
189 ////////////////////////////////////////////////////////////////////////////////////
190 class TRootBrowserHistory : public TList {
191 public:
192  void RecursiveRemove(TObject *obj) {
193  TRootBrowserHistoryCursor *cur;
194  TIter next(this);
195 
196  while ((cur = (TRootBrowserHistoryCursor*)next())) {
197  if (cur->fItem->GetUserData() == obj) {
198  Remove(cur);
199  delete cur;
200  }
201  }
202  }
203 
204  void DeleteItem(TGListTreeItem *item) {
205  TRootBrowserHistoryCursor *cur;
206  TIter next(this);
207 
208  while ((cur = (TRootBrowserHistoryCursor*)next())) {
209  if (cur->fItem == item) {
210  Remove(cur);
211  delete cur;
212  }
213  }
214  }
215 };
216 
217 
218 ////////////////////////////////////////////////////////////////////////////////////
219 class TRootBrowserCursorSwitcher {
220 private:
221  TGWindow *fW1;
222  TGWindow *fW2;
223 public:
224  TRootBrowserCursorSwitcher(TGWindow *w1, TGWindow *w2) : fW1(w1), fW2(w2) {
225  if (w1) gVirtualX->SetCursor(w1->GetId(), gVirtualX->CreateCursor(kWatch));
226  if (w2) gVirtualX->SetCursor(w2->GetId(), gVirtualX->CreateCursor(kWatch));
227  }
228  ~TRootBrowserCursorSwitcher() {
229  if (fW1) gVirtualX->SetCursor(fW1->GetId(), gVirtualX->CreateCursor(kPointer));
230  if (fW2) gVirtualX->SetCursor(fW2->GetId(), gVirtualX->CreateCursor(kPointer));
231  }
232 };
233 
234 ////////////////////////////////////////////////////////////////////////////////////
235 class TIconBoxThumb : public TObject {
236 public:
237  TString fName;
238  const TGPicture *fSmall;
239  const TGPicture *fLarge;
240 
241  TIconBoxThumb(const char *name, const TGPicture *spic, const TGPicture *pic) {
242  fName = name;
243  fSmall = spic;
244  fLarge = pic;
245  }
246  ULong_t Hash() const { return fName.Hash(); }
247  const char *GetName() const { return fName.Data(); }
248 };
249 
250 
251 
252 //----- Special ROOT object item (this are items in the icon box, see
253 //----- TRootIconBox)
254 ////////////////////////////////////////////////////////////////////////////////////
255 class TRootObjItem : public TGFileItem {
256 public:
257  TRootObjItem(const TGWindow *p, const TGPicture *bpic,
258  const TGPicture *spic, TGString *name,
259  TObject *obj, TClass *cl, EListViewMode viewMode = kLVSmallIcons);
260 
261  virtual TDNDData *GetDNDData(Atom_t) {
262  TObject *object = 0;
263  if (fObj->IsA() == TKey::Class())
264  object = ((TKey *)fObj)->ReadObj();
265  else
266  object = fObj;
267  if (object) {
268  if (!fBuf) fBuf = new TBufferFile(TBuffer::kWrite);
269  fBuf->WriteObject(object);
270  fDNDData.fData = fBuf->Buffer();
271  fDNDData.fDataLength = fBuf->Length();
272  }
273  fDNDData.fDataType = gVirtualX->InternAtom("application/root", kFALSE);
274  return &fDNDData;
275  }
276 
277  virtual Bool_t HandleDNDFinished() {
278  if (GetParent())
279  return ((TGFrame *)GetParent())->HandleDNDFinished();
280  return kFALSE;
281  }
282 
283 protected:
284  TObject *fObj;
285  TDNDData fDNDData;
286 };
287 
288 ////////////////////////////////////////////////////////////////////////////////
289 /// Create an icon box item.
290 
291 TRootObjItem::TRootObjItem(const TGWindow *p, const TGPicture *bpic,
292  const TGPicture *spic, TGString *name,
293  TObject *obj, TClass *, EListViewMode viewMode) :
294  TGFileItem(p, bpic, 0, spic, 0, name, 0, 0, 0, 0, 0, viewMode)
295 {
296  fObj = obj;
297  fDNDData.fData = 0;
298  fDNDData.fDataLength = 0;
299 
300  if (fSubnames) {
301  for (Int_t i = 0; fSubnames[i] != 0; ++i) delete fSubnames[i];
302  }
303  delete [] fSubnames;
304  fSubnames = new TGString* [2];
305 
306  fSubnames[0] = new TGString(obj->GetTitle());
307 
308  fSubnames[1] = 0;
309 
310  if (obj->IsA()->HasDefaultConstructor()) {
311  SetDNDSource(kTRUE);
312  }
313  if ((obj->IsA() == TFolder::Class()) ||
314  (obj->IsA() == TClass::Class())) {
315  SetDNDSource(kFALSE);
316  }
317 
318  int i;
319  for (i = 0; fSubnames[i] != 0; ++i)
320  ;
321  fCtw = new int[i];
322  for (i = 0; fSubnames[i] != 0; ++i)
323  fCtw[i] = gVirtualX->TextWidth(fFontStruct, fSubnames[i]->GetString(),
324  fSubnames[i]->GetLength());
325 }
326 
327 class TRootIconBox;
328 ////////////////////////////////////////////////////////////////////////////////////
329 class TRootIconList : public TList {
330 
331 private:
332  TRootIconBox *fIconBox; // iconbox to which list belongs
333  const TGPicture *fPic; // list view icon
334 
335 public:
336  TRootIconList(TRootIconBox* box = 0);
337  virtual ~TRootIconList();
338  void UpdateName();
339  const char *GetTitle() const { return "ListView Container"; }
340  Bool_t IsFolder() const { return kFALSE; }
341  void Browse(TBrowser *b);
342  const TGPicture *GetPicture() const { return fPic; }
343 };
344 
345 ////////////////////////////////////////////////////////////////////////////////
346 /// constructor
347 
348 TRootIconList::TRootIconList(TRootIconBox* box)
349 {
350  fPic = gClient->GetPicture("listview.xpm");
351  fIconBox = box;
352  fName = "empty";
353 }
354 
355 ////////////////////////////////////////////////////////////////////////////////
356 /// destructor
357 
358 TRootIconList::~TRootIconList()
359 {
360  gClient->FreePicture(fPic);
361 }
362 
363 ////////////////////////////////////////////////////////////////////////////////
364 /// composite name
365 
366 void TRootIconList::UpdateName()
367 {
368  if (!First()) return;
369 
370  if (fSize==1) {
371  fName = First()->GetName();
372  return;
373  }
374 
375  fName = First()->GetName();
376  fName += "-";
377  fName += Last()->GetName();
378 }
379 
380 //----- Special ROOT object container (this is the icon box on the
381 //----- right side of the browser)
382 ////////////////////////////////////////////////////////////////////////////////////
383 class TRootIconBox : public TGFileContainer {
384 friend class TRootIconList;
385 friend class TRootBrowserLite;
386 
387 private:
388  Bool_t fCheckHeaders; // if true check headers
389  TRootIconList *fCurrentList; //
390  TRootObjItem *fCurrentItem; //
391  Bool_t fGrouped; //
392  TString fCachedPicName; //
393  TList *fGarbage; // garbage for TRootIconList's
394  Int_t fGroupSize; // the total number of items when icon box switched to "global view" mode
395  TGString *fCurrentName; //
396  const TGPicture *fLargeCachedPic; //
397  const TGPicture *fSmallCachedPic; //
398  Bool_t fWasGrouped;
399  TObject *fActiveObject; //
400  Bool_t fIsEmpty;
401  THashTable *fThumbnails; // hash table with thumbnailed pictures
402  Bool_t fAutoThumbnail; //
404 
405  void *FindItem(const TString& name,
406  Bool_t direction = kTRUE,
407  Bool_t caseSensitive = kTRUE,
408  Bool_t beginWith = kFALSE);
409  void RemoveGarbage();
410 
411 public:
413  UInt_t options = kSunkenFrame,
415 
416  virtual ~TRootIconBox();
417 
418  void AddObjItem(const char *name, TObject *obj, TClass *cl);
419  void GetObjPictures(const TGPicture **pic, const TGPicture **spic,
420  TObject *obj, const char *name);
421  void SetObjHeaders();
422  void Refresh();
423  void RemoveAll();
424  void SetGroupSize(Int_t siz) { fGroupSize = siz; }
425  Int_t GetGroupSize() const { return fGroupSize; }
426  TGFrameElement *FindFrame(Int_t x, Int_t y, Bool_t exclude=kTRUE) { return TGContainer::FindFrame(x,y,exclude); }
427  Bool_t WasGrouped() const { return fWasGrouped; }
428 };
429 
430 ////////////////////////////////////////////////////////////////////////////////
431 /// Create iconbox containing ROOT objects in browser.
432 
433 TRootIconBox::TRootIconBox(TRootBrowserLite *browser, TGListView *lv, UInt_t options,
434  ULong_t back) : TGFileContainer(lv, options, back)
435 {
436  fListView = lv;
437  fBrowser = browser;
438 
439  fCheckHeaders = kTRUE;
440  fTotal = 0;
441  fGarbage = new TList();
442  fCurrentList = 0;
443  fCurrentItem = 0;
444  fGrouped = kFALSE;
445  fGroupSize = 1000;
446  fCurrentName = 0;
447  fWasGrouped = kFALSE;
448  fActiveObject = 0;
449  fIsEmpty = kTRUE;
450  fLargeCachedPic = 0;
451  fSmallCachedPic = 0;
452 
453  // Don't use timer HERE (timer is set in TBrowser).
454  StopRefreshTimer();
455  fRefresh = 0;
456  fThumbnails = new THashTable(50);
457  fAutoThumbnail = kTRUE;
458 }
459 
460 ////////////////////////////////////////////////////////////////////////////////
461 /// destructor
462 
463 TRootIconBox::~TRootIconBox()
464 {
465  RemoveAll();
466  RemoveGarbage();
467  delete fGarbage;
468  delete fThumbnails;
469 }
470 
471 ////////////////////////////////////////////////////////////////////////////////
472 /// Retrieve icons associated with class "name". Association is made
473 /// via the user's ~/.root.mimes file or via $ROOTSYS/etc/root.mimes.
474 
475 void TRootIconBox::GetObjPictures(const TGPicture **pic, const TGPicture **spic,
476  TObject *obj, const char *name)
477 {
478  static TImage *im = 0;
479  if (!im) {
480  im = TImage::Create();
481  }
482 
483  TString xpm_magic(name, 3);
484  Bool_t xpm = xpm_magic == "/* ";
485  const char *iconname = xpm ? obj->GetName() : name;
486 
487  if (obj->IsA()->InheritsFrom("TGeoVolume")) {
488  iconname = obj->GetIconName() ? obj->GetIconName() : obj->IsA()->GetName();
489  }
490 
491  if (fCachedPicName == iconname) {
492  *pic = fLargeCachedPic;
493  *spic = fSmallCachedPic;
494  return;
495  }
496 
497  *pic = fClient->GetMimeTypeList()->GetIcon(iconname, kFALSE);
498 
499  if (!(*pic) && xpm) {
500  if (im && im->SetImageBuffer((char**)&name, TImage::kXpm)) {
501  *pic = fClient->GetPicturePool()->GetPicture(iconname, im->GetPixmap(),
502  im->GetMask());
503  im->Scale(im->GetWidth()/2, im->GetHeight()/2);
504  *spic = fClient->GetPicturePool()->GetPicture(iconname, im->GetPixmap(),
505  im->GetMask());
506  }
507 
508  fClient->GetMimeTypeList()->AddType("[thumbnail]", iconname, iconname, iconname, "->Browse()");
509  return;
510  }
511 
512  if (*pic == 0) {
513  if (obj->IsFolder()) {
514  *pic = fFolder_s;
515  } else {
516  *pic = fDoc_s;
517  }
518  }
519  fLargeCachedPic = *pic;
520 
521  *spic = fClient->GetMimeTypeList()->GetIcon(iconname, kTRUE);
522 
523  if (*spic == 0) {
524  if (obj->IsFolder())
525  *spic = fFolder_t;
526  else
527  *spic = fDoc_t;
528  }
529  fSmallCachedPic = *spic;
530  fCachedPicName = iconname;
531 }
532 
533 ////////////////////////////////////////////////////////////////////////////////
534 /// delete all TRootIconLists from garbage
535 
536 void TRootIconBox::RemoveGarbage()
537 {
538  TIter next(fGarbage);
539  TList *li;
540 
541  while ((li=(TList *)next())) {
542  li->Clear("nodelete");
543  }
544  fGarbage->Delete();
545 }
546 
547 ////////////////////////////////////////////////////////////////////////////////
548 /// Add object to iconbox. Class is used to get the associated icons
549 /// via the mime file (see GetObjPictures()).
550 
551 void TRootIconBox::AddObjItem(const char *name, TObject *obj, TClass *cl)
552 {
553  if (!cl) return;
554 
555  Bool_t isSystemFile = kFALSE;
556  TGFileItem *fi;
557  fWasGrouped = kFALSE;
558  const TGPicture *pic = 0;
559  const TGPicture *spic = 0;
560 
561  if (obj->InheritsFrom("TRemoteObject")) {
562  // check if the real remote object is a system file or directory
563  TRemoteObject *robj = (TRemoteObject *)obj;
564  if ((TString(robj->GetClassName()) == "TSystemFile") ||
565  (TString(robj->GetClassName()) == "TSystemDirectory"))
566  isSystemFile = kTRUE;
567  }
568 
569  if (isSystemFile || obj->IsA() == TSystemFile::Class() ||
570  obj->IsA() == TSystemDirectory::Class()) {
571  if (fCheckHeaders) {
572  if (strcmp(fListView->GetHeader(1), "Attributes")) {
574  TGTextButton** buttons = fListView->GetHeaderButtons();
575  if (buttons) {
576  buttons[0]->Connect("Clicked()", "TRootBrowserLite", fBrowser,
577  TString::Format("SetSortMode(=%d)", kViewArrangeByName));
578  buttons[1]->Connect("Clicked()", "TRootBrowserLite", fBrowser,
579  TString::Format("SetSortMode(=%d)", kViewArrangeByType));
580  buttons[2]->Connect("Clicked()", "TRootBrowserLite", fBrowser,
581  TString::Format("SetSortMode(=%d)", kViewArrangeBySize));
582  buttons[5]->Connect("Clicked()", "TRootBrowserLite", fBrowser,
583  TString::Format("SetSortMode(=%d)", kViewArrangeByDate));
584  }
585  }
586  fCheckHeaders = kFALSE;
587  }
588 
589  TIconBoxThumb *thumb = 0;
590  char *thumbname = gSystem->ConcatFileName(gSystem->WorkingDirectory(), name);
591  thumb = (TIconBoxThumb *)fThumbnails->FindObject(gSystem->IsAbsoluteFileName(name) ? name :
592  thumbname);
593  delete []thumbname;
594 
595  if (thumb) {
596  spic = thumb->fSmall;
597  pic = thumb->fLarge;
598  }
599 
600  if (obj->InheritsFrom("TRemoteObject"))
601  // special case for remote object
602  fi = AddRemoteFile(obj, spic, pic);
603  else
604  fi = AddFile(name, spic, pic);
605  if (fi) {
606  fi->SetUserData(obj);
607  if (obj->IsA() == TSystemFile::Class()) {
608  TString str;
609  TDNDData data;
610  str = TString::Format("file://%s/%s\r\n",
611  gSystem->UnixPathName(obj->GetTitle()),
612  obj->GetName());
613  data.fData = (void *)str.Data();
614  data.fDataLength = str.Length()+1;
615  data.fDataType = gVirtualX->InternAtom("text/uri-list", kFALSE);
616  fi->SetDNDData(&data);
617  fi->SetDNDSource(kTRUE);
618  }
619  }
620 
621  fIsEmpty = kFALSE;
622  return;
623  }
624 
625  if (!fCurrentList) {
626  fCurrentList = new TRootIconList(this);
627  fGarbage->Add(fCurrentList);
628  }
629 
630  fCurrentList->Add(obj);
631  fCurrentList->UpdateName();
632  fIsEmpty = kFALSE;
633 
634  TGFrameElement *el;
635  TIter next(fList);
636  while ((el = (TGFrameElement *) next())) {
637  TGLVEntry *f = (TGLVEntry *) el->fFrame;
638  if (f->GetUserData() == obj) {
639  return;
640  }
641  }
642 
643  if (fGrouped && fCurrentItem && (fCurrentList->GetSize()>1)) {
644  fCurrentName->SetString(fCurrentList->GetName());
645  }
646 
648 
649  if ((fCurrentList->GetSize() < fGroupSize) && !fGrouped) {
650  GetObjPictures(&pic, &spic, obj, obj->GetIconName() ?
651  obj->GetIconName() : cl->GetName());
652 
653  if (fCheckHeaders) {
654  if (strcmp(fListView->GetHeader(1), "Title")) {
655  SetObjHeaders();
656  }
657  fCheckHeaders = kFALSE;
658  }
659 
660  fi = new TRootObjItem(this, pic, spic, new TGString(name), obj, cl, view);
661 
662  fi->SetUserData(obj);
663  AddItem(fi);
664  return;
665  }
666 
667  if (fGrouped && (fCurrentList->GetSize()==1)) {
668  fCurrentName = new TGString(fCurrentList->GetName());
669  fCurrentItem = new TRootObjItem(this, fCurrentList->GetPicture(), fCurrentList->GetPicture(),
670  fCurrentName,fCurrentList, TList::Class(), view);
671  fCurrentItem->SetUserData(fCurrentList);
672  AddItem(fCurrentItem);
673  fTotal = fList->GetSize();
674  return;
675  }
676 
677  if ((fCurrentList->GetSize()==fGroupSize) && !fGrouped) {
678  fGrouped = kTRUE;
679 
680  // clear fList
681  TGFrameElement *el2;
682  TIter nextl(fList);
683 
684  while ((el2 = (TGFrameElement *) nextl())) {
685  el2->fFrame->DestroyWindow();
686  delete el2->fFrame;
687  fList->Remove(el2);
688  delete el2;
689  }
690 
691  fCurrentName = new TGString(fCurrentList->GetName());
692  fi = new TRootObjItem(this, fCurrentList->GetPicture(), fCurrentList->GetPicture(),
693  fCurrentName, fCurrentList, TList::Class(), view);
694  fi->SetUserData(fCurrentList);
695  AddItem(fi);
696 
697  fCurrentList = new TRootIconList(this);
698  fGarbage->Add(fCurrentList);
699  fTotal = 1;
700  return;
701  }
702 
703  if ((fCurrentList->GetSize()==fGroupSize) && fGrouped) {
704  fCurrentList = new TRootIconList(this);
705  fGarbage->Add(fCurrentList);
706  return;
707  }
708 }
709 
710 ////////////////////////////////////////////////////////////////////////////////
711 /// browse icon list
712 
713 void TRootIconList::Browse(TBrowser *)
714 {
715  if (!fIconBox) return;
716 
717  TObject *obj;
718  TGFileItem *fi;
719  const TGPicture *pic = 0;
720  const TGPicture *spic = 0;
721  TClass *cl;
722  TString name;
723  TKey *key = 0;
724 
725  fIconBox->RemoveAll();
726  TObjLink *lnk = FirstLink();
727 
728  while (lnk) {
729  obj = lnk->GetObject();
730  lnk = lnk->Next();
731 
732  if (obj->IsA() == TKey::Class()) {
733  cl = TClass::GetClass(((TKey *)obj)->GetClassName());
734  key = (TKey *)obj;
735  } else if (obj->IsA() == TKeyMapFile::Class()) {
736  cl = TClass::GetClass(((TKeyMapFile *)obj)->GetTitle());
737  } else if (obj->InheritsFrom("TRemoteObject")) {
738  // special case for remote object: get real object class
739  TRemoteObject *robj = (TRemoteObject *)obj;
740  cl = TClass::GetClass(robj->GetClassName());
741  } else {
742  cl = obj->IsA();
743  }
744 
745  name = obj->GetName();
746 
747  if (key && obj->IsA() == TKey::Class()) {
748  name += ";";
749  name += key->GetCycle();
750  }
751 
752  fIconBox->GetObjPictures(&pic, &spic, obj, obj->GetIconName() ?
753  obj->GetIconName() : cl->GetName());
754 
755  fi = new TRootObjItem((const TGWindow*)fIconBox, pic, spic, new TGString(name.Data()),
756  obj, cl, (EListViewMode)fIconBox->GetViewMode());
757  fi->SetUserData(obj);
758  fIconBox->AddItem(fi);
759  fIconBox->fTotal++;
760 
761  if (obj==fIconBox->fActiveObject) {
762  fIconBox->ActivateItem((TGFrameElement*)fIconBox->fList->Last());
763  }
764  }
765 
766  fIconBox->fGarbage->Remove(this);
767  fIconBox->RemoveGarbage();
768  fIconBox->fGarbage->Add(this); // delete this later
769 
770  fIconBox->Refresh();
771  fIconBox->AdjustPosition();
772 
773  fIconBox->fWasGrouped = kTRUE;
774 }
775 
776 ////////////////////////////////////////////////////////////////////////////////
777 /// Find a frame which assosiated object has a name containing a "name" string.
778 
779 void *TRootIconBox::FindItem(const TString& name, Bool_t direction,
780  Bool_t caseSensitive,Bool_t beginWith)
781 {
782  if (!fGrouped) {
783  return TGContainer::FindItem(name, direction, caseSensitive, beginWith);
784  }
785 
786  if (name.IsNull()) return 0;
787  int idx = kNPOS;
788 
789  TGFrameElement* el = 0;
790  TString str;
792 
793  fLastDir = direction;
794  fLastCase = caseSensitive;
795  fLastName = name;
796 
797  if (fLastActiveEl) {
798  el = fLastActiveEl;
799 
800  if (direction) {
801  el = (TGFrameElement *)fList->After(el);
802  } else {
803  el = (TGFrameElement *)fList->Before(el);
804  }
805  } else {
806  if (direction) el = (TGFrameElement *)fList->First();
807  else el = (TGFrameElement *)fList->Last();
808  }
809 
810  TGLVEntry* lv = 0;
811  TObject* obj = 0;
812  TList* li = 0;
813 
814  while (el) {
815  lv = (TGLVEntry*)el->fFrame;
816  li = (TList*)lv->GetUserData();
817 
818  TIter next(li);
819 
820  while ((obj=next())) {
821  str = obj->GetName();
822  idx = str.Index(name,0,cmp);
823 
824  if (idx!=kNPOS) {
825  if (beginWith) {
826  if (idx==0) {
827  fActiveObject = obj;
828  return el;
829  }
830  } else {
831  fActiveObject = obj;
832  return el;
833  }
834  }
835  }
836  if (direction) {
837  el = (TGFrameElement *)fList->After(el);
838  } else {
839  el = (TGFrameElement *)fList->Before(el);
840  }
841  }
842  fActiveObject = 0;
843  return 0;
844 }
845 
846 ////////////////////////////////////////////////////////////////////////////////
847 /// Set list box headers used to display detailed object iformation.
848 /// Currently this is only "Name" and "Title".
849 
850 void TRootIconBox::SetObjHeaders()
851 {
852  fListView->SetHeaders(2);
853  fListView->SetHeader("Name", kTextLeft, kTextLeft, 0);
854  fListView->SetHeader("Title", kTextLeft, kTextLeft, 1);
855 }
856 
857 ////////////////////////////////////////////////////////////////////////////////
858 /// Sort icons, and send message to browser with number of objects
859 /// in box.
860 
861 void TRootIconBox::Refresh()
862 {
863  // This automatically calls layout
864  Sort(fSortType);
865 
866  // Make TRootBrowserLite display total objects in status bar
867  SendMessage(fMsgWindow, MK_MSG(kC_CONTAINER, kCT_SELCHANGED), fTotal, fSelected);
868 
869  MapSubwindows();
871 }
872 
873 ////////////////////////////////////////////////////////////////////////////////
874 /// Remove all items from icon box
875 
876 void TRootIconBox::RemoveAll()
877 {
878  if (fIsEmpty) return;
879 
880  fCheckHeaders = kTRUE;
882  fGrouped = kFALSE;
883  fCurrentItem = 0;
884  fCurrentList = 0;
885  fIsEmpty = kTRUE;
886 }
887 
888 
889 //_____________________________________________________________________________
890 //
891 // TRootBrowserLite
892 //
893 // ROOT object browser (looking like Windows Explorer).
894 //_____________________________________________________________________________
895 
897 
898 ////////////////////////////////////////////////////////////////////////////////
899 /// Create browser with a specified width and height.
900 
901 TRootBrowserLite::TRootBrowserLite(TBrowser *b, const char *name, UInt_t width, UInt_t height)
902  : TGMainFrame(gClient->GetDefaultRoot(), width, height), TBrowserImp(b)
903 {
904  CreateBrowser(name);
905 
906  Resize(width, height);
907  if (b) Show();
908 }
909 
910 ////////////////////////////////////////////////////////////////////////////////
911 /// Create browser with a specified width and height and at position x, y.
912 
914  UInt_t width, UInt_t height)
915  : TGMainFrame(gClient->GetDefaultRoot(), width, height), TBrowserImp(b)
916 {
917  CreateBrowser(name);
918 
919  MoveResize(x, y, width, height);
920  SetWMPosition(x, y);
921  if (b) Show();
922 }
923 
924 ////////////////////////////////////////////////////////////////////////////////
925 /// Browser destructor.
926 
928 {
929  if (fIconPic) gClient->FreePicture(fIconPic);
930 
931  delete fToolBarSep;
932 
933  fToolBar->Cleanup();
934  delete fToolBar;
935  delete fStatusBar;
936  delete fV1;
937  delete fV2;
938  delete fLbl1;
939  delete fLbl2;
940  delete fHf;
941  delete fTreeHdr;
942  delete fListHdr;
943  delete fIconBox;
944  delete fListView;
945  delete fLt;
946  delete fTreeView;
947 
948  delete fMenuBar;
949  delete fFileMenu;
950  delete fViewMenu;
951  delete fOptionMenu;
952  delete fHelpMenu;
953  delete fSortMenu;
954 
955  delete fMenuBarLayout;
956  delete fMenuBarItemLayout;
957  delete fMenuBarHelpLayout;
958  delete fBarLayout;
959 
960  delete fTextEdit;
961 
962  if (fWidgets) fWidgets->Delete();
963  delete fWidgets;
964 
965  fHistory->Delete();
966  delete fHistory;
967 }
968 
969 ////////////////////////////////////////////////////////////////////////////////
970 /// Create the actual browser.
971 
972 void TRootBrowserLite::CreateBrowser(const char *name)
973 {
974  fWidgets = new TList;
975  fHistory = new TRootBrowserHistory;
976  fHistoryCursor = 0;
978 
979  // Create menus
981  fFileMenu->AddEntry("&New Browser", kFileNewBrowser);
982  fFileMenu->AddEntry("New Browser &Lite", kFileNewBrowserLite);
983  fFileMenu->AddEntry("New Canvas", kFileNewCanvas);
984  fFileMenu->AddEntry("&Gui Builder", kFileNewBuilder);
985  fFileMenu->AddEntry("&Open...", kFileOpen);
987  fFileMenu->AddEntry("&Save", kFileSave);
988  fFileMenu->AddEntry("Save &As...", kFileSaveAs);
990  fFileMenu->AddEntry("&Print...", kFilePrint);
992  fFileMenu->AddEntry("&Close Browser", kFileCloseBrowser);
994  fFileMenu->AddEntry("&Quit ROOT", kFileQuit);
995 
996  //fFileMenu->DefaultEntry(kFileNewCanvas);
1000 
1002  fSortMenu->AddEntry("By &Name", kViewArrangeByName);
1003  fSortMenu->AddEntry("By &Type", kViewArrangeByType);
1004  fSortMenu->AddEntry("By &Size", kViewArrangeBySize);
1005  fSortMenu->AddEntry("By &Date", kViewArrangeByDate);
1007  fSortMenu->AddEntry("&Auto Arrange", kViewArrangeAuto);
1008 
1010 
1012  fViewMenu->AddEntry("&Toolbar", kViewToolBar);
1013  fViewMenu->AddEntry("Status &Bar", kViewStatusBar);
1015  fViewMenu->AddEntry("Lar&ge Icons", kViewLargeIcons);
1016  fViewMenu->AddEntry("S&mall Icons", kViewSmallIcons);
1017  fViewMenu->AddEntry("&List", kViewList);
1018  fViewMenu->AddEntry("&Details", kViewDetails);
1020  fViewMenu->AddEntry("Show &Hidden", kViewHidden);
1021  fViewMenu->AddPopup("Arrange &Icons", fSortMenu);
1022  fViewMenu->AddEntry("Lin&e up Icons", kViewLineUp);
1023  fViewMenu->AddEntry("&Group Icons", kViewGroupLV);
1024 
1026  fViewMenu->AddEntry("&Refresh (F5)", kViewRefresh);
1027 
1030 
1031  if (fBrowser) {
1032  if (gEnv->GetValue("Browser.ShowHidden", 0)) {
1035  } else {
1038  }
1039  }
1040 
1042  fOptionMenu->AddEntry("&Show Cycles", kOptionShowCycles);
1043  fOptionMenu->AddEntry("&AutoThumbnail", kOptionAutoThumbnail);
1044 
1046  fHelpMenu->AddEntry("&About ROOT...", kHelpAbout);
1048  fHelpMenu->AddEntry("Help On Browser...", kHelpOnBrowser);
1049  fHelpMenu->AddEntry("Help On Canvas...", kHelpOnCanvas);
1050  fHelpMenu->AddEntry("Help On Menus...", kHelpOnMenus);
1051  fHelpMenu->AddEntry("Help On Graphics Editor...", kHelpOnGraphicsEd);
1052  fHelpMenu->AddEntry("Help On Objects...", kHelpOnObjects);
1053  fHelpMenu->AddEntry("Help On PostScript...", kHelpOnPS);
1054  fHelpMenu->AddEntry("Help On Remote Session...", kHelpOnRemote);
1055 
1056  // This main frame will process the menu commands
1057  fFileMenu->Associate(this);
1058  fViewMenu->Associate(this);
1059  fSortMenu->Associate(this);
1060  fOptionMenu->Associate(this);
1061  fHelpMenu->Associate(this);
1062 
1063  // Create menubar layout hints
1067 
1068  // Create menubar
1069  fMenuBar = new TGMenuBar(this, 1, 1, kHorizontalFrame);
1074 
1076 
1077  // Create toolbar and separator
1078 
1079  fToolBarSep = new TGHorizontal3DLine(this);
1080  fToolBar = new TGToolBar(this, 60, 20, kHorizontalFrame);
1082 
1086  fFSComboBox->Associate(this);
1087 
1088  int spacing = 8;
1089 
1090  for (int i = 0; gToolBarData[i].fPixmap; i++) {
1091  if (strlen(gToolBarData[i].fPixmap) == 0) {
1092  spacing = 8;
1093  continue;
1094  }
1095  fToolBar->AddButton(this, &gToolBarData[i], spacing);
1096  spacing = 0;
1097  }
1098 
1099  fDrawOption = new TGComboBox(fToolBar, "");
1100  TGTextEntry *dropt_entry = fDrawOption->GetTextEntry();
1101  dropt_entry->SetToolTipText("Object Draw Option", 300);
1102  fDrawOption->Resize(80, 10);
1103  TGListBox *lb = fDrawOption->GetListBox();
1104  lb->Resize(lb->GetWidth(), 120);
1105  Int_t dropt = 1;
1106  fDrawOption->AddEntry("", dropt++);
1107  fDrawOption->AddEntry("same", dropt++);
1108  fDrawOption->AddEntry("box", dropt++);
1109  fDrawOption->AddEntry("lego", dropt++);
1110  fDrawOption->AddEntry("colz", dropt++);
1111  fDrawOption->AddEntry("alp", dropt++);
1112  fDrawOption->AddEntry("text", dropt++);
1113 
1115  fToolBar->AddFrame(new TGLabel(fToolBar,"Option"),
1116  new TGLayoutHints(kLHintsCenterY | kLHintsRight, 2,2,2,0));
1117 
1121 
1122  // Create panes
1123 
1124  fHf = new TGHorizontalFrame(this, 10, 10);
1125 
1126  fV1 = new TGVerticalFrame(fHf, 10, 10, kFixedWidth);
1127  fV2 = new TGVerticalFrame(fHf, 10, 10);
1128  fTreeHdr = new TGCompositeFrame(fV1, 10, 10, kSunkenFrame);
1129  fListHdr = new TGCompositeFrame(fV2, 10, 10, kSunkenFrame);
1130 
1131  fLbl1 = new TGLabel(fTreeHdr, "All Folders");
1132  fLbl2 = new TGLabel(fListHdr, "Contents of \".\"");
1133 
1134  TGLayoutHints *lo;
1135 
1136  lo = new TGLayoutHints(kLHintsLeft | kLHintsCenterY, 3, 0, 0, 0);
1137  fWidgets->Add(lo);
1138  fTreeHdr->AddFrame(fLbl1, lo);
1139  fListHdr->AddFrame(fLbl2, lo);
1140 
1141  lo = new TGLayoutHints(kLHintsTop | kLHintsExpandX, 0, 0, 1, 2);
1142  fWidgets->Add(lo);
1143  fV1->AddFrame(fTreeHdr, lo);
1144  fV2->AddFrame(fListHdr, lo);
1145 
1147 
1149  fWidgets->Add(lo);
1150  fHf->AddFrame(fV1, lo);
1151 
1153  splitter->SetFrame(fV1, kTRUE);
1155  fWidgets->Add(splitter);
1156  fWidgets->Add(lo);
1157  fHf->AddFrame(splitter, lo);
1158 
1160  fWidgets->Add(lo);
1161  fHf->AddFrame(fV2, lo);
1162 
1163  // Create tree
1164  fTreeView = new TGCanvas(fV1, 10, 10, kSunkenFrame | kDoubleBorder); // canvas
1165  fLt = new TGListTree(fTreeView, kHorizontalFrame,fgWhitePixel); // container
1166  fLt->Associate(this);
1167  fLt->SetAutoTips();
1168 
1172 
1173  // Create list view (icon box)
1174  fListView = new TGListView(fV2, 520, 250); // canvas
1175  // container
1177  fIconBox->Associate(this);
1178  fListView->SetIncrements(1, 19); // set vertical scroll one line height at a time
1180 
1181  TString str = gEnv->GetValue("Browser.AutoThumbnail", "yes");
1182  str.ToLower();
1183  fIconBox->fAutoThumbnail = (str == "yes") || atoi(str.Data());
1184  fIconBox->fAutoThumbnail ? fOptionMenu->CheckEntry(kOptionAutoThumbnail) :
1186 
1187  str = gEnv->GetValue("Browser.GroupView", "10000");
1188  Int_t igv = atoi(str.Data());
1189 
1190  if (igv>10) {
1192  fIconBox->SetGroupSize(igv);
1193  }
1194 
1195  // reuse lo from "create tree"
1197 
1198  AddFrame(fHf, lo);
1199 
1200  // Statusbar
1201 
1202  int parts[] = { 26, 74 };
1203  fStatusBar = new TGStatusBar(this, 60, 10);
1204  fStatusBar->SetParts(parts, 2);
1205  lo = new TGLayoutHints(kLHintsBottom | kLHintsExpandX, 0, 0, 3, 0);
1206  AddFrame(fStatusBar, lo);
1207 
1208  fTextEdit = 0;
1209 
1210  // Misc
1211  TString bname(name);
1212  bname.Prepend("Old ");
1213  SetWindowName(bname.Data());
1214  SetIconName(bname.Data());
1215  fIconPic = SetIconPixmap("rootdb_s.xpm");
1216  SetClassHints("ROOT", "Browser");
1217 
1218  SetWMSizeHints(600, 350, 10000, 10000, 2, 2);
1219 
1220  fListLevel = 0;
1221  fTreeLock = kFALSE;
1222 
1223  gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Escape), 0, kTRUE);
1224  gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_F5), 0, kTRUE);
1225  gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Right), kKeyMod1Mask, kTRUE);
1226  gVirtualX->GrabKey(fId, gVirtualX->KeysymToKeycode(kKey_Left), kKeyMod1Mask, kTRUE);
1227  ClearHistory();
1229 
1230  gVirtualX->SetDNDAware(fId, fDNDTypeList);
1231  MapSubwindows();
1232  SetDefaults();
1233  Resize();
1235 
1236  printf("\n You are using the old ROOT browser! A new version is available. To use it:\n");
1237  printf(" Select the \"New Browser\" entry from the \"File\" menu in the browser, or change\n");
1238  printf(" \"Browser.Name:\" from \"TRootBrowserLite\" to \"TRootBrowser\" in system.rootrc\n\n");
1239 
1240  Connect(fLt, "Checked(TObject*, Bool_t)", "TRootBrowserLite",
1241  this, "Checked(TObject *,Bool_t)");
1242 }
1243 
1244 ////////////////////////////////////////////////////////////////////////////////
1245 /// handle keys
1246 
1248 {
1249  if (event->fType == kGKeyPress) {
1250  UInt_t keysym;
1251  char input[10];
1252  gVirtualX->LookupString(event, input, sizeof(input), keysym);
1253 
1254  if (!event->fState && (EKeySym)keysym == kKey_F5) {
1255  Refresh(kTRUE);
1256  return kTRUE;
1257  }
1258  if (!event->fState && (EKeySym)keysym == kKey_Escape) {
1260  }
1261 
1262  if (event->fState & kKeyMod1Mask) {
1263  switch ((EKeySym)keysym & ~0x20) {
1264  case kKey_Right:
1265  HistoryForward();
1266  return kTRUE;
1267  case kKey_Left:
1268  HistoryBackward();
1269  return kTRUE;
1270  default:
1271  break;
1272  }
1273  }
1274  }
1275  return TGMainFrame::HandleKey(event);
1276 }
1277 
1278 ////////////////////////////////////////////////////////////////////////////////
1279 /// Add items to the browser. This function has to be called
1280 /// by the Browse() member function of objects when they are
1281 /// called by a browser. If check < 0 (default) no check box is drawn,
1282 /// if 0 then unchecked checkbox is added, if 1 checked checkbox is added.
1283 
1284 void TRootBrowserLite::Add(TObject *obj, const char *name, Int_t check)
1285 {
1286  if (!obj)
1287  return;
1288  if (obj->InheritsFrom("TObjectSpy"))
1289  return;
1290  if (!name) name = obj->GetName();
1291 
1292  AddToBox(obj, name);
1293  if (check > -1) {
1294  TGFrameElement *el;
1295  TIter next(fIconBox->fList);
1296  if (!obj->IsFolder()) {
1297  while ((el = (TGFrameElement *) next())) {
1298  TGLVEntry *f = (TGLVEntry *) el->fFrame;
1299  if (f->GetUserData() == obj) {
1300  f->SetCheckedEntry(check);
1301  }
1302  }
1303  }
1304  }
1305 
1306  // Don't show current dir and up dir links in the tree
1307  if (name[0] == '.' && ((name[1] == '\0') || (name[1] == '.' && name[2] == '\0')))
1308  return;
1309 
1310  if (obj->IsFolder())
1311  AddToTree(obj, name, check);
1312 }
1313 
1314 ////////////////////////////////////////////////////////////////////////////////
1315 /// Add a checkbox in the TGListTreeItem corresponding to obj
1316 /// and a checkmark on TGLVEntry if check = kTRUE.
1317 
1319 {
1320  if (obj) {
1321  TGListTreeItem *item = fLt->FindItemByObj(fLt->GetFirstItem(), obj);
1322  while (item) {
1323  fLt->SetCheckBox(item, kTRUE);
1324  fLt->CheckItem(item, check);
1325  item = fLt->FindItemByObj(item->GetNextSibling(), obj);
1326  }
1327  TGFrameElement *el;
1328  TIter next(fIconBox->fList);
1329  while ((el = (TGFrameElement *) next())) {
1330  TGLVEntry *f = (TGLVEntry *) el->fFrame;
1331  if (f->GetUserData() == obj) {
1332  f->SetCheckedEntry(check);
1333  }
1334  }
1335  }
1336 }
1337 
1338 ////////////////////////////////////////////////////////////////////////////////
1339 /// Check / uncheck the TGListTreeItem corresponding to this
1340 /// object and add a checkmark on TGLVEntry if check = kTRUE.
1341 
1343 {
1344  if (obj) {
1345  TGListTreeItem *item = fLt->FindItemByObj(fLt->GetFirstItem(), obj);
1346  while (item) {
1347  fLt->CheckItem(item, check);
1348  item = fLt->FindItemByObj(item->GetNextSibling(), obj);
1349  TGFrameElement *el;
1350  TIter next(fIconBox->fList);
1351  if (!obj->IsFolder()) {
1352  while ((el = (TGFrameElement *) next())) {
1353  TGLVEntry *f = (TGLVEntry *) el->fFrame;
1354  if (f->GetUserData() == obj) {
1355  f->SetCheckedEntry(check);
1356  }
1357  }
1358  }
1359  }
1360  }
1361 }
1362 
1363 ////////////////////////////////////////////////////////////////////////////////
1364 /// Remove checkbox from TGListTree and checkmark from TGListView.
1365 
1367 {
1368  if (obj) {
1369  TGListTreeItem *item = fLt->FindItemByObj(fLt->GetFirstItem(), obj);
1370  while (item) {
1371  fLt->SetCheckBox(item, kFALSE);
1372  item = fLt->FindItemByObj(item->GetNextSibling(), obj);
1373  TGFrameElement *el;
1374  TIter next(fIconBox->fList);
1375  if (!obj->IsFolder()) {
1376  while ((el = (TGFrameElement *) next())) {
1377  TGLVEntry *f = (TGLVEntry *) el->fFrame;
1378  if (f->GetUserData() == obj) {
1379  f->SetCheckedEntry(kFALSE);
1380  }
1381  }
1382  }
1383  }
1384  }
1385 }
1386 
1387 ////////////////////////////////////////////////////////////////////////////////
1388 /// Add items to the iconbox of the browser.
1389 
1390 void TRootBrowserLite::AddToBox(TObject *obj, const char *name)
1391 {
1392  if (obj) {
1393  if (!name) name = obj->GetName() ? obj->GetName() : "NoName";
1394  //const char *titlePtr = obj->GetTitle() ? obj->GetTitle() : " ";
1395 
1396  TClass *objClass = 0;
1397 
1398  if (obj->IsA() == TKey::Class())
1399  objClass = TClass::GetClass(((TKey *)obj)->GetClassName());
1400  else if (obj->IsA() == TKeyMapFile::Class())
1401  objClass = TClass::GetClass(((TKeyMapFile *)obj)->GetTitle());
1402  else if (obj->InheritsFrom("TRemoteObject")) {
1403  // special case for remote object: get real object class
1404  TRemoteObject *robj = (TRemoteObject *)obj;
1405  if (!strcmp(robj->GetClassName(), "TKey"))
1406  objClass = TClass::GetClass(robj->GetKeyClassName());
1407  else
1408  objClass = TClass::GetClass(robj->GetClassName());
1409  }
1410  else
1411  objClass = obj->IsA();
1412 
1413  fIconBox->AddObjItem(name, obj, objClass);
1414  }
1415 }
1416 
1417 ////////////////////////////////////////////////////////////////////////////////
1418 /// Add items to the current TGListTree of the browser.
1419 
1420 void TRootBrowserLite::AddToTree(TObject *obj, const char *name, Int_t check)
1421 {
1422  if (!obj)
1423  return;
1424  if (obj->InheritsFrom("TApplication"))
1425  fListLevel = 0;
1426  if (!fTreeLock) {
1427  if (!name) name = obj->GetName();
1428  if (name[0] == '.' && name[1] == '.')
1429  Info("AddToTree", "up one level %s", name);
1430  if(check > -1) {
1431  TGListTreeItem *item = fLt->AddItem(fListLevel, name, obj, 0, 0, kTRUE);
1432  if (item) fLt->CheckItem(item, (Bool_t)check);
1433  TString tip(obj->ClassName());
1434  if (obj->GetTitle()) {
1435  tip += " ";
1436  tip += obj->GetTitle();
1437  }
1438  fLt->SetToolTipItem(item, tip.Data());
1439  } else {
1440  // special case for remote object
1441  if (obj->InheritsFrom("TRemoteObject")) {
1442  // Nothing to do
1443  } else if (fListLevel) {
1444  // check also if one of its parents is a remote object
1445  TGListTreeItem *top = fListLevel;
1446  while (top->GetParent()) {
1447  TObject *tobj = (TObject *) top->GetUserData();
1448  if (tobj && (tobj->InheritsFrom("TRemoteObject") ||
1449  tobj->InheritsFrom("TApplicationRemote"))) {
1450  break;
1451  }
1452  top = top->GetParent();
1453  }
1454  }
1455  // add the object only if not already in the list
1456  if ((!fLt->FindChildByName(fListLevel, name)) &&
1457  (!fLt->FindChildByData(fListLevel, obj))) {
1458  TGListTreeItem *it = fLt->AddItem(fListLevel, name, obj);
1459  Long64_t bsize, fsize, objsize = 0;
1460  TString objinfo = obj->GetObjectInfo(1, 1);
1461  TString infos = obj->GetName();
1462  infos += "\n";
1463  infos += obj->GetTitle();
1464  if (!objinfo.IsNull() && !objinfo.BeginsWith("x=")) {
1465  objsize = objinfo.Atoll();
1466  if (objsize > 0) {
1467  infos += "\n";
1468  bsize = fsize = objsize;
1469  if (fsize > 1024) {
1470  fsize /= 1024;
1471  if (fsize > 1024) {
1472  // 3.7MB is more informative than just 3MB
1473  infos += TString::Format("Size: %lld.%lldM", fsize/1024,
1474  (fsize%1024)/103);
1475  } else {
1476  infos += TString::Format("Size: %lld.%lldK", bsize/1024,
1477  (bsize%1024)/103);
1478  }
1479  } else {
1480  infos += TString::Format("Size: %lld bytes", bsize);
1481  }
1482  }
1483  }
1484  if (it)
1485  it->SetTipText(infos.Data());
1486  }
1487  }
1488  }
1489 }
1490 
1491 ////////////////////////////////////////////////////////////////////////////////
1492 /// Browse object. This, in turn, will trigger the calling of
1493 /// TRootBrowserLite::Add() which will fill the IconBox and the tree.
1494 /// Emits signal "BrowseObj(TObject*)".
1495 
1497 {
1498  TGPosition pos = fIconBox->GetPagePosition();
1499  Emit("BrowseObj(TObject*)", (Long_t)obj);
1500 
1501  if (obj != gROOT) {
1502  if (!fLt->FindItemByObj(fLt->GetFirstItem(), obj)) {
1503  fListLevel = 0;
1504  Add(obj);
1507  if (obj->IsFolder())
1509  fLt->ClearViewPort();
1511  }
1512  }
1513 
1514  if (obj->IsFolder()) fIconBox->RemoveAll();
1515  obj->Browse(fBrowser);
1516  if ((fListLevel && obj->IsFolder()) || (!fListLevel && (obj == gROOT))) {
1517  fIconBox->Refresh();
1518  }
1519 
1520  if (fBrowser) {
1522  }
1523  UpdateDrawOption();
1524 
1525  fIconBox->SetHsbPosition(pos.fX);
1526  fIconBox->SetVsbPosition(pos.fY);
1527 }
1528 
1529 ////////////////////////////////////////////////////////////////////////////////
1530 /// add new draw option to the "history"
1531 
1533 {
1534  TString opt = GetDrawOption();
1535  TGListBox *lb = fDrawOption->GetListBox();
1536  TGLBContainer *lbc = (TGLBContainer *)lb->GetContainer();
1537 
1538  TIter next(lbc->GetList());
1539  TGFrameElement *el;
1540 
1541  while ((el = (TGFrameElement *)next())) {
1542  TGTextLBEntry *lbe = (TGTextLBEntry *)el->fFrame;
1543  if (lbe->GetText()->GetString() == opt) {
1544  return;
1545  }
1546  }
1547 
1548  Int_t nn = fDrawOption->GetNumberOfEntries() + 1;
1549  fDrawOption->AddEntry(opt.Data(), nn);
1550  fDrawOption->Select(nn);
1551 }
1552 
1553 ////////////////////////////////////////////////////////////////////////////////
1554 /// returns pointer to fIconBox object
1555 
1557 {
1558  return (TGFileContainer*)fIconBox;
1559 }
1560 
1561 ////////////////////////////////////////////////////////////////////////////////
1562 /// Really delete the browser and the this GUI.
1563 
1565 {
1566  fBrowser->SetBrowserImp(0);
1567  delete this;
1568 }
1569 
1570 ////////////////////////////////////////////////////////////////////////////////
1571 /// In case window is closed via WM we get here.
1572 
1574 {
1575  DeleteWindow();
1576 }
1577 
1578 ////////////////////////////////////////////////////////////////////////////////
1579 /// Display in statusbar total number of objects and number of
1580 /// selected objects in IconBox.
1581 
1583 {
1584  char tmp[64];
1585  const char *fmt;
1586 
1587  if (selected)
1588  fmt = "%d Object%s, %d selected.";
1589  else
1590  fmt = "%d Object%s.";
1591 
1592  snprintf(tmp, 64, fmt, total, (total == 1) ? "" : "s", selected);
1593  fStatusBar->SetText(tmp, 0);
1594 }
1595 
1596 ////////////////////////////////////////////////////////////////////////////////
1597 /// Display current directory in second label, fLbl2.
1598 
1600 {
1601  char *p, path[1024];
1602 
1603  fLt->GetPathnameFromItem(fListLevel, path, 12);
1604  p = path;
1605  while (*p && *(p+1) == '/') ++p;
1606  if (!p[0])
1607  fLbl2->SetText(new TGString("Contents of \".\""));
1608  else
1609  fLbl2->SetText(new TGString(Form("Contents of \"%s\"", p)));
1610  fListHdr->Layout();
1611 
1612  // Get full pathname for FS combobox (previously truncated to 12 levels deep)
1614  p = path;
1615  while (*p && *(p+1) == '/') ++p;
1616  fFSComboBox->Update(p);
1617 
1618  if (fListLevel) {
1619  // disable/enable up level navigation
1621  const char *dirname = gSystem->DirName(p);
1622  Bool_t disableUp;
1623 
1624  TObject *obj = (TObject*)fListLevel->GetUserData();
1625  disableUp = (strlen(dirname) == 1) && (*dirname == '/');
1626 
1627  // normal file directory
1628  if (disableUp && (obj) && (obj->IsA() == TSystemDirectory::Class())) {
1629  disableUp = strlen(p) == 1;
1630  }
1631  btn->SetState(disableUp ? kButtonDisabled : kButtonUp);
1633  }
1634 }
1635 
1636 ////////////////////////////////////////////////////////////////////////////////
1637 /// Execute default action for selected object (action is specified
1638 /// in the $HOME/.root.mimes or $ROOTSYS/etc/root.mimes file.
1639 /// Emits signal "ExecuteDefaultAction(TObject*)".
1640 
1642 {
1643  TRootBrowserCursorSwitcher cursorSwitcher(fIconBox, fLt);
1644  char action[512];
1646  TVirtualPad *wasp = gPad ? (TVirtualPad*)gPad->GetCanvas() : 0;
1647  TFile *wasf = gFile;
1648 
1649  // Special case for file system objects...
1650  if (obj->IsA() == TSystemFile::Class() ||
1651  obj->InheritsFrom("TRemoteObject")) {
1652  TString act;
1653  TString ext = obj->GetName();
1654 
1655  if (fClient->GetMimeTypeList()->GetAction(obj->GetName(), action)) {
1656  act = action;
1657  act.ReplaceAll("%s", obj->GetName());
1658  gInterpreter->SaveGlobalsContext();
1659 
1660  if (act[0] == '!') {
1661  act.Remove(0, 1);
1662  gSystem->Exec(act.Data());
1663  } else {
1664  // special case for remote object: remote process
1665  if (obj->InheritsFrom("TRemoteObject"))
1667  gApplication->ProcessLine(act.Data());
1668  }
1669  Emit("ExecuteDefaultAction(TObject*)", (Long_t)obj);
1670  }
1671 
1672  // special case for remote object: browse real object
1673  if (obj->InheritsFrom("TRemoteObject") && ext.EndsWith(".root")) {
1674  TRootBrowserCursorSwitcher cursorSwitcher2(fIconBox, fLt);
1676  gApplication->ProcessLine("((TApplicationServer *)gApplication)->BrowseFile(0);");
1677  Refresh();
1678  }
1679  ////////// new TFile was opened. Add it to the browser /////
1680  if (gFile && (wasf != gFile) && ext.EndsWith(".root")) {
1681  TGListTreeItem *itm = fLt->FindChildByData(0, gROOT->GetListOfFiles());
1682 
1683  if (itm) {
1684  fLt->ClearHighlighted();
1685  fListLevel = itm;
1688  itm = fLt->AddItem(fListLevel, gFile->GetName());
1689  itm->SetUserData(gFile);
1691  return;
1692  }
1693  }
1694 
1695  // only valid for local text files
1696  if (!obj->InheritsFrom("TRemoteObject"))
1697  BrowseTextFile(obj->GetName());
1698 
1699  /////////////// cache and change file's icon ///////////////////////
1700  TVirtualPad *nowp = gPad ? (TVirtualPad*)gPad->GetCanvas() : 0;
1701 
1702  if (fIconBox->fAutoThumbnail && nowp && (nowp != wasp)) {
1703  TSystemFile *sf = (TSystemFile*)obj;
1704  const TGPicture *pic, *spic;
1705 
1706  TIconBoxThumb *thumb = 0;
1707  TString path = gSystem->IsAbsoluteFileName(sf->GetName()) ? sf->GetName() :
1709 
1710  thumb = (TIconBoxThumb*)fIconBox->fThumbnails->FindObject(path);
1711 
1712  if (thumb) {
1713  spic = thumb->fSmall;
1714  pic = thumb->fLarge;
1715  } else {
1716  TImage *img = TImage::Create();
1717  nowp->Modified();
1718  nowp->Update();
1719  img->FromPad(nowp);
1720 
1721  if (!img->IsValid()) {
1722  return;
1723  }
1724 
1725  static const UInt_t sz = 72;
1726  UInt_t w = sz;
1727  UInt_t h = sz;
1728 
1729  if (img->GetWidth() > img->GetHeight()) {
1730  h = (img->GetHeight()*sz)/img->GetWidth();
1731  } else {
1732  w = (img->GetWidth()*sz)/img->GetHeight();
1733  }
1734 
1735  w = w < 54 ? 54 : w;
1736  h = h < 54 ? 54 : h;
1737 
1738  img->Scale(w, h);
1739  img->Merge(img, "tint"); // contrasting
1740  img->DrawBox(0, 0, w, h, "#ffff00", 1); // yellow frame
1741 
1742  pic = fClient->GetPicturePool()->GetPicture(path.Data(), img->GetPixmap(), 0);
1743  img->Scale(w/3, h/3);
1744  spic = fClient->GetPicturePool()->GetPicture(path.Data(), img->GetPixmap(), 0);
1745 
1746  thumb = new TIconBoxThumb(path.Data(), spic, pic);
1747  fIconBox->fThumbnails->Add(thumb);
1748  delete img;
1749  }
1750  }
1751  return;
1752  }
1753 
1754  // For other objects the default action is still hard coded in
1755  // their Browse() member function.
1756 }
1757 
1758 ////////////////////////////////////////////////////////////////////////////////
1759 /// Handle menu and other command generated by the user.
1760 
1762 {
1763  TRootHelpDialog *hd;
1764  TRootBrowserCursorSwitcher *cursorSwitcher = 0;
1765  TDirectory *tdir = 0;
1766  TString cmd;
1767 
1768  if (GET_SUBMSG(msg) != kCT_SELCHANGED) {
1769  cursorSwitcher = new TRootBrowserCursorSwitcher(fIconBox, fLt);
1770  }
1771 
1772  TObject *obj;
1773  TGListTreeItem *item = 0;
1774 
1775  gVirtualX->Update();
1776 
1777  switch (GET_MSG(msg)) {
1778 
1779  case kC_COMMAND:
1780 
1781  switch (GET_SUBMSG(msg)) {
1782 
1783  case kCM_BUTTON:
1784  // fallthrough
1785  case kCM_MENU:
1786 
1787  switch ((ERootBrowserCommands)parm1) {
1788  // Handle File menu items...
1789  case kFileNewBrowserLite:
1790  new TBrowser("Browser", "ROOT Object Browser");
1791  break;
1792  case kFileNewBrowser:
1793  gEnv->SetValue("Browser.Name", "TRootBrowser");
1794  new TBrowser();
1795  gEnv->SetValue("Browser.Name", "TRootBrowserLite");
1796  break;
1797  case kFileNewCanvas:
1798  gROOT->MakeDefCanvas();
1799  break;
1800  case kFileNewBuilder:
1802  break;
1803  case kFileOpen:
1804  {
1805  static TString dir(".");
1806  TGFileInfo fi;
1807  fi.fFileTypes = gOpenTypes;
1808  fi.fIniDir = StrDup(dir);
1809  new TGFileDialog(fClient->GetDefaultRoot(), this,
1810  kFDOpen,&fi);
1811  dir = fi.fIniDir;
1812  if (fi.fMultipleSelection && fi.fFileNamesList) {
1813  TObjString *el;
1814  TIter next(fi.fFileNamesList);
1815  while ((el = (TObjString *) next())) {
1816  new TFile(el->GetString(), "update");
1817  }
1818  }
1819  else if (fi.fFilename) {
1820  new TFile(fi.fFilename, "update");
1821  }
1822  }
1823  break;
1824  case kFileSave:
1825  case kFileSaveAs:
1826  break;
1827  case kFilePrint:
1828  break;
1829  case kFileCloseBrowser:
1830  SendCloseMessage();
1831  break;
1832  case kFileQuit:
1833  gApplication->Terminate(0);
1834  break;
1835 
1836  // Handle View menu items...
1837  case kViewToolBar:
1840  else
1841  ShowToolBar();
1842  break;
1843  case kViewStatusBar:
1846  else
1847  ShowStatusBar();
1848  break;
1849  case kViewLargeIcons:
1850  case kViewSmallIcons:
1851  case kViewList:
1852  case kViewDetails:
1853  SetViewMode((Int_t)parm1);
1854  break;
1855  case kViewHidden:
1859  } else {
1862  }
1863  Refresh(kTRUE);
1864  break;
1865  case kViewArrangeByName:
1866  case kViewArrangeByType:
1867  case kViewArrangeBySize:
1868  case kViewArrangeByDate:
1869  SetSortMode((Int_t)parm1);
1870  break;
1871  case kViewLineUp:
1872  break;
1873  case kViewRefresh:
1874  Refresh(kTRUE);
1875  break;
1876  case kViewGroupLV:
1879  TString gv = gEnv->GetValue("Browser.GroupView", "10000");
1880  Int_t igv = atoi(gv.Data());
1881 
1882  if (igv > 10) {
1883  fIconBox->SetGroupSize(igv);
1884  }
1885  } else {
1887  fIconBox->SetGroupSize(10000000); // very large value
1888  }
1889  break;
1890 
1891  // Handle Option menu items...
1892  case kOptionShowCycles:
1893  printf("Currently the browser always shows all cycles\n");
1894  break;
1895 
1896  case kOptionAutoThumbnail:
1899  fIconBox->fThumbnails->Delete();
1900  fIconBox->fAutoThumbnail = kFALSE;
1901  Refresh(kTRUE);
1902  } else {
1904  fIconBox->fAutoThumbnail = kTRUE;
1905  }
1906  break;
1907 
1908  // Handle toolbar button...
1909  case kOneLevelUp:
1910  {
1911  if (fBrowseTextFile) {
1912  HideTextEdit();
1913  break;
1914  }
1915  if (!fListLevel || !fListLevel->IsActive()) break;
1916 
1917  if (fListLevel && fIconBox->WasGrouped()) {
1918  if (fListLevel) {
1919  item = fListLevel->GetParent();
1920  if (item) fListLevel = item;
1921  obj = (TObject *) fListLevel->GetUserData();
1923  if (obj) BrowseObj(obj);
1924  }
1925 
1927  break;
1928  }
1929  if (fListLevel) item = fListLevel->GetParent();
1930 
1931 
1932  if (item) {
1933  fListLevel = item;
1934  obj = (TObject *)fListLevel->GetUserData();
1936  DisplayDirectory();
1937  if (obj) BrowseObj(obj);
1939  } else {
1940  obj = (TObject *)fListLevel->GetUserData();
1941  if (obj) ToSystemDirectory(gSystem->DirName(obj->GetTitle()));
1942  }
1943  break;
1944  }
1945 
1946  // toolbar buttons
1947  case kHistoryBack:
1948  HistoryBackward();
1949  break;
1950  case kHistoryForw:
1951  HistoryForward();
1952  break;
1953 
1954  case kViewFind:
1955  Search();
1956  break;
1957 
1958  // Handle Help menu items...
1959  case kHelpAbout:
1960  {
1961 #ifdef R__UNIX
1962  TString rootx = TROOT::GetBinDir() + "/root -a &";
1963  gSystem->Exec(rootx);
1964 #else
1965 #ifdef WIN32
1967 #else
1968  char str[32];
1969  sprintf(str, "About ROOT %s...", gROOT->GetVersion());
1970  hd = new TRootHelpDialog(this, str, 600, 400);
1971  hd->SetText(gHelpAbout);
1972  hd->Popup();
1973 #endif
1974 #endif
1975  }
1976  break;
1977  case kHelpOnCanvas:
1978  hd = new TRootHelpDialog(this, "Help on Canvas...", 600, 400);
1979  hd->SetText(gHelpCanvas);
1980  hd->Popup();
1981  break;
1982  case kHelpOnMenus:
1983  hd = new TRootHelpDialog(this, "Help on Menus...", 600, 400);
1985  hd->Popup();
1986  break;
1987  case kHelpOnGraphicsEd:
1988  hd = new TRootHelpDialog(this, "Help on Graphics Editor...", 600, 400);
1990  hd->Popup();
1991  break;
1992  case kHelpOnBrowser:
1993  hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
1995  hd->Popup();
1996  break;
1997  case kHelpOnObjects:
1998  hd = new TRootHelpDialog(this, "Help on Objects...", 600, 400);
1999  hd->SetText(gHelpObjects);
2000  hd->Popup();
2001  break;
2002  case kHelpOnPS:
2003  hd = new TRootHelpDialog(this, "Help on PostScript...", 600, 400);
2004  hd->SetText(gHelpPostscript);
2005  hd->Popup();
2006  break;
2007  case kHelpOnRemote:
2008  hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
2009  hd->SetText(gHelpRemote);
2010  hd->Popup();
2011  break;
2012  default:
2013  break;
2014  }
2015  break;
2016  case kCM_COMBOBOX:
2017  if (parm1 == kFSComboBox) {
2019  if (e) {
2020  const char *dirname = e->GetPath()->GetString();
2021  item = fLt->FindItemByPathname(dirname);
2022  if (item) {
2023  fListLevel = item;
2025  DisplayDirectory();
2027  } else {
2028  ToSystemDirectory(dirname);
2029  }
2030  }
2031  }
2032  break;
2033  default:
2034  break;
2035  }
2036 
2037  break;
2038 
2039  case kC_LISTTREE:
2040  switch (GET_SUBMSG(msg)) {
2041 
2042  case kCT_ITEMCLICK:
2043  // tell coverity that parm1 is a Long_t, and not an enum (even
2044  // if we compare it with an enum value) and the meaning of
2045  // parm1 depends on GET_MSG(msg) and GET_SUBMSG(msg)
2046  // coverity[mixed_enums]
2047  if (((EMouseButton)parm1 == kButton1) ||
2048  ((EMouseButton)parm1 == kButton3)) {
2049  HideTextEdit();
2050  TGListTreeItem *item2;
2051  TObject *obj2 = 0;
2052  if ((item2 = fLt->GetSelected()) != 0 ) {
2053  ListTreeHighlight(item2);
2054  fStatusBar->SetText("", 1); // clear
2055  }
2056  if (item2 && parm1 == kButton3) {
2057  Int_t x = (Int_t)(parm2 & 0xffff);
2058  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2059  obj2 = (TObject *) item2->GetUserData();
2060  if (obj2) {
2061  if (obj2->InheritsFrom("TTree")) {
2062  // if a tree not attached to any directory (e.g. in a TFolder)
2063  // then attach it to the current directory (gDirectory)
2064  cmd = TString::Format("((TTree *)0x%lx)->GetDirectory();",
2065  (ULong_t)obj2);
2066  tdir = (TDirectory *)gROOT->ProcessLine(cmd.Data());
2067  if (!tdir) {
2068  cmd = TString::Format("((TTree *)0x%lx)->SetDirectory(gDirectory);",
2069  (ULong_t)obj2);
2070  gROOT->ProcessLine(cmd.Data());
2071  }
2072  }
2073  fBrowser->GetContextMenu()->Popup(x, y, obj2, fBrowser);
2074  }
2075  }
2077  fListView->LayoutHeader(0);
2078  fListView->Layout();
2079  }
2080  break;
2081 
2082  case kCT_ITEMDBLCLICK:
2083  if (parm1 == kButton1) {
2084  if (fBrowseTextFile) {
2085  HideTextEdit();
2086  }
2087  if (fListLevel && fIconBox->WasGrouped()) {
2088  TObject *obj2;
2089  TGListTreeItem *item2;
2090 
2091  if (fListLevel) {
2092  item2 = fListLevel->GetParent();
2093  if (item2) fListLevel = item2;
2094 
2095  obj2 = (TObject *) fListLevel->GetUserData();
2097  if (obj2) {
2098  BrowseObj(obj2);
2099  }
2100  }
2101  break;
2102  }
2103  }
2104 
2105  default:
2106  break;
2107  }
2108  break;
2109 
2110  case kC_CONTAINER:
2111  switch (GET_SUBMSG(msg)) {
2112 
2113  case kCT_ITEMCLICK:
2114  if (fIconBox->NumSelected() == 1) {
2115  // display title of selected object
2116  TGFileItem *item2;
2117  void *p = 0;
2118  if ((item2 = (TGFileItem *)fIconBox->GetNextSelected(&p)) != 0) {
2119  TObject *obj2 = (TObject *)item2->GetUserData();
2120 
2121  TGListTreeItem *itm = 0;
2122  if (!fListLevel) itm = fLt->GetFirstItem();
2123  else itm = fListLevel->GetFirstChild();
2124  //Bool_t found = kFALSE;
2125 
2126  while (itm) {
2127  if (itm->GetUserData() == obj2) break;
2128  itm = itm->GetNextSibling();
2129  }
2130 
2131  if (itm) {
2132  if ((fListLevel && fListLevel->IsOpen()) || !fListLevel) {
2133  fLt->ClearHighlighted();
2134  fLt->HighlightItem(itm);
2136  }
2137  }
2138 
2139  if (obj2) fStatusBar->SetText(obj2->GetName(), 1);
2140  }
2141  }
2142  if (parm1 == kButton3) {
2143  // show context menu for selected object
2144  if (fIconBox->NumSelected() == 1) {
2145  void *p = 0;
2146  TGFileItem *item2;
2147  if ((item2 = (TGFileItem *) fIconBox->GetNextSelected(&p)) != 0) {
2148  Int_t x = (Int_t)(parm2 & 0xffff);
2149  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2150  TObject *obj2 = (TObject *)item2->GetUserData();
2151  if (obj2) {
2152  if (obj2->IsA() == TKey::Class()) {
2153  TKey *key = (TKey*)obj2;
2154  TClass *cl = TClass::GetClass(key->GetClassName());
2155  TString name = key->GetName();
2156  name += ";";
2157  name += key->GetCycle();
2158  //void *add = gROOT->FindObject((char *) name.Data());//key->GetName());
2159  void *add = gDirectory->FindObjectAny((char *) name.Data());
2160  if (cl->IsTObject()) {
2161  obj2 = (TObject*)add; // cl->DynamicCast(TObject::Class(),startadd);
2162  item2->SetUserData(obj2);
2163  } else {
2164  Error("ProcessMessage","do not support non TObject (like %s) yet",
2165  cl->GetName());
2166  break;
2167  }
2168  }
2169  if (obj2 && obj2->InheritsFrom("TTree")) {
2170  // if a tree not attached to any directory (e.g. in a TFolder)
2171  // then attach it to the current directory (gDirectory)
2172  cmd = TString::Format("((TTree *)0x%lx)->GetDirectory();",
2173  (ULong_t)obj2);
2174  tdir = (TDirectory *)gROOT->ProcessLine(cmd.Data());
2175  if (!tdir) {
2176  cmd = TString::Format("((TTree *)0x%lx)->SetDirectory(gDirectory);",
2177  (ULong_t)obj2);
2178  gROOT->ProcessLine(cmd.Data());
2179  }
2180  }
2181  fBrowser->GetContextMenu()->Popup(x, y, obj2, fBrowser);
2182  }
2183  }
2184  }
2185  }
2186  break;
2187  case kCT_ITEMDBLCLICK:
2188  if (parm1 == kButton1) {
2189  if (fIconBox->NumSelected() == 1) {
2190  void *p = 0;
2191  TGFileItem *item2;
2192  if ((item2 = (TGFileItem *) fIconBox->GetNextSelected(&p)) != 0) {
2193  TObject *obj2 = (TObject *)item2->GetUserData();
2194  if (obj2) {
2195  DoubleClicked(obj2);
2196  IconBoxAction(obj2);
2197  }
2198  delete cursorSwitcher;
2199  return kTRUE; //
2200  }
2201  }
2202  }
2203  break;
2204  case kCT_SELCHANGED:
2205  DisplayTotal((Int_t)parm1, (Int_t)parm2);
2206  break;
2207  default:
2208  break;
2209  }
2210 
2211  break;
2212 
2213  default:
2214  break;
2215  }
2216 
2217  delete cursorSwitcher;
2218 
2220  return kTRUE;
2221 }
2222 
2223 ////////////////////////////////////////////////////////////////////////////////
2224 /// Make object associated with item the current directory.
2225 
2227 {
2228  if (item) {
2229  TGListTreeItem *i = item;
2230  TString dir;
2231  while (i) {
2232  TObject *obj = (TObject*) i->GetUserData();
2233  if (obj) {
2234  if (obj->IsA() == TDirectoryFile::Class()) {
2235  dir = "/" + dir;
2236  dir = obj->GetName() + dir;
2237  }
2238  if (obj->IsA() == TFile::Class()) {
2239  dir = ":/" + dir;
2240  dir = obj->GetName() + dir;
2241  }
2242  if (obj->IsA() == TKey::Class()) {
2243  if (strcmp(((TKey*)obj)->GetClassName(), "TDirectoryFile") == 0) {
2244  dir = "/" + dir;
2245  dir = obj->GetName() + dir;
2246  }
2247  }
2248  }
2249  i = i->GetParent();
2250  }
2251 
2252  if (gDirectory && dir.Length()) gDirectory->cd(dir.Data());
2253  }
2254 }
2255 
2256 ////////////////////////////////////////////////////////////////////////////////
2257 /// helper method to track history
2258 
2260 {
2261  if (!fListLevel) return;
2262 
2263  fLt->ClearHighlighted();
2265 }
2266 
2267 ////////////////////////////////////////////////////////////////////////////////
2268 /// helper method to track history
2269 
2271 {
2273 
2274  if (!item || (fHistoryCursor &&
2275  (item == ((TRootBrowserHistoryCursor*)fHistoryCursor)->fItem))) return;
2276 
2277  TRootBrowserHistoryCursor *cur = (TRootBrowserHistoryCursor*)fHistoryCursor;
2278 
2279  while ((cur = (TRootBrowserHistoryCursor*)fHistory->After(fHistoryCursor))) {
2280  fHistory->Remove(cur);
2281  delete cur;
2282  }
2283 
2284  cur = new TRootBrowserHistoryCursor(item);
2285  fHistory->Add(cur);
2286  fHistoryCursor = cur;
2287  btn->SetState(kButtonUp);
2288 }
2289 
2290 ////////////////////////////////////////////////////////////////////////////////
2291 /// clear navigation history
2292 
2294 {
2295  fHistory->Delete();
2298  btn->SetState(kButtonDisabled);
2299  btn2->SetState(kButtonDisabled);
2300 }
2301 
2302 ////////////////////////////////////////////////////////////////////////////////
2303 /// go to the past
2304 
2306 {
2307  if (fBrowseTextFile) {
2308  HideTextEdit();
2309  return kFALSE;
2310  }
2311  TRootBrowserHistoryCursor *cur = (TRootBrowserHistoryCursor*)fHistory->Before(fHistoryCursor);
2314 
2315  if (!cur) {
2316  btn->SetState(kButtonDisabled);
2317  return kFALSE;
2318  }
2319 
2320  fLt->ClearHighlighted();
2321  fHistoryCursor = cur;
2322  fListLevel = cur->fItem;
2324  fLt->AdjustPosition();
2326 
2327  btn2->SetState(kButtonUp);
2328  cur = (TRootBrowserHistoryCursor*)fHistory->Before(fHistoryCursor);
2329  if (!cur) {
2330  btn->SetState(kButtonDisabled);
2331  return kFALSE;
2332  }
2333 
2334  return kTRUE;
2335 }
2336 
2337 ////////////////////////////////////////////////////////////////////////////////
2338 /// go to the future
2339 
2341 {
2342  if (fBrowseTextFile) {
2343  HideTextEdit();
2344  return kFALSE;
2345  }
2346 
2347  TRootBrowserHistoryCursor *cur = (TRootBrowserHistoryCursor*)fHistory->After(fHistoryCursor);
2350 
2351  if (!cur) {
2352  btn->SetState(kButtonDisabled);
2353  return kFALSE;
2354  }
2355 
2356  fLt->ClearHighlighted();
2357  fHistoryCursor = cur;
2358  fListLevel = cur->fItem;
2360  fLt->AdjustPosition();
2362 
2363  btn2->SetState(kButtonUp);
2364 
2365  cur = (TRootBrowserHistoryCursor*)fHistory->After(fHistoryCursor);
2366  if (!cur) {
2367  btn->SetState(kButtonDisabled);
2368  return kFALSE;
2369  }
2370 
2371  return kTRUE;
2372 }
2373 
2374 ////////////////////////////////////////////////////////////////////////////////
2375 /// delete list tree item, remove it from history
2376 
2378 {
2379  ((TRootBrowserHistory*)fHistory)->DeleteItem(item);
2380  fLt->DeleteItem(item);
2381 }
2382 
2383 ////////////////////////////////////////////////////////////////////////////////
2384 /// Open tree item and list in iconbox its contents.
2385 
2387 {
2388  if (item) {
2389  TObject *obj = (TObject *) item->GetUserData();
2390 
2391  if (obj) {
2392  if (obj->IsA() == TKey::Class()) {
2393 
2394  TKey *key = (TKey *)obj;
2395  TString name = obj->GetName();
2396  name += ";";
2397  name += key->GetCycle();
2398  Chdir(item->GetParent());
2399  //TObject *k_obj = gROOT->FindObject(name);
2400  TObject *k_obj = gDirectory->FindObjectAny(name);
2401 
2402  if (k_obj) {
2403  item->SetUserData(k_obj);
2404  obj = k_obj;
2405  }
2406  } else if (obj->InheritsFrom(TDirectoryFile::Class())) {
2407  Chdir(item->GetParent());
2408  }
2409  else if (obj->InheritsFrom("TApplicationRemote")) {
2410  if (!gApplication->GetAppRemote()) {
2411  gROOT->ProcessLine(Form(".R %s", item->GetText()));
2412  if (gApplication->GetAppRemote()) {
2413  Getlinem(kInit, TString::Format("\n%s:root [0]",
2415  }
2416  }
2417  }
2418  else if (obj->InheritsFrom("TRemoteObject")) {
2419  // special case for remote object
2420  TRemoteObject *robj = (TRemoteObject *)obj;
2421  // the real object is a TKey
2422  if (!strcmp(robj->GetClassName(), "TKey")) {
2423  TGListTreeItem *parent = item;
2424  TRemoteObject *probj = (TRemoteObject *)parent->GetUserData();
2425  // find the TFile remote object containing the TKey
2426  while ( probj && strcmp(probj->GetClassName(), "TFile")) {
2427  parent = parent->GetParent();
2428  probj = (TRemoteObject *)parent->GetUserData();
2429  }
2430  if (probj) {
2431  // remotely browse file (remotely call TFile::cd())
2434  TString::Format("((TApplicationServer *)gApplication)->BrowseFile(\"%s\");",
2435  probj->GetName()));
2436  }
2437  }
2438  }
2439  if (item->GetParent() && item->GetParent()->GetUserData() &&
2440  ((TObject *)item->GetParent()->GetUserData())->InheritsFrom("TApplicationRemote")) {
2441  // switch to remote session
2442  if (!gApplication->GetAppRemote()) {
2443  gROOT->ProcessLine(Form(".R %s", item->GetParent()->GetText()));
2444  if (gApplication->GetAppRemote()) {
2445  Getlinem(kInit, TString::Format("\n%s:root [0]",
2447  }
2448  }
2449  else if (!strcmp(item->GetText(), "ROOT Files")) {
2450  // update list of files opened in the remote session
2452  gApplication->ProcessLine("((TApplicationServer *)gApplication)->BrowseFile(0);");
2453  }
2454  }
2455  else {
2456  // check if the listtree item is from a local session or
2457  // from a remote session, then switch to the session it belongs to
2458  TGListTreeItem *top = item;
2459  while (top->GetParent()) {
2460  top = top->GetParent();
2461  }
2462  TObject *topobj = (TObject *) top->GetUserData();
2463  if (topobj && topobj->InheritsFrom("TApplicationRemote")) {
2464  // it belongs to a remote session
2465  if (!gApplication->GetAppRemote()) {
2466  // switch to remote session if not already in
2467  gROOT->ProcessLine(Form(".R %s", top->GetText()));
2468  if (gApplication->GetAppRemote()) {
2469  Getlinem(kInit, TString::Format("\n%s:root [0]",
2471  }
2472  }
2473  }
2474  else if (gApplication->GetAppRemote()) {
2475  // switch back to local session if not already in
2476  gApplication->ProcessLine(".R");
2477  Getlinem(kInit, "\nroot [0]");
2478  }
2479  }
2480 
2481  if (!fListLevel || !fListLevel->IsActive()) {
2482  fListLevel = item;
2483  BrowseObj(obj);
2485  }
2486  }
2487  DisplayDirectory();
2488  }
2489 }
2490 
2491 ////////////////////////////////////////////////////////////////////////////////
2492 /// display directory
2493 
2494 void TRootBrowserLite::ToSystemDirectory(const char *dirname)
2495 {
2496  TString dir = dirname;
2497 
2498  if (fListLevel) {
2499  TObject* obj = (TObject*)fListLevel->GetUserData();
2500 
2501  if (obj && (obj->IsA() == TSystemDirectory::Class())) {
2502  TObject* old = obj;
2503  fListLevel->Rename(dir.Data());
2504  obj = new TSystemDirectory(dir.Data(), dir.Data());
2505  while (fListLevel->GetFirstChild())
2508 
2509  fListLevel->SetUserData(obj);
2510  gROOT->GetListOfBrowsables()->Remove(old);
2511  delete old;
2512  gROOT->GetListOfBrowsables()->Add(obj);
2513  fTreeLock = kTRUE;
2514  BrowseObj(obj);
2515  fTreeLock = kFALSE;
2516 
2519  DisplayDirectory();
2520  //gSystem->ChangeDirectory(dir.Data());
2521  fStatusBar->SetText(dir.Data(), 1);
2522  ClearHistory(); // clear browsing history
2523  }
2524  }
2525  return;
2526 }
2527 
2528 ////////////////////////////////////////////////////////////////////////////////
2529 /// sets drawing option
2530 
2532 {
2533  fDrawOption->GetTextEntry()->SetText(option);
2534 }
2535 
2536 ////////////////////////////////////////////////////////////////////////////////
2537 /// returns drawing option
2538 
2540 {
2541  return fDrawOption->GetTextEntry()->GetText();
2542 }
2543 ////////////////////////////////////////////////////////////////////////////////
2544 /// Emits signal when double clicking on icon.
2545 
2547 {
2548  Emit("DoubleClicked(TObject*)", (Long_t)obj);
2549 }
2550 
2551 ////////////////////////////////////////////////////////////////////////////////
2552 /// Emits signal when double clicking on icon.
2553 
2555 {
2556  Long_t args[2];
2557 
2558  args[0] = (Long_t)obj;
2559  args[1] = checked;
2560 
2561  Emit("Checked(TObject*,Bool_t)", args);
2562 }
2563 
2564 ////////////////////////////////////////////////////////////////////////////////
2565 /// Default action when double clicking on icon.
2566 
2568 {
2569  Bool_t browsable = kFALSE;
2570  const char *dirname = 0;
2571  if (obj) {
2572 
2573  TRootBrowserCursorSwitcher cursorSwitcher(fIconBox, fLt);
2574 
2575  Bool_t useLock = kTRUE;
2576 
2577  if (obj->IsA()->GetMethodWithPrototype("Browse", "TBrowser*"))
2578  browsable = kTRUE;
2579 
2580  if (obj->InheritsFrom("TLeaf")) {
2581  TObject *dir = (TObject *)gROOT->ProcessLine(Form("((%s *)0x%lx)->GetBranch()->GetDirectory();",
2582  obj->ClassName(), (ULong_t)obj));
2583  if (!dir) {
2584  browsable = kFALSE;
2585  }
2586  }
2587  if (obj->InheritsFrom("TBranchElement")) {
2588  TObject *dir = (TObject *)gROOT->ProcessLine(Form("((%s *)0x%lx)->GetDirectory();",
2589  obj->ClassName(), (ULong_t)obj));
2590  if (!dir) {
2591  browsable = kFALSE;
2592  }
2593  }
2594 
2595  if (obj->InheritsFrom("TKey")) {
2596  TKey *key = dynamic_cast<TKey*>(obj);
2597  if (key && key->GetClassName() && (!strcmp(key->GetClassName(), "TFormula")))
2598  browsable = kFALSE;
2599  }
2600 
2601  if (obj->IsA() == TSystemDirectory::Class()) {
2602  useLock = kFALSE;
2603 
2604  TString t(obj->GetName());
2605  if (t == ".") goto out;
2606  if (t == "..") {
2607  if (fListLevel && fListLevel->GetParent()) {
2609  obj = (TObject*)fListLevel->GetUserData();
2610  if (fListLevel->GetParent()) {
2612  } else {
2613  obj = (TObject*)fListLevel->GetUserData();
2614  fListLevel = 0;
2615  }
2616  } else {
2617  dirname = gSystem->DirName(gSystem->pwd());
2618  ToSystemDirectory(dirname);
2619  return;
2620  }
2621  }
2622  }
2623 
2624  if (obj && obj->IsFolder()) {
2625  fIconBox->RemoveAll();
2626  TGListTreeItem *itm = 0;
2627 
2628  if (fListLevel) {
2630  itm = fListLevel->GetFirstChild();
2631  } else {
2632  itm = fLt->GetFirstItem();
2633  }
2634 
2635  while (itm && (itm->GetUserData() != obj)) {
2636  itm = itm->GetNextSibling();
2637  }
2638 
2639  if (!itm && fListLevel) {
2640  // special case for remote objects
2641  Bool_t isRemote = kFALSE;
2642  if (obj->InheritsFrom("TRemoteObject"))
2643  isRemote = kTRUE;
2644  else if (fListLevel) {
2645  // check also if one of its parents is a remote object
2646  TGListTreeItem *top = fListLevel;
2647  while (top->GetParent()) {
2648  TObject *tobj = (TObject *) top->GetUserData();
2649  if (tobj && (tobj->InheritsFrom("TRemoteObject") ||
2650  tobj->InheritsFrom("TApplicationRemote"))) {
2651  isRemote = kTRUE;
2652  break;
2653  }
2654  top = top->GetParent();
2655  }
2656  }
2657  if (isRemote) {
2658  // add the remote object only if not already in the list
2659  if ((!fLt->FindChildByName(fListLevel, obj->GetName())) &&
2660  (!fLt->FindChildByData(fListLevel, obj))) {
2661  itm = fLt->AddItem(fListLevel, obj->GetName());
2662  if (itm) itm->SetUserData(obj);
2663  }
2664  else {
2665  // set the current item to the one found in the list
2666  itm = fLt->FindChildByData(fListLevel, obj) ?
2667  fLt->FindChildByData(fListLevel, obj) :
2669  }
2670  }
2671  else {
2672  itm = fLt->AddItem(fListLevel, obj->GetName());
2673  if (itm) itm->SetUserData(obj);
2674  }
2675  }
2676 
2677  if (itm) {
2678  fListLevel = itm;
2679  DisplayDirectory();
2680  TObject *kobj = (TObject *)itm->GetUserData();
2681 
2682  if (kobj && kobj->IsA() == TKey::Class()) {
2684  //kobj = gROOT->FindObject(kobj->GetName());
2685  kobj = gDirectory->FindObjectAny(kobj->GetName());
2686 
2687  if (kobj) {
2688  TGListTreeItem *parent = fListLevel->GetParent();
2690  TGListTreeItem *kitem = fLt->AddItem(parent, kobj->GetName(), kobj);
2691  if (kitem) {
2692  obj = kobj;
2693  useLock = kFALSE;
2694  kitem->SetUserData(kobj);
2695  fListLevel = kitem;
2696  } else
2697  fListLevel = parent;
2698  }
2699  }
2701  }
2702  }
2703 
2704  if (browsable) {
2705  if (useLock) fTreeLock = kTRUE;
2706  Emit("BrowseObj(TObject*)", (Long_t)obj);
2707  if (obj) obj->Browse(fBrowser);
2708  if (useLock) fTreeLock = kFALSE;
2709  }
2710 
2711 out:
2712  if (obj && obj->IsA() != TSystemFile::Class()) {
2713  if (obj->IsFolder()) {
2714  fIconBox->Refresh();
2715  }
2716 
2717  if (fBrowser) {
2719  }
2720 
2723  }
2724  }
2725 }
2726 
2727 ////////////////////////////////////////////////////////////////////////////////
2728 /// Recursively remove object from browser.
2729 
2731 {
2732  // don't delete fIconBox items here (it's status will be updated
2733  // via TBrowser::Refresh() which should be called once all objects have
2734  // been removed.
2735 
2736  TGListTreeItem *item = fLt->FindItemByObj(fLt->GetFirstItem(), obj);
2737  if (item == 0)
2738  return;
2739  if (fListLevel && (item == fListLevel)) {
2740  TGListTreeItem *parent = item->GetParent();
2741  if (parent) {
2742  fListLevel = parent;
2743  fLt->ClearHighlighted();
2746  }
2747  else
2748  fListLevel = 0;
2749  }
2750  DeleteListTreeItem(item);
2751 }
2752 
2753 ////////////////////////////////////////////////////////////////////////////////
2754 /// Refresh the browser contents.
2755 
2757 {
2758  Bool_t refresh = fBrowser && fBrowser->GetRefreshFlag();
2759 
2760  if (fTextEdit && !gROOT->IsExecutingMacro() && force) {
2763  return;
2764  }
2765 
2766  if ( (refresh || force) && !fIconBox->WasGrouped()
2767  && fIconBox->NumItems()<fIconBox->GetGroupSize() ) {
2768 
2769  TRootBrowserCursorSwitcher cursorSwitcher(fIconBox, fLt);
2770  static UInt_t prev = 0;
2771  UInt_t curr = gROOT->GetListOfBrowsables()->GetSize();
2772  if (!prev) prev = curr;
2773 
2774  if (prev != curr) { // refresh gROOT
2775  TGListTreeItem *sav = fListLevel;
2776  fListLevel = 0;
2777  BrowseObj(gROOT);
2778  fListLevel = sav;
2779  prev = curr;
2780  }
2781 
2782  // Refresh the IconBox
2783  if (fListLevel) {
2784  TObject *obj = (TObject *)fListLevel->GetUserData();
2785  if (obj) {
2786  fTreeLock = kTRUE;
2787  BrowseObj(obj);
2788  fTreeLock = kFALSE;
2789  }
2790  }
2791  }
2793 }
2794 
2795 ////////////////////////////////////////////////////////////////////////////////
2796 /// Show or hide toolbar.
2797 
2799 {
2800  if (show) {
2804  } else {
2808  }
2809 }
2810 
2811 ////////////////////////////////////////////////////////////////////////////////
2812 /// Show or hide statusbar.
2813 
2815 {
2816  if (show) {
2819  } else {
2822  }
2823 }
2824 
2825 ////////////////////////////////////////////////////////////////////////////////
2826 /// Set defaults depending on settings in the user's .rootrc.
2827 
2828 void TRootBrowserLite::SetDefaults(const char *iconStyle, const char *sortBy)
2829 {
2830  const char *opt;
2831 
2832  // IconStyle: big, small, list, details
2833  if (iconStyle)
2834  opt = iconStyle;
2835  else
2836  opt = gEnv->GetValue("Browser.IconStyle", "small");
2837  if (!strcasecmp(opt, "big"))
2839  else if (!strcasecmp(opt, "small"))
2841  else if (!strcasecmp(opt, "list"))
2843  else if (!strcasecmp(opt, "details"))
2845  else
2847 
2848  // SortBy: name, type, size, date
2849  if (sortBy)
2850  opt = sortBy;
2851  else
2852  opt = gEnv->GetValue("Browser.SortBy", "name");
2853  if (!strcasecmp(opt, "name"))
2855  else if (!strcasecmp(opt, "type"))
2857  else if (!strcasecmp(opt, "size"))
2859  else if (!strcasecmp(opt, "date"))
2861  else
2863 
2864  fIconBox->Refresh();
2865 }
2866 
2867 ////////////////////////////////////////////////////////////////////////////////
2868 /// Set iconbox's view mode and update menu and toolbar buttons accordingly.
2869 
2871 {
2872  int i, bnum;
2873  EListViewMode lv;
2874 
2875  if (force || (fViewMode != new_mode)) {
2876 
2877  switch (new_mode) {
2878  default:
2879  if (!force)
2880  return;
2881  else
2882  new_mode = kViewLargeIcons;
2883  // intentionally no break
2884  case kViewLargeIcons:
2885  bnum = 2;
2886  lv = kLVLargeIcons;
2887  break;
2888  case kViewSmallIcons:
2889  bnum = 3;
2890  lv = kLVSmallIcons;
2891  break;
2892  case kViewList:
2893  bnum = 4;
2894  lv = kLVList;
2895  break;
2896  case kViewDetails:
2897  bnum = 5;
2898  lv = kLVDetails;
2899  break;
2900  }
2901 
2902  fViewMode = new_mode;
2904 
2905  for (i = 2; i <= 5; ++i)
2906  gToolBarData[i].fButton->SetState((i == bnum) ? kButtonEngaged : kButtonUp);
2907 
2908  fListView->SetViewMode(lv);
2909  TGTextButton** buttons = fListView->GetHeaderButtons();
2910  if ((lv == kLVDetails) && (buttons)) {
2911  if (!strcmp(fListView->GetHeader(1), "Attributes")) {
2912  buttons[0]->Connect("Clicked()", "TRootBrowserLite", this,
2913  TString::Format("SetSortMode(=%d)", kViewArrangeByName));
2914  buttons[1]->Connect("Clicked()", "TRootBrowserLite", this,
2915  TString::Format("SetSortMode(=%d)", kViewArrangeByType));
2916  buttons[2]->Connect("Clicked()", "TRootBrowserLite", this,
2917  TString::Format("SetSortMode(=%d)", kViewArrangeBySize));
2918  buttons[5]->Connect("Clicked()", "TRootBrowserLite", this,
2919  TString::Format("SetSortMode(=%d)", kViewArrangeByDate));
2920  }
2921  }
2922  fIconBox->AdjustPosition();
2923  }
2924 }
2925 
2926 ////////////////////////////////////////////////////////////////////////////////
2927 /// Set iconbox's sort mode and update menu radio buttons accordingly.
2928 
2930 {
2931  EFSSortMode smode;
2932 
2933  switch (new_mode) {
2934  default:
2935  new_mode = kViewArrangeByName;
2936  // intentionally no break
2937  case kViewArrangeByName:
2938  smode = kSortByName;
2939  break;
2940  case kViewArrangeByType:
2941  smode = kSortByType;
2942  break;
2943  case kViewArrangeBySize:
2944  smode = kSortBySize;
2945  break;
2946  case kViewArrangeByDate:
2947  smode = kSortByDate;
2948  break;
2949  }
2950 
2951  fSortMode = new_mode;
2953 
2954  fIconBox->Sort(smode);
2955 }
2956 
2957 ////////////////////////////////////////////////////////////////////////////////
2958 /// starts serach dialog
2959 
2961 {
2962  if (!fTextEdit) {
2963  fIconBox->Search(kFALSE);
2964  } else {
2966  }
2967 }
2968 
2969 ////////////////////////////////////////////////////////////////////////////////
2970 /// test
2971 
2972 static Bool_t isBinary(const char *str, int len)
2973 {
2974  for (int i = 0; i < len; i++) {
2975  char c = str[i];
2976  if (((c < 32) || (c > 126)) && (c != '\t') && (c != '\r') && (c != '\n')) {
2977  return kTRUE;
2978  }
2979  }
2980  return kFALSE;
2981 }
2982 
2983 ////////////////////////////////////////////////////////////////////////////////
2984 /// hide text edit
2985 
2987 {
2988  if (!fTextEdit) return;
2989 
2994  TGButton *savbtn = fToolBar->GetButton(kViewSave);
2995  savbtn->Disconnect();
2997  delete fTextEdit;
2998  fTextEdit = 0;
3000  fV2->MapSubwindows();
3001  fV2->Layout();
3003  fTextFileName = "";
3004 }
3005 
3006 ////////////////////////////////////////////////////////////////////////////////
3007 /// browse text file
3008 
3010 {
3011  Bool_t loaded = (fTextEdit != 0);
3012  if (gSystem->AccessPathName(file, kReadPermission)) {
3013  if (loaded) {
3014  HistoryBackward();
3015  }
3016  return;
3017  }
3018  const int bufferSize = 1024;
3019  char buffer[bufferSize];
3020 
3021  FILE *fd = fopen(file, "rb");
3022  if (fd == 0) {
3023  if (loaded) {
3024  HistoryBackward();
3025  }
3026  return;
3027  }
3028  int sz = fread(buffer, 1, bufferSize, fd);
3029  fclose(fd);
3030 
3031  if ((sz > 0) && isBinary(buffer, sz)) {
3032  if (loaded) {
3033  HistoryBackward();
3034  }
3035  return;
3036  }
3037 
3038  if (!fTextEdit) {
3041  TColor *col = gROOT->GetColor(19);
3042  if (col)
3043  fTextEdit->SetBackgroundColor(col->GetPixel());
3045  TGSearchDialog::SearchDialog()->Connect("TextEntered(char *)", "TGTextEdit",
3046  fTextEdit, "Search(char *,Bool_t,Bool_t)");
3047  }
3049  TGButton *savbtn = fToolBar->GetButton(kViewSave);
3050  savbtn->Connect("Released()", "TGTextEdit", fTextEdit, "SaveFile(=0,kTRUE)");
3051  }
3052  fTextFileName = file;
3053  fTextEdit->LoadFile(file);
3054  if (loaded) return;
3055 
3056  if (fTextFileName.EndsWith(".C")) {
3057  ShowMacroButtons();
3058  } else {
3060  }
3063  fTextEdit->MapWindow();
3064  fV2->MapSubwindows();
3065  fV2->Layout();
3067 
3068  if (fListLevel) {
3070  }
3072 
3073  if (btn) {
3074  btn->SetState(kButtonDisabled);
3075  }
3076 
3078 
3079  if (btn2) {
3080  btn2->SetState(kButtonUp);
3081  }
3082 }
3083 
3084 ////////////////////////////////////////////////////////////////////////////////
3085 /// executed browsed text macro
3086 
3088 {
3089  char *tmpfile = gSystem->ConcatFileName(gSystem->TempDirectory(),
3090  fTextFileName.Data());
3091 
3092  gROOT->SetExecutingMacro(kTRUE);
3093  fTextEdit->SaveFile(tmpfile, kFALSE);
3094  gROOT->Macro(tmpfile);
3095  gSystem->Unlink(tmpfile);
3096  delete [] tmpfile;
3097  gROOT->SetExecutingMacro(kFALSE);
3098 }
3099 
3100 ////////////////////////////////////////////////////////////////////////////////
3101 /// interrupt browsed macro execution
3102 
3104 {
3105  gROOT->SetInterrupt(kTRUE);
3106 }
3107 
3108 ////////////////////////////////////////////////////////////////////////////////
3109 /// show/hide macro buttons
3110 
3112 {
3116 
3117  static Bool_t connected = kFALSE;
3118 
3119  if (!show) {
3120  bt1->UnmapWindow();
3121  bt2->UnmapWindow();
3122  bt3->UnmapWindow();
3123  } else {
3124  bt1->MapWindow();
3125  bt2->MapWindow();
3126  bt3->MapWindow();
3127 
3128  if (!connected && fTextEdit) {
3129  bt1->Connect("Pressed()", "TRootBrowserLite", this, "ExecMacro()");
3130  bt2->Connect("Pressed()", "TRootBrowserLite", this, "InterruptMacro()");
3131  connected = kTRUE;
3132  }
3133  }
3134 }
3135 
3136 ////////////////////////////////////////////////////////////////////////////////
3137 /// Set text in column col in status bar.
3138 
3139 void TRootBrowserLite::SetStatusText(const char *txt, Int_t col)
3140 {
3142  TGStatusBar* status = GetStatusBar();
3143  if (status!=0) {
3144  status->SetText(txt, col);
3145  }
3146 }
3147 
3148 ////////////////////////////////////////////////////////////////////////////////
3149 /// Interface method to the old browser.
3150 
3152  UInt_t width, UInt_t height,
3153  Option_t * /*opt*/)
3154 {
3155  TRootBrowserLite *browser = new TRootBrowserLite(b, title, width, height);
3156  return (TBrowserImp *)browser;
3157 }
3158 
3159 ////////////////////////////////////////////////////////////////////////////////
3160 /// Interface method to the old browser.
3161 
3163  Int_t y, UInt_t width, UInt_t height,
3164  Option_t * /*opt*/)
3165 {
3166  TRootBrowserLite *browser = new TRootBrowserLite(b, title, x, y, width, height);
3167  return (TBrowserImp *)browser;
3168 }
void SetBrowserImp(TBrowserImp *i)
Definition: TBrowser.h:93
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1172
const TGString * GetPath() const
Definition: TGFSComboBox.h:63
virtual void AddToTree(TObject *obj, const char *name, Int_t check=-1)
Add items to the current TGListTree of the browser.
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
void AddType(const char *type, const char *pat, const char *icon, const char *sicon, const char *action)
Add a mime type to the list of mime types.
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:1276
std::string GetName(const std::string &scope_name)
Definition: Cppyy.cxx:145
TGFSComboBox * fFSComboBox
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
virtual TGTextEntry * GetTextEntry() const
Definition: TGComboBox.h:131
virtual Bool_t IsAbsoluteFileName(const char *dir)
Return true if dir is an absolute pathname.
Definition: TSystem.cxx:949
virtual Long_t ProcessLine(const char *line, Bool_t sync=kFALSE, Int_t *error=0)
Process a single command line, either a C++ statement or an interpreter command starting with a "...
virtual TGButton * GetButton(Int_t id) const
Finds and returns a pointer to the button with the specified identifier id.
Definition: TGToolBar.cxx:156
TGLayoutHints * fMenuBarItemLayout
TGCompositeFrame * fListHdr
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
Definition: TGListBox.cxx:1419
TGVerticalFrame * fV1
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:467
const char * GetClassName() const
Definition: TRemoteObject.h:56
TGTextEdit * fTextEdit
void SetViewMode(Int_t new_mode, Bool_t force=kFALSE)
Set iconbox&#39;s view mode and update menu and toolbar buttons accordingly.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:854
Int_t fDataLength
Definition: TGDNDManager.h:78
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
Definition: TBufferFile.h:47
virtual void * GetUserData() const =0
long long Long64_t
Definition: RtypesCore.h:69
TGListTreeItem * FindChildByData(TGListTreeItem *item, void *userData)
Find child of item by userData.
UInt_t Hash(const TString &s)
Definition: TString.h:462
Utility class for browsing TMapFile objects.
Definition: TKeyMapFile.h:20
virtual void RemoveAll()
Remove all items from the container.
Definition: TGCanvas.cxx:638
TGListTreeItem * FindItemByObj(TGListTreeItem *item, void *ptr)
Find item with fUserData == ptr.
virtual void MoveResize(Int_t x, Int_t y, UInt_t w=0, UInt_t h=0)
Move and/or resize the frame.
Definition: TGFrame.cxx:611
R__EXTERN const char gHelpPostscript[]
Definition: HelpText.h:18
virtual UInt_t GetHeight() const
Definition: TImage.h:229
Int_t fY
Definition: TGDimension.h:51
virtual void AdjustHeaders()
Definition: TGListView.h:172
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:869
Int_t DeleteItem(TGListTreeItem *item)
Delete item from list tree.
virtual void DrawBox(Int_t, Int_t, Int_t, Int_t, const char *="#000000", UInt_t=1, Int_t=0)
Definition: TImage.h:188
virtual TGFrame * GetContainer() const
Definition: TGListBox.h:335
Collectable string class.
Definition: TObjString.h:28
TGLayoutHints * fComboLayout
void SetDrawOption(Option_t *option="")
sets drawing option
TRootIconBox * fIconBox
TGPopupMenu * fViewMenu
const char Option_t
Definition: RtypesCore.h:62
const TGPicture * GetIcon(const char *filename, Bool_t small_icon)
Return icon belonging to mime type of filename.
virtual void SetStatusText(const char *txt, Int_t col)
Set text in column col in status bar.
virtual Bool_t HandleKey(Event_t *event)
Handle keyboard events.
Definition: TGFrame.cxx:1564
virtual TGButton * AddButton(const TGWindow *w, ToolBarData_t *button, Int_t spacing=0)
Add button to toolbar.
Definition: TGToolBar.cxx:91
void SetWindowName(const char *name=0)
Set window name. This is typically done via the window manager.
Definition: TGFrame.cxx:1746
const Mask_t kKeyMod1Mask
Definition: GuiTypes.h:197
virtual UInt_t GetWidth() const
Definition: TImage.h:228
virtual const char * GetIconName() const
Returns mime type name of object.
Definition: TObject.cxx:367
const Ssiz_t kNPOS
Definition: RtypesCore.h:111
virtual Bool_t IsValid() const
Definition: TImage.h:230
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:638
Bool_t HistoryForward()
go to the future
virtual void SetToolTipText(const char *text, Long_t delayms=500)
Set tool tip text associated with this text entry.
virtual void Update()=0
void Search()
starts serach dialog
REAL splitter
Definition: triangle.c:616
virtual const char * GetClassName() const
Definition: TKey.h:71
UInt_t GetHeight() const
Definition: TGFrame.h:272
virtual void DoubleClicked(TObject *obj)
Emits signal when double clicking on icon.
TH1 * h
Definition: legend2.C:5
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition: TGMenu.cxx:1714
TGFileContainer * GetIconBox() const
returns pointer to fIconBox object
TGStatusBar * GetStatusBar() const
virtual void SetFrame(TGFrame *frame, Bool_t left)
Set frame to be resized.
Definition: TGSplitter.cxx:140
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format...
Definition: TFile.h:46
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition: TList.cxx:689
R__EXTERN const char gHelpPullDownMenus[]
Definition: HelpText.h:21
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition: TGMenu.cxx:1835
EListViewMode
Definition: TGListView.h:39
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition: TGMenu.cxx:1797
const TGPicture * SetIconPixmap(const char *iconName)
Set window icon pixmap by name.
Definition: TGFrame.cxx:1774
#define gROOT
Definition: TROOT.h:402
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:585
TGToolBar * fToolBar
R__ALWAYS_INLINE Bool_t TestBit(UInt_t f) const
Definition: TObject.h:172
virtual void Associate(const TGWindow *w)
Definition: TGCanvas.h:99
Basic string class.
Definition: TString.h:125
#define gClient
Definition: TGClient.h:166
static Pixel_t fgWhitePixel
Definition: TGFrame.h:150
virtual void ShowStatusBar(Bool_t show=kTRUE)
Show or hide statusbar.
virtual void ShowFrame(TGFrame *f)
Show sub frame.
Definition: TGFrame.cxx:1186
Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Handle menu and other command generated by the user.
void ToLower()
Change string to lower-case.
Definition: TString.cxx:1099
virtual void RemoveAll()
Remove all frames from composite frame.
Definition: TGFrame.cxx:1113
virtual void CheckObjectItem(TObject *obj, Bool_t check=kFALSE)
Check / uncheck the TGListTreeItem corresponding to this object and add a checkmark on TGLVEntry if c...
int Int_t
Definition: RtypesCore.h:41
virtual const char * DirName(const char *pathname)
Return the directory name in pathname.
Definition: TSystem.cxx:1004
bool Bool_t
Definition: RtypesCore.h:59
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:373
virtual void AddEntry(TGHotString *s, Int_t id, void *ud=0, const TGPicture *p=0, TGMenuEntry *before=0)
Add a menu entry.
Definition: TGMenu.cxx:987
#define gInterpreter
Definition: TInterpreter.h:526
An abstract interface to image processing library.
Definition: TImage.h:29
virtual void Terminate(Int_t status=0)
Terminate the application by call TSystem::Exit() unless application has been told to return from Run...
virtual void Merge(const TImage *, const char *="alphablend", Int_t=0, Int_t=0)
Definition: TImage.h:172
virtual void SetViewMode(EListViewMode viewMode)
Set list view mode.
void AddToHistory(TGListTreeItem *item)
helper method to track history
TString & Prepend(const char *cs)
Definition: TString.h:607
R__EXTERN TApplication * gApplication
Definition: TApplication.h:165
virtual void Cleanup()
Cleanup and delete all objects contained in this composite frame.
Definition: TGToolBar.cxx:213
virtual void LayoutHeader(TGFrame *head)
Layout list view components (container and contents of container).
UInt_t GetWidth() const
Definition: TGFrame.h:271
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1
static TGSearchDialog *& SearchDialog()
Return global search dialog.
void SetIconName(const char *name)
Set window icon name. This is typically done via the window manager.
Definition: TGFrame.cxx:1759
Option_t * GetDrawOption() const
returns drawing option
virtual void Layout()
Layout list view components (container and contents of container).
virtual char * GetObjectInfo(Int_t px, Int_t py) const
Returns string containing info about the object at position (px,py).
Definition: TObject.cxx:386
virtual void AddSeparator(TGMenuEntry *before=0)
Add a menu separator to the menu.
Definition: TGMenu.cxx:1057
Handle_t GetId() const
Definition: TGObject.h:47
Bool_t IsDragging() const
Definition: TGDNDManager.h:175
TGLayoutHints * fMenuBarLayout
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
TGListTreeItem * GetSelected() const
Definition: TGListTree.h:397
R__EXTERN const char gHelpAbout[]
Definition: HelpText.h:14
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition: TString.cxx:616
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:694
virtual Pixmap_t GetPixmap()
Definition: TImage.h:235
virtual void RemoveFrame(TGFrame *f)
Remove frame from composite frame.
Definition: TGFrame.cxx:1131
virtual const char * UnixPathName(const char *unixpathname)
Convert from a Unix pathname to a local pathname.
Definition: TSystem.cxx:1044
R__EXTERN TGDNDManager * gDNDManager
Definition: TGDNDManager.h:203
TGListView * fListView
virtual void SetValue(const char *name, const char *value, EEnvLevel level=kEnvChange, const char *type=0)
Set the value of a resource or create a new resource.
Definition: TEnv.cxx:736
virtual void Scale(UInt_t, UInt_t)
Definition: TImage.h:141
#define gFile
Definition: TFile.h:322
static TBrowserImp * NewBrowser(TBrowser *b=0, const char *title="ROOT Browser", UInt_t width=800, UInt_t height=500, Option_t *opt="")
Interface method to the old browser.
TGListTreeItem * FindChildByName(TGListTreeItem *item, const char *name)
Find child of item by name.
virtual TGFrameElement * FindFrame(Int_t x, Int_t y, Bool_t exclude=kTRUE)
Find frame located int container at position x,y.
Definition: TGCanvas.cxx:1654
void SetText(const char *helpText)
Set help text from helpText buffer in TGTextView.
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
Definition: TSystem.cxx:1357
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:128
TGLayoutHints * fExpandLayout
THashTable implements a hash table to store TObject&#39;s.
Definition: THashTable.h:35
Double_t x[n]
Definition: legend1.C:17
R__EXTERN const char gHelpBrowserLite[]
Definition: HelpText.h:16
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session...
Definition: TRemoteObject.h:36
void ShowMacroButtons(Bool_t show=kTRUE)
show/hide macro buttons
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:2365
TGPicturePool * GetPicturePool() const
Definition: TGClient.h:135
TGPopupMenu * fSortMenu
TGCompositeFrame * fTreeHdr
virtual void SetDefaultHeaders()
Default headers are: Name, Attributes, Size, Owner, Group, Modified.
void Class()
Definition: Class.C:29
static Pixel_t GetDefaultFrameBackground()
Get default frame background.
Definition: TGFrame.cxx:665
void AdjustPosition(TGListTreeItem *item)
Move content to position of item.
virtual void SetIncrements(Int_t hInc, Int_t vInc)
Set horizontal and vertical scrollbar increments.
virtual void SetText(TGString *newText)
Set new text in label.
Definition: TGLabel.cxx:177
virtual void SetUserData(void *, Bool_t=kFALSE)
Definition: TGListTree.h:94
const char ** fFileTypes
Definition: TGFileDialog.h:63
Bool_t EndDrag()
End dragging.
void SetWMSizeHints(UInt_t wmin, UInt_t hmin, UInt_t wmax, UInt_t hmax, UInt_t winc, UInt_t hinc)
Give the window manager minimum and maximum size hints.
Definition: TGFrame.cxx:1862
virtual void SetCheckedEntry(Bool_t check=kTRUE)
Definition: TGListView.h:122
void SetToolTipItem(TGListTreeItem *item, const char *string)
Set tooltip text for this item.
TGTextButton ** GetHeaderButtons()
Definition: TGListView.h:177
virtual Bool_t IsActive() const =0
const char * GetKeyClassName() const
Definition: TRemoteObject.h:58
Handle_t Atom_t
Definition: GuiTypes.h:36
TGListTreeItem * fListLevel
virtual void Select(Int_t id, Bool_t emit=kTRUE)
Make the selected item visible in the combo box window and emit signals according to the second param...
Definition: TGComboBox.cxx:443
TGCompositeFrame(const TGCompositeFrame &)
ECaseCompare
Definition: TString.h:245
TGPopupMenu * fHelpMenu
virtual void AddToBox(TObject *obj, const char *name)
Add items to the iconbox of the browser.
void * fData
Definition: TGDNDManager.h:77
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2231
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Definition: TMath.h:1150
void SetSortMode(Int_t new_mode)
Set iconbox&#39;s sort mode and update menu radio buttons accordingly.
virtual void Popup(Int_t x, Int_t y, TObject *obj, TVirtualPad *c=0, TVirtualPad *p=0)
Popup context menu at given location in canvas c and pad p for selected object.
virtual void SendMessage(const TGWindow *w, Long_t msg, Long_t parm1, Long_t parm2)
Send message (i.e.
Definition: TGFrame.cxx:627
EListViewMode GetViewMode() const
Definition: TGListView.h:179
virtual void BrowseObj(TObject *obj)
Browse object.
virtual TList * GetList() const
Definition: TGFrame.h:369
virtual Bool_t LoadFile(const char *fname, long startpos=0, long length=-1)
Load a file in the text view widget.
Definition: TGTextView.cxx:452
void SetClassHints(const char *className, const char *resourceName)
Set the windows class and resource name.
Definition: TGFrame.cxx:1814
TGPopupMenu * fFileMenu
virtual void ShowToolBar(Bool_t show=kTRUE)
Show or hide toolbar.
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition: TSystem.cxx:1458
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:24
virtual void Add(TObject *obj, const char *name=0, Int_t check=-1)
Add items to the browser.
virtual void SetText(TGString *text, Int_t partidx=0)
Set text in partition partidx in status bar.
Long64_t Atoll() const
Return long long value of string.
Definition: TString.cxx:2001
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:49
virtual void * FindItem(const TString &name, Bool_t direction=kTRUE, Bool_t caseSensitive=kTRUE, Bool_t subString=kFALSE)
Definition: TGCanvas.cxx:1687
TGMenuBar * fMenuBar
void IconBoxAction(TObject *obj)
Default action when double clicking on icon.
TApplication * GetAppRemote() const
Definition: TApplication.h:145
TGMimeTypes * GetMimeTypeList() const
Definition: TGClient.h:155
auto * lv
Definition: textalign.C:5
void UpdateDrawOption()
add new draw option to the "history"
Describes an Operating System directory for the browser.
virtual const char * GetHeader(Int_t idx) const
Returns name of header idx.
A doubly linked list.
Definition: TList.h:44
const char * pwd()
Definition: TSystem.h:405
virtual TGListBox * GetListBox() const
Definition: TGComboBox.h:130
void CloseWindow()
In case window is closed via WM we get here.
void CreateBrowser(const char *name)
Create the actual browser.
void OpenItem(TGListTreeItem *item)
Open item in list tree (i.e. show child items).
virtual void SetTipText(const char *)
Definition: TGListTree.h:92
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
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:867
TGLayoutHints * fBarLayout
void SetUserData(void *userData)
Definition: TGListView.h:112
const TString & GetString() const
Definition: TObjString.h:47
void SetDNDSource(Bool_t onoff)
Definition: TGFrame.h:315
virtual void Show()
void DisplayTotal(Int_t total, Int_t selected)
Display in statusbar total number of objects and number of selected objects in IconBox.
void SetDNDData(TDNDData *data)
virtual void SendCloseMessage()
Send close message to self.
Definition: TGFrame.cxx:1702
virtual const char * ApplicationName() const
Definition: TApplication.h:123
EMouseButton
Definition: GuiTypes.h:213
TList * fList
Definition: TGFrame.h:351
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:655
virtual UInt_t GetDefaultWidth() const
Definition: TGFrame.h:371
R__EXTERN TSystem * gSystem
Definition: TSystem.h:540
TGHorizontal3DLine * fToolBarSep
void Popup()
Show help dialog.
EGEventType fType
Definition: GuiTypes.h:174
Bool_t fMultipleSelection
Definition: TGFileDialog.h:66
R__EXTERN const char gHelpCanvas[]
Definition: HelpText.h:22
void * GetUserData() const
Definition: TGListView.h:113
Int_t GET_SUBMSG(Long_t val)
TGListTreeItem * GetNextSibling() const
Definition: TGListTree.h:77
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:84
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:818
virtual void Associate(const TGWindow *w)
Definition: TGMenu.h:219
void GetPathnameFromItem(TGListTreeItem *item, char *path, Int_t depth=0)
Get pathname from item.
void AddItem(TGListTreeItem *parent, TGListTreeItem *item)
Add given item to list tree.
virtual Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:443
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:561
virtual TObject * Before(const TObject *obj) const
Returns the object before object obj.
Definition: TList.cxx:368
void SetRefreshFlag(Bool_t flag)
Definition: TBrowser.h:97
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from browser.
virtual const char * GetText() const =0
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
char * Form(const char *fmt,...)
void ClearHighlighted()
Un highlight items.
Ssiz_t Length() const
Definition: TString.h:386
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition: TGPicture.cxx:80
EFSSortMode
Definition: TGFSContainer.h:30
TGFrame * fFrame
Definition: TGLayout.h:119
void ExecMacro()
executed browsed text macro
TList * fFileNamesList
Definition: TGFileDialog.h:67
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
virtual TObject * After(const TObject *obj) const
Returns the object after object obj.
Definition: TList.cxx:327
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:661
virtual void Update(const char *path)
Update file system combo box.
Int_t fX
Definition: TGDimension.h:50
Bool_t GetRefreshFlag() const
Definition: TBrowser.h:95
TGHorizontalFrame * fHf
Bool_t HistoryBackward()
go to the past
Atom_t fDataType
Definition: TGDNDManager.h:75
virtual void ExecuteDefaultAction(TObject *obj)
Execute default action for selected object (action is specified in the $HOME/.root.mimes or $ROOTSYS/etc/root.mimes file.
void Chdir(TGListTreeItem *item)
Make object associated with item the current directory.
virtual void RCheckEntry(Int_t id, Int_t IDfirst, Int_t IDlast)
Radio-select entry (note that they cannot be unselected, the selection must be moved to another entry...
Definition: TGMenu.cxx:1850
void Rename(const char *new_name)
Definition: TGListTree.h:86
TGComboBox * fDrawOption
#define gVirtualX
Definition: TVirtualX.h:350
R__EXTERN const char gHelpObjects[]
Definition: HelpText.h:23
virtual void SetBackgroundColor(Pixel_t)
Set background color of the canvas frame.
Definition: TGView.cxx:580
TGVerticalFrame * fV2
virtual void ClearViewPort()
Clear view port and redraw full content.
Definition: TGCanvas.cxx:888
char * StrDup(const char *str)
Duplicate the string str.
Definition: TString.cxx:2544
Int_t GET_MSG(Long_t val)
const char * GetString() const
Definition: TGString.h:40
const Bool_t kFALSE
Definition: RtypesCore.h:88
EKeySym
Definition: KeySymbols.h:25
void ClearHistory()
clear navigation history
Bool_t GetAction(const char *filename, char *action)
Return in action the mime action string belonging to filename.
static unsigned int total
const char * GetText() const
Definition: TGTextEntry.h:134
TString & Remove(Ssiz_t pos)
Definition: TString.h:619
long Long_t
Definition: RtypesCore.h:50
virtual void Modified(Bool_t flag=1)=0
TGListTreeItem * GetParent() const
Definition: TGListTree.h:73
void ReallyDelete()
Really delete the browser and the this GUI.
virtual Bool_t Search(const char *string, Bool_t direction=kTRUE, Bool_t caseSensitive=kFALSE)
Search for string in the specified direction.
Definition: TGTextEdit.cxx:633
virtual void SetReadOnly(Bool_t on=kTRUE)
Definition: TGTextView.h:128
virtual void SetDefaults(const char *iconStyle=0, const char *sortBy=0)
Set defaults depending on settings in the user&#39;s .rootrc.
#define ClassImp(name)
Definition: Rtypes.h:359
void Print(std::ostream &os, const OptionType &opt)
virtual void SetEditDisabled(UInt_t on=1)
Set edit disable flag for this frame and subframes.
Definition: TGFrame.cxx:1004
const TGString * GetText() const
Definition: TGListBox.h:115
virtual Pixmap_t GetMask()
Definition: TImage.h:236
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:106
virtual void RemoveCheckBox(TObject *obj)
Remove checkbox from TGListTree and checkmark from TGListView.
TObject * fHistoryCursor
Describe directory structure in memory.
Definition: TDirectory.h:34
virtual void FromPad(TVirtualPad *, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0)
Definition: TImage.h:122
TGListTreeItem * GetFirstChild() const
Definition: TGListTree.h:74
TRootBrowserLite(TBrowser *b=0, const char *title="ROOT Browser", UInt_t width=800, UInt_t height=500)
Create browser with a specified width and height.
R__EXTERN TEnv * gEnv
Definition: TEnv.h:171
unsigned long ULong_t
Definition: RtypesCore.h:51
char * fFilename
Definition: TGFileDialog.h:61
virtual void AddCheckBox(TObject *obj, Bool_t check=kFALSE)
Add a checkbox in the TGListTreeItem corresponding to obj and a checkmark on TGLVEntry if check = kTR...
Double_t y[n]
Definition: legend1.C:17
R__EXTERN const char gHelpGraphicsEditor[]
Definition: HelpText.h:20
static const char * gOpenTypes[]
Bool_t Disconnect(const char *signal=0, void *receiver=0, const char *slot=0)
Disconnects signal of this object from slot of receiver.
Definition: TQObject.cxx:1025
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
void HideTextEdit()
hide text edit
The color creation and management class.
Definition: TColor.h:19
void InterruptMacro()
interrupt browsed macro execution
void BrowseTextFile(const char *file)
browse text file
void HighlightListLevel()
helper method to track history
void DeleteListTreeItem(TGListTreeItem *item)
delete list tree item, remove it from history
void ListTreeHighlight(TGListTreeItem *item)
Open tree item and list in iconbox its contents.
virtual void AddFrame(TGFrame *f, TGLayoutHints *l=0)
Add frame to the composite frame using the specified layout hints.
Definition: TGFrame.cxx:1099
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:2887
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Definition: TList.cxx:399
ERootBrowserCommands
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
Bool_t IsNull() const
Definition: TString.h:383
Handle_t fId
Definition: TGObject.h:36
virtual Int_t GetNumberOfEntries() const
Definition: TGComboBox.h:127
void SetCheckBox(TGListTreeItem *item, Bool_t on=kTRUE)
Set check button state for the node &#39;item&#39;.
virtual Bool_t IsOpen() const
Definition: TGListTree.h:79
Mother of all ROOT objects.
Definition: TObject.h:37
virtual void SetHeaders(Int_t ncolumns)
Set number of headers, i.e.
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:401
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition: TClass.cxx:5668
A TSystemFile describes an operating system file.
Definition: TSystemFile.h:29
virtual void UnmapWindow()
Definition: TGFrame.h:253
void SetWMPosition(Int_t x, Int_t y)
Give the window manager a window position hint.
Definition: TGFrame.cxx:1837
virtual void CheckEntry(Int_t id)
Check a menu entry (i.e. add a check mark in front of it).
Definition: TGMenu.cxx:1772
TGLayoutHints * fMenuBarHelpLayout
TGListTreeItem * FindItemByPathname(const char *path)
Find item by pathname.
virtual ~TRootBrowserLite()
Browser destructor.
virtual void Add(TObject *obj)
Definition: TList.h:87
static TGuiBuilder * Instance()
return an instance of TGuiBuilder object
Definition: file.py:1
virtual void MapWindow()
Definition: TGFrame.h:251
static Bool_t isBinary(const char *str, int len)
test
TGClient * fClient
Definition: TGObject.h:37
void SetAutoTips(Bool_t on=kTRUE)
Definition: TGListTree.h:366
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:232
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
const char * fPixmap
Definition: TGToolBar.h:33
#define snprintf
Definition: civetweb.c:822
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
#define gPad
Definition: TVirtualPad.h:285
UInt_t fState
Definition: GuiTypes.h:180
Atom_t * fDNDTypeList
Definition: TGFrame.h:482
virtual void SetParts(Int_t npart)
Divide the status bar in npart equal sized parts.
virtual void SetHeader(const char *s, Int_t hmode, Int_t cmode, Int_t idx)
Set header button idx [0-fNColumns>, hmode is the x text alignmode (ETextJustification) for the heade...
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TObject.cxx:473
R__EXTERN const char gHelpRemote[]
Definition: HelpText.h:25
virtual void Refresh(Bool_t force=kFALSE)
Refresh the browser contents.
#define gDirectory
Definition: TDirectory.h:213
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition: TROOT.cxx:2842
virtual void AddPopup(TGHotString *s, TGPopupMenu *popup, TGMenuEntry *before=0, const TGPicture *p=0)
Add a (cascading) popup menu to a popup menu.
Definition: TGMenu.cxx:1149
void Emit(const char *signal, const T &arg)
Activate signal with single parameter.
Definition: TQObject.h:165
void CheckItem(TGListTreeItem *item, Bool_t check=kTRUE)
Set check button state for the node &#39;item&#39;.
virtual void Checked(TObject *obj, Bool_t check)
Emits signal when double clicking on icon.
TGStatusBar * fStatusBar
virtual void SetText(const char *text, Bool_t emit=kTRUE)
Sets text entry to text, clears the selection and moves the cursor to the end of the line...
static TImage * Create()
Create an image.
Definition: TImage.cxx:36
virtual Bool_t HandleKey(Event_t *event)
handle keys
Short_t GetCycle() const
Return cycle number associated to this key.
Definition: TKey.cxx:564
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:357
virtual Int_t GetSize() const
Definition: TCollection.h:180
void HighlightItem(TGListTreeItem *item)
Highlight item.
virtual Bool_t SaveFile(const char *fname, Bool_t saveas=kFALSE)
Save file.
Definition: TGTextEdit.cxx:387
TGListTreeItem * GetFirstItem() const
Definition: TGListTree.h:396
TBrowser * fBrowser
Definition: TBrowserImp.h:32
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
friend class TRootIconBox
void DisplayDirectory()
Display current directory in second label, fLbl2.
static ToolBarData_t gToolBarData[]
virtual Int_t GetValue(const char *name, Int_t dflt) const
Returns the integer value for a resource.
Definition: TEnv.cxx:491
const Bool_t kTRUE
Definition: RtypesCore.h:87
Int_t GetLength() const
Definition: TGString.h:39
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
Definition: TSystem.cxx:1052
TContextMenu * GetContextMenu() const
Definition: TBrowser.h:94
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=0)
Add popup menu to menu bar.
Definition: TGMenu.cxx:415
virtual Bool_t SetImageBuffer(char **, EImageFileTypes=TImage::kPng)
Definition: TImage.h:242
void ToSystemDirectory(const char *dirname)
display directory
char name[80]
Definition: TGX11.cxx:109
void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition: TBrowser.h:103
virtual void DestroyWindow()
Definition: TGWindow.h:92
Int_t RecursiveDeleteItem(TGListTreeItem *item, void *userData)
Delete item with fUserData == ptr.
TGPopupMenu * fOptionMenu
char * fIniDir
Definition: TGFileDialog.h:62
ABC describing GUI independent browser implementation protocol.
Definition: TBrowserImp.h:29
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:185
virtual TGLBEntry * GetSelectedEntry() const
Definition: TGComboBox.h:135
const TGPicture * fIconPic
const char * Data() const
Definition: TString.h:345