1    	// @(#)root/base:$Id$
2    	// Author: Fons Rademakers   25/10/95
3    	
4    	/*************************************************************************
5    	 * Copyright (C) 1995-2000, 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   	
13   	#ifndef ROOT_TBrowser
14   	#define ROOT_TBrowser
15   	
16   	//////////////////////////////////////////////////////////////////////////
17   	//                                                                      //
18   	// TBrowser                                                             //
19   	//                                                                      //
20   	// Using a TBrowser on can browse all ROOT objects. It shows in a list  //
21   	// on the left side of the window all browsable ROOT classes. Selecting //
22   	// one of the classes displays, in the iconbox on the right side, all   //
23   	// objects in the class. Selecting one of the objects in the iconbox,   //
24   	// will place all browsable objects in a new list and draws the         //
25   	// contents of the selected class in the iconbox. And so on....         //
26   	//                                                                      //
27   	//////////////////////////////////////////////////////////////////////////
28   	
29   	#ifndef ROOT_TNamed
30   	#include "TNamed.h"
31   	#endif
32   	#ifndef ROOT_TBrowserImp
33   	#include "TBrowserImp.h"
34   	#endif
35   	
36   	
37   	class TContextMenu;
38   	class TBrowserTimer;
39   	
40   	
41   	class TBrowser : public TNamed {
42   	
43   	private:
44   	   TObject       *fLastSelectedObject; //!The last TObject selected by user
45   	   
46   	   TBrowser(const TBrowser&);             // TBrowser can not be copied since we do not know the type of the TBrowserImp (and it can not be 'Cloned')
47   	   TBrowser& operator=(const TBrowser&);  // TBrowser can not be copied since we do not know the type of the TBrowserImp (and it can not be 'Cloned')
48   	   
49   	protected:
50   	   TBrowserImp   *fImp;                //!Window system specific browser implementation
51   	   TBrowserTimer *fTimer;              //!Browser's timer
52   	   TContextMenu  *fContextMenu;        //!Context menu pointer
53   	   Bool_t         fNeedRefresh;        //True if the browser needs refresh
54   	
55   	public:
56   	   enum {
57   	      kNoHidden     = BIT(9)   // don't show '.' files and directories
58   	   };
59   	
60   	   TBrowser(const char *name="Browser", const char *title="ROOT Object Browser", TBrowserImp *extimp=0, Option_t *opt="");
61   	   TBrowser(const char *name, const char *title, UInt_t width, UInt_t height, TBrowserImp *extimp=0, Option_t *opt="");
62   	   TBrowser(const char *name, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height, TBrowserImp *extimp=0, Option_t *opt="");
63   	
64   	   TBrowser(const char *name, TObject *obj, const char *title="ROOT Object Browser", Option_t *opt="");
65   	   TBrowser(const char *name, TObject *obj, const char *title, UInt_t width, UInt_t height, Option_t *opt="");
66   	   TBrowser(const char *name, TObject *obj, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height, Option_t *opt="");
67   	
68   	   TBrowser(const char *name, void *obj, TClass *cl, const char *objname="", const char *title="ROOT Foreign Browser", Option_t *opt="");
69   	   TBrowser(const char *name, void *obj, TClass *cl, const char *objname, const char *title, UInt_t width, UInt_t height, Option_t *opt="");
70   	   TBrowser(const char *name, void *obj, TClass *cl, const char *objname, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height, Option_t *opt="");
71   	
72   	   // In a world with only standard C++ compliant compilers, we could also add:
73   	   // template <class T>  TBrowser(const char *name, T *obj, const char *objname="", const char *title="ROOT Foreign Browser") :
74   	   //       : TNamed(name, title), fLastSelectedObject(0), fTimer(0), fContextMenu(0),
75   	   //            fNeedRefresh(kFALSE)
76   	   // {
77   	   //    Create a new browser with a name, title, width and height for TObject *obj.
78   	   //
79   	   //    fImp = gGuiFactory->CreateBrowserImp(this, title, width, height);
80   	   //    Create(new TBrowserObject(obj,gROOT->GetClass(typeid(T)),objname));
81   	   // }
82   	
83   	   virtual ~TBrowser();
84   	
85   	   void          Add(TObject *obj,             const char *name = 0, Int_t check = -1);
86   	   void          Add(void    *obj, TClass *cl, const char *name = 0, Int_t check = -1);
87   	
88   	   void          AddCheckBox(TObject *obj, Bool_t check = kFALSE);
89   	   void          CheckObjectItem(TObject *obj, Bool_t check = kFALSE);
90   	   void          RemoveCheckBox(TObject *obj);
91   	
92   	   virtual void  Create(TObject *obj = 0);      // Create this Browser
93   	   void          BrowseObject(TObject *obj)    { fImp->BrowseObj(obj); }
94   	   void          ExecuteDefaultAction(TObject *obj);
95   	   TBrowserImp  *GetBrowserImp() const         { return fImp; }
96   	   void          SetBrowserImp(TBrowserImp *i) { fImp = i; }
97   	   TContextMenu *GetContextMenu() const        { return fContextMenu; }
98   	   Bool_t        GetRefreshFlag() const        { return fNeedRefresh; }
99   	   TObject      *GetSelected() const           { return fLastSelectedObject; }
100  	   void          SetRefreshFlag(Bool_t flag)   { fNeedRefresh = flag; }
101  	   void          Iconify()                     { fImp->Iconify(); }
102  	   virtual void  RecursiveRemove(TObject *obj);
103  	   void          Refresh();
104  	   void          SetSelected(TObject *clickedObject);
105  	   void          Show()                        { fImp->Show(); }
106  	   void          SetDrawOption(Option_t *option="") { fImp->SetDrawOption(option); }
107  	   Option_t     *GetDrawOption() const { return  fImp->GetDrawOption(); }
108  	
109  	   Long_t        ExecPlugin(const char *name = 0, const char *fname = 0, 
110  	                            const char *cmd = 0, Int_t pos = 1, Int_t subpos = -1) {
111  	                    return fImp->ExecPlugin(name, fname, cmd, pos, subpos); 
112  	                 }
113  	   void          SetStatusText(const char *txt, Int_t col) {
114  	                    fImp->SetStatusText(txt, col); 
115  	                 }
116  	   void          StartEmbedding(Int_t pos, Int_t subpos) {
117  	                    fImp->StartEmbedding(pos, subpos); 
118  	                 }
119  	   void          StopEmbedding(const char *name = "") { fImp->StopEmbedding(name); }
120  	
121  	   ClassDef(TBrowser,0)  //ROOT Object Browser
122  	};
123  	
124  	#endif
125