Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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
33class TContextMenu;
34class TBrowserTimer;
35
36
37class TBrowser : public TNamed {
38
39private:
40 TObject *fLastSelectedObject{nullptr}; //!The last TObject selected by user
41
42 TBrowser(const TBrowser&) = delete; // 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&) = delete; // TBrowser can not be copied since we do not know the type of the TBrowserImp (and it can not be 'Cloned')
44
45protected:
46 TBrowserImp *fImp{nullptr}; //!Window system specific browser implementation
47 TBrowserTimer *fTimer{nullptr}; //!Browser's timer
48 TContextMenu *fContextMenu{nullptr}; //!Context menu pointer
49 Bool_t fNeedRefresh{kFALSE}; //True if the browser needs refresh
50
52
53public:
55 kNoHidden = BIT(9) // don't show '.' files and directories
56 };
57
58 TBrowser(const char *name="Browser", const char *title = "ROOT Object Browser", TBrowserImp *extimp = nullptr, Option_t *opt = "");
59 TBrowser(const char *name, const char *title, UInt_t width, UInt_t height, TBrowserImp *extimp = nullptr, Option_t *opt = "");
60 TBrowser(const char *name, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height, TBrowserImp *extimp = nullptr, Option_t *opt = "");
61
62 TBrowser(const char *name, TObject *obj, const char *title="ROOT Object Browser", Option_t *opt="");
63 TBrowser(const char *name, TObject *obj, const char *title, UInt_t width, UInt_t height, Option_t *opt="");
64 TBrowser(const char *name, TObject *obj, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height, Option_t *opt="");
65
66 TBrowser(const char *name, void *obj, TClass *cl, const char *objname="", const char *title="ROOT Foreign Browser", Option_t *opt="");
67 TBrowser(const char *name, void *obj, TClass *cl, const char *objname, const char *title, UInt_t width, UInt_t height, Option_t *opt="");
68 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="");
69
70 // In a world with only standard C++ compliant compilers, we could also add:
71 // template <class T> TBrowser(const char *name, T *obj, const char *objname="", const char *title="ROOT Foreign Browser") :
72 // : TNamed(name, title), fLastSelectedObject(0), fTimer(0), fContextMenu(0),
73 // fNeedRefresh(kFALSE)
74 // {
75 // Create a new browser with a name, title, width and height for TObject *obj.
76 //
77 // fImp = gGuiFactory->CreateBrowserImp(this, title, width, height);
78 // Create(new TBrowserObject(obj,gROOT->GetClass(typeid(T)),objname));
79 // }
80
81 virtual ~TBrowser();
82
83 void Add(TObject *obj, const char *name = nullptr, Int_t check = -1);
84 void Add(void *obj, TClass *cl, const char *name = nullptr, Int_t check = -1);
85
86 void AddCheckBox(TObject *obj, Bool_t check = kFALSE);
87 void CheckObjectItem(TObject *obj, Bool_t check = kFALSE);
88 void RemoveCheckBox(TObject *obj);
89
90 virtual void Create(TObject *obj = nullptr); // Create this Browser
91 virtual void Destructor();
92 void BrowseObject(TObject *obj) { if (fImp) fImp->BrowseObj(obj); }
94 TBrowserImp *GetBrowserImp() const { return fImp; }
95 void SetBrowserImp(TBrowserImp *i) { fImp = i; }
99 void SetRefreshFlag(Bool_t flag) { fNeedRefresh = flag; }
100 void Iconify() { if (fImp) fImp->Iconify(); }
101 void RecursiveRemove(TObject *obj) override;
102 void Refresh();
103 void SetSelected(TObject *clickedObject);
104 void Show() { if (fImp) fImp->Show(); }
106 Option_t *GetDrawOption() const override { return (fImp) ? fImp->GetDrawOption() : nullptr; }
107
108 Longptr_t ExecPlugin(const char *name = nullptr, const char *fname = nullptr,
109 const char *cmd = nullptr, Int_t pos = 1, Int_t subpos = -1) {
110 return (fImp) ? fImp->ExecPlugin(name, fname, cmd, pos, subpos) : -1;
111 }
112 void SetStatusText(const char *txt, Int_t col) {
113 if (fImp) fImp->SetStatusText(txt, col);
114 }
115 void StartEmbedding(Int_t pos, Int_t subpos) {
116 if (fImp) fImp->StartEmbedding(pos, subpos);
117 }
118 void StopEmbedding(const char *name = "") { if (fImp) fImp->StopEmbedding(name); }
119
120 ClassDefOverride(TBrowser,0) //ROOT Object Browser
121};
122
123#endif
bool Bool_t
Definition RtypesCore.h:63
int Int_t
Definition RtypesCore.h:45
long Longptr_t
Definition RtypesCore.h:82
unsigned int UInt_t
Definition RtypesCore.h:46
constexpr Bool_t kFALSE
Definition RtypesCore.h:101
const char Option_t
Definition RtypesCore.h:66
#define BIT(n)
Definition Rtypes.h:85
#define ClassDefOverride(name, id)
Definition Rtypes.h:341
Option_t Option_t option
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
char name[80]
Definition TGX11.cxx:110
ABC describing GUI independent browser implementation protocol.
Definition TBrowserImp.h:29
virtual void Iconify()
Definition TBrowserImp.h:52
virtual Option_t * GetDrawOption() const
Definition TBrowserImp.h:57
virtual void StartEmbedding(Int_t, Int_t)
Definition TBrowserImp.h:61
virtual void SetStatusText(const char *, Int_t)
Definition TBrowserImp.h:60
virtual void BrowseObj(TObject *)
Definition TBrowserImp.h:48
virtual Longptr_t ExecPlugin(const char *, const char *, const char *, Int_t, Int_t)
Definition TBrowserImp.h:59
virtual void SetDrawOption(Option_t *="")
Definition TBrowserImp.h:56
virtual void Show()
Definition TBrowserImp.h:55
virtual void StopEmbedding(const char *)
Definition TBrowserImp.h:62
Called whenever timer times out.
Definition TBrowser.cxx:51
Using a TBrowser one can browse all ROOT objects.
Definition TBrowser.h:37
void RecursiveRemove(TObject *obj) override
Recursively remove obj from browser.
Definition TBrowser.cxx:408
Longptr_t ExecPlugin(const char *name=nullptr, const char *fname=nullptr, const char *cmd=nullptr, Int_t pos=1, Int_t subpos=-1)
Definition TBrowser.h:108
void CheckObjectItem(TObject *obj, Bool_t check=kFALSE)
Change status of checkbox for this item.
Definition TBrowser.cxx:346
TBrowserImp * fImp
Definition TBrowser.h:46
void SetDrawOption(Option_t *option="") override
Set drawing option for object.
Definition TBrowser.h:105
TObject * fLastSelectedObject
Definition TBrowser.h:40
void SetRefreshFlag(Bool_t flag)
Definition TBrowser.h:99
virtual ~TBrowser()
Delete the browser.
Definition TBrowser.cxx:280
void StartEmbedding(Int_t pos, Int_t subpos)
Definition TBrowser.h:115
TContextMenu * fContextMenu
Browser's timer.
Definition TBrowser.h:48
virtual void Destructor()
Actual browser destructor.
Definition TBrowser.cxx:288
TContextMenu * GetContextMenu() const
Definition TBrowser.h:96
void StopEmbedding(const char *name="")
Definition TBrowser.h:118
Bool_t InitGraphics()
Definition TBrowser.cxx:107
void Show()
Definition TBrowser.h:104
@ kNoHidden
Definition TBrowser.h:55
void RemoveCheckBox(TObject *obj)
Remove checkbox for this item.
Definition TBrowser.cxx:356
void Iconify()
Definition TBrowser.h:100
TBrowserTimer * fTimer
Window system specific browser implementation.
Definition TBrowser.h:47
virtual void Create(TObject *obj=nullptr)
Create the browser, called by the ctors.
Definition TBrowser.cxx:366
void Refresh()
Refresh browser contents.
Definition TBrowser.cxx:419
TBrowser(const TBrowser &)=delete
The last TObject selected by user.
void SetSelected(TObject *clickedObject)
Assign the last selected object.
Definition TBrowser.cxx:429
Bool_t fNeedRefresh
Context menu pointer.
Definition TBrowser.h:49
TObject * GetSelected() const
Definition TBrowser.h:98
Bool_t GetRefreshFlag() const
Definition TBrowser.h:97
void ExecuteDefaultAction(TObject *obj)
Execute default action for selected object (action is specified in the $HOME/.root....
Definition TBrowser.cxx:399
TBrowserImp * GetBrowserImp() const
Definition TBrowser.h:94
Option_t * GetDrawOption() const override
Get option used by the graphics system to draw this object.
Definition TBrowser.h:106
void AddCheckBox(TObject *obj, Bool_t check=kFALSE)
Add checkbox for this item.
Definition TBrowser.cxx:336
TBrowser & operator=(const TBrowser &)=delete
void BrowseObject(TObject *obj)
Definition TBrowser.h:92
void SetStatusText(const char *txt, Int_t col)
Definition TBrowser.h:112
void Add(TObject *obj, const char *name=nullptr, Int_t check=-1)
Add object with name to browser.
Definition TBrowser.cxx:303
void SetBrowserImp(TBrowserImp *i)
Definition TBrowser.h:95
TClass instances represent classes, structs and namespaces in the ROOT type system.
Definition TClass.h:81
This class provides an interface to context sensitive popup menus.
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
Mother of all ROOT objects.
Definition TObject.h:41
Double_t y[n]
Definition legend1.C:17
Double_t x[n]
Definition legend1.C:17