ROOT  6.06/09
Reference Guide
TRootBrowser.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id: 7cf312b9bc9940a03d7c0cee95eea0085dc9898c $
2 // Author: Bertrand Bellenot 26/09/2007
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2007, 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 #ifndef ROOT_TRootBrowser
13 #define ROOT_TRootBrowser
14 
15 #ifndef ROOT_TGFrame
16 #include "TGFrame.h"
17 #endif
18 
19 #ifndef ROOT_TBrowserImp
20 #include "TBrowserImp.h"
21 #endif
22 
23 class TGLayoutHints;
24 class TGTab;
25 class TGMenuBar;
26 class TGPopupMenu;
27 class TGStatusBar;
28 class TGVSplitter;
29 class TGHSplitter;
30 
31 //_____________________________________________________________________________
32 //
33 // TBrowserPlugin
34 //
35 // Helper class used to manage plugins (command or macro to be executed).
36 //_____________________________________________________________________________
37 
38 class TBrowserPlugin : public TNamed
39 {
40 public:
41  Int_t fTab; // Tab number
42  Int_t fSubTab; // Tab element number
43  TString fCommand; // Command to be executed
44 
45  TBrowserPlugin(const char *name, const char *cmd = "", Int_t tab = 1,
46  Int_t sub = -1) : TNamed(name, cmd), fTab(tab),
47  fSubTab(sub), fCommand(cmd) { }
48  virtual ~TBrowserPlugin() {}
49 
50  void SetTab(Int_t tab) { fTab = tab; }
51  void SetSubTab(Int_t sub) { fSubTab = sub; }
52  void SetCommand(const char *cmd) { fCommand = cmd; }
53 
54  ClassDef(TBrowserPlugin, 0) // basic plugin description class
55 };
56 
57 class TRootBrowser : public TGMainFrame, public TBrowserImp {
58 private:
59  TRootBrowser(const TRootBrowser&); // Not implemented
60  TRootBrowser& operator=(const TRootBrowser&); // Not implemented
61 
62 protected:
63 
64  TGLayoutHints *fLH0, *fLH1, *fLH2, *fLH3; // Layout hints, part 1
65  TGLayoutHints *fLH4, *fLH5, *fLH6, *fLH7; // Layout hints, part 2
66  TGTab *fTabLeft; // Left Tab
67  TGTab *fTabRight; // Right Tab
68  TGTab *fTabBottom; // Bottom Tab
69  TGTab *fEditTab; // Tab in "Edit" mode
70  Int_t fEditPos; // Id of tab in "Edit" mode
71  Int_t fEditSubPos; // Id of subtab in "Edit" mode
72  TGVerticalFrame *fVf; // Vertical frame
73  TGHorizontalFrame *fHf; // Horizontal frame
74  TGHorizontalFrame *fH1; // Horizontal frame
75  TGHorizontalFrame *fH2; // Horizontal frame
76  TGVerticalFrame *fV1; // Vertical frame
77  TGVerticalFrame *fV2; // Vertical frame
78  TGVSplitter *fVSplitter; // Vertical splitter
79  TGHSplitter *fHSplitter; // Horizontal splitter
80  TGCompositeFrame *fEditFrame; // Frame in "Edit" mode
81  TGHorizontalFrame *fTopMenuFrame; // Top menu frame
82  TGHorizontalFrame *fPreMenuFrame; // First (owned) menu frame
83  TGHorizontalFrame *fMenuFrame; // Shared menu frame
84  TGHorizontalFrame *fToolbarFrame; // Toolbar frame
85  TGMenuBar *fMenuBar; // Main (owned) menu bar
86  TGPopupMenu *fMenuFile; // "File" popup menu
87  TGPopupMenu *fMenuExecPlugin; // "Exec Plugin" popup menu
88  TGPopupMenu *fMenuHelp; // "Browser Help" popup menu
89  TGCompositeFrame *fActMenuBar; // Actual (active) menu bar
90  TBrowserImp *fActBrowser; // Actual (active) browser imp
91  TList fBrowsers; // List of (sub)browsers
92  TList fPlugins; // List of plugins
93  TGStatusBar *fStatusBar; // Status bar
94  Int_t fNbInitPlugins; // Number of initial plugins (from .rootrc)
95  Int_t fNbTab[3]; // Number of tab elements (for each Tab)
96  Int_t fCrTab[3]; // Actual (active) tab elements (for each Tab)
97  Int_t fPid; // Current process id
98  Bool_t fShowCloseTab; // kTRUE to show close icon on tab elements
99  const TGPicture *fIconPic; // icon picture
100 
101 public:
103  kBrowse = 11011,
122  };
123 
126  };
127 
128  TRootBrowser(TBrowser *b = 0, const char *name = "ROOT Browser", UInt_t width = 800, UInt_t height = 500, Option_t *opt="", Bool_t initshow=kTRUE);
129  TRootBrowser(TBrowser *b, const char *name, Int_t x, Int_t y, UInt_t width, UInt_t height, Option_t *opt="", Bool_t initshow=kTRUE);
130  virtual ~TRootBrowser();
131 
132  void InitPlugins(Option_t *opt="");
133 
134  void CreateBrowser(const char *name);
135  void CloneBrowser();
136  virtual void CloseWindow();
137  virtual void CloseTab(Int_t id);
138  virtual void CloseTabs();
139  void DoTab(Int_t id);
140  void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
141  TGFrame *GetActFrame() const { return (TGFrame *)fEditFrame; }
143  TGStatusBar *GetStatusBar() const { return fStatusBar; }
144  TGTab *GetTabLeft() const { return fTabLeft; }
145  TGTab *GetTabRight() const { return fTabRight; }
146  TGTab *GetTabBottom() const { return fTabBottom; }
147  TGTab *GetTab(Int_t pos) const;
148  void SetTab(Int_t pos = kRight, Int_t subpos = -1);
149  void SetTabTitle(const char *title, Int_t pos = kRight, Int_t subpos = -1);
150  void HandleMenu(Int_t id);
151  void RecursiveReparent(TGPopupMenu *popup);
152  void RemoveTab(Int_t pos, Int_t subpos);
153  void SetActBrowser(TBrowserImp *b) { fActBrowser = b; }
154  void ShowMenu(TGCompositeFrame *menu);
155  virtual void StartEmbedding(Int_t pos = kRight, Int_t subpos = -1);
156  virtual void StopEmbedding(const char *name = 0) { StopEmbedding(name, 0); }
157  void StopEmbedding(const char *name, TGLayoutHints *layout);
158  void SwitchMenus(TGCompositeFrame *from);
159 
160  virtual void BrowseObj(TObject *obj); //*SIGNAL*
161  virtual void ExecuteDefaultAction(TObject *obj); //*SIGNAL*
162  virtual void DoubleClicked(TObject *obj); //*SIGNAL*
163  virtual void Checked(TObject *obj, Bool_t check); //*SIGNAL*
164 
165  virtual void Add(TObject *obj, const char *name = 0, Int_t check = -1);
166  virtual void RecursiveRemove(TObject *obj);
167  virtual void Refresh(Bool_t force = kFALSE);
168  virtual void Show() { MapRaised(); }
169  Option_t *GetDrawOption() const;
170  TGMainFrame *GetMainFrame() const { return (TGMainFrame *)this; }
171 
172  virtual Long_t ExecPlugin(const char *name = 0, const char *fname = 0,
173  const char *cmd = 0, Int_t pos = kRight,
174  Int_t subpos = -1);
175  virtual void SetStatusText(const char *txt, Int_t col);
176  virtual Bool_t HandleKey(Event_t *event);
177 
178  virtual void ShowCloseTab(Bool_t show) { fShowCloseTab = show; }
179  virtual Bool_t IsCloseTabShown() const { return fShowCloseTab; }
180 
181  // overridden from TGMainFrame
182  virtual void ReallyDelete();
183 
184  static TBrowserImp *NewBrowser(TBrowser *b = 0, const char *title = "ROOT Browser", UInt_t width = 800, UInt_t height = 500, Option_t *opt="");
185  static TBrowserImp *NewBrowser(TBrowser *b, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height, Option_t *opt="");
186 
187  ClassDef(TRootBrowser, 0) // New ROOT Browser
188 };
189 
190 #endif
TGCompositeFrame * fEditFrame
Definition: TRootBrowser.h:80
void CloneBrowser()
Clone the browser.
virtual void Checked(TObject *obj, Bool_t check)
Emits signal when double clicking on icon.
virtual void StartEmbedding(Int_t pos=kRight, Int_t subpos=-1)
Start embedding external frame in the tab "pos" and tab element "subpos".
Definition: TGTab.h:66
TList fPlugins
Definition: TRootBrowser.h:92
TGPopupMenu * fMenuExecPlugin
Definition: TRootBrowser.h:87
TGLayoutHints * fLH4
Definition: TRootBrowser.h:65
const char Option_t
Definition: RtypesCore.h:62
virtual void Add(TObject *obj, const char *name=0, Int_t check=-1)
Add items to the actual browser.
TGVerticalFrame * fVf
Definition: TRootBrowser.h:72
TGTab * GetTabLeft() const
Definition: TRootBrowser.h:144
TGTab * GetTab(Int_t pos) const
Returns the TGTab at position pos.
void InitPlugins(Option_t *opt="")
Initialize default plugins.
TList fBrowsers
Definition: TRootBrowser.h:91
TGHorizontalFrame * fToolbarFrame
Definition: TRootBrowser.h:84
TGCompositeFrame * fActMenuBar
Definition: TRootBrowser.h:89
Basic string class.
Definition: TString.h:137
TGStatusBar * GetStatusBar() const
Definition: TRootBrowser.h:143
TGHorizontalFrame * fH2
Definition: TRootBrowser.h:75
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
const Bool_t kFALSE
Definition: Rtypes.h:92
TGLayoutHints * fLH2
Definition: TRootBrowser.h:64
TGLayoutHints * fLH5
Definition: TRootBrowser.h:65
virtual void MapRaised()
Definition: TGFrame.h:268
virtual Long_t ExecPlugin(const char *name=0, const char *fname=0, const char *cmd=0, Int_t pos=kRight, Int_t subpos=-1)
Execute a macro and embed the created frame in the tab "pos" and tab element "subpos".
TGStatusBar * fStatusBar
Definition: TRootBrowser.h:93
void SetSubTab(Int_t sub)
Definition: TRootBrowser.h:51
TGLayoutHints * fLH7
Definition: TRootBrowser.h:65
virtual void DoubleClicked(TObject *obj)
Emits signal when double clicking on icon.
Int_t fEditSubPos
Definition: TRootBrowser.h:71
virtual void ReallyDelete()
Really delete the browser and the this GUI.
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:33
TGHorizontalFrame * fTopMenuFrame
Definition: TRootBrowser.h:81
virtual void ExecuteDefaultAction(TObject *obj)
Emits signal "ExecuteDefaultAction(TObject*)".
virtual void Refresh(Bool_t force=kFALSE)
Refresh the actual browser contents.
Option_t * GetDrawOption() const
Returns drawing option.
virtual Bool_t HandleKey(Event_t *event)
Handle keyboard events.
TRootBrowser & operator=(const TRootBrowser &)
TGVSplitter * fVSplitter
Definition: TRootBrowser.h:78
virtual ~TBrowserPlugin()
Definition: TRootBrowser.h:48
TGLayoutHints * fLH3
Definition: TRootBrowser.h:64
TGLayoutHints * fLH6
Definition: TRootBrowser.h:65
TGVerticalFrame * fV2
Definition: TRootBrowser.h:77
void SetCommand(const char *cmd)
Definition: TRootBrowser.h:52
A doubly linked list.
Definition: TList.h:47
Int_t fEditPos
Definition: TRootBrowser.h:70
TGTab * fTabRight
Definition: TRootBrowser.h:67
TGHorizontalFrame * fHf
Definition: TRootBrowser.h:73
Using a TBrowser one can browse all ROOT objects.
Definition: TBrowser.h:41
void SetTab(Int_t tab)
Definition: TRootBrowser.h:50
virtual void Show()
Definition: TRootBrowser.h:168
void SetTabTitle(const char *title, Int_t pos=kRight, Int_t subpos=-1)
Set text "title" of Tab "subpos" in TGTab "pos".
virtual void SetStatusText(const char *txt, Int_t col)
Set text in culumn col in status bar.
void HandleMenu(Int_t id)
Handle menu entries events.
virtual void BrowseObj(TObject *obj)
Browse object.
Int_t fCrTab[3]
Definition: TRootBrowser.h:96
unsigned int UInt_t
Definition: RtypesCore.h:42
TString fCommand
Definition: TRootBrowser.h:43
virtual void RecursiveRemove(TObject *obj)
Recursively remove object from browser.
TGTab * fTabBottom
Definition: TRootBrowser.h:68
virtual void CloseTab(Int_t id)
Remove tab element id from right tab.
void SetTab(Int_t pos=kRight, Int_t subpos=-1)
Switch to Tab "subpos" in TGTab "pos".
virtual void ShowCloseTab(Bool_t show)
Definition: TRootBrowser.h:178
TGTab * fTabLeft
Definition: TRootBrowser.h:66
TGFrame * GetToolbarFrame() const
Definition: TRootBrowser.h:142
void RecursiveReparent(TGPopupMenu *popup)
Recursively reparent TGPopupMenu to gClient->GetDefaultRoot().
TGLayoutHints * fLH0
Definition: TRootBrowser.h:64
virtual void CloseTabs()
Properly close the mainframes embedded in the different tabs.
TGFrame * GetActFrame() const
Definition: TRootBrowser.h:141
long Long_t
Definition: RtypesCore.h:50
virtual void CloseWindow()
Called when window is closed via the window manager.
virtual ~TRootBrowser()
Clean up all widgets, frames and layouthints that were used.
TGHorizontalFrame * fPreMenuFrame
Definition: TRootBrowser.h:82
const TGPicture * fIconPic
Definition: TRootBrowser.h:99
virtual Bool_t IsCloseTabShown() const
Definition: TRootBrowser.h:179
Double_t y[n]
Definition: legend1.C:17
TGPopupMenu * fMenuFile
Definition: TRootBrowser.h:86
virtual void StopEmbedding(const char *name=0)
Definition: TRootBrowser.h:156
Int_t fNbTab[3]
Definition: TRootBrowser.h:95
void RemoveTab(Int_t pos, Int_t subpos)
Remove tab element "subpos" from tab "pos".
#define name(a, b)
Definition: linkTestLib0.cpp:5
TGHSplitter * fHSplitter
Definition: TRootBrowser.h:79
Mother of all ROOT objects.
Definition: TObject.h:58
TGHorizontalFrame * fMenuFrame
Definition: TRootBrowser.h:83
TBrowserImp * fActBrowser
Definition: TRootBrowser.h:90
void CreateBrowser(const char *name)
TGPopupMenu * fMenuHelp
Definition: TRootBrowser.h:88
Int_t fNbInitPlugins
Definition: TRootBrowser.h:94
void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
Display a tooltip with infos about the primitive below the cursor.
void SetActBrowser(TBrowserImp *b)
Definition: TRootBrowser.h:153
void ShowMenu(TGCompositeFrame *menu)
Show the selected frame's menu and hide previous one.
const Bool_t kTRUE
Definition: Rtypes.h:91
TRootBrowser(const TRootBrowser &)
TObject * obj
TGVerticalFrame * fV1
Definition: TRootBrowser.h:76
TGTab * GetTabRight() const
Definition: TRootBrowser.h:145
TGHorizontalFrame * fH1
Definition: TRootBrowser.h:74
void SwitchMenus(TGCompositeFrame *from)
Move the menu from original frame to our TGMenuFrame, or display the menu associated to the current t...
void DoTab(Int_t id)
Handle Tab navigation.
TGTab * fEditTab
Definition: TRootBrowser.h:69
TGTab * GetTabBottom() const
Definition: TRootBrowser.h:146
TGMainFrame * GetMainFrame() const
Definition: TRootBrowser.h:170
static TBrowserImp * NewBrowser(TBrowser *b=0, const char *title="ROOT Browser", UInt_t width=800, UInt_t height=500, Option_t *opt="")
static contructor returning TBrowserImp, as needed by the plugin mechanism.
TBrowserPlugin(const char *name, const char *cmd="", Int_t tab=1, Int_t sub=-1)
Definition: TRootBrowser.h:45
Bool_t fShowCloseTab
Definition: TRootBrowser.h:98
TGMenuBar * fMenuBar
Definition: TRootBrowser.h:85
TGLayoutHints * fLH1
Definition: TRootBrowser.h:64
ABC describing GUI independent browser implementation protocol.
Definition: TBrowserImp.h:31