Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/gui:$Id$
0002 // Author: Bertrand Bellenot   26/09/2007
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2007, 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 #ifndef ROOT_TGFileBrowser
0013 #define ROOT_TGFileBrowser
0014 
0015 #include "TGFrame.h"
0016 
0017 #include "TBrowserImp.h"
0018 
0019 #include <list>
0020 #include <map>
0021 #include <string>
0022 
0023 class TGCanvas;
0024 class TGListTree;
0025 class TGListTreeItem;
0026 class TGPicture;
0027 class TGComboBox;
0028 class TContextMenu;
0029 class TRegexp;
0030 class TString;
0031 class TRootBrowser;
0032 class TSystemDirectory;
0033 class TSystemFile;
0034 class TGPictureButton;
0035 
0036 class TGFileBrowser : public TGMainFrame, public TBrowserImp {
0037 
0038 public:
0039    typedef std::list<TGListTreeItem*> sLTI_t;
0040    typedef sLTI_t::iterator           sLTI_i;
0041    typedef sLTI_t::reverse_iterator   sLTI_ri;
0042    typedef std::map<TGListTreeItem*, std::string> mFiltered_t;
0043 
0044 protected:
0045    TRootBrowser      *fNewBrowser;        ///< Pointer back to the Browser
0046    TGHorizontalFrame *fTopFrame;          ///< Top horizontal frame
0047    TGHorizontalFrame *fBotFrame;          ///< Bottom horizontal frame
0048    TGCanvas          *fCanvas;            ///< Canvas for the list tree
0049    TGListTree        *fListTree;          ///< Main list tree
0050    TGListTreeItem    *fListLevel;         ///< Current list tree level
0051    TGListTreeItem    *fCurrentDir;        ///< Current (list tree) directory
0052    TGListTreeItem    *fRootDir;           ///< Root (list tree) directory
0053    TGComboBox        *fDrawOption;        ///< Draw options combobox
0054    TGComboBox        *fFileType;          ///< File type combobox
0055    TContextMenu      *fContextMenu;       ///< pointer to context menu
0056    TGPictureButton   *fSortButton;        ///< "Sort" button
0057    TGPictureButton   *fRefreshButton;     ///< "Refresh" button
0058    TGPictureButton   *fFilterButton;      ///< "Filter" button
0059    const TGPicture   *fRootIcon;          ///< Root files icon
0060    const TGPicture   *fFileIcon;          ///< System files icon
0061    const TGPicture   *fCachedPic;         ///< Cached picture
0062    TString            fCachedPicName;     ///< Cached picture name
0063    TRegexp           *fFilter;            ///< Regular expression used to filter files
0064    TSystemDirectory  *fDir;               ///< Actual (selected) system directory
0065    TSystemFile       *fFile;              ///< Actual (selected) system file
0066    Int_t              fGroupSize;         ///< total number of items when icon box switched to "global view" mode
0067    Long_t             fNKeys, fCnt;       ///< Counters for keys inside a Root file
0068    Bool_t             fGrouped;           ///< kTRUE if Root file content (keys) is grouped
0069    Bool_t             fShowHidden;        ///< kTRUE to display hidden files
0070    Bool_t             fDblClick;          ///< kTRUE if user double-clicked on a list tree item
0071 
0072    sLTI_t             fSortedItems;       ///< List of sorted list-tree items.
0073    mFiltered_t        fFilteredItems;     ///< List of filtered list-tree items.
0074    TString            fFilterStr;         ///< Filter expression string
0075 
0076    void CreateBrowser();
0077 
0078 public:
0079    TGFileBrowser(const TGWindow *p, TBrowser *b = nullptr, UInt_t w = 200, UInt_t h = 400);
0080    ~TGFileBrowser() override;
0081 
0082    void         Add(TObject *obj, const char *name = nullptr, Int_t check = -1) override;
0083    void         BrowseObj(TObject *obj) override;
0084    void         RecursiveRemove(TObject *obj) override;
0085    void         Refresh(Bool_t force = kFALSE) override;
0086    void         Show() override { MapRaised(); }
0087    Option_t    *GetDrawOption() const override;
0088 
0089    TRootBrowser *GetNewBrowser() const          { return fNewBrowser; }
0090    void          SetNewBrowser(TRootBrowser* b) { fNewBrowser = b;    }
0091 
0092    void        AddFSDirectory(const char* entry, const char* path = nullptr, Option_t *opt = "");
0093    void        AddKey(TGListTreeItem *itm, TObject *obj, const char *name = nullptr);
0094    void        AddRemoteFile(TObject *obj);
0095    void        ApplyFilter(Int_t id);
0096    void        Chdir(TGListTreeItem *item);
0097    void        Checked(TObject *obj, Bool_t check);
0098    Bool_t      CheckFiltered(TGListTreeItem *item, Bool_t but = kFALSE);
0099    void        CheckRemote(TGListTreeItem *item);
0100    Bool_t      CheckSorted(TGListTreeItem *item, Bool_t but = kFALSE);
0101    void        Clicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y);
0102    TString     DirName(TGListTreeItem* item);
0103    TString     FullPathName(TGListTreeItem* item);
0104    void        DoubleClicked(TGListTreeItem *item, Int_t btn);
0105    Long_t      XXExecuteDefaultAction(TObject *obj);
0106    char       *FormatFileInfo(const char *fname, Long64_t size, Long_t modtime);
0107    void        GetFilePictures(const TGPicture **pic, Int_t file_type, Bool_t is_link, const char *name);
0108    void        GetObjPicture(const TGPicture **pic, TObject *obj);
0109    void        GotoDir(const char *path);
0110    void        PadModified();
0111    void        RequestFilter();
0112    void        Selected(char *);
0113    void        ToggleSort();
0114    void        Update();
0115 
0116    TGListTree     *GetListTree() const { return fListTree; }
0117    TGListTreeItem *GetRootDir() const { return fRootDir; }
0118 
0119    ClassDefOverride(TGFileBrowser, 0) // File browser.
0120 };
0121 
0122 #endif