Logo ROOT   6.14/05
Reference Guide
TBrowser.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Fons Rademakers 25/10/95
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 #ifndef ROOT_TBrowser
14 #define ROOT_TBrowser
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TBrowser //
19 // //
20 // Using a TBrowser on can browse all ROOT objects. It shows in a list //
21 // on the left side of the window all browsable ROOT classes. Selecting //
22 // one of the classes displays, in the iconbox on the right side, all //
23 // objects in the class. Selecting one of the objects in the iconbox, //
24 // will place all browsable objects in a new list and draws the //
25 // contents of the selected class in the iconbox. And so on.... //
26 // //
27 //////////////////////////////////////////////////////////////////////////
28 
29 #include "TNamed.h"
30 #include "TBrowserImp.h"
31 
32 
33 class TContextMenu;
34 class TBrowserTimer;
35 
36 
37 class TBrowser : public TNamed {
38 
39 private:
40  TObject *fLastSelectedObject; //!The last TObject selected by user
41 
42  TBrowser(const TBrowser&); // TBrowser can not be copied since we do not know the type of the TBrowserImp (and it can not be 'Cloned')
43  TBrowser& operator=(const TBrowser&); // TBrowser can not be copied since we do not know the type of the TBrowserImp (and it can not be 'Cloned')
44 
45 protected:
46  TBrowserImp *fImp; //!Window system specific browser implementation
47  TBrowserTimer *fTimer; //!Browser's timer
48  TContextMenu *fContextMenu; //!Context menu pointer
49  Bool_t fNeedRefresh; //True if the browser needs refresh
50 
51 public:
52  enum EStatusBits {
53  kNoHidden = BIT(9) // don't show '.' files and directories
54  };
55 
56  TBrowser(const char *name="Browser", const char *title="ROOT Object Browser", TBrowserImp *extimp=0, Option_t *opt="");
57  TBrowser(const char *name, const char *title, UInt_t width, UInt_t height, TBrowserImp *extimp=0, Option_t *opt="");
58  TBrowser(const char *name, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height, TBrowserImp *extimp=0, Option_t *opt="");
59 
60  TBrowser(const char *name, TObject *obj, const char *title="ROOT Object Browser", Option_t *opt="");
61  TBrowser(const char *name, TObject *obj, const char *title, UInt_t width, UInt_t height, Option_t *opt="");
62  TBrowser(const char *name, TObject *obj, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height, Option_t *opt="");
63 
64  TBrowser(const char *name, void *obj, TClass *cl, const char *objname="", const char *title="ROOT Foreign Browser", Option_t *opt="");
65  TBrowser(const char *name, void *obj, TClass *cl, const char *objname, const char *title, UInt_t width, UInt_t height, Option_t *opt="");
66  TBrowser(const char *name, void *obj, TClass *cl, const char *objname, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height, Option_t *opt="");
67 
68  // In a world with only standard C++ compliant compilers, we could also add:
69  // template <class T> TBrowser(const char *name, T *obj, const char *objname="", const char *title="ROOT Foreign Browser") :
70  // : TNamed(name, title), fLastSelectedObject(0), fTimer(0), fContextMenu(0),
71  // fNeedRefresh(kFALSE)
72  // {
73  // Create a new browser with a name, title, width and height for TObject *obj.
74  //
75  // fImp = gGuiFactory->CreateBrowserImp(this, title, width, height);
76  // Create(new TBrowserObject(obj,gROOT->GetClass(typeid(T)),objname));
77  // }
78 
79  virtual ~TBrowser();
80 
81  void Add(TObject *obj, const char *name = 0, Int_t check = -1);
82  void Add(void *obj, TClass *cl, const char *name = 0, Int_t check = -1);
83 
84  void AddCheckBox(TObject *obj, Bool_t check = kFALSE);
85  void CheckObjectItem(TObject *obj, Bool_t check = kFALSE);
86  void RemoveCheckBox(TObject *obj);
87 
88  virtual void Create(TObject *obj = 0); // Create this Browser
89  virtual void Destructor();
90  void BrowseObject(TObject *obj) { if (fImp) fImp->BrowseObj(obj); }
91  void ExecuteDefaultAction(TObject *obj);
92  TBrowserImp *GetBrowserImp() const { return fImp; }
93  void SetBrowserImp(TBrowserImp *i) { fImp = i; }
95  Bool_t GetRefreshFlag() const { return fNeedRefresh; }
97  void SetRefreshFlag(Bool_t flag) { fNeedRefresh = flag; }
98  void Iconify() { if (fImp) fImp->Iconify(); }
99  virtual void RecursiveRemove(TObject *obj);
100  void Refresh();
101  void SetSelected(TObject *clickedObject);
102  void Show() { if (fImp) fImp->Show(); }
103  void SetDrawOption(Option_t *option="") { if (fImp) fImp->SetDrawOption(option); }
104  Option_t *GetDrawOption() const { return (fImp) ? fImp->GetDrawOption() : 0; }
105 
106  Long_t ExecPlugin(const char *name = 0, const char *fname = 0,
107  const char *cmd = 0, Int_t pos = 1, Int_t subpos = -1) {
108  return (fImp) ? fImp->ExecPlugin(name, fname, cmd, pos, subpos) : -1;
109  }
110  void SetStatusText(const char *txt, Int_t col) {
111  if (fImp) fImp->SetStatusText(txt, col);
112  }
113  void StartEmbedding(Int_t pos, Int_t subpos) {
114  if (fImp) fImp->StartEmbedding(pos, subpos);
115  }
116  void StopEmbedding(const char *name = "") { if (fImp) fImp->StopEmbedding(name); }
117 
118  ClassDef(TBrowser,0) //ROOT Object Browser
119 };
120 
121 #endif
void SetBrowserImp(TBrowserImp *i)
Definition: TBrowser.h:93
void Add(TObject *obj, const char *name=0, Int_t check=-1)
Add object with name to browser.
Definition: TBrowser.cxx:261
virtual ~TBrowser()
Delete the browser.
Definition: TBrowser.cxx:238
TBrowserImp * GetBrowserImp() const
Definition: TBrowser.h:92
TBrowserTimer * fTimer
Window system specific browser implementation.
Definition: TBrowser.h:47
void StartEmbedding(Int_t pos, Int_t subpos)
Definition: TBrowser.h:113
virtual void BrowseObj(TObject *)
Definition: TBrowserImp.h:51
TObject * fLastSelectedObject
Definition: TBrowser.h:40
const char Option_t
Definition: RtypesCore.h:62
TBrowser(const TBrowser &)
The last TObject selected by user.
image html pict1_TGaxis_012 png width
Define new text attributes for the label number "labNum".
Definition: TGaxis.cxx:2551
#define BIT(n)
Definition: Rtypes.h:78
void ExecuteDefaultAction(TObject *obj)
Execute default action for selected object (action is specified in the $HOME/.root.mimes or $ROOTSYS/etc/root.mimes file).
Definition: TBrowser.cxx:357
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void CheckObjectItem(TObject *obj, Bool_t check=kFALSE)
Change status of checkbox for this item.
Definition: TBrowser.cxx:304
void SetSelected(TObject *clickedObject)
Assign the last selected object.
Definition: TBrowser.cxx:387
void AddCheckBox(TObject *obj, Bool_t check=kFALSE)
Add checkbox for this item.
Definition: TBrowser.cxx:294
virtual void Create(TObject *obj=0)
Create the browser, called by the ctors.
Definition: TBrowser.cxx:324
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:320
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
virtual void Iconify()
Definition: TBrowserImp.h:55
TBrowser & operator=(const TBrowser &)
void SetStatusText(const char *txt, Int_t col)
Definition: TBrowser.h:110
virtual void StopEmbedding(const char *)
Definition: TBrowserImp.h:65
virtual void SetStatusText(const char *, Int_t)
Definition: TBrowserImp.h:63
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:37
Long_t ExecPlugin(const char *name=0, const char *fname=0, const char *cmd=0, Int_t pos=1, Int_t subpos=-1)
Definition: TBrowser.h:106
Bool_t fNeedRefresh
Context menu pointer.
Definition: TBrowser.h:49
This class provides an interface to context sensitive popup menus.
Definition: TContextMenu.h:40
void SetRefreshFlag(Bool_t flag)
Definition: TBrowser.h:97
unsigned int UInt_t
Definition: RtypesCore.h:42
virtual Long_t ExecPlugin(const char *, const char *, const char *, Int_t, Int_t)
Definition: TBrowserImp.h:62
virtual void SetDrawOption(Option_t *option="")
Definition: TBrowserImp.cxx:22
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
Bool_t GetRefreshFlag() const
Definition: TBrowser.h:95
void RemoveCheckBox(TObject *obj)
Remove checkbox for this item.
Definition: TBrowser.cxx:314
const Bool_t kFALSE
Definition: RtypesCore.h:88
long Long_t
Definition: RtypesCore.h:50
EStatusBits
Definition: TBrowser.h:52
Double_t y[n]
Definition: legend1.C:17
virtual void StartEmbedding(Int_t, Int_t)
Definition: TBrowserImp.h:64
virtual void Show()
Definition: TBrowserImp.h:58
Mother of all ROOT objects.
Definition: TObject.h:37
void StopEmbedding(const char *name="")
Definition: TBrowser.h:116
virtual void Destructor()
Actual browser destructor.
Definition: TBrowser.cxx:246
void Show()
Definition: TBrowser.h:102
void BrowseObject(TObject *obj)
Definition: TBrowser.h:90
void Iconify()
Definition: TBrowser.h:98
virtual Option_t * GetDrawOption() const
Definition: TBrowserImp.h:60
TBrowserImp * fImp
Definition: TBrowser.h:46
TObject * GetSelected() const
Definition: TBrowser.h:96
Option_t * GetDrawOption() const
Get option used by the graphics system to draw this object.
Definition: TBrowser.h:104
TContextMenu * fContextMenu
Browser&#39;s timer.
Definition: TBrowser.h:48
TContextMenu * GetContextMenu() const
Definition: TBrowser.h:94
void Refresh()
Refresh browser contents.
Definition: TBrowser.cxx:377
char name[80]
Definition: TGX11.cxx:109
void SetDrawOption(Option_t *option="")
Set drawing option for object.
Definition: TBrowser.h:103
virtual void RecursiveRemove(TObject *obj)
Recursively remove obj from browser.
Definition: TBrowser.cxx:366
ABC describing GUI independent browser implementation protocol.
Definition: TBrowserImp.h:29