ROOT  6.06/08
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 
152 static ToolBarData_t gToolBarData[] = {
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  gInterpreter->DeleteGlobal(fBrowser);
1567  if (fBrowser->IsOnHeap())
1568  delete fBrowser; // will in turn delete this object
1569  else
1570  fBrowser->Destructor(); // will in turn delete this object
1571 }
1572 
1573 ////////////////////////////////////////////////////////////////////////////////
1574 /// In case window is closed via WM we get here.
1575 
1577 {
1578  DeleteWindow();
1579 }
1580 
1581 ////////////////////////////////////////////////////////////////////////////////
1582 /// Display in statusbar total number of objects and number of
1583 /// selected objects in IconBox.
1584 
1586 {
1587  char tmp[64];
1588  const char *fmt;
1589 
1590  if (selected)
1591  fmt = "%d Object%s, %d selected.";
1592  else
1593  fmt = "%d Object%s.";
1594 
1595  snprintf(tmp, 64, fmt, total, (total == 1) ? "" : "s", selected);
1596  fStatusBar->SetText(tmp, 0);
1597 }
1598 
1599 ////////////////////////////////////////////////////////////////////////////////
1600 /// Display current directory in second label, fLbl2.
1601 
1603 {
1604  char *p, path[1024];
1605 
1606  fLt->GetPathnameFromItem(fListLevel, path, 12);
1607  p = path;
1608  while (*p && *(p+1) == '/') ++p;
1609  if (!p[0])
1610  fLbl2->SetText(new TGString("Contents of \".\""));
1611  else
1612  fLbl2->SetText(new TGString(Form("Contents of \"%s\"", p)));
1613  fListHdr->Layout();
1614 
1615  // Get full pathname for FS combobox (previously truncated to 12 levels deep)
1617  p = path;
1618  while (*p && *(p+1) == '/') ++p;
1619  fFSComboBox->Update(p);
1620 
1621  if (fListLevel) {
1622  // disable/enable up level navigation
1624  const char *dirname = gSystem->DirName(p);
1625  Bool_t disableUp;
1626 
1627  TObject *obj = (TObject*)fListLevel->GetUserData();
1628  disableUp = (strlen(dirname) == 1) && (*dirname == '/');
1629 
1630  // normal file directory
1631  if (disableUp && (obj) && (obj->IsA() == TSystemDirectory::Class())) {
1632  disableUp = strlen(p) == 1;
1633  }
1634  btn->SetState(disableUp ? kButtonDisabled : kButtonUp);
1636  }
1637 }
1638 
1639 ////////////////////////////////////////////////////////////////////////////////
1640 /// Execute default action for selected object (action is specified
1641 /// in the $HOME/.root.mimes or $ROOTSYS/etc/root.mimes file.
1642 /// Emits signal "ExecuteDefaultAction(TObject*)".
1643 
1645 {
1646  TRootBrowserCursorSwitcher cursorSwitcher(fIconBox, fLt);
1647  char action[512];
1649  TVirtualPad *wasp = gPad ? (TVirtualPad*)gPad->GetCanvas() : 0;
1650  TFile *wasf = gFile;
1651 
1652  // Special case for file system objects...
1653  if (obj->IsA() == TSystemFile::Class() ||
1654  obj->InheritsFrom("TRemoteObject")) {
1655  TString act;
1656  TString ext = obj->GetName();
1657 
1658  if (fClient->GetMimeTypeList()->GetAction(obj->GetName(), action)) {
1659  act = action;
1660  act.ReplaceAll("%s", obj->GetName());
1661  gInterpreter->SaveGlobalsContext();
1662 
1663  if (act[0] == '!') {
1664  act.Remove(0, 1);
1665  gSystem->Exec(act.Data());
1666  } else {
1667  // special case for remote object: remote process
1668  if (obj->InheritsFrom("TRemoteObject"))
1670  gApplication->ProcessLine(act.Data());
1671  }
1672  Emit("ExecuteDefaultAction(TObject*)", (Long_t)obj);
1673  }
1674 
1675  // special case for remote object: browse real object
1676  if (obj->InheritsFrom("TRemoteObject") && ext.EndsWith(".root")) {
1677  TRootBrowserCursorSwitcher cursorSwitcher2(fIconBox, fLt);
1679  gApplication->ProcessLine("((TApplicationServer *)gApplication)->BrowseFile(0);");
1680  Refresh();
1681  }
1682  ////////// new TFile was opened. Add it to the browser /////
1683  if (gFile && (wasf != gFile) && ext.EndsWith(".root")) {
1684  TGListTreeItem *itm = fLt->FindChildByData(0, gROOT->GetListOfFiles());
1685 
1686  if (itm) {
1687  fLt->ClearHighlighted();
1688  fListLevel = itm;
1691  itm = fLt->AddItem(fListLevel, gFile->GetName());
1692  itm->SetUserData(gFile);
1694  return;
1695  }
1696  }
1697 
1698  // only valid for local text files
1699  if (!obj->InheritsFrom("TRemoteObject"))
1700  BrowseTextFile(obj->GetName());
1701 
1702  /////////////// cache and change file's icon ///////////////////////
1703  TVirtualPad *nowp = gPad ? (TVirtualPad*)gPad->GetCanvas() : 0;
1704 
1705  if (fIconBox->fAutoThumbnail && nowp && (nowp != wasp)) {
1706  TSystemFile *sf = (TSystemFile*)obj;
1707  const TGPicture *pic, *spic;
1708 
1709  TIconBoxThumb *thumb = 0;
1710  TString path = gSystem->IsAbsoluteFileName(sf->GetName()) ? sf->GetName() :
1712 
1713  thumb = (TIconBoxThumb*)fIconBox->fThumbnails->FindObject(path);
1714 
1715  if (thumb) {
1716  spic = thumb->fSmall;
1717  pic = thumb->fLarge;
1718  } else {
1719  TImage *img = TImage::Create();
1720  nowp->Modified();
1721  nowp->Update();
1722  img->FromPad(nowp);
1723 
1724  if (!img->IsValid()) {
1725  return;
1726  }
1727 
1728  static const UInt_t sz = 72;
1729  UInt_t w = sz;
1730  UInt_t h = sz;
1731 
1732  if (img->GetWidth() > img->GetHeight()) {
1733  h = (img->GetHeight()*sz)/img->GetWidth();
1734  } else {
1735  w = (img->GetWidth()*sz)/img->GetHeight();
1736  }
1737 
1738  w = w < 54 ? 54 : w;
1739  h = h < 54 ? 54 : h;
1740 
1741  img->Scale(w, h);
1742  img->Merge(img, "tint"); // contrasting
1743  img->DrawBox(0, 0, w, h, "#ffff00", 1); // yellow frame
1744 
1745  pic = fClient->GetPicturePool()->GetPicture(path.Data(), img->GetPixmap(), 0);
1746  img->Scale(w/3, h/3);
1747  spic = fClient->GetPicturePool()->GetPicture(path.Data(), img->GetPixmap(), 0);
1748 
1749  thumb = new TIconBoxThumb(path.Data(), spic, pic);
1750  fIconBox->fThumbnails->Add(thumb);
1751  delete img;
1752  }
1753  }
1754  return;
1755  }
1756 
1757  // For other objects the default action is still hard coded in
1758  // their Browse() member function.
1759 }
1760 
1761 ////////////////////////////////////////////////////////////////////////////////
1762 /// Handle menu and other command generated by the user.
1763 
1765 {
1766  TRootHelpDialog *hd;
1767  TRootBrowserCursorSwitcher *cursorSwitcher = 0;
1768  TDirectory *tdir = 0;
1769  TString cmd;
1770 
1771  if (GET_SUBMSG(msg) != kCT_SELCHANGED) {
1772  cursorSwitcher = new TRootBrowserCursorSwitcher(fIconBox, fLt);
1773  }
1774 
1775  TObject *obj;
1776  TGListTreeItem *item = 0;
1777 
1778  gVirtualX->Update();
1779 
1780  switch (GET_MSG(msg)) {
1781 
1782  case kC_COMMAND:
1783 
1784  switch (GET_SUBMSG(msg)) {
1785 
1786  case kCM_BUTTON:
1787  // fallthrough
1788  case kCM_MENU:
1789 
1790  switch ((ERootBrowserCommands)parm1) {
1791  // Handle File menu items...
1792  case kFileNewBrowserLite:
1793  new TBrowser("Browser", "ROOT Object Browser");
1794  break;
1795  case kFileNewBrowser:
1796  gEnv->SetValue("Browser.Name", "TRootBrowser");
1797  new TBrowser();
1798  gEnv->SetValue("Browser.Name", "TRootBrowserLite");
1799  break;
1800  case kFileNewCanvas:
1801  gROOT->MakeDefCanvas();
1802  break;
1803  case kFileNewBuilder:
1805  break;
1806  case kFileOpen:
1807  {
1808  static TString dir(".");
1809  TGFileInfo fi;
1810  fi.fFileTypes = gOpenTypes;
1811  fi.fIniDir = StrDup(dir);
1812  new TGFileDialog(fClient->GetDefaultRoot(), this,
1813  kFDOpen,&fi);
1814  dir = fi.fIniDir;
1815  if (fi.fMultipleSelection && fi.fFileNamesList) {
1816  TObjString *el;
1817  TIter next(fi.fFileNamesList);
1818  while ((el = (TObjString *) next())) {
1819  new TFile(el->GetString(), "update");
1820  }
1821  }
1822  else if (fi.fFilename) {
1823  new TFile(fi.fFilename, "update");
1824  }
1825  }
1826  break;
1827  case kFileSave:
1828  case kFileSaveAs:
1829  break;
1830  case kFilePrint:
1831  break;
1832  case kFileCloseBrowser:
1833  SendCloseMessage();
1834  break;
1835  case kFileQuit:
1836  gApplication->Terminate(0);
1837  break;
1838 
1839  // Handle View menu items...
1840  case kViewToolBar:
1843  else
1844  ShowToolBar();
1845  break;
1846  case kViewStatusBar:
1849  else
1850  ShowStatusBar();
1851  break;
1852  case kViewLargeIcons:
1853  case kViewSmallIcons:
1854  case kViewList:
1855  case kViewDetails:
1856  SetViewMode((Int_t)parm1);
1857  break;
1858  case kViewHidden:
1862  } else {
1865  }
1866  Refresh(kTRUE);
1867  break;
1868  case kViewArrangeByName:
1869  case kViewArrangeByType:
1870  case kViewArrangeBySize:
1871  case kViewArrangeByDate:
1872  SetSortMode((Int_t)parm1);
1873  break;
1874  case kViewLineUp:
1875  break;
1876  case kViewRefresh:
1877  Refresh(kTRUE);
1878  break;
1879  case kViewGroupLV:
1882  TString gv = gEnv->GetValue("Browser.GroupView", "10000");
1883  Int_t igv = atoi(gv.Data());
1884 
1885  if (igv > 10) {
1886  fIconBox->SetGroupSize(igv);
1887  }
1888  } else {
1890  fIconBox->SetGroupSize(10000000); // very large value
1891  }
1892  break;
1893 
1894  // Handle Option menu items...
1895  case kOptionShowCycles:
1896  printf("Currently the browser always shows all cycles\n");
1897  break;
1898 
1899  case kOptionAutoThumbnail:
1902  fIconBox->fThumbnails->Delete();
1903  fIconBox->fAutoThumbnail = kFALSE;
1904  Refresh(kTRUE);
1905  } else {
1907  fIconBox->fAutoThumbnail = kTRUE;
1908  }
1909  break;
1910 
1911  // Handle toolbar button...
1912  case kOneLevelUp:
1913  {
1914  if (fBrowseTextFile) {
1915  HideTextEdit();
1916  break;
1917  }
1918  if (!fListLevel || !fListLevel->IsActive()) break;
1919 
1920  if (fListLevel && fIconBox->WasGrouped()) {
1921  if (fListLevel) {
1922  item = fListLevel->GetParent();
1923  if (item) fListLevel = item;
1924  obj = (TObject *) fListLevel->GetUserData();
1926  if (obj) BrowseObj(obj);
1927  }
1928 
1930  break;
1931  }
1932  if (fListLevel) item = fListLevel->GetParent();
1933 
1934 
1935  if (item) {
1936  fListLevel = item;
1937  obj = (TObject *)fListLevel->GetUserData();
1939  DisplayDirectory();
1940  if (obj) BrowseObj(obj);
1942  } else {
1943  obj = (TObject *)fListLevel->GetUserData();
1944  if (obj) ToSystemDirectory(gSystem->DirName(obj->GetTitle()));
1945  }
1946  break;
1947  }
1948 
1949  // toolbar buttons
1950  case kHistoryBack:
1951  HistoryBackward();
1952  break;
1953  case kHistoryForw:
1954  HistoryForward();
1955  break;
1956 
1957  case kViewFind:
1958  Search();
1959  break;
1960 
1961  // Handle Help menu items...
1962  case kHelpAbout:
1963  {
1964 #ifdef R__UNIX
1965  TString rootx = TROOT::GetBinDir() + "/root -a &";
1966  gSystem->Exec(rootx);
1967 #else
1968 #ifdef WIN32
1970 #else
1971  char str[32];
1972  sprintf(str, "About ROOT %s...", gROOT->GetVersion());
1973  hd = new TRootHelpDialog(this, str, 600, 400);
1974  hd->SetText(gHelpAbout);
1975  hd->Popup();
1976 #endif
1977 #endif
1978  }
1979  break;
1980  case kHelpOnCanvas:
1981  hd = new TRootHelpDialog(this, "Help on Canvas...", 600, 400);
1982  hd->SetText(gHelpCanvas);
1983  hd->Popup();
1984  break;
1985  case kHelpOnMenus:
1986  hd = new TRootHelpDialog(this, "Help on Menus...", 600, 400);
1988  hd->Popup();
1989  break;
1990  case kHelpOnGraphicsEd:
1991  hd = new TRootHelpDialog(this, "Help on Graphics Editor...", 600, 400);
1993  hd->Popup();
1994  break;
1995  case kHelpOnBrowser:
1996  hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
1998  hd->Popup();
1999  break;
2000  case kHelpOnObjects:
2001  hd = new TRootHelpDialog(this, "Help on Objects...", 600, 400);
2002  hd->SetText(gHelpObjects);
2003  hd->Popup();
2004  break;
2005  case kHelpOnPS:
2006  hd = new TRootHelpDialog(this, "Help on PostScript...", 600, 400);
2007  hd->SetText(gHelpPostscript);
2008  hd->Popup();
2009  break;
2010  case kHelpOnRemote:
2011  hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
2012  hd->SetText(gHelpRemote);
2013  hd->Popup();
2014  break;
2015  default:
2016  break;
2017  }
2018  break;
2019  case kCM_COMBOBOX:
2020  if (parm1 == kFSComboBox) {
2022  if (e) {
2023  const char *dirname = e->GetPath()->GetString();
2024  item = fLt->FindItemByPathname(dirname);
2025  if (item) {
2026  fListLevel = item;
2028  DisplayDirectory();
2030  } else {
2031  ToSystemDirectory(dirname);
2032  }
2033  }
2034  }
2035  break;
2036  default:
2037  break;
2038  }
2039 
2040  break;
2041 
2042  case kC_LISTTREE:
2043  switch (GET_SUBMSG(msg)) {
2044 
2045  case kCT_ITEMCLICK:
2046  // tell coverity that parm1 is a Long_t, and not an enum (even
2047  // if we compare it with an enum value) and the meaning of
2048  // parm1 depends on GET_MSG(msg) and GET_SUBMSG(msg)
2049  // coverity[mixed_enums]
2050  if (((EMouseButton)parm1 == kButton1) ||
2051  ((EMouseButton)parm1 == kButton3)) {
2052  HideTextEdit();
2053  TGListTreeItem *item2;
2054  TObject *obj2 = 0;
2055  if ((item2 = fLt->GetSelected()) != 0 ) {
2056  ListTreeHighlight(item2);
2057  fStatusBar->SetText("", 1); // clear
2058  }
2059  if (item2 && parm1 == kButton3) {
2060  Int_t x = (Int_t)(parm2 & 0xffff);
2061  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2062  obj2 = (TObject *) item2->GetUserData();
2063  if (obj2) {
2064  if (obj2->InheritsFrom("TTree")) {
2065  // if a tree not attached to any directory (e.g. in a TFolder)
2066  // then attach it to the current directory (gDirectory)
2067  cmd = TString::Format("((TTree *)0x%lx)->GetDirectory();",
2068  (ULong_t)obj2);
2069  tdir = (TDirectory *)gROOT->ProcessLine(cmd.Data());
2070  if (!tdir) {
2071  cmd = TString::Format("((TTree *)0x%lx)->SetDirectory(gDirectory);",
2072  (ULong_t)obj2);
2073  gROOT->ProcessLine(cmd.Data());
2074  }
2075  }
2076  fBrowser->GetContextMenu()->Popup(x, y, obj2, fBrowser);
2077  }
2078  }
2080  fListView->LayoutHeader(0);
2081  fListView->Layout();
2082  }
2083  break;
2084 
2085  case kCT_ITEMDBLCLICK:
2086  if (parm1 == kButton1) {
2087  if (fBrowseTextFile) {
2088  HideTextEdit();
2089  }
2090  if (fListLevel && fIconBox->WasGrouped()) {
2091  TObject *obj2;
2092  TGListTreeItem *item2;
2093 
2094  if (fListLevel) {
2095  item2 = fListLevel->GetParent();
2096  if (item2) fListLevel = item2;
2097 
2098  obj2 = (TObject *) fListLevel->GetUserData();
2100  if (obj2) {
2101  BrowseObj(obj2);
2102  }
2103  }
2104  break;
2105  }
2106  }
2107 
2108  default:
2109  break;
2110  }
2111  break;
2112 
2113  case kC_CONTAINER:
2114  switch (GET_SUBMSG(msg)) {
2115 
2116  case kCT_ITEMCLICK:
2117  if (fIconBox->NumSelected() == 1) {
2118  // display title of selected object
2119  TGFileItem *item2;
2120  void *p = 0;
2121  if ((item2 = (TGFileItem *)fIconBox->GetNextSelected(&p)) != 0) {
2122  TObject *obj2 = (TObject *)item2->GetUserData();
2123 
2124  TGListTreeItem *itm = 0;
2125  if (!fListLevel) itm = fLt->GetFirstItem();
2126  else itm = fListLevel->GetFirstChild();
2127  //Bool_t found = kFALSE;
2128 
2129  while (itm) {
2130  if (itm->GetUserData() == obj2) break;
2131  itm = itm->GetNextSibling();
2132  }
2133 
2134  if (itm) {
2135  if ((fListLevel && fListLevel->IsOpen()) || !fListLevel) {
2136  fLt->ClearHighlighted();
2137  fLt->HighlightItem(itm);
2139  }
2140  }
2141 
2142  if (obj2) fStatusBar->SetText(obj2->GetName(), 1);
2143  }
2144  }
2145  if (parm1 == kButton3) {
2146  // show context menu for selected object
2147  if (fIconBox->NumSelected() == 1) {
2148  void *p = 0;
2149  TGFileItem *item2;
2150  if ((item2 = (TGFileItem *) fIconBox->GetNextSelected(&p)) != 0) {
2151  Int_t x = (Int_t)(parm2 & 0xffff);
2152  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2153  TObject *obj2 = (TObject *)item2->GetUserData();
2154  if (obj2) {
2155  if (obj2->IsA() == TKey::Class()) {
2156  TKey *key = (TKey*)obj2;
2157  TClass *cl = TClass::GetClass(key->GetClassName());
2158  TString name = key->GetName();
2159  name += ";";
2160  name += key->GetCycle();
2161  //void *add = gROOT->FindObject((char *) name.Data());//key->GetName());
2162  void *add = gDirectory->FindObjectAny((char *) name.Data());
2163  if (cl->IsTObject()) {
2164  obj2 = (TObject*)add; // cl->DynamicCast(TObject::Class(),startadd);
2165  item2->SetUserData(obj2);
2166  } else {
2167  Error("ProcessMessage","do not support non TObject (like %s) yet",
2168  cl->GetName());
2169  break;
2170  }
2171  }
2172  if (obj2 && obj2->InheritsFrom("TTree")) {
2173  // if a tree not attached to any directory (e.g. in a TFolder)
2174  // then attach it to the current directory (gDirectory)
2175  cmd = TString::Format("((TTree *)0x%lx)->GetDirectory();",
2176  (ULong_t)obj2);
2177  tdir = (TDirectory *)gROOT->ProcessLine(cmd.Data());
2178  if (!tdir) {
2179  cmd = TString::Format("((TTree *)0x%lx)->SetDirectory(gDirectory);",
2180  (ULong_t)obj2);
2181  gROOT->ProcessLine(cmd.Data());
2182  }
2183  }
2184  fBrowser->GetContextMenu()->Popup(x, y, obj2, fBrowser);
2185  }
2186  }
2187  }
2188  }
2189  break;
2190  case kCT_ITEMDBLCLICK:
2191  if (parm1 == kButton1) {
2192  if (fIconBox->NumSelected() == 1) {
2193  void *p = 0;
2194  TGFileItem *item2;
2195  if ((item2 = (TGFileItem *) fIconBox->GetNextSelected(&p)) != 0) {
2196  TObject *obj2 = (TObject *)item2->GetUserData();
2197  if (obj2) {
2198  DoubleClicked(obj2);
2199  IconBoxAction(obj2);
2200  }
2201  delete cursorSwitcher;
2202  return kTRUE; //
2203  }
2204  }
2205  }
2206  break;
2207  case kCT_SELCHANGED:
2208  DisplayTotal((Int_t)parm1, (Int_t)parm2);
2209  break;
2210  default:
2211  break;
2212  }
2213 
2214  break;
2215 
2216  default:
2217  break;
2218  }
2219 
2220  delete cursorSwitcher;
2221 
2223  return kTRUE;
2224 }
2225 
2226 ////////////////////////////////////////////////////////////////////////////////
2227 /// Make object associated with item the current directory.
2228 
2230 {
2231  if (item) {
2232  TGListTreeItem *i = item;
2233  TString dir;
2234  while (i) {
2235  TObject *obj = (TObject*) i->GetUserData();
2236  if (obj) {
2237  if (obj->IsA() == TDirectoryFile::Class()) {
2238  dir = "/" + dir;
2239  dir = obj->GetName() + dir;
2240  }
2241  if (obj->IsA() == TFile::Class()) {
2242  dir = ":/" + dir;
2243  dir = obj->GetName() + dir;
2244  }
2245  if (obj->IsA() == TKey::Class()) {
2246  if (strcmp(((TKey*)obj)->GetClassName(), "TDirectoryFile") == 0) {
2247  dir = "/" + dir;
2248  dir = obj->GetName() + dir;
2249  }
2250  }
2251  }
2252  i = i->GetParent();
2253  }
2254 
2255  if (gDirectory && dir.Length()) gDirectory->cd(dir.Data());
2256  }
2257 }
2258 
2259 ////////////////////////////////////////////////////////////////////////////////
2260 /// helper method to track history
2261 
2263 {
2264  if (!fListLevel) return;
2265 
2266  fLt->ClearHighlighted();
2268 }
2269 
2270 ////////////////////////////////////////////////////////////////////////////////
2271 /// helper method to track history
2272 
2274 {
2276 
2277  if (!item || (fHistoryCursor &&
2278  (item == ((TRootBrowserHistoryCursor*)fHistoryCursor)->fItem))) return;
2279 
2280  TRootBrowserHistoryCursor *cur = (TRootBrowserHistoryCursor*)fHistoryCursor;
2281 
2282  while ((cur = (TRootBrowserHistoryCursor*)fHistory->After(fHistoryCursor))) {
2283  fHistory->Remove(cur);
2284  delete cur;
2285  }
2286 
2287  cur = new TRootBrowserHistoryCursor(item);
2288  fHistory->Add(cur);
2289  fHistoryCursor = cur;
2290  btn->SetState(kButtonUp);
2291 }
2292 
2293 ////////////////////////////////////////////////////////////////////////////////
2294 /// clear navigation history
2295 
2297 {
2298  fHistory->Delete();
2301  btn->SetState(kButtonDisabled);
2302  btn2->SetState(kButtonDisabled);
2303 }
2304 
2305 ////////////////////////////////////////////////////////////////////////////////
2306 /// go to the past
2307 
2309 {
2310  if (fBrowseTextFile) {
2311  HideTextEdit();
2312  return kFALSE;
2313  }
2314  TRootBrowserHistoryCursor *cur = (TRootBrowserHistoryCursor*)fHistory->Before(fHistoryCursor);
2317 
2318  if (!cur) {
2319  btn->SetState(kButtonDisabled);
2320  return kFALSE;
2321  }
2322 
2323  fLt->ClearHighlighted();
2324  fHistoryCursor = cur;
2325  fListLevel = cur->fItem;
2327  fLt->AdjustPosition();
2329 
2330  btn2->SetState(kButtonUp);
2331  cur = (TRootBrowserHistoryCursor*)fHistory->Before(fHistoryCursor);
2332  if (!cur) {
2333  btn->SetState(kButtonDisabled);
2334  return kFALSE;
2335  }
2336 
2337  return kTRUE;
2338 }
2339 
2340 ////////////////////////////////////////////////////////////////////////////////
2341 /// go to the future
2342 
2344 {
2345  if (fBrowseTextFile) {
2346  HideTextEdit();
2347  return kFALSE;
2348  }
2349 
2350  TRootBrowserHistoryCursor *cur = (TRootBrowserHistoryCursor*)fHistory->After(fHistoryCursor);
2353 
2354  if (!cur) {
2355  btn->SetState(kButtonDisabled);
2356  return kFALSE;
2357  }
2358 
2359  fLt->ClearHighlighted();
2360  fHistoryCursor = cur;
2361  fListLevel = cur->fItem;
2363  fLt->AdjustPosition();
2365 
2366  btn2->SetState(kButtonUp);
2367 
2368  cur = (TRootBrowserHistoryCursor*)fHistory->After(fHistoryCursor);
2369  if (!cur) {
2370  btn->SetState(kButtonDisabled);
2371  return kFALSE;
2372  }
2373 
2374  return kTRUE;
2375 }
2376 
2377 ////////////////////////////////////////////////////////////////////////////////
2378 /// delete list tree item, remove it from history
2379 
2381 {
2382  ((TRootBrowserHistory*)fHistory)->DeleteItem(item);
2383  fLt->DeleteItem(item);
2384 }
2385 
2386 ////////////////////////////////////////////////////////////////////////////////
2387 /// Open tree item and list in iconbox its contents.
2388 
2390 {
2391  if (item) {
2392  TObject *obj = (TObject *) item->GetUserData();
2393 
2394  if (obj) {
2395  if (obj->IsA() == TKey::Class()) {
2396 
2397  TKey *key = (TKey *)obj;
2398  TString name = obj->GetName();
2399  name += ";";
2400  name += key->GetCycle();
2401  Chdir(item->GetParent());
2402  //TObject *k_obj = gROOT->FindObject(name);
2403  TObject *k_obj = gDirectory->FindObjectAny(name);
2404 
2405  if (k_obj) {
2406  item->SetUserData(k_obj);
2407  obj = k_obj;
2408  }
2409  } else if (obj->InheritsFrom(TDirectoryFile::Class())) {
2410  Chdir(item->GetParent());
2411  }
2412  else if (obj->InheritsFrom("TApplicationRemote")) {
2413  if (!gApplication->GetAppRemote()) {
2414  gROOT->ProcessLine(Form(".R %s", item->GetText()));
2415  if (gApplication->GetAppRemote()) {
2416  Getlinem(kInit, TString::Format("\n%s:root [0]",
2418  }
2419  }
2420  }
2421  else if (obj->InheritsFrom("TRemoteObject")) {
2422  // special case for remote object
2423  TRemoteObject *robj = (TRemoteObject *)obj;
2424  // the real object is a TKey
2425  if (!strcmp(robj->GetClassName(), "TKey")) {
2426  TGListTreeItem *parent = item;
2427  TRemoteObject *probj = (TRemoteObject *)parent->GetUserData();
2428  // find the TFile remote object containing the TKey
2429  while ( probj && strcmp(probj->GetClassName(), "TFile")) {
2430  parent = parent->GetParent();
2431  probj = (TRemoteObject *)parent->GetUserData();
2432  }
2433  if (probj) {
2434  // remotely browse file (remotely call TFile::cd())
2437  TString::Format("((TApplicationServer *)gApplication)->BrowseFile(\"%s\");",
2438  probj->GetName()));
2439  }
2440  }
2441  }
2442  if (item->GetParent() && item->GetParent()->GetUserData() &&
2443  ((TObject *)item->GetParent()->GetUserData())->InheritsFrom("TApplicationRemote")) {
2444  // switch to remote session
2445  if (!gApplication->GetAppRemote()) {
2446  gROOT->ProcessLine(Form(".R %s", item->GetParent()->GetText()));
2447  if (gApplication->GetAppRemote()) {
2448  Getlinem(kInit, TString::Format("\n%s:root [0]",
2450  }
2451  }
2452  else if (!strcmp(item->GetText(), "ROOT Files")) {
2453  // update list of files opened in the remote session
2455  gApplication->ProcessLine("((TApplicationServer *)gApplication)->BrowseFile(0);");
2456  }
2457  }
2458  else {
2459  // check if the listtree item is from a local session or
2460  // from a remote session, then switch to the session it belongs to
2461  TGListTreeItem *top = item;
2462  while (top->GetParent()) {
2463  top = top->GetParent();
2464  }
2465  TObject *topobj = (TObject *) top->GetUserData();
2466  if (topobj && topobj->InheritsFrom("TApplicationRemote")) {
2467  // it belongs to a remote session
2468  if (!gApplication->GetAppRemote()) {
2469  // switch to remote session if not already in
2470  gROOT->ProcessLine(Form(".R %s", top->GetText()));
2471  if (gApplication->GetAppRemote()) {
2472  Getlinem(kInit, TString::Format("\n%s:root [0]",
2474  }
2475  }
2476  }
2477  else if (gApplication->GetAppRemote()) {
2478  // switch back to local session if not already in
2479  gApplication->ProcessLine(".R");
2480  Getlinem(kInit, "\nroot [0]");
2481  }
2482  }
2483 
2484  if (!fListLevel || !fListLevel->IsActive()) {
2485  fListLevel = item;
2486  BrowseObj(obj);
2488  }
2489  }
2490  DisplayDirectory();
2491  }
2492 }
2493 
2494 ////////////////////////////////////////////////////////////////////////////////
2495 /// display directory
2496 
2497 void TRootBrowserLite::ToSystemDirectory(const char *dirname)
2498 {
2499  TString dir = dirname;
2500 
2501  if (fListLevel) {
2502  TObject* obj = (TObject*)fListLevel->GetUserData();
2503 
2504  if (obj && (obj->IsA() == TSystemDirectory::Class())) {
2505  TObject* old = obj;
2506  fListLevel->Rename(dir.Data());
2507  obj = new TSystemDirectory(dir.Data(), dir.Data());
2508  while (fListLevel->GetFirstChild())
2511 
2512  fListLevel->SetUserData(obj);
2513  gROOT->GetListOfBrowsables()->Remove(old);
2514  delete old;
2515  gROOT->GetListOfBrowsables()->Add(obj);
2516  fTreeLock = kTRUE;
2517  BrowseObj(obj);
2518  fTreeLock = kFALSE;
2519 
2522  DisplayDirectory();
2523  //gSystem->ChangeDirectory(dir.Data());
2524  fStatusBar->SetText(dir.Data(), 1);
2525  ClearHistory(); // clear browsing history
2526  }
2527  }
2528  return;
2529 }
2530 
2531 ////////////////////////////////////////////////////////////////////////////////
2532 /// sets drawing option
2533 
2535 {
2536  fDrawOption->GetTextEntry()->SetText(option);
2537 }
2538 
2539 ////////////////////////////////////////////////////////////////////////////////
2540 /// returns drawing option
2541 
2543 {
2544  return fDrawOption->GetTextEntry()->GetText();
2545 }
2546 ////////////////////////////////////////////////////////////////////////////////
2547 /// Emits signal when double clicking on icon.
2548 
2550 {
2551  Emit("DoubleClicked(TObject*)", (Long_t)obj);
2552 }
2553 
2554 ////////////////////////////////////////////////////////////////////////////////
2555 /// Emits signal when double clicking on icon.
2556 
2558 {
2559  Long_t args[2];
2560 
2561  args[0] = (Long_t)obj;
2562  args[1] = checked;
2563 
2564  Emit("Checked(TObject*,Bool_t)", args);
2565 }
2566 
2567 ////////////////////////////////////////////////////////////////////////////////
2568 /// Default action when double clicking on icon.
2569 
2571 {
2572  Bool_t browsable = kFALSE;
2573  const char *dirname = 0;
2574  if (obj) {
2575 
2576  TRootBrowserCursorSwitcher cursorSwitcher(fIconBox, fLt);
2577 
2578  Bool_t useLock = kTRUE;
2579 
2580  if (obj->IsA()->GetMethodWithPrototype("Browse", "TBrowser*"))
2581  browsable = kTRUE;
2582 
2583  if (obj->InheritsFrom("TLeaf")) {
2584  TObject *dir = (TObject *)gROOT->ProcessLine(Form("((%s *)0x%lx)->GetBranch()->GetDirectory();",
2585  obj->ClassName(), (ULong_t)obj));
2586  if (!dir) {
2587  browsable = kFALSE;
2588  }
2589  }
2590  if (obj->InheritsFrom("TBranchElement")) {
2591  TObject *dir = (TObject *)gROOT->ProcessLine(Form("((%s *)0x%lx)->GetDirectory();",
2592  obj->ClassName(), (ULong_t)obj));
2593  if (!dir) {
2594  browsable = kFALSE;
2595  }
2596  }
2597 
2598  if (obj->InheritsFrom("TKey")) {
2599  TKey *key = dynamic_cast<TKey*>(obj);
2600  if (key && key->GetClassName() && (!strcmp(key->GetClassName(), "TFormula")))
2601  browsable = kFALSE;
2602  }
2603 
2604  if (obj->IsA() == TSystemDirectory::Class()) {
2605  useLock = kFALSE;
2606 
2607  TString t(obj->GetName());
2608  if (t == ".") goto out;
2609  if (t == "..") {
2610  if (fListLevel && fListLevel->GetParent()) {
2612  obj = (TObject*)fListLevel->GetUserData();
2613  if (fListLevel->GetParent()) {
2615  } else {
2616  obj = (TObject*)fListLevel->GetUserData();
2617  fListLevel = 0;
2618  }
2619  } else {
2620  dirname = gSystem->DirName(gSystem->pwd());
2621  ToSystemDirectory(dirname);
2622  return;
2623  }
2624  }
2625  }
2626 
2627  if (obj && obj->IsFolder()) {
2628  fIconBox->RemoveAll();
2629  TGListTreeItem *itm = 0;
2630 
2631  if (fListLevel) {
2633  itm = fListLevel->GetFirstChild();
2634  } else {
2635  itm = fLt->GetFirstItem();
2636  }
2637 
2638  while (itm && (itm->GetUserData() != obj)) {
2639  itm = itm->GetNextSibling();
2640  }
2641 
2642  if (!itm && fListLevel) {
2643  // special case for remote objects
2644  Bool_t isRemote = kFALSE;
2645  if (obj->InheritsFrom("TRemoteObject"))
2646  isRemote = kTRUE;
2647  else if (fListLevel) {
2648  // check also if one of its parents is a remote object
2649  TGListTreeItem *top = fListLevel;
2650  while (top->GetParent()) {
2651  TObject *tobj = (TObject *) top->GetUserData();
2652  if (tobj && (tobj->InheritsFrom("TRemoteObject") ||
2653  tobj->InheritsFrom("TApplicationRemote"))) {
2654  isRemote = kTRUE;
2655  break;
2656  }
2657  top = top->GetParent();
2658  }
2659  }
2660  if (isRemote) {
2661  // add the remote object only if not already in the list
2662  if ((!fLt->FindChildByName(fListLevel, obj->GetName())) &&
2663  (!fLt->FindChildByData(fListLevel, obj))) {
2664  itm = fLt->AddItem(fListLevel, obj->GetName());
2665  if (itm) itm->SetUserData(obj);
2666  }
2667  else {
2668  // set the current item to the one found in the list
2669  itm = fLt->FindChildByData(fListLevel, obj) ?
2670  fLt->FindChildByData(fListLevel, obj) :
2672  }
2673  }
2674  else {
2675  itm = fLt->AddItem(fListLevel, obj->GetName());
2676  if (itm) itm->SetUserData(obj);
2677  }
2678  }
2679 
2680  if (itm) {
2681  fListLevel = itm;
2682  DisplayDirectory();
2683  TObject *kobj = (TObject *)itm->GetUserData();
2684 
2685  if (kobj && kobj->IsA() == TKey::Class()) {
2687  //kobj = gROOT->FindObject(kobj->GetName());
2688  kobj = gDirectory->FindObjectAny(kobj->GetName());
2689 
2690  if (kobj) {
2691  TGListTreeItem *parent = fListLevel->GetParent();
2693  TGListTreeItem *kitem = fLt->AddItem(parent, kobj->GetName(), kobj);
2694  if (kitem) {
2695  obj = kobj;
2696  useLock = kFALSE;
2697  kitem->SetUserData(kobj);
2698  fListLevel = kitem;
2699  } else
2700  fListLevel = parent;
2701  }
2702  }
2704  }
2705  }
2706 
2707  if (browsable) {
2708  if (useLock) fTreeLock = kTRUE;
2709  Emit("BrowseObj(TObject*)", (Long_t)obj);
2710  if (obj) obj->Browse(fBrowser);
2711  if (useLock) fTreeLock = kFALSE;
2712  }
2713 
2714 out:
2715  if (obj && obj->IsA() != TSystemFile::Class()) {
2716  if (obj->IsFolder()) {
2717  fIconBox->Refresh();
2718  }
2719 
2720  if (fBrowser) {
2722  }
2723 
2726  }
2727  }
2728 }
2729 
2730 ////////////////////////////////////////////////////////////////////////////////
2731 /// Recursively remove object from browser.
2732 
2734 {
2735  // don't delete fIconBox items here (it's status will be updated
2736  // via TBrowser::Refresh() which should be called once all objects have
2737  // been removed.
2738 
2739  TGListTreeItem *item = fLt->FindItemByObj(fLt->GetFirstItem(), obj);
2740  if (item == 0)
2741  return;
2742  if (fListLevel && (item == fListLevel)) {
2743  TGListTreeItem *parent = item->GetParent();
2744  if (parent) {
2745  fListLevel = parent;
2746  fLt->ClearHighlighted();
2749  }
2750  else
2751  fListLevel = 0;
2752  }
2753  DeleteListTreeItem(item);
2754 }
2755 
2756 ////////////////////////////////////////////////////////////////////////////////
2757 /// Refresh the browser contents.
2758 
2760 {
2761  Bool_t refresh = fBrowser && fBrowser->GetRefreshFlag();
2762 
2763  if (fTextEdit && !gROOT->IsExecutingMacro() && force) {
2766  return;
2767  }
2768 
2769  if ( (refresh || force) && !fIconBox->WasGrouped()
2770  && fIconBox->NumItems()<fIconBox->GetGroupSize() ) {
2771 
2772  TRootBrowserCursorSwitcher cursorSwitcher(fIconBox, fLt);
2773  static UInt_t prev = 0;
2774  UInt_t curr = gROOT->GetListOfBrowsables()->GetSize();
2775  if (!prev) prev = curr;
2776 
2777  if (prev != curr) { // refresh gROOT
2778  TGListTreeItem *sav = fListLevel;
2779  fListLevel = 0;
2780  BrowseObj(gROOT);
2781  fListLevel = sav;
2782  prev = curr;
2783  }
2784 
2785  // Refresh the IconBox
2786  if (fListLevel) {
2787  TObject *obj = (TObject *)fListLevel->GetUserData();
2788  if (obj) {
2789  fTreeLock = kTRUE;
2790  BrowseObj(obj);
2791  fTreeLock = kFALSE;
2792  }
2793  }
2794  }
2796 }
2797 
2798 ////////////////////////////////////////////////////////////////////////////////
2799 /// Show or hide toolbar.
2800 
2802 {
2803  if (show) {
2807  } else {
2811  }
2812 }
2813 
2814 ////////////////////////////////////////////////////////////////////////////////
2815 /// Show or hide statusbar.
2816 
2818 {
2819  if (show) {
2822  } else {
2825  }
2826 }
2827 
2828 ////////////////////////////////////////////////////////////////////////////////
2829 /// Set defaults depending on settings in the user's .rootrc.
2830 
2831 void TRootBrowserLite::SetDefaults(const char *iconStyle, const char *sortBy)
2832 {
2833  const char *opt;
2834 
2835  // IconStyle: big, small, list, details
2836  if (iconStyle)
2837  opt = iconStyle;
2838  else
2839  opt = gEnv->GetValue("Browser.IconStyle", "small");
2840  if (!strcasecmp(opt, "big"))
2842  else if (!strcasecmp(opt, "small"))
2844  else if (!strcasecmp(opt, "list"))
2846  else if (!strcasecmp(opt, "details"))
2848  else
2850 
2851  // SortBy: name, type, size, date
2852  if (sortBy)
2853  opt = sortBy;
2854  else
2855  opt = gEnv->GetValue("Browser.SortBy", "name");
2856  if (!strcasecmp(opt, "name"))
2858  else if (!strcasecmp(opt, "type"))
2860  else if (!strcasecmp(opt, "size"))
2862  else if (!strcasecmp(opt, "date"))
2864  else
2866 
2867  fIconBox->Refresh();
2868 }
2869 
2870 ////////////////////////////////////////////////////////////////////////////////
2871 /// Set iconbox's view mode and update menu and toolbar buttons accordingly.
2872 
2874 {
2875  int i, bnum;
2876  EListViewMode lv;
2877 
2878  if (force || (fViewMode != new_mode)) {
2879 
2880  switch (new_mode) {
2881  default:
2882  if (!force)
2883  return;
2884  else
2885  new_mode = kViewLargeIcons;
2886  // intentionally no break
2887  case kViewLargeIcons:
2888  bnum = 2;
2889  lv = kLVLargeIcons;
2890  break;
2891  case kViewSmallIcons:
2892  bnum = 3;
2893  lv = kLVSmallIcons;
2894  break;
2895  case kViewList:
2896  bnum = 4;
2897  lv = kLVList;
2898  break;
2899  case kViewDetails:
2900  bnum = 5;
2901  lv = kLVDetails;
2902  break;
2903  }
2904 
2905  fViewMode = new_mode;
2907 
2908  for (i = 2; i <= 5; ++i)
2909  gToolBarData[i].fButton->SetState((i == bnum) ? kButtonEngaged : kButtonUp);
2910 
2911  fListView->SetViewMode(lv);
2912  TGTextButton** buttons = fListView->GetHeaderButtons();
2913  if ((lv == kLVDetails) && (buttons)) {
2914  if (!strcmp(fListView->GetHeader(1), "Attributes")) {
2915  buttons[0]->Connect("Clicked()", "TRootBrowserLite", this,
2916  TString::Format("SetSortMode(=%d)", kViewArrangeByName));
2917  buttons[1]->Connect("Clicked()", "TRootBrowserLite", this,
2918  TString::Format("SetSortMode(=%d)", kViewArrangeByType));
2919  buttons[2]->Connect("Clicked()", "TRootBrowserLite", this,
2920  TString::Format("SetSortMode(=%d)", kViewArrangeBySize));
2921  buttons[5]->Connect("Clicked()", "TRootBrowserLite", this,
2922  TString::Format("SetSortMode(=%d)", kViewArrangeByDate));
2923  }
2924  }
2925  fIconBox->AdjustPosition();
2926  }
2927 }
2928 
2929 ////////////////////////////////////////////////////////////////////////////////
2930 /// Set iconbox's sort mode and update menu radio buttons accordingly.
2931 
2933 {
2934  EFSSortMode smode;
2935 
2936  switch (new_mode) {
2937  default:
2938  new_mode = kViewArrangeByName;
2939  // intentionally no break
2940  case kViewArrangeByName:
2941  smode = kSortByName;
2942  break;
2943  case kViewArrangeByType:
2944  smode = kSortByType;
2945  break;
2946  case kViewArrangeBySize:
2947  smode = kSortBySize;
2948  break;
2949  case kViewArrangeByDate:
2950  smode = kSortByDate;
2951  break;
2952  }
2953 
2954  fSortMode = new_mode;
2956 
2957  fIconBox->Sort(smode);
2958 }
2959 
2960 ////////////////////////////////////////////////////////////////////////////////
2961 /// starts serach dialog
2962 
2964 {
2965  if (!fTextEdit) {
2966  fIconBox->Search(kFALSE);
2967  } else {
2969  }
2970 }
2971 
2972 ////////////////////////////////////////////////////////////////////////////////
2973 /// test
2974 
2975 static Bool_t isBinary(const char *str, int len)
2976 {
2977  for (int i = 0; i < len; i++) {
2978  char c = str[i];
2979  if (((c < 32) || (c > 126)) && (c != '\t') && (c != '\r') && (c != '\n')) {
2980  return kTRUE;
2981  }
2982  }
2983  return kFALSE;
2984 }
2985 
2986 ////////////////////////////////////////////////////////////////////////////////
2987 /// hide text edit
2988 
2990 {
2991  if (!fTextEdit) return;
2992 
2997  TGButton *savbtn = fToolBar->GetButton(kViewSave);
2998  savbtn->Disconnect();
3000  delete fTextEdit;
3001  fTextEdit = 0;
3003  fV2->MapSubwindows();
3004  fV2->Layout();
3006  fTextFileName = "";
3007 }
3008 
3009 ////////////////////////////////////////////////////////////////////////////////
3010 /// browse text file
3011 
3012 void TRootBrowserLite::BrowseTextFile(const char *file)
3013 {
3014  Bool_t loaded = (fTextEdit != 0);
3015  if (gSystem->AccessPathName(file, kReadPermission)) {
3016  if (loaded) {
3017  HistoryBackward();
3018  }
3019  return;
3020  }
3021  const int bufferSize = 1024;
3022  char buffer[bufferSize];
3023 
3024  FILE *fd = fopen(file, "rb");
3025  if (fd == 0) {
3026  if (loaded) {
3027  HistoryBackward();
3028  }
3029  return;
3030  }
3031  int sz = fread(buffer, 1, bufferSize, fd);
3032  fclose(fd);
3033 
3034  if ((sz > 0) && isBinary(buffer, sz)) {
3035  if (loaded) {
3036  HistoryBackward();
3037  }
3038  return;
3039  }
3040 
3041  if (!fTextEdit) {
3044  TColor *col = gROOT->GetColor(19);
3045  if (col)
3046  fTextEdit->SetBackgroundColor(col->GetPixel());
3048  TGSearchDialog::SearchDialog()->Connect("TextEntered(char *)", "TGTextEdit",
3049  fTextEdit, "Search(char *,Bool_t,Bool_t)");
3050  }
3052  TGButton *savbtn = fToolBar->GetButton(kViewSave);
3053  savbtn->Connect("Released()", "TGTextEdit", fTextEdit, "SaveFile(=0,kTRUE)");
3054  }
3055  fTextFileName = file;
3056  fTextEdit->LoadFile(file);
3057  if (loaded) return;
3058 
3059  if (fTextFileName.EndsWith(".C")) {
3060  ShowMacroButtons();
3061  } else {
3063  }
3066  fTextEdit->MapWindow();
3067  fV2->MapSubwindows();
3068  fV2->Layout();
3070 
3071  if (fListLevel) {
3073  }
3075 
3076  if (btn) {
3077  btn->SetState(kButtonDisabled);
3078  }
3079 
3081 
3082  if (btn2) {
3083  btn2->SetState(kButtonUp);
3084  }
3085 }
3086 
3087 ////////////////////////////////////////////////////////////////////////////////
3088 /// executed browsed text macro
3089 
3091 {
3092  char *tmpfile = gSystem->ConcatFileName(gSystem->TempDirectory(),
3093  fTextFileName.Data());
3094 
3095  gROOT->SetExecutingMacro(kTRUE);
3096  fTextEdit->SaveFile(tmpfile, kFALSE);
3097  gROOT->Macro(tmpfile);
3098  gSystem->Unlink(tmpfile);
3099  delete [] tmpfile;
3100  gROOT->SetExecutingMacro(kFALSE);
3101 }
3102 
3103 ////////////////////////////////////////////////////////////////////////////////
3104 /// interrupt browsed macro execution
3105 
3107 {
3108  gROOT->SetInterrupt(kTRUE);
3109 }
3110 
3111 ////////////////////////////////////////////////////////////////////////////////
3112 /// show/hide macro buttons
3113 
3115 {
3119 
3120  static Bool_t connected = kFALSE;
3121 
3122  if (!show) {
3123  bt1->UnmapWindow();
3124  bt2->UnmapWindow();
3125  bt3->UnmapWindow();
3126  } else {
3127  bt1->MapWindow();
3128  bt2->MapWindow();
3129  bt3->MapWindow();
3130 
3131  if (!connected && fTextEdit) {
3132  bt1->Connect("Pressed()", "TRootBrowserLite", this, "ExecMacro()");
3133  bt2->Connect("Pressed()", "TRootBrowserLite", this, "InterruptMacro()");
3134  connected = kTRUE;
3135  }
3136  }
3137 }
3138 
3139 ////////////////////////////////////////////////////////////////////////////////
3140 /// Set text in column col in status bar.
3141 
3142 void TRootBrowserLite::SetStatusText(const char *txt, Int_t col)
3143 {
3145  TGStatusBar* status = GetStatusBar();
3146  if (status!=0) {
3147  status->SetText(txt, col);
3148  }
3149 }
3150 
3151 ////////////////////////////////////////////////////////////////////////////////
3152 /// Interface method to the old browser.
3153 
3155  UInt_t width, UInt_t height,
3156  Option_t * /*opt*/)
3157 {
3158  TRootBrowserLite *browser = new TRootBrowserLite(b, title, width, height);
3159  return (TBrowserImp *)browser;
3160 }
3161 
3162 ////////////////////////////////////////////////////////////////////////////////
3163 /// Interface method to the old browser.
3164 
3166  Int_t y, UInt_t width, UInt_t height,
3167  Option_t * /*opt*/)
3168 {
3169  TRootBrowserLite *browser = new TRootBrowserLite(b, title, x, y, width, height);
3170  return (TBrowserImp *)browser;
3171 }
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1172
const TGString * GetPath() const
Definition: TGFSComboBox.h:65
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:51
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:1264
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:133
virtual Bool_t IsAbsoluteFileName(const char *dir)
Return true if dir is an absolute pathname.
Definition: TSystem.cxx:945
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
action
Definition: ROOT.py:93
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:404
const char * GetClassName() const
Definition: TRemoteObject.h:62
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:892
Int_t fDataLength
Definition: TGDNDManager.h:80
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
Definition: TBufferFile.h:51
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:459
Utility class for browsing TMapFile objects.
Definition: TKeyMapFile.h:22
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:20
virtual UInt_t GetHeight() const
Definition: TImage.h:245
Int_t fY
Definition: TGDimension.h:53
virtual void AdjustHeaders()
Definition: TGListView.h:178
virtual const char * WorkingDirectory()
Return working directory.
Definition: TSystem.cxx:865
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:204
virtual TGFrame * GetContainer() const
Definition: TGListBox.h:343
Collectable string class.
Definition: TObjString.h:32
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:199
virtual UInt_t GetWidth() const
Definition: TImage.h:244
virtual const char * GetIconName() const
Returns mime type name of object.
Definition: TObject.cxx:425
virtual Bool_t IsValid() const
Definition: TImage.h:246
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition: TString.h:635
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
#define gDirectory
Definition: TDirectory.h:218
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
virtual const char * GetClassName() const
Definition: TKey.h:77
UInt_t GetHeight() const
Definition: TGFrame.h:288
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:45
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition: TList.cxx:580
R__EXTERN const char gHelpPullDownMenus[]
Definition: HelpText.h:23
virtual Bool_t IsEntryChecked(Int_t id)
Return true if menu item is checked.
Definition: TGMenu.cxx:1835
EListViewMode
Definition: TGListView.h:45
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:352
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:582
TGToolBar * fToolBar
virtual void Associate(const TGWindow *w)
Definition: TGCanvas.h:101
Basic string class.
Definition: TString.h:137
#define gClient
Definition: TGClient.h:174
static Pixel_t fgWhitePixel
Definition: TGFrame.h:166
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:1088
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:996
bool Bool_t
Definition: RtypesCore.h:59
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:389
const Bool_t kFALSE
Definition: Rtypes.h:92
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:502
An abstract interface to image processing library.
Definition: TImage.h:45
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:188
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:604
R__EXTERN TApplication * gApplication
Definition: TApplication.h:171
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:287
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:444
virtual void AddSeparator(TGMenuEntry *before=0)
Add a menu separator to the menu.
Definition: TGMenu.cxx:1057
Handle_t GetId() const
Definition: TGObject.h:52
Bool_t IsDragging() const
Definition: TGDNDManager.h:177
TGLayoutHints * fMenuBarLayout
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
TGListTreeItem * GetSelected() const
Definition: TGListTree.h:403
R__EXTERN const char gHelpAbout[]
Definition: HelpText.h:16
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition: TString.cxx:605
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition: TObject.cxx:732
virtual Pixmap_t GetPixmap()
Definition: TImage.h:251
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:1036
R__EXTERN TGDNDManager * gDNDManager
Definition: TGDNDManager.h:205
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:725
virtual void Scale(UInt_t, UInt_t)
Definition: TImage.h:157
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:1345
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:187
TGLayoutHints * fExpandLayout
THashTable implements a hash table to store TObject&#39;s.
Definition: THashTable.h:39
Double_t x[n]
Definition: legend1.C:17
R__EXTERN const char gHelpBrowserLite[]
Definition: HelpText.h:18
The TRemoteObject class provides protocol for browsing ROOT objects from a remote ROOT session...
Definition: TRemoteObject.h:42
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:2334
TGPicturePool * GetPicturePool() const
Definition: TGClient.h:143
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
Int_t bsize[]
Definition: SparseFit4.cxx:31
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:100
const char ** fFileTypes
Definition: TGFileDialog.h:65
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:128
void SetToolTipItem(TGListTreeItem *item, const char *string)
Set tooltip text for this item.
TGTextButton ** GetHeaderButtons()
Definition: TGListView.h:183
virtual Bool_t IsActive() const =0
const char * GetKeyClassName() const
Definition: TRemoteObject.h:64
Handle_t Atom_t
Definition: GuiTypes.h:38
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:257
TGPopupMenu * fHelpMenu
virtual void AddToBox(TObject *obj, const char *name)
Add items to the iconbox of the browser.
void * fData
Definition: TGDNDManager.h:79
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2220
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Definition: TMath.h:1002
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:185
virtual void BrowseObj(TObject *obj)
Browse object.
virtual TList * GetList() const
Definition: TGFrame.h:385
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:1446
Book space in a file, create I/O buffers, to fill them, (un)compress them.
Definition: TKey.h:30
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:1990
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition: TVirtualPad.h:59
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:151
TGMimeTypes * GetMimeTypeList() const
Definition: TGClient.h:163
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:559
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:47
const char * pwd()
Definition: TSystem.h:415
virtual TGListBox * GetListBox() const
Definition: TGComboBox.h:132
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:98
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
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:1135
TGLayoutHints * fBarLayout
void SetUserData(void *userData)
Definition: TGListView.h:118
void SetDNDSource(Bool_t onoff)
Definition: TGFrame.h:331
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:129
EMouseButton
Definition: GuiTypes.h:215
TList * fList
Definition: TGFrame.h:367
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:556
virtual UInt_t GetDefaultWidth() const
Definition: TGFrame.h:387
R__EXTERN TSystem * gSystem
Definition: TSystem.h:549
TGHorizontal3DLine * fToolBarSep
void Popup()
Show help dialog.
EGEventType fType
Definition: GuiTypes.h:176
Bool_t fMultipleSelection
Definition: TGFileDialog.h:68
R__EXTERN const char gHelpCanvas[]
Definition: HelpText.h:24
void * GetUserData() const
Definition: TGListView.h:119
Int_t GET_SUBMSG(Long_t val)
TGListTreeItem * GetNextSibling() const
Definition: TGListTree.h:83
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:480
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:90
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:674
virtual void Associate(const TGWindow *w)
Definition: TGMenu.h:227
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:487
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:558
virtual TObject * Before(const TObject *obj) const
Returns the object before object obj.
Definition: TList.cxx:321
void SetRefreshFlag(Bool_t flag)
Definition: TBrowser.h:101
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:918
char * Form(const char *fmt,...)
void ClearHighlighted()
Un highlight items.
Ssiz_t Length() const
Definition: TString.h:390
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition: TGPicture.cxx:79
EFSSortMode
Definition: TGFSContainer.h:36
TGFrame * fFrame
Definition: TGLayout.h:125
void ExecMacro()
executed browsed text macro
TList * fFileNamesList
Definition: TGFileDialog.h:69
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
virtual TObject * After(const TObject *obj) const
Returns the object after object obj.
Definition: TList.cxx:288
virtual Int_t Exec(const char *shellcmd)
Execute a command.
Definition: TSystem.cxx:657
virtual void Update(const char *path)
Update file system combo box.
Int_t fX
Definition: TGDimension.h:52
Bool_t GetRefreshFlag() const
Definition: TBrowser.h:99
TGHorizontalFrame * fHf
Bool_t HistoryBackward()
go to the past
Atom_t fDataType
Definition: TGDNDManager.h:77
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:92
TGComboBox * fDrawOption
TString GetString() const
Definition: TObjString.h:50
#define gVirtualX
Definition: TVirtualX.h:362
R__EXTERN const char gHelpObjects[]
Definition: HelpText.h:25
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:2513
Int_t GET_MSG(Long_t val)
const char * GetString() const
Definition: TGString.h:44
EKeySym
Definition: KeySymbols.h:27
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:140
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
long Long_t
Definition: RtypesCore.h:50
virtual void Modified(Bool_t flag=1)=0
TGListTreeItem * GetParent() const
Definition: TGListTree.h:79
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:132
virtual void SetDefaults(const char *iconStyle=0, const char *sortBy=0)
Set defaults depending on settings in the user&#39;s .rootrc.
Bool_t IsOnHeap() const
Definition: TObject.h:140
#define ClassImp(name)
Definition: Rtypes.h:279
double f(double x)
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:123
virtual Pixmap_t GetMask()
Definition: TImage.h:252
virtual void AddEntry(TGString *s, Int_t id)
Definition: TGComboBox.h:108
virtual void RemoveCheckBox(TObject *obj)
Remove checkbox from TGListTree and checkmark from TGListView.
TObject * fHistoryCursor
Describe directory structure in memory.
Definition: TDirectory.h:41
virtual void FromPad(TVirtualPad *, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0)
Definition: TImage.h:138
TGListTreeItem * GetFirstChild() const
Definition: TGListTree.h:80
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:174
unsigned long ULong_t
Definition: RtypesCore.h:51
char * fFilename
Definition: TGFileDialog.h:63
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:22
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:1293
void HideTextEdit()
hide text edit
The color creation and management class.
Definition: TColor.h:23
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:2871
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Definition: TList.cxx:348
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:387
Handle_t fId
Definition: TGObject.h:40
#define name(a, b)
Definition: linkTestLib0.cpp:5
virtual Int_t GetNumberOfEntries() const
Definition: TGComboBox.h:129
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:85
Mother of all ROOT objects.
Definition: TObject.h:58
virtual void SetHeaders(Int_t ncolumns)
Set number of headers, i.e.
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:459
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition: TClass.cxx:5541
A TSystemFile describes an operating system file.
Definition: TSystemFile.h:31
virtual void UnmapWindow()
Definition: TGFrame.h:269
virtual void Destructor()
Actual browser destructor.
Definition: TBrowser.cxx:244
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:81
const Ssiz_t kNPOS
Definition: Rtypes.h:115
static TGuiBuilder * Instance()
return an instance of TGuiBuilder object
virtual void MapWindow()
Definition: TGFrame.h:267
static Bool_t isBinary(const char *str, int len)
test
TGClient * fClient
Definition: TGObject.h:41
void SetAutoTips(Bool_t on=kTRUE)
Definition: TGListTree.h:372
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:232
TLine * lv
Definition: textalign.C:5
const char * fPixmap
Definition: TGToolBar.h:35
void NeedRedraw(TGWindow *w, Bool_t force=kFALSE)
Set redraw flags.
Definition: TGClient.cxx:370
#define gPad
Definition: TVirtualPad.h:288
UInt_t fState
Definition: GuiTypes.h:182
Atom_t * fDNDTypeList
Definition: TGFrame.h:498
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:517
R__EXTERN const char gHelpRemote[]
Definition: HelpText.h:27
virtual void Refresh(Bool_t force=kFALSE)
Refresh the browser contents.
static const TString & GetBinDir()
Get the binary directory in the installation. Static utility function.
Definition: TROOT.cxx:2538
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 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:37
virtual Bool_t HandleKey(Event_t *event)
handle keys
Short_t GetCycle() const
Return cycle number associated to this key.
Definition: TKey.cxx:561
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:415
virtual Int_t GetSize() const
Definition: TCollection.h:95
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:402
TBrowser * fBrowser
Definition: TBrowserImp.h:34
virtual void DeleteWindow()
Delete window.
Definition: TGFrame.cxx:258
const Bool_t kTRUE
Definition: Rtypes.h:91
friend class TRootIconBox
void DisplayDirectory()
Display current directory in second label, fLbl2.
Int_t GetLength() const
Definition: TGString.h:43
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
Definition: TSystem.cxx:1044
TContextMenu * GetContextMenu() const
Definition: TBrowser.h:98
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:258
void ToSystemDirectory(const char *dirname)
display directory
void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition: TBrowser.h:107
virtual void DestroyWindow()
Definition: TGWindow.h:94
Int_t RecursiveDeleteItem(TGListTreeItem *item, void *userData)
Delete item with fUserData == ptr.
if(line.BeginsWith("/*"))
Definition: HLFactory.cxx:443
TGPopupMenu * fOptionMenu
char * fIniDir
Definition: TGFileDialog.h:64
ABC describing GUI independent browser implementation protocol.
Definition: TBrowserImp.h:31
virtual void SetState(EButtonState state, Bool_t emit=kFALSE)
Set button state.
Definition: TGButton.cxx:185
virtual TGLBEntry * GetSelectedEntry() const
Definition: TGComboBox.h:137
const TGPicture * fIconPic
const char * Data() const
Definition: TString.h:349
#define gFile
Definition: TFile.h:307