// @(#)root/gui:$Id$
// 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_TGFileBrowser
#define ROOT_TGFileBrowser

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

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

#include <list>
#include <map>

class TGCanvas;
class TGListTree;
class TGListTreeItem;
class TGPicture;
class TGComboBox;
class TContextMenu;
class TRegexp;
class TString;
class TRootBrowser;
class TSystemDirectory;
class TSystemFile;
class TGPictureButton;

class TGFileBrowser : public TGMainFrame, public TBrowserImp {

public:
   typedef std::list<TGListTreeItem*> sLTI_t;
   typedef sLTI_t::iterator           sLTI_i;
   typedef sLTI_t::reverse_iterator   sLTI_ri;
   typedef std::map<TGListTreeItem*, const char *> mFiltered_t;
   typedef mFiltered_t::iterator      mFiltered_i;

protected:
   TRootBrowser      *fNewBrowser;        // Pointer back to the Browser
   TGHorizontalFrame *fTopFrame;          // Top horizontal frame
   TGHorizontalFrame *fBotFrame;          // Bottom horizontal frame
   TGCanvas          *fCanvas;            // Canvas for the list tree
   TGListTree        *fListTree;          // Main list tree
   TGListTreeItem    *fListLevel;         // Current list tree level
   TGListTreeItem    *fCurrentDir;        // Current (list tree) directory
   TGListTreeItem    *fRootDir;           // Root (list tree) directory
   TGComboBox        *fDrawOption;        // Draw options combobox
   TGComboBox        *fFileType;          // File type combobox
   TContextMenu      *fContextMenu;       // pointer to context menu
   TGPictureButton   *fSortButton;        // "Sort" button
   TGPictureButton   *fRefreshButton;     // "Refresh" button
   TGPictureButton   *fFilterButton;      // "Filter" button
   const TGPicture   *fRootIcon;          // Root files icon
   const TGPicture   *fFileIcon;          // System files icon
   const TGPicture   *fCachedPic;         // Cached picture
   TString            fCachedPicName;     // Cached picture name
   TRegexp           *fFilter;            // Regular expression used to filter files
   TSystemDirectory  *fDir;               // Actual (selected) system directory
   TSystemFile       *fFile;              // Actual (selected) system file
   Int_t              fGroupSize;         // total number of items when icon box switched to "global view" mode
   Long_t             fNKeys, fCnt;       // Counters for keys inside a Root file
   Bool_t             fGrouped;           // kTRUE if Root file content (keys) is grouped
   Bool_t             fShowHidden;        // kTRUE to display hidden files
   Bool_t             fDblClick;          // kTRUE if user double-clicked on a list tree item

   sLTI_t             fSortedItems;       // List of sorted list-tree items.
   mFiltered_t        fFilteredItems;     // List of filtered list-tree items.
   TString            fFilterStr;         // Filter expression string

   void CreateBrowser();

public:
   TGFileBrowser(const TGWindow *p, TBrowser* b=0, UInt_t w=200, UInt_t h=400);
   virtual ~TGFileBrowser();

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

   TRootBrowser *GetNewBrowser() const          { return fNewBrowser; }
   void          SetNewBrowser(TRootBrowser* b) { fNewBrowser = b;    }

   void        AddFSDirectory(const char* entry, const char* path=0, Option_t *opt="");
   void        AddKey(TGListTreeItem *itm, TObject *obj, const char *name = 0);
   void        AddRemoteFile(TObject *obj);
   void        ApplyFilter(Int_t id);
   void        Chdir(TGListTreeItem *item);
   void        Checked(TObject *obj, Bool_t check);
   Bool_t      CheckFiltered(TGListTreeItem *item, Bool_t but = kFALSE);
   void        CheckRemote(TGListTreeItem *item);
   Bool_t      CheckSorted(TGListTreeItem *item, Bool_t but = kFALSE);
   void        Clicked(TGListTreeItem *item, Int_t btn, Int_t x, Int_t y);
   TString     DirName(TGListTreeItem* item);
   TString     FullPathName(TGListTreeItem* item);
   void        DoubleClicked(TGListTreeItem *item, Int_t btn);
   Long_t      XXExecuteDefaultAction(TObject *obj);
   char       *FormatFileInfo(const char *fname, Long64_t size, Long_t modtime);
   void        GetFilePictures(const TGPicture **pic, Int_t file_type, Bool_t is_link, const char *name);
   void        GetObjPicture(const TGPicture **pic, TObject *obj);
   void        GotoDir(const char *path);
   void        PadModified();
   void        RequestFilter();
   void        Selected(char *);
   void        ToggleSort();
   void        Update();

