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: Fons Rademakers   20/01/98
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2021, 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_TGFileDialog
0014 #define ROOT_TGFileDialog
0015 
0016 
0017 #include "TGFrame.h"
0018 
0019 
0020 enum EFileDialogMode {
0021    kFDOpen,
0022    kFDSave,
0023    kDOpen,
0024    kDSave
0025 };
0026 
0027 
0028 class TGTextBuffer;
0029 class TGTextEntry;
0030 class TGComboBox;
0031 class TGPictureButton;
0032 class TGTextButton;
0033 class TGCheckButton;
0034 class TGListView;
0035 class TGFileContainer;
0036 class TGFSComboBox;
0037 
0038 
0039 class TGFileInfo {
0040 
0041 private:
0042    TGFileInfo(const TGFileInfo&) = delete;
0043    TGFileInfo& operator=(const TGFileInfo&) = delete;
0044 
0045 public:
0046    char         *fFilename{nullptr};            ///< selected file name
0047    char         *fIniDir{nullptr};              ///< on input: initial directory, on output: new directory
0048    const char  **fFileTypes{nullptr};           ///< file types used to filter selectable files
0049    Int_t         fFileTypeIdx{0};               ///< selected file type, index in fFileTypes
0050    Bool_t        fOverwrite{kFALSE};            ///< if true overwrite the file with existing name on save
0051    Bool_t        fMultipleSelection{kFALSE};    ///< if true, allow multiple file selection
0052    TList        *fFileNamesList{nullptr};       ///< list of selected file names
0053 
0054    TGFileInfo() = default;
0055    ~TGFileInfo();
0056 
0057    void SetFilename(const char *fname);
0058    void SetIniDir(const char *inidir);
0059    void DeleteFileNamesList();
0060 
0061    void SetMultipleSelection(Bool_t option);
0062 };
0063 
0064 
0065 class TGFileDialog : public TGTransientFrame {
0066 
0067 protected:
0068    TGTextBuffer      *fTbfname;  ///< text buffer of file name
0069    TGTextEntry       *fName;     ///< file name text entry
0070    TGComboBox        *fTypes;    ///< file type combo box
0071    TGFSComboBox      *fTreeLB;   ///< file system path combo box
0072    TGPictureButton   *fCdup;     ///< top toolbar button
0073    TGPictureButton   *fNewf;     ///< top toolbar button
0074    TGPictureButton   *fList;     ///< top toolbar button
0075    TGPictureButton   *fDetails;  ///< top toolbar button
0076    TGCheckButton     *fCheckB;   ///< set on/off file overwriting for Open dialog
0077                                  ///< OR set on/off multiple file selection for SaveAs dialog
0078    const TGPicture   *fPcdup;    ///< picture for fCdup
0079    const TGPicture   *fPnewf;    ///< picture for fNewf
0080    const TGPicture   *fPlist;    ///< picture for fList
0081    const TGPicture   *fPdetails; ///< picture for fDetails
0082    TGTextButton      *fOk;       ///< ok button
0083    TGTextButton      *fCancel;   ///< cancel button
0084    TGListView        *fFv;       ///< file list view
0085    TGFileContainer   *fFc;       ///< file list view container (containing the files)
0086    TGFileInfo        *fFileInfo; ///< file info passed to this dialog
0087    EFileDialogMode    fDlgType;  ///< the dialog type passed
0088 
0089 private:
0090    TGFileDialog(const TGFileDialog&) = delete;
0091    TGFileDialog& operator=(const TGFileDialog&) = delete;
0092 
0093 public:
0094    TGFileDialog(const TGWindow *p = nullptr, const TGWindow *main = nullptr,
0095                 EFileDialogMode dlg_type = kFDOpen, TGFileInfo *file_info = nullptr);
0096    ~TGFileDialog() override;
0097 
0098    Bool_t ProcessMessage(Longptr_t msg, Longptr_t parm1, Longptr_t parm2) override;
0099    void CloseWindow() override;
0100 
0101    ClassDefOverride(TGFileDialog,0)  //File selection dialog
0102 };
0103 
0104 #endif