GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
GRootBrowser.h
Go to the documentation of this file.
1#ifndef ROOT_GRootBrowser
2#define ROOT_GRootBrowser
3
4/** \addtogroup GROOT
5 * @{
6 */
7
8#ifndef ROOT_TGFrame
9#include "TGFrame.h"
10#endif
11
12#ifndef ROOT_TBrowserImp
13#include "TBrowserImp.h"
14#endif
15
16class TGLayoutHints;
17class TGTab;
18class TGMenuBar;
19class TGPopupMenu;
20class TGStatusBar;
21class TGVSplitter;
22class TGHSplitter;
23
24/////////////////////////////////////////////////////////////////
25///
26/// \class GBrowserPlugin
27///
28/// Helper class used to manage plugins (command or macro to be executed).
29///
30/// Largely! taken from GRootBrowserLite in the Root Software package.
31/// This class exists because I needed to change
32/// some of the connections in CreateBrowser() function to
33/// the GRootCanvas class instead of the the TRootCanvas.
34///
35/// pcb.
36///
37/////////////////////////////////////////////////////////////////
38
39class GBrowserPlugin : public TNamed {
40public:
41 Int_t fTab; ///< Tab number
42 Int_t fSubTab; ///< Tab element number
43 TString fCommand; ///< Command to be executed
44
45 explicit GBrowserPlugin(const char* name, const char* cmd = "", Int_t tab = 1, Int_t sub = -1)
46 : TNamed(name, cmd), fTab(tab), fSubTab(sub), fCommand(cmd)
47 {
48 }
49
50 void SetTab(Int_t tab) { fTab = tab; } ///< simple setter function for the tab number
51 void SetSubTab(Int_t sub) { fSubTab = sub; } ///< simple setter function for the tab element number
52 void SetCommand(const char* cmd) { fCommand = cmd; } ///< simple setter function for the command to be executed
53
54 /// \cond CLASSIMP
55 ClassDefOverride(GBrowserPlugin, 0) // NOLINT(readability-else-after-return)
56 /// \endcond
57};
58
59/////////////////////////////////////////////////////////////////
60///
61/// \class GRootBrowser
62///
63/// This class creates a ROOT object browser, constitued by three main
64/// tabs.
65///
66/// All tabs can 'swallow' frames, thanks to the new method:
67/// ExecPlugin(const char *name = 0, const char *fname = 0,
68/// const char *cmd = 0, Int_t pos = kRight,
69/// Int_t subpos = -1)
70/// allowing to select plugins (can be a macro or a command)
71/// to be executed, and where to embed the frame created by
72/// the plugin (tab and tab element). Examples:
73///
74/// create a new browser:
75/// TBrowser b;
76///
77/// create a new TCanvas in a new top right tab element:
78/// b.ExecPlugin("Canvas", 0, "new TCanvas()");
79///
80/// create a new top right tab element embedding the
81/// TGMainFrame created by the macro 'myMacro.C':
82/// b.ExecPlugin("MyPlugin", "myMacro.C");
83///
84/// create a new bottom tab element embedding the
85/// TGMainFrame created by the macro 'myMacro.C':
86/// b.ExecPlugin("MyPlugin", "myMacro.C", 0, GRootBrowser::kBottom);
87///
88/// this browser implementation can be selected via the env
89/// 'Browser.Name' in .rootrc, (GRootBrowser or GRootBrowserLite)
90/// the default being GRootBrowserLite (old browser)
91/// a list of options (plugins) for the new GRootBrowser is also
92/// specified via the env 'Browser.Options' in .rootrc, the default
93/// being: FECI
94/// Here is the list of available options:
95/// F: File browser E: Text Editor H: HTML browser C: Canvas I: I/O
96/// redirection P: Proof G: GL viewer
97///
98/////////////////////////////////////////////////////////////////
99
100class GRootBrowser : public TGMainFrame, public TBrowserImp {
101private:
102 GRootBrowser(const GRootBrowser&); // Not implemented
103 GRootBrowser(GRootBrowser&&) noexcept; // Not implemented
104 GRootBrowser& operator=(const GRootBrowser&); // Not implemented
105 GRootBrowser& operator=(GRootBrowser&&) noexcept; // Not implemented
106
107 TGLayoutHints* fLH0{nullptr}; ///< Layout hints, part 1
108 TGLayoutHints* fLH1{nullptr}; ///< Layout hints, part 2
109 TGLayoutHints* fLH2{nullptr}; ///< Layout hints, part 3
110 TGLayoutHints* fLH3{nullptr}; ///< Layout hints, part 4
111 TGLayoutHints* fLH4{nullptr}; ///< Layout hints, part 5
112 TGLayoutHints* fLH5{nullptr}; ///< Layout hints, part 6
113 TGLayoutHints* fLH6{nullptr}; ///< Layout hints, part 7
114 TGLayoutHints* fLH7{nullptr}; ///< Layout hints, part 8
115 TGTab* fTabLeft{nullptr}; ///< Left Tab
116 TGTab* fTabRight{nullptr}; ///< Right Tab
117 TGTab* fTabBottom{nullptr}; ///< Bottom Tab
118 TGTab* fEditTab{nullptr}; ///< Tab in "Edit" mode
119 Int_t fEditPos{0}; ///< Id of tab in "Edit" mode
120 Int_t fEditSubPos{0}; ///< Id of subtab in "Edit" mode
121 TGVerticalFrame* fVf{nullptr}; ///< Vertical frame
122 TGHorizontalFrame* fHf{nullptr}; ///< Horizontal frame
123 TGHorizontalFrame* fH1{nullptr}; ///< Horizontal frame
124 TGHorizontalFrame* fH2{nullptr}; ///< Horizontal frame
125 TGVerticalFrame* fV1{nullptr}; ///< Vertical frame
126 TGVerticalFrame* fV2{nullptr}; ///< Vertical frame
127 TGVSplitter* fVSplitter{nullptr}; ///< Vertical splitter
128 TGHSplitter* fHSplitter{nullptr}; ///< Horizontal splitter
129 TGCompositeFrame* fEditFrame{nullptr}; ///< Frame in "Edit" mode
130 TGHorizontalFrame* fTopMenuFrame{nullptr}; ///< Top menu frame
131 TGHorizontalFrame* fPreMenuFrame{nullptr}; ///< First (owned) menu frame
132 TGHorizontalFrame* fMenuFrame{nullptr}; ///< Shared menu frame
133 TGHorizontalFrame* fToolbarFrame{nullptr}; ///< Toolbar frame
134 TGMenuBar* fMenuBar{nullptr}; ///< Main (owned) menu bar
135 TGPopupMenu* fMenuFile{nullptr}; ///< "File" popup menu
136 TGPopupMenu* fMenuExecPlugin{nullptr}; ///< "Exec Plugin" popup menu
137 TGPopupMenu* fMenuHelp{nullptr}; ///< "Browser Help" popup menu
138 TGCompositeFrame* fActMenuBar{nullptr}; ///< Actual (active) menu bar
139 TBrowserImp* fActBrowser{nullptr}; ///< Actual (active) browser imp
140 TList fBrowsers; ///< List of (sub)browsers
141 TList fPlugins; ///< List of plugins
142 TGStatusBar* fStatusBar{nullptr}; ///< Status bar
143 Int_t fNbInitPlugins{0}; ///< Number of initial plugins (from .rootrc)
144 std::array<Int_t, 3> fNbTab{}; ///< Number of tab elements (for each Tab)
145 std::array<Int_t, 3> fCrTab{}; ///< Actual (active) tab elements (for each Tab)
146 Int_t fPid{0}; ///< Current process id
147 Bool_t fShowCloseTab{kTRUE}; ///< kTRUE to show close icon on tab elements
148 const TGPicture* fIconPic{nullptr}; ///< icon picture
149
150public:
172
173 enum class EInsertPosition { kLeft,
174 kRight,
175 kBottom };
176
177 explicit GRootBrowser(TBrowser* b = nullptr, const char* name = "ROOT Browser", UInt_t width = 800, UInt_t height = 500, Option_t* opt = "", Bool_t initshow = kTRUE);
178 GRootBrowser(TBrowser* b, const char* name, Int_t x, Int_t y, UInt_t width, UInt_t height, Option_t* opt = "", Bool_t initshow = kTRUE);
180
181 void InitPlugins(Option_t* opt = "");
182
183 void CreateBrowser(const char* name);
184 void CloneBrowser();
185 void CloseWindow() override;
186 virtual void CloseTab(Int_t id);
187 void CloseTabs() override;
188 void DoTab(Int_t id);
189 void EventInfo(Int_t event, Int_t px, Int_t py, TObject* selected);
190 TGFrame* GetActFrame() const { return static_cast<TGFrame*>(fEditFrame); }
191 TGFrame* GetToolbarFrame() const { return static_cast<TGFrame*>(fToolbarFrame); }
192 TGStatusBar* GetStatusBar() const { return fStatusBar; }
193 TGTab* GetTabLeft() const { return fTabLeft; }
194 TGTab* GetTabRight() const { return fTabRight; }
195 TGTab* GetTabBottom() const { return fTabBottom; }
196 TGTab* GetTab(Int_t pos) const;
197 void SetTab(Int_t pos = static_cast<Int_t>(EInsertPosition::kRight), Int_t subpos = -1);
198 void SetTabTitle(const char* title, Int_t pos = static_cast<Int_t>(EInsertPosition::kRight), Int_t subpos = -1);
199 void HandleMenu(Int_t id);
200 void RecursiveReparent(TGPopupMenu* popup);
201 void RemoveTab(Int_t pos, Int_t subpos);
202 void SetActBrowser(TBrowserImp* b) { fActBrowser = b; }
203 void ShowMenu(TGCompositeFrame* menu);
204 void StartEmbedding(Int_t pos = static_cast<Int_t>(EInsertPosition::kRight), Int_t subpos = -1) override;
205 void StopEmbedding(const char* name = nullptr) override { StopEmbedding(name, nullptr); }
206 void StopEmbedding(const char* name, TGLayoutHints* layout);
207 void SwitchMenus(TGCompositeFrame* from);
208
209 void BrowseObj(TObject* obj) override; //*SIGNAL*
210 void ExecuteDefaultAction(TObject* obj) override; //*SIGNAL*
211 virtual void DoubleClicked(TObject* obj); //*SIGNAL*
212 virtual void Checked(TObject* obj, Bool_t checked); //*SIGNAL*
213
214 void Add(TObject* obj, const char* name = nullptr, Int_t check = -1) override;
215 void RecursiveRemove(TObject* obj) override;
216 void Refresh(Bool_t force = kFALSE) override;
217 void Show() override { MapRaised(); }
218 Option_t* GetDrawOption() const override;
219 TGMainFrame* GetMainFrame() const override { return const_cast<TGMainFrame*>(static_cast<const TGMainFrame*>(this)); } // NOLINT(cppcoreguidelines-pro-type-const-cast)
220
221 Long_t ExecPlugin(const char* name = nullptr, const char* fname = nullptr, const char* cmd = nullptr,
222 Int_t pos = static_cast<Int_t>(EInsertPosition::kRight), Int_t subpos = -1) override;
223 void SetStatusText(const char* txt, Int_t col) override;
224 Bool_t HandleKey(Event_t* event) override;
225
226 virtual void ShowCloseTab(Bool_t show) { fShowCloseTab = show; }
227 virtual Bool_t IsCloseTabShown() const { return fShowCloseTab; }
228
229 // overridden from TGMainFrame
230 void ReallyDelete() override;
231
232 static TBrowserImp* NewBrowser(TBrowser* b = nullptr, const char* title = "ROOT Browser", UInt_t width = 800,
233 UInt_t height = 500, Option_t* opt = "");
234 static TBrowserImp* NewBrowser(TBrowser* b, const char* title, Int_t x, Int_t y, UInt_t width, UInt_t height,
235 Option_t* opt = "");
236
237 /// \cond CLASSIMP
238 ClassDefOverride(GRootBrowser, 0) // NOLINT(readability-else-after-return)
239 /// \endcond
240};
241/*! @} */
242#endif
void SetSubTab(Int_t sub)
simple setter function for the tab element number
Int_t fTab
Tab number.
void SetCommand(const char *cmd)
simple setter function for the command to be executed
Int_t fSubTab
Tab element number.
TString fCommand
Command to be executed.
GBrowserPlugin(const char *name, const char *cmd="", Int_t tab=1, Int_t sub=-1)
void SetTab(Int_t tab)
simple setter function for the tab number
TBrowserImp * fActBrowser
Actual (active) browser imp.
void ReallyDelete() override
void InitPlugins(Option_t *opt="")
Int_t fEditSubPos
Id of subtab in "Edit" mode.
TGVerticalFrame * fVf
Vertical frame.
void CloseWindow() override
Int_t fPid
Current process id.
void CreateBrowser(const char *name)
void HandleMenu(Int_t id)
TGTab * GetTabRight() const
Long_t ExecPlugin(const char *name=nullptr, const char *fname=nullptr, const char *cmd=nullptr, Int_t pos=static_cast< Int_t >(EInsertPosition::kRight), Int_t subpos=-1) override
TGMenuBar * fMenuBar
Main (owned) menu bar.
TGLayoutHints * fLH3
Layout hints, part 4.
void SetStatusText(const char *txt, Int_t col) override
void RecursiveRemove(TObject *obj) override
TGVerticalFrame * fV1
Vertical frame.
TGPopupMenu * fMenuFile
"File" popup menu
TGHorizontalFrame * fHf
Horizontal frame.
void SwitchMenus(TGCompositeFrame *from)
std::array< Int_t, 3 > fCrTab
Actual (active) tab elements (for each Tab)
TGHorizontalFrame * fToolbarFrame
Toolbar frame.
Int_t fNbInitPlugins
Number of initial plugins (from .rootrc)
TGStatusBar * fStatusBar
Status bar.
void StartEmbedding(Int_t pos=static_cast< Int_t >(EInsertPosition::kRight), Int_t subpos=-1) override
void SetTab(Int_t pos=static_cast< Int_t >(EInsertPosition::kRight), Int_t subpos=-1)
virtual void CloseTab(Int_t id)
void SetTabTitle(const char *title, Int_t pos=static_cast< Int_t >(EInsertPosition::kRight), Int_t subpos=-1)
void Add(TObject *obj, const char *name=nullptr, Int_t check=-1) override
TGHSplitter * fHSplitter
Horizontal splitter.
TGTab * fEditTab
Tab in "Edit" mode.
void CloseTabs() override
TGLayoutHints * fLH1
Layout hints, part 2.
TGPopupMenu * fMenuExecPlugin
"Exec Plugin" popup menu
void SetActBrowser(TBrowserImp *b)
TGCompositeFrame * fEditFrame
Frame in "Edit" mode.
virtual Bool_t IsCloseTabShown() const
TGTab * fTabRight
Right Tab.
Bool_t fShowCloseTab
kTRUE to show close icon on tab elements
TList fBrowsers
List of (sub)browsers.
TGHorizontalFrame * fH2
Horizontal frame.
void Show() override
static TBrowserImp * NewBrowser(TBrowser *b=nullptr, const char *title="ROOT Browser", UInt_t width=800, UInt_t height=500, Option_t *opt="")
const TGPicture * fIconPic
icon picture
TGLayoutHints * fLH6
Layout hints, part 7.
TGTab * fTabBottom
Bottom Tab.
void ExecuteDefaultAction(TObject *obj) override
TGHorizontalFrame * fH1
Horizontal frame.
TGVerticalFrame * fV2
Vertical frame.
virtual void ShowCloseTab(Bool_t show)
TGHorizontalFrame * fMenuFrame
Shared menu frame.
Option_t * GetDrawOption() const override
TGCompositeFrame * fActMenuBar
Actual (active) menu bar.
void Refresh(Bool_t force=kFALSE) override
TGVSplitter * fVSplitter
Vertical splitter.
TGLayoutHints * fLH5
Layout hints, part 6.
void DoTab(Int_t id)
void BrowseObj(TObject *obj) override
void RemoveTab(Int_t pos, Int_t subpos)
TGTab * GetTabLeft() const
Int_t fEditPos
Id of tab in "Edit" mode.
GRootBrowser(GRootBrowser &&) noexcept
TGFrame * GetToolbarFrame() const
TGTab * fTabLeft
Left Tab.
TGStatusBar * GetStatusBar() const
GRootBrowser(const GRootBrowser &)
TGHorizontalFrame * fTopMenuFrame
Top menu frame.
void StopEmbedding(const char *name=nullptr) override
TGLayoutHints * fLH0
Layout hints, part 1.
TGFrame * GetActFrame() const
TGPopupMenu * fMenuHelp
"Browser Help" popup menu
TGLayoutHints * fLH2
Layout hints, part 3.
TGTab * GetTab(Int_t pos) const
void ShowMenu(TGCompositeFrame *menu)
virtual void DoubleClicked(TObject *obj)
void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected)
Bool_t HandleKey(Event_t *event) override
TList fPlugins
List of plugins.
TGHorizontalFrame * fPreMenuFrame
First (owned) menu frame.
TGMainFrame * GetMainFrame() const override
virtual void Checked(TObject *obj, Bool_t checked)
void RecursiveReparent(TGPopupMenu *popup)
TGTab * GetTabBottom() const
TGLayoutHints * fLH7
Layout hints, part 8.
std::array< Int_t, 3 > fNbTab
Number of tab elements (for each Tab)
TGLayoutHints * fLH4
Layout hints, part 5.