// @(#)root/gui:$Id: 7cf312b9bc9940a03d7c0cee95eea0085dc9898c $
// Author: Bertrand Bellenot   26/09/2007

/*************************************************************************
 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TRootBrowser
#define ROOT_TRootBrowser

#ifndef ROOT_TGFrame
#include "TGFrame.h"
#endif

#ifndef ROOT_TBrowserImp
#include "TBrowserImp.h"
#endif

class TGLayoutHints;
class TGTab;
class TGMenuBar;
class TGPopupMenu;
class TGStatusBar;
class TGVSplitter;
class TGHSplitter;

//_____________________________________________________________________________
//
// TBrowserPlugin
//
// Helper class used to manage plugins (command or macro to be executed).
//_____________________________________________________________________________

class TBrowserPlugin : public TNamed
{
public:
   Int_t    fTab;             // Tab number
   Int_t    fSubTab;          // Tab element number
   TString  fCommand;         // Command to be executed

   TBrowserPlugin(const char *name, const char *cmd = "", Int_t tab = 1,
                  Int_t sub = -1) : TNamed(name, cmd), fTab(tab),
      fSubTab(sub), fCommand(cmd) { }
   virtual ~TBrowserPlugin() {}

   void     SetTab(Int_t tab) { fTab = tab; }
   void     SetSubTab(Int_t sub) { fSubTab = sub; }
   void     SetCommand(const char *cmd) { fCommand = cmd; }

   ClassDef(TBrowserPlugin, 0)  // basic plugin description class
};

class TRootBrowser : public TGMainFrame, public TBrowserImp {
private:
   TRootBrowser(const TRootBrowser&); // Not implemented
   TRootBrowser& operator=(const TRootBrowser&); // Not implemented

protected:

   TGLayoutHints     *fLH0, *fLH1, *fLH2, *fLH3;   // Layout hints, part 1
   TGLayoutHints     *fLH4, *fLH5, *fLH6, *fLH7;   // Layout hints, part 2
   TGTab             *fTabLeft;                    // Left Tab
   TGTab             *fTabRight;                   // Right Tab
   TGTab             *fTabBottom;                  // Bottom Tab
   TGTab             *fEditTab;                    // Tab in "Edit" mode
   Int_t              fEditPos;                    // Id of tab in "Edit" mode
   Int_t              fEditSubPos;                 // Id of subtab in "Edit" mode
   TGVerticalFrame   *fVf;                         // Vertical frame
   TGHorizontalFrame *fHf;                         // Horizontal frame
   TGHorizontalFrame *fH1;                         // Horizontal frame
   TGHorizontalFrame *fH2;                         // Horizontal frame
   TGVerticalFrame   *fV1;                         // Vertical frame
   TGVerticalFrame   *fV2;                         // Vertical frame
   TGVSplitter       *fVSplitter;                  // Vertical splitter
   TGHSplitter       *fHSplitter;                  // Horizontal splitter
   TGCompositeFrame  *fEditFrame;                  // Frame in "Edit" mode
   TGHorizontalFrame *fTopMenuFrame;               // Top menu frame
   TGHorizontalFrame *fPreMenuFrame;               // First (owned) menu frame
   TGHorizontalFrame *fMenuFrame;                  // Shared menu frame
   TGHorizontalFrame *fToolbarFrame;               // Toolbar frame
   TGMenuBar         *fMenuBar;                    // Main (owned) menu bar
   TGPopupMenu       *fMenuFile;                   // "File" popup menu
   TGPopupMenu       *fMenuExecPlugin;             // "Exec Plugin" popup menu
   TGPopupMenu       *fMenuHelp;                   // "Browser Help" popup menu
   TGCompositeFrame  *fActMenuBar;                 // Actual (active) menu bar
   TBrowserImp       *fActBrowser;                 // Actual (active) browser imp
   TList              fBrowsers;                   // List of (sub)browsers
   TList              fPlugins;                    // List of plugins
   TGStatusBar       *fStatusBar;                  // Status bar
   Int_t              fNbInitPlugins;              // Number of initial plugins (from .rootrc)
   Int_t              fNbTab[3];                   // Number of tab elements (for each Tab)
   Int_t              fCrTab[3];                   // Actual (active) tab elements (for each Tab)
   Int_t              fPid;                        // Current process id
   Bool_t             fShowCloseTab;               // kTRUE to show close icon on tab elements
   const TGPicture   *fIconPic;                    // icon picture

public:
   enum ENewBrowserMessages {
      kBrowse = 11011,
      kOpenFile,
      kClone,
      kHelpAbout,
      kHelpOnBrowser,
      kHelpOnCanvas,
      kHelpOnMenus,
      kHelpOnGraphicsEd,
      kHelpOnObjects,
      kHelpOnPS,
      kHelpOnRemote,
      kNewEditor,
      kNewCanvas,
      kNewHtml,
      kExecPluginMacro,
      kExecPluginCmd,
      kCloseTab,
      kCloseWindow,
      kQuitRoot
   };

   enum EInsertPosition {
      kLeft, kRight, kBottom
   };

   TRootBrowser(TBrowser *b = 0, const char *name = "ROOT Browser", UInt_t width = 800, UInt_t height = 500, Option_t *opt="", Bool_t initshow=kTRUE);
   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);
   virtual ~TRootBrowser();

   void              InitPlugins(Option_t *opt="");

   void              CreateBrowser(const char *name);
   void              CloneBrowser();
   virtual void      CloseWindow();
   virtual void      CloseTab(Int_t id);
   virtual void      CloseTabs();
   void              DoTab(Int_t id);
   void              EventInfo(Int_t event, Int_t px, Int_t py, TObject *selected);
   TGFrame          *GetActFrame() const { return (TGFrame *)fEditFrame; }
   TGFrame          *GetToolbarFrame() const { return (TGFrame *)fToolbarFrame; }
   TGStatusBar      *GetStatusBar() const { return fStatusBar; }
   TGTab            *GetTabLeft() const { return fTabLeft; }
   TGTab            *GetTabRight() const { return fTabRight; }
   TGTab            *GetTabBottom() const { return fTabBottom; }
   TGTab            *GetTab(Int_t pos) const;
   void              SetTab(Int_t pos = kRight, Int_t subpos = -1);
   void              SetTabTitle(const char *title, Int_t pos = kRight, Int_t subpos = -1);
   void              HandleMenu(Int_t id);
   void              RecursiveReparent(TGPopupMenu *popup);
   void              RemoveTab(Int_t pos, Int_t subpos);
   void              SetActBrowser(TBrowserImp *b) { fActBrowser = b; }
   void              ShowMenu(TGCompositeFrame *menu);
   virtual void      StartEmbedding(Int_t pos = kRight, Int_t subpos = -1);
   virtual void      StopEmbedding(const char *name = 0) { StopEmbedding(name, 0); }
   void              StopEmbedding(const char *name, TGLayoutHints *layout);
   void              SwitchMenus(TGCompositeFrame *from);

   virtual void      BrowseObj(TObject *obj);             //*SIGNAL*
   virtual void      ExecuteDefaultAction(TObject *obj);  //*SIGNAL*
   virtual void      DoubleClicked(TObject *obj);         //*SIGNAL*
   virtual void      Checked(TObject *obj, Bool_t check); //*SIGNAL*

   virtual void      Add(TObject *obj, const char *name = 0, Int_t check = -1);
   virtual void      RecursiveRemove(TObject *obj);
   virtual void      Refresh(Bool_t force = kFALSE);
   virtual void      Show() { MapRaised(); }
   Option_t         *GetDrawOption() const;
   TGMainFrame      *GetMainFrame() const { return (TGMainFrame *)this; }

   virtual Long_t    ExecPlugin(const char *name = 0, const char *fname = 0,
                                const char *cmd = 0, Int_t pos = kRight,
                                Int_t subpos = -1);
   virtual void      SetStatusText(const char *txt, Int_t col);
   virtual Bool_t    HandleKey(Event_t *event);

   virtual void      ShowCloseTab(Bool_t show) { fShowCloseTab = show; }
   virtual Bool_t    IsCloseTabShown() const { return fShowCloseTab; }

   // overridden from TGMainFrame
   virtual void      ReallyDelete();

   static TBrowserImp *NewBrowser(TBrowser *b = 0, const char *title = "ROOT Browser", UInt_t width = 800, UInt_t height = 500, Option_t *opt="");
   static TBrowserImp *NewBrowser(TBrowser *b, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height, Option_t *opt="");

   ClassDef(TRootBrowser, 0) // New ROOT Browser
};

#endif
 TRootBrowser.h:1
 TRootBrowser.h:2
 TRootBrowser.h:3
 TRootBrowser.h:4
 TRootBrowser.h:5
 TRootBrowser.h:6
 TRootBrowser.h:7
 TRootBrowser.h:8
 TRootBrowser.h:9
 TRootBrowser.h:10
 TRootBrowser.h:11
 TRootBrowser.h:12
 TRootBrowser.h:13
 TRootBrowser.h:14
 TRootBrowser.h:15
 TRootBrowser.h:16
 TRootBrowser.h:17
 TRootBrowser.h:18
 TRootBrowser.h:19
 TRootBrowser.h:20
 TRootBrowser.h:21
 TRootBrowser.h:22
 TRootBrowser.h:23
 TRootBrowser.h:24
 TRootBrowser.h:25
 TRootBrowser.h:26
 TRootBrowser.h:27
 TRootBrowser.h:28
 TRootBrowser.h:29
 TRootBrowser.h:30
 TRootBrowser.h:31
 TRootBrowser.h:32
 TRootBrowser.h:33
 TRootBrowser.h:34
 TRootBrowser.h:35
 TRootBrowser.h:36
 TRootBrowser.h:37
 TRootBrowser.h:38
 TRootBrowser.h:39
 TRootBrowser.h:40
 TRootBrowser.h:41
 TRootBrowser.h:42
 TRootBrowser.h:43
 TRootBrowser.h:44
 TRootBrowser.h:45
 TRootBrowser.h:46
 TRootBrowser.h:47
 TRootBrowser.h:48
 TRootBrowser.h:49
 TRootBrowser.h:50
 TRootBrowser.h:51
 TRootBrowser.h:52
 TRootBrowser.h:53
 TRootBrowser.h:54
 TRootBrowser.h:55
 TRootBrowser.h:56
 TRootBrowser.h:57
 TRootBrowser.h:58
 TRootBrowser.h:59
 TRootBrowser.h:60
 TRootBrowser.h:61
 TRootBrowser.h:62
 TRootBrowser.h:63
 TRootBrowser.h:64
 TRootBrowser.h:65
 TRootBrowser.h:66
 TRootBrowser.h:67
 TRootBrowser.h:68
 TRootBrowser.h:69
 TRootBrowser.h:70
 TRootBrowser.h:71
 TRootBrowser.h:72
 TRootBrowser.h:73
 TRootBrowser.h:74
 TRootBrowser.h:75
 TRootBrowser.h:76
 TRootBrowser.h:77
 TRootBrowser.h:78
 TRootBrowser.h:79
 TRootBrowser.h:80
 TRootBrowser.h:81
 TRootBrowser.h:82
 TRootBrowser.h:83
 TRootBrowser.h:84
 TRootBrowser.h:85
 TRootBrowser.h:86
 TRootBrowser.h:87
 TRootBrowser.h:88
 TRootBrowser.h:89
 TRootBrowser.h:90
 TRootBrowser.h:91
 TRootBrowser.h:92
 TRootBrowser.h:93
 TRootBrowser.h:94
 TRootBrowser.h:95
 TRootBrowser.h:96
 TRootBrowser.h:97
 TRootBrowser.h:98
 TRootBrowser.h:99
 TRootBrowser.h:100
 TRootBrowser.h:101
 TRootBrowser.h:102
 TRootBrowser.h:103
 TRootBrowser.h:104
 TRootBrowser.h:105
 TRootBrowser.h:106
 TRootBrowser.h:107
 TRootBrowser.h:108
 TRootBrowser.h:109
 TRootBrowser.h:110
 TRootBrowser.h:111
 TRootBrowser.h:112
 TRootBrowser.h:113
 TRootBrowser.h:114
 TRootBrowser.h:115
 TRootBrowser.h:116
 TRootBrowser.h:117
 TRootBrowser.h:118
 TRootBrowser.h:119
 TRootBrowser.h:120
 TRootBrowser.h:121
 TRootBrowser.h:122
 TRootBrowser.h:123
 TRootBrowser.h:124
 TRootBrowser.h:125
 TRootBrowser.h:126
 TRootBrowser.h:127
 TRootBrowser.h:128
 TRootBrowser.h:129
 TRootBrowser.h:130
 TRootBrowser.h:131
 TRootBrowser.h:132
 TRootBrowser.h:133
 TRootBrowser.h:134
 TRootBrowser.h:135
 TRootBrowser.h:136
 TRootBrowser.h:137
 TRootBrowser.h:138
 TRootBrowser.h:139
 TRootBrowser.h:140
 TRootBrowser.h:141
 TRootBrowser.h:142
 TRootBrowser.h:143
 TRootBrowser.h:144
 TRootBrowser.h:145
 TRootBrowser.h:146
 TRootBrowser.h:147
 TRootBrowser.h:148
 TRootBrowser.h:149
 TRootBrowser.h:150
 TRootBrowser.h:151
 TRootBrowser.h:152
 TRootBrowser.h:153
 TRootBrowser.h:154
 TRootBrowser.h:155
 TRootBrowser.h:156
 TRootBrowser.h:157
 TRootBrowser.h:158
 TRootBrowser.h:159
 TRootBrowser.h:160
 TRootBrowser.h:161
 TRootBrowser.h:162
 TRootBrowser.h:163
 TRootBrowser.h:164
 TRootBrowser.h:165
 TRootBrowser.h:166
 TRootBrowser.h:167
 TRootBrowser.h:168
 TRootBrowser.h:169
 TRootBrowser.h:170
 TRootBrowser.h:171
 TRootBrowser.h:172
 TRootBrowser.h:173
 TRootBrowser.h:174
 TRootBrowser.h:175
 TRootBrowser.h:176
 TRootBrowser.h:177
 TRootBrowser.h:178
 TRootBrowser.h:179
 TRootBrowser.h:180
 TRootBrowser.h:181
 TRootBrowser.h:182
 TRootBrowser.h:183
 TRootBrowser.h:184
 TRootBrowser.h:185
 TRootBrowser.h:186
 TRootBrowser.h:187
 TRootBrowser.h:188
 TRootBrowser.h:189
 TRootBrowser.h:190