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