   ClassDef(TGFileBrowser, 0) // File browser.
};

#endif
 TGFileBrowser.h:1
 TGFileBrowser.h:2
 TGFileBrowser.h:3
 TGFileBrowser.h:4
 TGFileBrowser.h:5
 TGFileBrowser.h:6
 TGFileBrowser.h:7
 TGFileBrowser.h:8
 TGFileBrowser.h:9
 TGFileBrowser.h:10
 TGFileBrowser.h:11
 TGFileBrowser.h:12
 TGFileBrowser.h:13
 TGFileBrowser.h:14
 TGFileBrowser.h:15
 TGFileBrowser.h:16
 TGFileBrowser.h:17
 TGFileBrowser.h:18
 TGFileBrowser.h:19
 TGFileBrowser.h:20
 TGFileBrowser.h:21
 TGFileBrowser.h:22
 TGFileBrowser.h:23
 TGFileBrowser.h:24
 TGFileBrowser.h:25
 TGFileBrowser.h:26
 TGFileBrowser.h:27
 TGFileBrowser.h:28
 TGFileBrowser.h:29
 TGFileBrowser.h:30
 TGFileBrowser.h:31
 TGFileBrowser.h:32
 TGFileBrowser.h:33
 TGFileBrowser.h:34
 TGFileBrowser.h:35
 TGFileBrowser.h:36
 TGFileBrowser.h:37
 TGFileBrowser.h:38
 TGFileBrowser.h:39
 TGFileBrowser.h:40
 TGFileBrowser.h:41
 TGFileBrowser.h:42
 TGFileBrowser.h:43
 TGFileBrowser.h:44
 TGFileBrowser.h:45
 TGFileBrowser.h:46
 TGFileBrowser.h:47
 TGFileBrowser.h:48
 TGFileBrowser.h:49
 TGFileBrowser.h:50
 TGFileBrowser.h:51
 TGFileBrowser.h:52
 TGFileBrowser.h:53
 TGFileBrowser.h:54
 TGFileBrowser.h:55
 TGFileBrowser.h:56
 TGFileBrowser.h:57
 TGFileBrowser.h:58
 TGFileBrowser.h:59
 TGFileBrowser.h:60
 TGFileBrowser.h:61
 TGFileBrowser.h:62
 TGFileBrowser.h:63
 TGFileBrowser.h:64
 TGFileBrowser.h:65
 TGFileBrowser.h:66
 TGFileBrowser.h:67
 TGFileBrowser.h:68
 TGFileBrowser.h:69
 TGFileBrowser.h:70
 TGFileBrowser.h:71
 TGFileBrowser.h:72
 TGFileBrowser.h:73
 TGFileBrowser.h:74
 TGFileBrowser.h:75
 TGFileBrowser.h:76
 TGFileBrowser.h:77
 TGFileBrowser.h:78
 TGFileBrowser.h:79
 TGFileBrowser.h:80
 TGFileBrowser.h:81
 TGFileBrowser.h:82
 TGFileBrowser.h:83
 TGFileBrowser.h:84
 TGFileBrowser.h:85
 TGFileBrowser.h:86
 TGFileBrowser.h:87
 TGFileBrowser.h:88
 TGFileBrowser.h:89
 TGFileBrowser.h:90
 TGFileBrowser.h:91
 TGFileBrowser.h:92
 TGFileBrowser.h:93
 TGFileBrowser.h:94
 TGFileBrowser.h:95
 TGFileBrowser.h:96
 TGFileBrowser.h:97
 TGFileBrowser.h:98
 TGFileBrowser.h:99
 TGFileBrowser.h:100
 TGFileBrowser.h:101
 TGFileBrowser.h:102
 TGFileBrowser.h:103
 TGFileBrowser.h:104
 TGFileBrowser.h:105
 TGFileBrowser.h:106
 TGFileBrowser.h:107
 TGFileBrowser.h:108
 TGFileBrowser.h:109
 TGFileBrowser.h:110
 TGFileBrowser.h:111
 TGFileBrowser.h:112
 TGFileBrowser.h:113
 TGFileBrowser.h:114
 TGFileBrowser.h:115
 TGFileBrowser.h:116
 TGFileBrowser.h:117
 TGFileBrowser.h:118
 TGFileBrowser.h:119
 TGFileBrowser.h:120
 TGFileBrowser.h:121
 TGFileBrowser.h:122
 TGFileBrowser.h:123