Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGFileDialog.h
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 20/01/98
3
4/*************************************************************************
5 * Copyright (C) 1995-2021, 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_TGFileDialog
14#define ROOT_TGFileDialog
15
16//////////////////////////////////////////////////////////////////////////
17// //
18// TGFileDialog //
19// //
20// This class creates a file selection dialog. It contains a combo box //
21// to select the desired directory. A listview with the different //
22// files in the current directory and a combo box with which you can //
23// select a filter (on file extensions). //
24// When creating a file dialog one passes a pointer to a TGFileInfo //
25// object. In this object you can set the fFileTypes and fIniDir to //
26// specify the list of file types for the filter combo box and the //
27// initial directory. When the TGFileDialog ctor returns the selected //
28// file name can be found in the TGFileInfo::fFilename field and the //
29// selected directory in TGFileInfo::fIniDir. The fFilename and //
30// fIniDir are deleted by the TGFileInfo dtor. //
31// //
32//////////////////////////////////////////////////////////////////////////
33
34#include "TGFrame.h"
35
36
41 kDSave
42};
43
44
45class TGTextBuffer;
46class TGTextEntry;
47class TGComboBox;
48class TGPictureButton;
49class TGTextButton;
50class TGCheckButton;
51class TGListView;
52class TGFileContainer;
53class TGFSComboBox;
54
55
57
58private:
59 TGFileInfo(const TGFileInfo&) = delete;
60 TGFileInfo& operator=(const TGFileInfo&) = delete;
61
62public:
63 char *fFilename{nullptr}; // selected file name
64 char *fIniDir{nullptr}; // on input: initial directory, on output: new directory
65 const char **fFileTypes{nullptr}; // file types used to filter selectable files
66 Int_t fFileTypeIdx{0}; // selected file type, index in fFileTypes
67 Bool_t fOverwrite{kFALSE}; // if true overwrite the file with existing name on save
68 Bool_t fMultipleSelection{kFALSE}; // if true, allow multiple file selection
69 TList *fFileNamesList{nullptr}; // list of selected file names
70
71 TGFileInfo() = default;
73
74 void SetFilename(const char *fname);
75 void SetIniDir(const char *inidir);
77
78 void SetMultipleSelection(Bool_t option);
79};
80
81
83
84protected:
85 TGTextBuffer *fTbfname; // text buffer of file name
86 TGTextEntry *fName; // file name text entry
87 TGComboBox *fTypes; // file type combo box
88 TGFSComboBox *fTreeLB; // file system path combo box
89 TGPictureButton *fCdup; // top toolbar button
90 TGPictureButton *fNewf; // top toolbar button
91 TGPictureButton *fList; // top toolbar button
92 TGPictureButton *fDetails; // top toolbar button
93 TGCheckButton *fCheckB; // set on/off file overwriting for Open dialog
94 // OR set on/off multiple file selection for SaveAs dialog
95 const TGPicture *fPcdup; // picture for fCdup
96 const TGPicture *fPnewf; // picture for fNewf
97 const TGPicture *fPlist; // picture for fList
98 const TGPicture *fPdetails; // picture for fDetails
99 TGTextButton *fOk; // ok button
100 TGTextButton *fCancel; // cancel button
101 TGListView *fFv; // file list view
102 TGFileContainer *fFc; // file list view container (containing the files)
103 TGFileInfo *fFileInfo; // file info passed to this dialog
104 EFileDialogMode fDlgType; // the dialog type passed
105
106private:
107 TGFileDialog(const TGFileDialog&) = delete;
109
110public:
111 TGFileDialog(const TGWindow *p = nullptr, const TGWindow *main = nullptr,
112 EFileDialogMode dlg_type = kFDOpen, TGFileInfo *file_info = nullptr);
113 virtual ~TGFileDialog();
114
115 virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
116 virtual void CloseWindow();
117
118 ClassDef(TGFileDialog,0) //File selection dialog
119};
120
121#endif
const Bool_t kFALSE
Definition RtypesCore.h:92
long Long_t
Definition RtypesCore.h:54
#define ClassDef(name, id)
Definition Rtypes.h:325
EFileDialogMode
@ kFDOpen
@ kDOpen
@ kDSave
@ kFDSave
virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2)
Process messages generated by the user input in the file dialog.
const TGPicture * fPcdup
const TGPicture * fPdetails
TGFileContainer * fFc
TGFileDialog & operator=(const TGFileDialog &)=delete
TGPictureButton * fDetails
TGPictureButton * fNewf
EFileDialogMode fDlgType
TGTextBuffer * fTbfname
TGTextButton * fCancel
TGFSComboBox * fTreeLB
virtual void CloseWindow()
Close file dialog.
TGFileInfo * fFileInfo
TGTextEntry * fName
const TGPicture * fPnewf
TGPictureButton * fList
TGPictureButton * fCdup
TGListView * fFv
const TGPicture * fPlist
virtual ~TGFileDialog()
Delete file dialog.
TGTextButton * fOk
TGCheckButton * fCheckB
TGFileDialog(const TGFileDialog &)=delete
TGComboBox * fTypes
TList * fFileNamesList
TGFileInfo & operator=(const TGFileInfo &)=delete
char * fFilename
void SetMultipleSelection(Bool_t option)
Turn on/off multiple selection.
Int_t fFileTypeIdx
const char ** fFileTypes
char * fIniDir
~TGFileInfo()
TGFileInfo Destructor.
TGFileInfo(const TGFileInfo &)=delete
Bool_t fOverwrite
void DeleteFileNamesList()
Delete file names list.
void SetFilename(const char *fname)
Set file name.
Bool_t fMultipleSelection
void SetIniDir(const char *inidir)
Set directory name.
TGFileInfo()=default
A doubly linked list.
Definition TList.h:44
int main()