ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
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) {
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) {
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) {
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;
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;
1966 # ifdef ROOTBINDIR
1967  rootx = ROOTBINDIR;
1968 # else
1969  rootx = gSystem->Getenv("ROOTSYS");
1970  if (!rootx.IsNull()) rootx += "/bin";
1971 # endif
1972  rootx += "/root -a &";
1973  gSystem->Exec(rootx);
1974 #else
1975 #ifdef WIN32
1977 #else
1978  char str[32];
1979  sprintf(str, "About ROOT %s...", gROOT->GetVersion());
1980  hd = new TRootHelpDialog(this, str, 600, 400);
1981  hd->SetText(gHelpAbout);
1982  hd->Popup();
1983 #endif
1984 #endif
1985  }
1986  break;
1987  case kHelpOnCanvas:
1988  hd = new TRootHelpDialog(this, "Help on Canvas...", 600, 400);
1989  hd->SetText(gHelpCanvas);
1990  hd->Popup();
1991  break;
1992  case kHelpOnMenus:
1993  hd = new TRootHelpDialog(this, "Help on Menus...", 600, 400);
1995  hd->Popup();
1996  break;
1997  case kHelpOnGraphicsEd:
1998  hd = new TRootHelpDialog(this, "Help on Graphics Editor...", 600, 400);
2000  hd->Popup();
2001  break;
2002  case kHelpOnBrowser:
2003  hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
2005  hd->Popup();
2006  break;
2007  case kHelpOnObjects:
2008  hd = new TRootHelpDialog(this, "Help on Objects...", 600, 400);
2009  hd->SetText(gHelpObjects);
2010  hd->Popup();
2011  break;
2012  case kHelpOnPS:
2013  hd = new TRootHelpDialog(this, "Help on PostScript...", 600, 400);
2014  hd->SetText(gHelpPostscript);
2015  hd->Popup();
2016  break;
2017  case kHelpOnRemote:
2018  hd = new TRootHelpDialog(this, "Help on Browser...", 600, 400);
2019  hd->SetText(gHelpRemote);
2020  hd->Popup();
2021  break;
2022  default:
2023  break;
2024  }
2025  break;
2026  case kCM_COMBOBOX:
2027  if (parm1 == kFSComboBox) {
2029  if (e) {
2030  const char *dirname = e->GetPath()->GetString();
2031  item = fLt->FindItemByPathname(dirname);
2032  if (item) {
2033  fListLevel = item;
2035  DisplayDirectory();
2037  } else {
2038  ToSystemDirectory(dirname);
2039  }
2040  }
2041  }
2042  break;
2043  default:
2044  break;
2045  }
2046 
2047  break;
2048 
2049  case kC_LISTTREE:
2050  switch (GET_SUBMSG(msg)) {
2051 
2052  case kCT_ITEMCLICK:
2053  // tell coverity that parm1 is a Long_t, and not an enum (even
2054  // if we compare it with an enum value) and the meaning of
2055  // parm1 depends on GET_MSG(msg) and GET_SUBMSG(msg)
2056  // coverity[mixed_enums]
2057  if (((EMouseButton)parm1 == kButton1) ||
2058  ((EMouseButton)parm1 == kButton3)) {
2059  HideTextEdit();
2060  TGListTreeItem *item2;
2061  TObject *obj2 = 0;
2062  if ((item2 = fLt->GetSelected()) != 0 ) {
2063  ListTreeHighlight(item2);
2064  fStatusBar->SetText("", 1); // clear
2065  }
2066  if (item2 && parm1 == kButton3) {
2067  Int_t x = (Int_t)(parm2 & 0xffff);
2068  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2069  obj2 = (TObject *) item2->GetUserData();
2070  if (obj2) {
2071  if (obj2->InheritsFrom("TTree")) {
2072  // if a tree not attached to any directory (e.g. in a TFolder)
2073  // then attach it to the current directory (gDirectory)
2074  cmd = TString::Format("((TTree *)0x%lx)->GetDirectory();",
2075  (ULong_t)obj2);
2076  tdir = (TDirectory *)gROOT->ProcessLine(cmd.Data());
2077  if (!tdir) {
2078  cmd = TString::Format("((TTree *)0x%lx)->SetDirectory(gDirectory);",
2079  (ULong_t)obj2);
2080  gROOT->ProcessLine(cmd.Data());
2081  }
2082  }
2083  fBrowser->GetContextMenu()->Popup(x, y, obj2, fBrowser);
2084  }
2085  }
2087  fListView->LayoutHeader(0);
2088  fListView->Layout();
2089  }
2090  break;
2091 
2092  case kCT_ITEMDBLCLICK:
2093  if (parm1 == kButton1) {
2094  if (fBrowseTextFile) {
2095  HideTextEdit();
2096  }
2097  if (fListLevel && fIconBox->WasGrouped()) {
2098  TObject *obj2;
2099  TGListTreeItem *item2;
2100 
2101  if (fListLevel) {
2102  item2 = fListLevel->GetParent();
2103  if (item2) fListLevel = item2;
2104 
2105  obj2 = (TObject *) fListLevel->GetUserData();
2107  if (obj2) {
2108  BrowseObj(obj2);
2109  }
2110  }
2111  break;
2112  }
2113  }
2114 
2115  default:
2116  break;
2117  }
2118  break;
2119 
2120  case kC_CONTAINER:
2121  switch (GET_SUBMSG(msg)) {
2122 
2123  case kCT_ITEMCLICK:
2124  if (fIconBox->NumSelected() == 1) {
2125  // display title of selected object
2126  TGFileItem *item2;
2127  void *p = 0;
2128  if ((item2 = (TGFileItem *)fIconBox->GetNextSelected(&p)) != 0) {
2129  TObject *obj2 = (TObject *)item2->GetUserData();
2130 
2131  TGListTreeItem *itm = 0;
2132  if (!fListLevel) itm = fLt->GetFirstItem();
2133  else itm = fListLevel->GetFirstChild();
2134  //Bool_t found = kFALSE;
2135 
2136  while (itm) {
2137  if (itm->GetUserData() == obj2) break;
2138  itm = itm->GetNextSibling();
2139  }
2140 
2141  if (itm) {
2142  if ((fListLevel && fListLevel->IsOpen()) || !fListLevel) {
2143  fLt->ClearHighlighted();
2144  fLt->HighlightItem(itm);
2146  }
2147  }
2148 
2149  if (obj2) fStatusBar->SetText(obj2->GetName(), 1);
2150  }
2151  }
2152  if (parm1 == kButton3) {
2153  // show context menu for selected object
2154  if (fIconBox->NumSelected() == 1) {
2155  void *p = 0;
2156  TGFileItem *item2;
2157  if ((item2 = (TGFileItem *) fIconBox->GetNextSelected(&p)) != 0) {
2158  Int_t x = (Int_t)(parm2 & 0xffff);
2159  Int_t y = (Int_t)((parm2 >> 16) & 0xffff);
2160  TObject *obj2 = (TObject *)item2->GetUserData();
2161  if (obj2) {
2162  if (obj2->IsA() == TKey::Class()) {
2163  TKey *key = (TKey*)obj2;
2164  TClass *cl = TClass::GetClass(key->GetClassName());
2165  TString name = key->GetName();
2166  name += ";";
2167  name += key->GetCycle();
2168  //void *add = gROOT->FindObject((char *) name.Data());//key->GetName());
2169  void *add = gDirectory->FindObjectAny((char *) name.Data());
2170  if (cl->IsTObject()) {
2171  obj2 = (TObject*)add; // cl->DynamicCast(TObject::Class(),startadd);
2172  item2->SetUserData(obj2);
2173  } else {
2174  Error("ProcessMessage","do not support non TObject (like %s) yet",
2175  cl->GetName());
2176  break;
2177  }
2178  }
2179  if (obj2 && obj2->InheritsFrom("TTree")) {
2180  // if a tree not attached to any directory (e.g. in a TFolder)
2181  // then attach it to the current directory (gDirectory)
2182  cmd = TString::Format("((TTree *)0x%lx)->GetDirectory();",
2183  (ULong_t)obj2);
2184  tdir = (TDirectory *)gROOT->ProcessLine(cmd.Data());
2185  if (!tdir) {
2186  cmd = TString::Format("((TTree *)0x%lx)->SetDirectory(gDirectory);",
2187  (ULong_t)obj2);
2188  gROOT->ProcessLine(cmd.Data());
2189  }
2190  }
2191  fBrowser->GetContextMenu()->Popup(x, y, obj2, fBrowser);
2192  }
2193  }
2194  }
2195  }
2196  break;
2197  case kCT_ITEMDBLCLICK:
2198  if (parm1 == kButton1) {
2199  if (fIconBox->NumSelected() == 1) {
2200  void *p = 0;
2201  TGFileItem *item2;
2202  if ((item2 = (TGFileItem *) fIconBox->GetNextSelected(&p)) != 0) {
2203  TObject *obj2 = (TObject *)item2->GetUserData();
2204  if (obj2) {
2205  DoubleClicked(obj2);
2206  IconBoxAction(obj2);
2207  }
2208  delete cursorSwitcher;
2209  return kTRUE; //
2210  }
2211  }
2212  }
2213  break;
2214  case kCT_SELCHANGED:
2215  DisplayTotal((Int_t)parm1, (Int_t)parm2);
2216  break;
2217  default:
2218  break;
2219  }
2220 
2221  break;
2222 
2223  default:
2224  break;
2225  }
2226 
2227  delete cursorSwitcher;
2228 
2230  return kTRUE;
2231 }
2232 
2233 ////////////////////////////////////////////////////////////////////////////////
2234 /// Make object associated with item the current directory.
2235 
2237 {
2238  if (item) {
2239  TGListTreeItem *i = item;
2240  TString dir;
2241  while (i) {
2242  TObject *obj = (TObject*) i->GetUserData();
2243  if (obj) {
2244  if (obj->IsA() == TDirectoryFile::Class()) {
2245  dir = "/" + dir;
2246  dir = obj->GetName() + dir;
2247  }
2248  if (obj->IsA() == TFile::Class()) {
2249  dir = ":/" + dir;
2250  dir = obj->GetName() + dir;
2251  }
2252  if (obj->IsA() == TKey::Class()) {
2253  if (strcmp(((TKey*)obj)->GetClassName(), "TDirectoryFile") == 0) {
2254  dir = "/" + dir;
2255  dir = obj->GetName() + dir;
2256  }
2257  }
2258  }
2259  i = i->GetParent();
2260  }
2261 
2262  if (gDirectory && dir.Length()) gDirectory->cd(dir.Data());
2263  }
2264 }
2265 
2266 ////////////////////////////////////////////////////////////////////////////////
2267 /// helper method to track history
2268 
2270 {
2271  if (!fListLevel) return;
2272 
2273  fLt->ClearHighlighted();
2275 }
2276 
2277 ////////////////////////////////////////////////////////////////////////////////
2278 /// helper method to track history
2279 
2281 {
2283 
2284  if (!item || (fHistoryCursor &&
2285  (item == ((TRootBrowserHistoryCursor*)fHistoryCursor)->fItem))) return;
2286 
2287  TRootBrowserHistoryCursor *cur = (TRootBrowserHistoryCursor*)fHistoryCursor;
2288 
2289  while ((cur = (TRootBrowserHistoryCursor*)fHistory->After(fHistoryCursor))) {
2290  fHistory->Remove(cur);
2291  delete cur;
2292  }
2293 
2294  cur = new TRootBrowserHistoryCursor(item);
2295  fHistory->Add(cur);
2296  fHistoryCursor = cur;
2297  btn->SetState(kButtonUp);
2298 }
2299 
2300 ////////////////////////////////////////////////////////////////////////////////
2301 /// clear navigation history
2302 
2304 {
2305  fHistory->Delete();
2308  btn->SetState(kButtonDisabled);
2309  btn2->SetState(kButtonDisabled);
2310 }
2311 
2312 ////////////////////////////////////////////////////////////////////////////////
2313 /// go to the past
2314 
2316 {
2317  if (fBrowseTextFile) {
2318  HideTextEdit();
2319  return kFALSE;
2320  }
2321  TRootBrowserHistoryCursor *cur = (TRootBrowserHistoryCursor*)fHistory->Before(fHistoryCursor);
2324 
2325  if (!cur) {
2326  btn->SetState(kButtonDisabled);
2327  return kFALSE;
2328  }
2329 
2330  fLt->ClearHighlighted();
2331  fHistoryCursor = cur;
2332  fListLevel = cur->fItem;
2334  fLt->AdjustPosition();
2336 
2337  btn2->SetState(kButtonUp);
2338  cur = (TRootBrowserHistoryCursor*)fHistory->Before(fHistoryCursor);
2339  if (!cur) {
2340  btn->SetState(kButtonDisabled);
2341  return kFALSE;
2342  }
2343 
2344  return kTRUE;
2345 }
2346 
2347 ////////////////////////////////////////////////////////////////////////////////
2348 /// go to the future
2349 
2351 {
2352  if (fBrowseTextFile) {
2353  HideTextEdit();
2354  return kFALSE;
2355  }
2356 
2357  TRootBrowserHistoryCursor *cur = (TRootBrowserHistoryCursor*)fHistory->After(fHistoryCursor);
2360 
2361  if (!cur) {
2362  btn->SetState(kButtonDisabled);
2363  return kFALSE;
2364  }
2365 
2366  fLt->ClearHighlighted();
2367  fHistoryCursor = cur;
2368  fListLevel = cur->fItem;
2370  fLt->AdjustPosition();
2372 
2373  btn2->SetState(kButtonUp);
2374 
2375  cur = (TRootBrowserHistoryCursor*)fHistory->After(fHistoryCursor);
2376  if (!cur) {
2377  btn->SetState(kButtonDisabled);
2378  return kFALSE;
2379  }
2380 
2381  return kTRUE;
2382 }
2383 
2384 ////////////////////////////////////////////////////////////////////////////////
2385 /// delete list tree item, remove it from history
2386 
2388 {
2389  ((TRootBrowserHistory*)fHistory)->DeleteItem(item);
2390  fLt->DeleteItem(item);
2391 }
2392 
2393 ////////////////////////////////////////////////////////////////////////////////
2394 /// Open tree item and list in iconbox its contents.
2395 
2397 {
2398  if (item) {
2399  TObject *obj = (TObject *) item->GetUserData();
2400 
2401  if (obj) {
2402  if (obj->IsA() == TKey::Class()) {
2403 
2404  TKey *key = (TKey *)obj;
2405  TString name = obj->GetName();
2406  name += ";";
2407  name += key->GetCycle();
2408  Chdir(item->GetParent());
2409  //TObject *k_obj = gROOT->FindObject(name);
2410  TObject *k_obj = gDirectory->FindObjectAny(name);
2411 
2412  if (k_obj) {
2413  item->SetUserData(k_obj);
2414  obj = k_obj;
2415  }
2416  } else if (obj->InheritsFrom(TDirectoryFile::Class())) {
2417  Chdir(item->GetParent());
2418  }
2419  else if (obj->InheritsFrom("TApplicationRemote")) {
2420  if (!gApplication->GetAppRemote()) {
2421  gROOT->ProcessLine(Form(".R %s", item->GetText()));
2422  if (gApplication->GetAppRemote()) {
2423  Getlinem(kInit, TString::Format("\n%s:root [0]",
2425  }
2426  }
2427  }
2428  else if (obj->InheritsFrom("TRemoteObject")) {
2429  // special case for remote object
2430  TRemoteObject *robj = (TRemoteObject *)obj;
2431  // the real object is a TKey
2432  if (!strcmp(robj->GetClassName(), "TKey")) {
2433  TGListTreeItem *parent = item;
2434  TRemoteObject *probj = (TRemoteObject *)parent->GetUserData();
2435  // find the TFile remote object containing the TKey
2436  while ( probj && strcmp(probj->GetClassName(), "TFile")) {
2437  parent = parent->GetParent();
2438  probj = (TRemoteObject *)parent->GetUserData();
2439  }
2440  if (probj) {
2441  // remotely browse file (remotely call TFile::cd())
2444  TString::Format("((TApplicationServer *)gApplication)->BrowseFile(\"%s\");",
2445  probj->GetName()));
2446  }
2447  }
2448  }
2449  if (item->GetParent() && item->GetParent()->GetUserData() &&
2450  ((TObject *)item->GetParent()->GetUserData())->InheritsFrom("TApplicationRemote")) {
2451  // switch to remote session
2452  if (!gApplication->GetAppRemote()) {
2453  gROOT->ProcessLine(Form(".R %s", item->GetParent()->GetText()));
2454  if (gApplication->GetAppRemote()) {
2455  Getlinem(kInit, TString::Format("\n%s:root [0]",
2457  }
2458  }
2459  else if (!strcmp(item->GetText(), "ROOT Files")) {
2460  // update list of files opened in the remote session
2462  gApplication->ProcessLine("((TApplicationServer *)gApplication)->BrowseFile(0);");
2463  }
2464  }
2465  else {
2466  // check if the listtree item is from a local session or
2467  // from a remote session, then switch to the session it belongs to
2468  TGListTreeItem *top = item;
2469  while (top->GetParent()) {
2470  top = top->GetParent();
2471  }
2472  TObject *topobj = (TObject *) top->GetUserData();
2473  if (topobj && topobj->InheritsFrom("TApplicationRemote")) {
2474  // it belongs to a remote session
2475  if (!gApplication->GetAppRemote()) {
2476  // switch to remote session if not already in
2477  gROOT->ProcessLine(Form(".R %s", top->GetText()));
2478  if (gApplication->GetAppRemote()) {
2479  Getlinem(kInit, TString::Format("\n%s:root [0]",
2481  }
2482  }
2483  }
2484  else if (gApplication->GetAppRemote()) {
2485  // switch back to local session if not already in
2486  gApplication->ProcessLine(".R");
2487  Getlinem(kInit, "\nroot [0]");
2488  }
2489  }
2490 
2491  if (!fListLevel || !fListLevel->IsActive()) {
2492  fListLevel = item;
2493  BrowseObj(obj);
2495  }
2496  }
2497  DisplayDirectory();
2498  }
2499 }
2500 
2501 ////////////////////////////////////////////////////////////////////////////////
2502 /// display directory
2503 
2504 void TRootBrowserLite::ToSystemDirectory(const char *dirname)
2505 {
2506  TString dir = dirname;
2507 
2508  if (fListLevel) {
2509  TObject* obj = (TObject*)fListLevel->GetUserData();
2510 
2511  if (obj && (obj->IsA() == TSystemDirectory::Class())) {
2512  TObject* old = obj;
2513  fListLevel->Rename(dir.Data());
2514  obj = new TSystemDirectory(dir.Data(), dir.Data());
2515  while (fListLevel->GetFirstChild())
2518 
2519  fListLevel->SetUserData(obj);
2520  gROOT->GetListOfBrowsables()->Remove(old);
2521  delete old;
2522  gROOT->GetListOfBrowsables()->Add(obj);
2523  fTreeLock = kTRUE;
2524  BrowseObj(obj);
2525  fTreeLock = kFALSE;
2526 
2529  DisplayDirectory();
2530  //gSystem->ChangeDirectory(dir.Data());
2531  fStatusBar->SetText(dir.Data(), 1);
2532  ClearHistory(); // clear browsing history
2533  }
2534  }
2535  return;
2536 }
2537 
2538 ////////////////////////////////////////////////////////////////////////////////
2539 /// sets drawing option
2540 
2542 {
2543  fDrawOption->GetTextEntry()->SetText(option);
2544 }
2545 
2546 ////////////////////////////////////////////////////////////////////////////////
2547 /// returns drawing option
2548 
2550 {
2551  return fDrawOption->GetTextEntry()->GetText();
2552 }
2553 ////////////////////////////////////////////////////////////////////////////////
2554 /// Emits signal when double clicking on icon.
2555 
2557 {
2558  Emit("DoubleClicked(TObject*)", (Long_t)obj);
2559 }
2560 
2561 ////////////////////////////////////////////////////////////////////////////////
2562 /// Emits signal when double clicking on icon.
2563 
2565 {
2566  Long_t args[2];
2567 
2568  args[0] = (Long_t)obj;
2569  args[1] = checked;
2570 
2571  Emit("Checked(TObject*,Bool_t)", args);
2572 }
2573 
2574 ////////////////////////////////////////////////////////////////////////////////
2575 /// Default action when double clicking on icon.
2576 
2578 {
2579  Bool_t browsable = kFALSE;
2580  const char *dirname = 0;
2581  if (obj) {
2582 
2583  TRootBrowserCursorSwitcher cursorSwitcher(fIconBox, fLt);
2584 
2585  Bool_t useLock = kTRUE;
2586 
2587  if (obj->IsA()->GetMethodWithPrototype("Browse", "TBrowser*"))
2588  browsable = kTRUE;
2589 
2590  if (obj->InheritsFrom("TLeaf")) {
2591  TObject *dir = (TObject *)gROOT->ProcessLine(Form("((%s *)0x%lx)->GetBranch()->GetDirectory();",
2592  obj->ClassName(), (ULong_t)obj));
2593  if (!dir) {
2594  browsable = kFALSE;
2595  }
2596  }
2597  if (obj->InheritsFrom("TBranchElement")) {
2598  TObject *dir = (TObject *)gROOT->ProcessLine(Form("((%s *)0x%lx)->GetDirectory();",
2599  obj->ClassName(), (ULong_t)obj));
2600  if (!dir) {
2601  browsable = kFALSE;
2602  }
2603  }
2604 
2605  if (obj->InheritsFrom("TKey")) {
2606  TKey *key = dynamic_cast<TKey*>(obj);
2607  if (key && key->GetClassName() && (!strcmp(key->GetClassName(), "TFormula")))
2608  browsable = kFALSE;
2609  }
2610 
2611  if (obj->IsA() == TSystemDirectory::Class()) {
2612  useLock = kFALSE;
2613 
2614  TString t(obj->GetName());
2615  if (t == ".") goto out;
2616  if (t == "..") {
2617  if (fListLevel && fListLevel->GetParent()) {
2619  obj = (TObject*)fListLevel->GetUserData();
2620  if (fListLevel->GetParent()) {
2622  } else {
2623  obj = (TObject*)fListLevel->GetUserData();
2624  fListLevel = 0;
2625  }
2626  } else {
2627  dirname = gSystem->DirName(gSystem->pwd());
2628  ToSystemDirectory(dirname);
2629  return;
2630  }
2631  }
2632  }
2633 
2634  if (obj && obj->IsFolder()) {
2635  fIconBox->RemoveAll();
2636  TGListTreeItem *itm = 0;
2637 
2638  if (fListLevel) {
2640  itm = fListLevel->GetFirstChild();
2641  } else {
2642  itm = fLt->GetFirstItem();
2643  }
2644 
2645  while (itm && (itm->GetUserData() != obj)) {
2646  itm = itm->GetNextSibling();
2647  }
2648 
2649  if (!itm && fListLevel) {
2650  // special case for remote objects
2651  Bool_t isRemote = kFALSE;
2652  if (obj->InheritsFrom("TRemoteObject"))
2653  isRemote = kTRUE;
2654  else if (fListLevel) {
2655  // check also if one of its parents is a remote object
2656  TGListTreeItem *top = fListLevel;
2657  while (top->GetParent()) {
2658  TObject *tobj = (TObject *) top->GetUserData();
2659  if (tobj && (tobj->InheritsFrom("TRemoteObject") ||
2660  tobj->InheritsFrom("TApplicationRemote"))) {
2661  isRemote = kTRUE;
2662  break;
2663  }
2664  top = top->GetParent();
2665  }
2666  }
2667  if (isRemote) {
2668  // add the remote object only if not already in the list
2669  if ((!fLt->FindChildByName(fListLevel, obj->GetName())) &&
2670  (!fLt->FindChildByData(fListLevel, obj))) {
2671  itm = fLt->AddItem(fListLevel, obj->GetName());
2672  if (itm) itm->SetUserData(obj);
2673  }
2674  else {
2675  // set the current item to the one found in the list
2676  itm = fLt->FindChildByData(fListLevel, obj) ?
2677  fLt->FindChildByData(fListLevel, obj) :
2679  }
2680  }
2681  else {
2682  itm = fLt->AddItem(fListLevel, obj->GetName());
2683  if (itm) itm->SetUserData(obj);
2684  }
2685  }
2686 
2687  if (itm) {
2688  fListLevel = itm;
2689  DisplayDirectory();
2690  TObject *kobj = (TObject *)itm->GetUserData();
2691 
2692  if (kobj && kobj->IsA() == TKey::Class()) {
2694  //kobj = gROOT->FindObject(kobj->GetName());
2695  kobj = gDirectory->FindObjectAny(kobj->GetName());
2696 
2697  if (kobj) {
2698  TGListTreeItem *parent = fListLevel->GetParent();
2700  TGListTreeItem *kitem = fLt->AddItem(parent, kobj->GetName(), kobj);
2701  if (kitem) {
2702  obj = kobj;
2703  useLock = kFALSE;
2704  kitem->SetUserData(kobj);
2705  fListLevel = kitem;
2706  } else
2707  fListLevel = parent;
2708  }
2709  }
2711  }
2712  }
2713 
2714  if (browsable) {
2715  if (useLock) fTreeLock = kTRUE;
2716  Emit("BrowseObj(TObject*)", (Long_t)obj);
2717  if (obj) obj->Browse(fBrowser);
2718  if (useLock) fTreeLock = kFALSE;
2719  }
2720 
2721 out:
2722  if (obj && obj->IsA() != TSystemFile::Class()) {
2723  if (obj->IsFolder()) {
2724  fIconBox->Refresh();
2725  }
2726 
2727  if (fBrowser) {
2729  }
2730 
2733  }
2734  }
2735 }
2736 
2737 ////////////////////////////////////////////////////////////////////////////////
2738 /// Recursively remove object from browser.
2739 
2741 {
2742  // don't delete fIconBox items here (it's status will be updated
2743  // via TBrowser::Refresh() which should be called once all objects have
2744  // been removed.
2745 
2747  if (item == 0)
2748  return;
2749  if (fListLevel && (item == fListLevel)) {
2750  TGListTreeItem *parent = item->GetParent();
2751  if (parent) {
2752  fListLevel = parent;
2753  fLt->ClearHighlighted();
2756  }
2757  else
2758  fListLevel = 0;
2759  }
2760  DeleteListTreeItem(item);
2761 }
2762 
2763 ////////////////////////////////////////////////////////////////////////////////
2764 /// Refresh the browser contents.
2765 
2767 {
2768  Bool_t refresh = fBrowser && fBrowser->GetRefreshFlag();
2769 
2770  if (fTextEdit && !gROOT->IsExecutingMacro() && force) {
2773  return;
2774  }
2775 
2776  if ( (refresh || force) && !fIconBox->WasGrouped()
2777  && fIconBox->NumItems()<fIconBox->GetGroupSize() ) {
2778 
2779  TRootBrowserCursorSwitcher cursorSwitcher(fIconBox, fLt);
2780  static UInt_t prev = 0;
2781  UInt_t curr = gROOT->GetListOfBrowsables()->GetSize();
2782  if (!prev) prev = curr;
2783 
2784  if (prev != curr) { // refresh gROOT
2785  TGListTreeItem *sav = fListLevel;
2786  fListLevel = 0;
2787  BrowseObj(gROOT);
2788  fListLevel = sav;
2789  prev = curr;
2790  }
2791 
2792  // Refresh the IconBox
2793  if (fListLevel) {
2794  TObject *obj = (TObject *)fListLevel->GetUserData();
2795  if (obj) {
2796  fTreeLock = kTRUE;
2797  BrowseObj(obj);
2798  fTreeLock = kFALSE;
2799  }
2800  }
2801  }
2803 }
2804 
2805 ////////////////////////////////////////////////////////////////////////////////
2806 /// Show or hide toolbar.
2807 
2809 {
2810  if (show) {
2814  } else {
2818  }
2819 }
2820 
2821 ////////////////////////////////////////////////////////////////////////////////
2822 /// Show or hide statusbar.
2823 
2825 {
2826  if (show) {
2829  } else {
2832  }
2833 }
2834 
2835 ////////////////////////////////////////////////////////////////////////////////
2836 /// Set defaults depending on settings in the user's .rootrc.
2837 
2838 void TRootBrowserLite::SetDefaults(const char *iconStyle, const char *sortBy)
2839 {
2840  const char *opt;
2841 
2842  // IconStyle: big, small, list, details
2843  if (iconStyle)
2844  opt = iconStyle;
2845  else
2846  opt = gEnv->GetValue("Browser.IconStyle", "small");
2847  if (!strcasecmp(opt, "big"))
2849  else if (!strcasecmp(opt, "small"))
2851  else if (!strcasecmp(opt, "list"))
2853  else if (!strcasecmp(opt, "details"))
2855  else
2857 
2858  // SortBy: name, type, size, date
2859  if (sortBy)
2860  opt = sortBy;
2861  else
2862  opt = gEnv->GetValue("Browser.SortBy", "name");
2863  if (!strcasecmp(opt, "name"))
2865  else if (!strcasecmp(opt, "type"))
2867  else if (!strcasecmp(opt, "size"))
2869  else if (!strcasecmp(opt, "date"))
2871  else
2873 
2874  fIconBox->Refresh();
2875 }
2876 
2877 ////////////////////////////////////////////////////////////////////////////////
2878 /// Set iconbox's view mode and update menu and toolbar buttons accordingly.
2879 
2881 {
2882  int i, bnum;
2883  EListViewMode lv;
2884 
2885  if (force || (fViewMode != new_mode)) {
2886 
2887  switch (new_mode) {
2888  default:
2889  if (!force)
2890  return;
2891  else
2892  new_mode = kViewLargeIcons;
2893  // intentionally no break
2894  case kViewLargeIcons:
2895  bnum = 2;
2896  lv = kLVLargeIcons;
2897  break;
2898  case kViewSmallIcons:
2899  bnum = 3;
2900  lv = kLVSmallIcons;
2901  break;
2902  case kViewList:
2903  bnum = 4;
2904  lv = kLVList;
2905  break;
2906  case kViewDetails:
2907  bnum = 5;
2908  lv = kLVDetails;
2909  break;
2910  }
2911 
2912  fViewMode = new_mode;
2914 
2915  for (i = 2; i <= 5; ++i)
2916  gToolBarData[i].fButton->SetState((i == bnum) ? kButtonEngaged : kButtonUp);
2917 
2918  fListView->SetViewMode(lv);
2919  TGTextButton** buttons = fListView->GetHeaderButtons();
2920  if ((lv == kLVDetails) && (buttons)) {
2921  if (!strcmp(fListView->GetHeader(1), "Attributes")) {
2922  buttons[0]->Connect("Clicked()", "TRootBrowserLite", this,
2923  TString::Format("SetSortMode(=%d)", kViewArrangeByName));
2924  buttons[1]->Connect("Clicked()", "TRootBrowserLite", this,
2925  TString::Format("SetSortMode(=%d)", kViewArrangeByType));
2926  buttons[2]->Connect("Clicked()", "TRootBrowserLite", this,
2927  TString::Format("SetSortMode(=%d)", kViewArrangeBySize));
2928  buttons[5]->Connect("Clicked()", "TRootBrowserLite", this,
2929  TString::Format("SetSortMode(=%d)", kViewArrangeByDate));
2930  }
2931  }
2932  fIconBox->AdjustPosition();
2933  }
2934 }
2935 
2936 ////////////////////////////////////////////////////////////////////////////////
2937 /// Set iconbox's sort mode and update menu radio buttons accordingly.
2938 
2940 {
2941  EFSSortMode smode;
2942 
2943  switch (new_mode) {
2944  default:
2945  new_mode = kViewArrangeByName;
2946  // intentionally no break
2947  case kViewArrangeByName:
2948  smode = kSortByName;
2949  break;
2950  case kViewArrangeByType:
2951  smode = kSortByType;
2952  break;
2953  case kViewArrangeBySize:
2954  smode = kSortBySize;
2955  break;
2956  case kViewArrangeByDate:
2957  smode = kSortByDate;
2958  break;
2959  }
2960 
2961  fSortMode = new_mode;
2963 
2964  fIconBox->Sort(smode);
2965 }
2966 
2967 ////////////////////////////////////////////////////////////////////////////////
2968 /// starts serach dialog
2969 
2971 {
2972  if (!fTextEdit) {
2973  fIconBox->Search(kFALSE);
2974  } else {
2976  }
2977 }
2978 
2979 ////////////////////////////////////////////////////////////////////////////////
2980 /// test
2981 
2982 static Bool_t isBinary(const char *str, int len)
2983 {
2984  for (int i = 0; i < len; i++) {
2985  char c = str[i];
2986  if (((c < 32) || (c > 126)) && (c != '\t') && (c != '\r') && (c != '\n')) {
2987  return kTRUE;
2988  }
2989  }
2990  return kFALSE;
2991 }
2992 
2993 ////////////////////////////////////////////////////////////////////////////////
2994 /// hide text edit
2995 
2997 {
2998  if (!fTextEdit) return;
2999 
3004  TGButton *savbtn = fToolBar->GetButton(kViewSave);
3005  savbtn->Disconnect();
3007  delete fTextEdit;
3008  fTextEdit = 0;
3010  fV2->MapSubwindows();
3011  fV2->Layout();
3013  fTextFileName = "";
3014 }
3015 
3016 ////////////////////////////////////////////////////////////////////////////////
3017 /// browse text file
3018 
3020 {
3021  Bool_t loaded = (fTextEdit != 0);
3022  if (gSystem->AccessPathName(file, kReadPermission)) {
3023  if (loaded) {
3024  HistoryBackward();
3025  }
3026  return;
3027  }
3028  const int bufferSize = 1024;
3029  char buffer[bufferSize];
3030 
3031  FILE *fd = fopen(file, "rb");
3032  if (fd == 0) {
3033  if (loaded) {
3034  HistoryBackward();
3035  }
3036  return;
3037  }
3038  int sz = fread(buffer, 1, bufferSize, fd);
3039  fclose(fd);
3040 
3041  if ((sz > 0) && isBinary(buffer, sz)) {
3042  if (loaded) {
3043  HistoryBackward();
3044  }
3045  return;
3046  }
3047 
3048  if (!fTextEdit) {
3051  TColor *col = gROOT->GetColor(19);
3052  if (col)
3053  fTextEdit->SetBackgroundColor(col->GetPixel());
3055  TGSearchDialog::SearchDialog()->Connect("TextEntered(char *)", "TGTextEdit",
3056  fTextEdit, "Search(char *,Bool_t,Bool_t)");
3057  }
3059  TGButton *savbtn = fToolBar->GetButton(kViewSave);
3060  savbtn->Connect("Released()", "TGTextEdit", fTextEdit, "SaveFile(=0,kTRUE)");
3061  }
3062  fTextFileName = file;
3063  fTextEdit->LoadFile(file);
3064  if (loaded) return;
3065 
3066  if (fTextFileName.EndsWith(".C")) {
3067  ShowMacroButtons();
3068  } else {
3070  }
3073  fTextEdit->MapWindow();
3074  fV2->MapSubwindows();
3075  fV2->Layout();
3077 
3078  if (fListLevel) {
3080  }
3082 
3083  if (btn) {
3084  btn->SetState(kButtonDisabled);
3085  }
3086 
3088 
3089  if (btn2) {
3090  btn2->SetState(kButtonUp);
3091  }
3092 }
3093 
3094 ////////////////////////////////////////////////////////////////////////////////
3095 /// executed browsed text macro
3096 
3098 {
3099  char *tmpfile = gSystem->ConcatFileName(gSystem->TempDirectory(),
3100  fTextFileName.Data());
3101 
3102  gROOT->SetExecutingMacro(kTRUE);
3103  fTextEdit->SaveFile(tmpfile, kFALSE);
3104  gROOT->Macro(tmpfile);
3105  gSystem->Unlink(tmpfile);
3106  delete [] tmpfile;
3107  gROOT->SetExecutingMacro(kFALSE);
3108 }
3109 
3110 ////////////////////////////////////////////////////////////////////////////////
3111 /// interrupt browsed macro execution
3112 
3114 {
3115  gROOT->SetInterrupt(kTRUE);
3116 }
3117 
3118 ////////////////////////////////////////////////////////////////////////////////
3119 /// show/hide macro buttons
3120 
3122 {
3126 
3127  static Bool_t connected = kFALSE;
3128 
3129  if (!show) {
3130  bt1->UnmapWindow();
3131  bt2->UnmapWindow();
3132  bt3->UnmapWindow();
3133  } else {
3134  bt1->MapWindow();
3135  bt2->MapWindow();
3136  bt3->MapWindow();
3137 
3138  if (!connected && fTextEdit) {
3139  bt1->Connect("Pressed()", "TRootBrowserLite", this, "ExecMacro()");
3140  bt2->Connect("Pressed()", "TRootBrowserLite", this, "InterruptMacro()");
3141  connected = kTRUE;
3142  }
3143  }
3144 }
3145 
3146 ////////////////////////////////////////////////////////////////////////////////
3147 /// Set text in column col in status bar.
3148 
3149 void TRootBrowserLite::SetStatusText(const char *txt, Int_t col)
3150 {
3153  if (status!=0) {
3154  status->SetText(txt, col);
3155  }
3156 }
3157 
3158 ////////////////////////////////////////////////////////////////////////////////
3159 /// Interface method to the old browser.
3160 
3162  UInt_t width, UInt_t height,
3163  Option_t * /*opt*/)
3164 {
3165  TRootBrowserLite *browser = new TRootBrowserLite(b, title, width, height);
3166  return (TBrowserImp *)browser;
3167 }
3168 
3169 ////////////////////////////////////////////////////////////////////////////////
3170 /// Interface method to the old browser.
3171 
3173  Int_t y, UInt_t width, UInt_t height,
3174  Option_t * /*opt*/)
3175 {
3176  TRootBrowserLite *browser = new TRootBrowserLite(b, title, x, y, width, height);
3177  return (TBrowserImp *)browser;
3178 }
virtual void HideFrame(TGFrame *f)
Hide sub frame.
Definition: TGFrame.cxx:1172
virtual void AddToTree(TObject *obj, const char *name, Int_t check=-1)
Add items to the current TGListTree of the browser.
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:1213
TGFSComboBox * fFSComboBox
virtual void Resize(UInt_t w=0, UInt_t h=0)
Resize the frame.
Definition: TGFrame.cxx:587
TApplication * GetAppRemote() const
Definition: TApplication.h:151
virtual Bool_t IsAbsoluteFileName(const char *dir)
Return true if dir is an absolute pathname.
Definition: TSystem.cxx:929
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 "...
const TGString * GetPath() const
Definition: TGFSComboBox.h:65
TGLayoutHints * fMenuBarItemLayout
TGCompositeFrame * fListHdr
void * fObj
virtual void Resize(UInt_t w, UInt_t h)
Resize the listbox widget.
Definition: TGListBox.cxx:1419
TGVerticalFrame * fV1
EListViewMode GetViewMode() const
Definition: TGListView.h:185
virtual void Delete(Option_t *option="")
Remove all objects from the list AND delete all heap based objects.
Definition: TList.cxx:405
TGTextEdit * fTextEdit
void SetViewMode(Int_t new_mode, Bool_t force=kFALSE)
Set iconbox's view mode and update menu and toolbar buttons accordingly.
tuple buffer
Definition: tree.py:99
Int_t fDataLength
Definition: TGDNDManager.h:80
Bool_t IsOnHeap() const
Definition: TObject.h:140
The concrete implementation of TBuffer for writing/reading to/from a ROOT file or socket...
Definition: TBufferFile.h:51
TDNDData fDNDData
Definition: TGFSContainer.h:69
Option_t * GetDrawOption() const
returns drawing option
TGPicturePool * GetPicturePool() const
Definition: TGClient.h:143
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.
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
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 Bool_t InheritsFrom(const char *classname) const
Returns kTRUE if object inherits from class "classname".
Definition: TObject.cxx:487
const TGWindow * GetParent() const
Definition: TGWindow.h:87
ClassImp(TSeqCollection) Int_t TSeqCollection TIter next(this)
Return index of object in collection.
ClassImp(TRootBrowserLite) TRootBrowserLite
Create browser with a specified width and height.
Ssiz_t Length() const
Definition: TString.h:390
virtual void DrawBox(Int_t, Int_t, Int_t, Int_t, const char *="#000000", UInt_t=1, Int_t=0)
Definition: TImage.h:204
Collectable string class.
Definition: TObjString.h:32
TGLayoutHints * fComboLayout
void SetDrawOption(Option_t *option="")
sets drawing option
TRootIconBox * fIconBox
TGPopupMenu * fViewMenu
virtual ULong_t Hash() const
Return hash value for this object.
Definition: TObject.cxx:477
return c
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
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
virtual Bool_t IsValid() const
Definition: TImage.h:246
virtual void DoubleClicked(TObject *obj)
Emits signal when double clicking on icon.
TH1 * h
Definition: legend2.C:5
Bool_t IsTObject() const
Return kTRUE is the class inherits from TObject.
Definition: TClass.cxx:5462
UInt_t GetWidth() const
Definition: TGFrame.h:287
Bool_t GetRefreshFlag() const
Definition: TBrowser.h:99
virtual void DisableEntry(Int_t id)
Disable entry (disabled entries appear in a sunken relieve).
Definition: TGMenu.cxx:1712
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Definition: TObject.cxx:892
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
Short_t GetCycle() const
Return cycle number associated to this key.
Definition: TKey.cxx:561
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:1833
EListViewMode
Definition: TGListView.h:45
virtual void UnCheckEntry(Int_t id)
Uncheck menu entry (i.e. remove check mark).
Definition: TGMenu.cxx:1795
const TGPicture * SetIconPixmap(const char *iconName)
Set window icon pixmap by name.
Definition: TGFrame.cxx:1774
#define gROOT
Definition: TROOT.h:344
TGToolBar * fToolBar
virtual UInt_t GetWidth() const
Definition: TImage.h:244
virtual TGButton * GetButton(Int_t id) const
Finds and returns a pointer to the button with the specified identifier id.
Definition: TGToolBar.cxx:156
virtual void Associate(const TGWindow *w)
Definition: TGCanvas.h:101
virtual const char * TempDirectory() const
Return a user configured or systemwide directory to create temporary files in.
Definition: TSystem.cxx:1395
Basic string class.
Definition: TString.h:137
virtual TList * GetList() const
Definition: TGFrame.h:385
#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 const char * GetClassName() const
Definition: TKey.h:77
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:1075
virtual void RemoveAll()
Remove all frames from composite frame.
Definition: TGFrame.cxx:1113
TAlienJobStatus * status
Definition: TAlienJob.cxx:51
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:980
bool Bool_t
Definition: RtypesCore.h:59
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TObject.cxx:517
Int_t MK_MSG(EWidgetMessageTypes msg, EWidgetMessageTypes submsg)
const Bool_t kFALSE
Definition: Rtypes.h:92
virtual Int_t GetNumberOfEntries() const
Definition: TGComboBox.h:129
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:985
#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 GetHeight() const
Definition: TGFrame.h:288
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Definition: fillpatterns.C:1
virtual TGLBEntry * GetSelectedEntry() const
Definition: TGComboBox.h:137
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
const char * GetKeyClassName() const
Definition: TRemoteObject.h:64
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
Definition: TString.h:558
virtual void Layout()
Layout list view components (container and contents of container).
virtual void AddSeparator(TGMenuEntry *before=0)
Add a menu separator to the menu.
Definition: TGMenu.cxx:1055
TGLayoutHints * fMenuBarLayout
virtual void Layout()
Layout the elements of the composite frame.
Definition: TGFrame.cxx:1239
R__EXTERN const char gHelpAbout[]
Definition: HelpText.h:16
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:1020
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:749
virtual void Scale(UInt_t, UInt_t)
Definition: TImage.h:157
virtual Bool_t HandleDNDFinished()
#define gFile
Definition: TFile.h:307
const char * Data() const
Definition: TString.h:349
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 * GetParent() const
Definition: TGListTree.h:79
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.
tuple obj2
Definition: fildir.py:84
virtual int Unlink(const char *name)
Unlink, i.e. remove, a file.
Definition: TSystem.cxx:1294
TGLayoutHints * fExpandLayout
THashTable implements a hash table to store TObject'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
virtual TObject * After(const TObject *obj) const
Returns the object after object obj.
Definition: TList.cxx:289
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:2321
TGPopupMenu * fSortMenu
TGCompositeFrame * fTreeHdr
virtual void SetDefaultHeaders()
Default headers are: Name, Attributes, Size, Owner, Group, Modified.
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
void Class()
Definition: Class.C:29
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
const char * GetText() const
Definition: TGTextEntry.h:140
virtual Bool_t IsActive() const =0
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 &)
virtual Bool_t IsFolder() const
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects)...
Definition: TCollection.h:100
virtual const char * Getenv(const char *env)
Get environment variable.
Definition: TSystem.cxx:1575
ECaseCompare
Definition: TString.h:257
TGPopupMenu * fHelpMenu
virtual void AddToBox(TObject *obj, const char *name)
Add items to the iconbox of the browser.
if(pyself &&pyself!=Py_None)
void * fData
Definition: TGDNDManager.h:79
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'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
virtual void BrowseObj(TObject *obj)
Browse object.
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
virtual const char * GetIconName() const
Returns mime type name of object.
Definition: TObject.cxx:425
TGPopupMenu * fFileMenu
char * Buffer() const
Definition: TBuffer.h:93
virtual void ShowToolBar(Bool_t show=kTRUE)
Show or hide toolbar.
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.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:918
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
virtual TGFrame * GetContainer() const
Definition: TGListBox.h:343
TGMenuBar * fMenuBar
void IconBoxAction(TObject *obj)
Default action when double clicking on icon.
char * out
Definition: TBase64.cxx:29
TGListTreeItem * GetFirstItem() const
Definition: TGListTree.h:402
void Emit(const char *signal)
Acitvate signal without args.
Definition: TQObject.cxx:559
virtual TDNDData * GetDNDData(Atom_t)
Definition: TGFrame.h:338
void UpdateDrawOption()
add new draw option to the "history"
Describes an Operating System directory for the browser.
TGStatusBar * GetStatusBar() const
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
Definition: TObject.cxx:594
virtual UInt_t GetHeight() const
Definition: TImage.h:245
A doubly linked list.
Definition: TList.h:47
const char * pwd()
Definition: TSystem.h:411
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()
TThread * t[5]
Definition: threadsh1.C:13
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
EMouseButton
Definition: GuiTypes.h:215
TList * fList
Definition: TGFrame.h:367
TString GetString() const
Definition: TObjString.h:50
TGListTreeItem * GetNextSibling() const
Definition: TGListTree.h:83
Bool_t EndsWith(const char *pat, ECaseCompare cmp=kExact) const
Return true if string ends with the specified string.
Definition: TString.cxx:2207
TGListTreeItem * GetFirstChild() const
Definition: TGListTree.h:80
R__EXTERN TSystem * gSystem
Definition: TSystem.h:545
virtual UInt_t GetDefaultWidth() const
Definition: TGFrame.h:387
virtual TObject * Before(const TObject *obj) const
Returns the object before object obj.
Definition: TList.cxx:322
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
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
Int_t GET_SUBMSG(Long_t val)
virtual Int_t GetValue(const char *name, Int_t dflt)
Returns the integer value for a resource.
Definition: TEnv.cxx:494
virtual const char * ClassName() const
Returns name of class to which the object belongs.
Definition: TObject.cxx:187
virtual void Associate(const TGWindow *w)
Definition: TGWidget.h:90
virtual TObject * Remove(TObject *obj)
Remove object from the list.
Definition: TList.cxx:675
virtual UInt_t GetDefaultHeight() const
Definition: TGFrame.h:389
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.
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
Bool_t TestBit(UInt_t f) const
Definition: TObject.h:173
char * Form(const char *fmt,...)
void ClearHighlighted()
Un highlight items.
virtual TGListBox * GetListBox() const
Definition: TGComboBox.h:132
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition: TGPicture.cxx:79
EFSSortMode
Definition: TGFSContainer.h:36
tuple w
Definition: qtexample.py:51
TGFrame * fFrame
Definition: TGLayout.h:125
void ExecMacro()
executed browsed text macro
TList * fFileNamesList
Definition: TGFileDialog.h:69
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:51
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:81
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
TGHorizontalFrame * fHf
Bool_t HistoryBackward()
go to the past
Bool_t IsNull() const
Definition: TString.h:387
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:1848
void Rename(const char *new_name)
Definition: TGListTree.h:92
TGComboBox * fDrawOption
#define gVirtualX
Definition: TVirtualX.h:362
R__EXTERN const char gHelpObjects[]
Definition: HelpText.h:25
static TImage * Create()
TGMimeTypes * GetMimeTypeList() const
Definition: TGClient.h:163
virtual void SetBackgroundColor(Pixel_t)
Set background color of the canvas frame.
Definition: TGView.cxx:580
TH1F * total
Definition: threadsh2.C:15
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:2500
Int_t GET_MSG(Long_t val)
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.
virtual TObject * Last() const
Return the last object in the list. Returns 0 when list is empty.
Definition: TList.cxx:581
TGListTreeItem * GetSelected() const
Definition: TGListTree.h:403
TString & Remove(Ssiz_t pos)
Definition: TString.h:616
long Long_t
Definition: RtypesCore.h:50
virtual void Modified(Bool_t flag=1)=0
TGFrame * fSelected
const TGWindow * GetDefaultRoot() const
Returns the root (i.e.
Definition: TGClient.cxx:232
TBufferFile * fBuf
Definition: TGFSContainer.h:68
void ReallyDelete()
Really delete the browser and the this GUI.
virtual Bool_t IsOpen() const
Definition: TGListTree.h:85
virtual Int_t GetSize() const
Definition: TCollection.h:95
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 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's .rootrc.
virtual const char * GetHeader(Int_t idx) const
Returns name of header idx.
virtual void SetEditDisabled(UInt_t on=1)
Set edit disable flag for this frame and subframes.
Definition: TGFrame.cxx:1004
tuple file
Definition: fildir.py:20
virtual const char * GetName() const
Returns name of object.
Definition: TObject.cxx:415
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
Long64_t Atoll() const
Return long long value of string.
Definition: TString.cxx:1977
Int_t GetLength() const
Definition: TGString.h:43
Describe directory structure in memory.
Definition: TDirectory.h:44
virtual void FromPad(TVirtualPad *, Int_t=0, Int_t=0, UInt_t=0, UInt_t=0)
Definition: TImage.h:138
void * GetUserData() const
Definition: TGListView.h:119
TRootBrowserLite(TBrowser *b=0, const char *title="ROOT Browser", UInt_t width=800, UInt_t height=500)
R__EXTERN TEnv * gEnv
Definition: TEnv.h:174
bar Show()
ClassImp(TMCParticle) void TMCParticle printf(": p=(%7.3f,%7.3f,%9.3f) ;", fPx, fPy, fPz)
void dir(char *path=0)
Definition: rootalias.C:30
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
TGFileContainer * GetIconBox() const
returns pointer to fIconBox object
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:47
void InterruptMacro()
interrupt browsed macro execution
void Browse(TBrowser *b)
Browse this collection (called by TBrowser).
void BrowseTextFile(const char *file)
browse text file
void HighlightListLevel()
helper method to track history
virtual void WriteObject(const TObject *obj)
Write object to I/O buffer.
void DeleteListTreeItem(TGListTreeItem *item)
delete list tree item, remove it from history
tuple view
Definition: tornado.py:20
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:2801
virtual void Clear(Option_t *option="")
Remove all objects from the list.
Definition: TList.cxx:349
ERootBrowserCommands
virtual void MapSubwindows()
Map all sub windows that are part of the composite frame.
Definition: TGFrame.cxx:1146
const char * GetClassName() const
Definition: TRemoteObject.h:62
Handle_t fId
Definition: TGObject.h:40
#define name(a, b)
Definition: linkTestLib0.cpp:5
void SetCheckBox(TGListTreeItem *item, Bool_t on=kTRUE)
Set check button state for the node 'item'.
Mother of all ROOT objects.
Definition: TObject.h:58
virtual void SetHeaders(Int_t ncolumns)
Set number of headers, i.e.
virtual TObject * First() const
Return the first object in the list. Returns 0 when list is empty.
Definition: TList.cxx:557
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:1770
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
Int_t Length() const
Definition: TBuffer.h:96
static TGuiBuilder * Instance()
return an instance of TGuiBuilder object
virtual void RecursiveRemove(TObject *obj)
Remove object from this collection and recursively remove the object from all other objects (and coll...
Definition: TList.cxx:635
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
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
Bool_t IsDragging() const
Definition: TGDNDManager.h:177
#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...
R__EXTERN const char gHelpRemote[]
Definition: HelpText.h:27
const char * GetString() const
Definition: TGString.h:44
virtual void Refresh(Bool_t force=kFALSE)
Refresh the browser contents.
#define gDirectory
Definition: TDirectory.h:221
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:1147
void CheckItem(TGListTreeItem *item, Bool_t check=kTRUE)
Set check button state for the node 'item'.
const TGString * GetText() const
Definition: TGListBox.h:123
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...
virtual Bool_t HandleKey(Event_t *event)
handle keys
Ssiz_t Index(const char *pat, Ssiz_t i=0, ECaseCompare cmp=kExact) const
Definition: TString.h:582
virtual const char * ApplicationName() const
Definition: TApplication.h:129
void HighlightItem(TGListTreeItem *item)
Highlight item.
virtual Bool_t SaveFile(const char *fname, Bool_t saveas=kFALSE)
Save file.
Definition: TGTextEdit.cxx:387
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
virtual const char * GetTitle() const
Returns title of object.
Definition: TObject.cxx:459
TObject * obj
void DisplayDirectory()
Display current directory in second label, fLbl2.
virtual char * ConcatFileName(const char *dir, const char *name)
Concatenate a directory and a file name. User must delete returned string.
Definition: TSystem.cxx:1028
Handle_t GetId() const
Definition: TGObject.h:52
virtual void AddPopup(TGHotString *s, TGPopupMenu *menu, TGLayoutHints *l, TGPopupMenu *before=0)
Add popup menu to menu bar.
Definition: TGMenu.cxx:415
TContextMenu * GetContextMenu() const
Definition: TBrowser.h:98
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.
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 TGTextEntry * GetTextEntry() const
Definition: TGComboBox.h:133
const TGPicture * fIconPic