Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:11:33

0001 // @(#)root/base:$Id$
0002 // Author: Fons Rademakers   25/10/95
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 
0013 #ifndef ROOT_TBrowser
0014 #define ROOT_TBrowser
0015 
0016 //////////////////////////////////////////////////////////////////////////
0017 //                                                                      //
0018 // TBrowser                                                             //
0019 //                                                                      //
0020 // Using a TBrowser on can browse all ROOT objects. It shows in a list  //
0021 // on the left side of the window all browsable ROOT classes. Selecting //
0022 // one of the classes displays, in the iconbox on the right side, all   //
0023 // objects in the class. Selecting one of the objects in the iconbox,   //
0024 // will place all browsable objects in a new list and draws the         //
0025 // contents of the selected class in the iconbox. And so on....         //
0026 //                                                                      //
0027 //////////////////////////////////////////////////////////////////////////
0028 
0029 #include "TNamed.h"
0030 #include "TBrowserImp.h"
0031 
0032 
0033 class TContextMenu;
0034 class TBrowserTimer;
0035 
0036 
0037 class TBrowser : public TNamed {
0038 
0039 private:
0040    TObject       *fLastSelectedObject{nullptr}; //!The last TObject selected by user
0041 
0042    TBrowser(const TBrowser&) = delete;             // TBrowser can not be copied since we do not know the type of the TBrowserImp (and it can not be 'Cloned')
0043    TBrowser& operator=(const TBrowser&) = delete;  // TBrowser can not be copied since we do not know the type of the TBrowserImp (and it can not be 'Cloned')
0044 
0045 protected:
0046    TBrowserImp   *fImp{nullptr};                //!Window system specific browser implementation
0047    TBrowserTimer *fTimer{nullptr};              //!Browser's timer
0048    TContextMenu  *fContextMenu{nullptr};        //!Context menu pointer
0049    Bool_t         fNeedRefresh{kFALSE};         //True if the browser needs refresh
0050 
0051    Bool_t         InitGraphics();
0052 
0053 public:
0054    enum EStatusBits {
0055       kNoHidden     = BIT(9)   // don't show '.' files and directories
0056    };
0057 
0058    TBrowser(const char *name="Browser", const char *title = "ROOT Object Browser", TBrowserImp *extimp = nullptr, Option_t *opt = "");
0059    TBrowser(const char *name, const char *title, UInt_t width, UInt_t height, TBrowserImp *extimp = nullptr, Option_t *opt = "");
0060    TBrowser(const char *name, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height, TBrowserImp *extimp = nullptr, Option_t *opt = "");
0061 
0062    TBrowser(const char *name, TObject *obj, const char *title="ROOT Object Browser", Option_t *opt="");
0063    TBrowser(const char *name, TObject *obj, const char *title, UInt_t width, UInt_t height, Option_t *opt="");
0064    TBrowser(const char *name, TObject *obj, const char *title, Int_t x, Int_t y, UInt_t width, UInt_t height, Option_t *opt="");
0065 
0066    TBrowser(const char *name, void *obj, TClass *cl, const char *objname="", const char *title="ROOT Foreign Browser", Option_t *opt="");
0067    TBrowser(const char *name, void *obj, TClass *cl, const char *objname, const char *title, UInt_t width, UInt_t height, Option_t *opt="");
0068    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="");
0069 
0070    // In a world with only standard C++ compliant compilers, we could also add:
0071    // template <class T>  TBrowser(const char *name, T *obj, const char *objname="", const char *title="ROOT Foreign Browser") :
0072    //       : TNamed(name, title), fLastSelectedObject(0), fTimer(0), fContextMenu(0),
0073    //            fNeedRefresh(kFALSE)
0074    // {
0075    //    Create a new browser with a name, title, width and height for TObject *obj.
0076    //
0077    //    fImp = gGuiFactory->CreateBrowserImp(this, title, width, height);
0078    //    Create(new TBrowserObject(obj,gROOT->GetClass(typeid(T)),objname));
0079    // }
0080 
0081    virtual ~TBrowser();
0082 
0083    void          Add(TObject *obj,             const char *name = nullptr, Int_t check = -1);
0084    void          Add(void    *obj, TClass *cl, const char *name = nullptr, Int_t check = -1);
0085 
0086    void          AddCheckBox(TObject *obj, Bool_t check = kFALSE);
0087    void          CheckObjectItem(TObject *obj, Bool_t check = kFALSE);
0088    void          RemoveCheckBox(TObject *obj);
0089 
0090    virtual void  Create(TObject *obj = nullptr);      // Create this Browser
0091    virtual void  Destructor();
0092    void          BrowseObject(TObject *obj)    { if (fImp) fImp->BrowseObj(obj); }
0093    void          ExecuteDefaultAction(TObject *obj);
0094    TBrowserImp  *GetBrowserImp() const         { return fImp; }
0095    void          SetBrowserImp(TBrowserImp *i) { fImp = i; }
0096    TContextMenu *GetContextMenu() const        { return fContextMenu; }
0097    Bool_t        GetRefreshFlag() const        { return fNeedRefresh; }
0098    TObject      *GetSelected() const           { return fLastSelectedObject; }
0099    void          SetRefreshFlag(Bool_t flag)   { fNeedRefresh = flag; }
0100    void          Iconify()                     { if (fImp) fImp->Iconify(); }
0101    void          RecursiveRemove(TObject *obj) override;
0102    void          Refresh();
0103    void          SetSelected(TObject *clickedObject);
0104    void          Show()                        { if (fImp) fImp->Show(); }
0105    void          SetDrawOption(Option_t *option="") override { if (fImp) fImp->SetDrawOption(option); }
0106    Option_t     *GetDrawOption() const override { return  (fImp) ? fImp->GetDrawOption() : nullptr; }
0107 
0108    Longptr_t     ExecPlugin(const char *name = nullptr, const char *fname = nullptr,
0109                             const char *cmd = nullptr, Int_t pos = 1, Int_t subpos = -1) {
0110                     return (fImp) ? fImp->ExecPlugin(name, fname, cmd, pos, subpos) : -1;
0111                  }
0112    void          SetStatusText(const char *txt, Int_t col) {
0113                     if (fImp) fImp->SetStatusText(txt, col);
0114                  }
0115    void          StartEmbedding(Int_t pos, Int_t subpos) {
0116                     if (fImp) fImp->StartEmbedding(pos, subpos);
0117                  }
0118    void          StopEmbedding(const char *name = "") { if (fImp) fImp->StopEmbedding(name); }
0119 
0120    ClassDefOverride(TBrowser,0)  //ROOT Object Browser
0121 };
0122 
0123 #endif