Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 #include "TGFrame.h"
16 
17 #include "TBrowserImp.h"
18 
19 class TGLayoutHints;
20 class TGTab;
21 class TGMenuBar;
22 class TGPopupMenu;
23 class TGStatusBar;
24 class TGVSplitter;
25 class TGHSplitter;
26 
27 //_____________________________________________________________________________
28 //
29 // TBrowserPlugin
30 //
31 // Helper class used to manage plugins (command or macro to be executed).
32 //_____________________________________________________________________________
33 
34 class TBrowserPlugin : public TNamed
35 {
36 public:
37  Int_t fTab; // Tab number
38  Int_t fSubTab; // Tab element number
39  TString fCommand; // Command to be executed
40 
41  TBrowserPlugin(const char *name, const char *cmd = "", Int_t tab = 1,
42  Int_t sub = -1) : TNamed(name, cmd), fTab(tab),
43  fSubTab(sub), fCommand(cmd) { }
44  virtual ~TBrowserPlugin() {}
45 
46  void SetTab(Int_t tab) { fTab = tab; }
47  void SetSubTab(Int_t sub) { fSubTab = sub; }
48  void SetCommand(const char *cmd) { fCommand = cmd; }
49 
50  ClassDef(TBrowserPlugin, 0) // basic plugin description class
51 };
52 
53 class TRootBrowser : public TGMainFrame, public TBrowserImp {
54 private:
55  TRootBrowser(const TRootBrowser&); // Not implemented
56  TRootBrowser& operator=(const TRootBrowser&); // Not implemented
57 
58 protected:
59 
60  TGLayoutHints *fLH0, *fLH1, *fLH2, *fLH3; // Layout hints, part 1
61  TGLayoutHints *fLH4, *fLH5, *fLH6, *fLH7; // Layout hints, part 2
62  TGTab *fTabLeft; // Left Tab
63  TGTab *fTabRight; // Right Tab
64  TGTab *fTabBottom; // Bottom Tab
65  TGTab *fEditTab; // Tab in "Edit" mode
66  Int_t fEditPos; // Id of tab in "Edit" mode
67  Int_t fEditSubPos; // Id of subtab in "Edit" mode
68  TGVerticalFrame *fVf; // Vertical frame
69  TGHorizontalFrame *fHf; // Horizontal frame
70  TGHorizontalFrame *fH1; // Horizontal frame
71  TGHorizontalFrame *fH2; // Horizontal frame
72  TGVerticalFrame *fV1; // Vertical frame
73  TGVerticalFrame *fV2; // Vertical frame
74  TGVSplitter *fVSplitter; // Vertical splitter
75  TGHSplitter *fHSplitter; // Horizontal splitter
76  TGCompositeFrame *fEditFrame; // Frame in "Edit" mode
77  TGHorizontalFrame *fTopMenuFrame; // Top menu frame
78  TGHorizontalFrame *fPreMenuFrame; // First (owned) menu frame
79  TGHorizontalFrame *fMenuFrame; // Shared menu frame
80  TGHorizontalFrame *fToolbarFrame; // Toolbar frame
81  TGMenuBar *fMenuBar; // Main (owned) menu bar
82  TGPopupMenu *fMenuFile; // "File" popup menu
83  TGPopupMenu *fMenuExecPlugin; // "Exec Plugin" popup menu
84  TGPopupMenu *fMenuHelp; // "Browser Help" popup menu
85  TGCompositeFrame *fActMenuBar; // Actual (active) menu bar
86  TBrowserImp *fActBrowser; // Actual (active) browser imp
87  TList fBrowsers; // List of (sub)browsers
88  TList fPlugins; // List of plugins
89  TGStatusBar *fStatusBar; // Status bar
90  Int_t fNbInitPlugins; // Number of initial plugins (from .rootrc)
91  Int_t fNbTab[3]; // Number of tab elements (for each Tab)
92  Int_t fCrTab[3]; // Actual (active) tab elements (for each Tab)
93  Int_t fPid; // Current process id
94  Bool_t fShowCloseTab; // kTRUE to show close icon on tab elements
95  const TGPicture *fIconPic; // icon picture
96 
97 public:
98  enum ENewBrowserMessages {
99  kBrowse = 11011,
100  kOpenFile,
101  kClone,
102  kHelpAbout,
103  kHelpOnBrowser,
104  kHelpOnCanvas,
105  kHelpOnMenus,
106  kHelpOnGraphicsEd,
107  kHelpOnObjects,
108  kHelpOnPS,
109  kHelpOnRemote,
110  kNewEditor,
111  kNewCanvas,
112  kNewHtml,
113  kExecPluginMacro,
114  kExecPluginCmd,
115  kCloseTab,
116  kCloseWindow,
117  kQuitRoot
118  };
119 
120  enum EInsertPosition {
121  kLeft, kRight, kBottom
122  };
123 
124  TRootBrowser(TBrowser *b = 0, const char *name = "ROOT Browser", UInt_t width = 800, UInt_t height = 500, Option_t *opt="", Bool_t initshow=kTRUE);
125  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);
126  virtual ~TRootBrowser();
127 
128  void InitPlugins(Option_t *opt="");
129 
130  void CreateBrowser(const char *name);
131  void CloneBrowser();
132  virtual void CloseWindow();
133  virtual void CloseTab(Int_t id);
134  virtual void CloseTabs();
135  void DoTab(Int_t id);
136  void EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
137  TGFrame *GetActFrame() const { return (TGFrame *)fEditFrame; }
138  TGFrame *GetToolbarFrame() const { return (TGFrame *)fToolbarFrame; }
139  TGStatusBar *GetStatusBar() const { return fStatusBar; }
140  TGTab *GetTabLeft() const { return fTabLeft; }
141  TGTab *GetTabRight() const { return fTabRight; }
142  TGTab *GetTabBottom() const { return fTabBottom; }
143  TGTab *GetTab(Int_t pos) const;
144  void SetTab(Int_t pos = kRight, Int_t subpos = -1);
145  void SetTabTitle(const char *title, Int_t pos = kRight, Int_t subpos = -1);
146  void HandleMenu(Int_t id);
147  void RecursiveReparent(TGPopupMenu *popup);
148  void RemoveTab(Int_t pos, Int_t subpos);
149  void SetActBrowser(TBrowserImp *b) { fActBrowser = b; }
150  void ShowMenu(TGCompositeFrame *menu);
151  virtual void StartEmbedding(Int_t pos = kRight, Int_t subpos = -1);
152  virtual void StopEmbedding(const char *name = 0) { StopEmbedding(name, 0); }
153  void StopEmbedding(const char *name, TGLayoutHints *layout);
154  void SwitchMenus(TGCompositeFrame *from);
155 
156  virtual void BrowseObj(TObject *obj); //*SIGNAL*
157  virtual void ExecuteDefaultAction(TObject *obj); //*SIGNAL*
158  virtual void DoubleClicked(TObject *obj); //*SIGNAL*
159  virtual void Checked(TObject *obj, Bool_t check); //*SIGNAL*
160 
161  virtual void Add(TObject *obj, const char *name = 0, Int_t check = -1);
162  virtual void RecursiveRemove(TObject *obj);
163  virtual void Refresh(Bool_t force = kFALSE);
164  virtual void Show() { MapRaised(); }
165  Option_t *GetDrawOption() const;
166  TGMainFrame *GetMainFrame() const { return (TGMainFrame *)this; }
167 
168  virtual Long_t ExecPlugin(const char *name = 0, const char *fname = 0,
169  const char *cmd = 0, Int_t pos = kRight,
170  Int_t subpos = -1);
171  virtual void SetStatusText(const char *txt, Int_t col);
172  virtual Bool_t HandleKey(Event_t *event);
173 
174  virtual void ShowCloseTab(Bool_t show) { fShowCloseTab = show; }
175  virtual Bool_t IsCloseTabShown() const { return fShowCloseTab; }
176  Bool_t IsWebGUI();
177 
178  // overridden from TGMainFrame
179  virtual void ReallyDelete();
180 
181  static TBrowserImp *NewBrowser(TBrowser *b = 0, const char *title = "ROOT Browser", UInt_t width = 800, UInt_t height = 500, Option_t *opt="");
182  static TBrowserImp *NewBrowser(TBrowser *b, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height, Option_t *opt="");
183 
184  ClassDef(TRootBrowser, 0) // New ROOT Browser
185 };
186 
187 #endif