Logo ROOT  
Reference Guide
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-2000, 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
40};
41
42
43class TGTextBuffer;
44class TGTextEntry;
45class TGComboBox;
46class TGPictureButton;
47class TGTextButton;
48class TGCheckButton;
49class TGListView;
50class TGFileContainer;
51class TGFSComboBox;
52
53
55
56private:
57 TGFileInfo(const TGFileInfo&) = delete; // not implemented
58 TGFileInfo& operator=(const TGFileInfo&) = delete; // not implemented
59
60public:
61 char *fFilename{nullptr}; // selected file name
62 char *fIniDir{nullptr}; // on input: initial directory, on output: new directory
63 const char **fFileTypes{nullptr}; // file types used to filter selectable files
64 Int_t fFileTypeIdx{0}; // selected file type, index in fFileTypes
65 Bool_t fOverwrite{kFALSE}; // if true overwrite the file with existing name on save
66 Bool_t fMultipleSelection{kFALSE}; // if true, allow multiple file selection
67 TList *fFileNamesList{nullptr}; // list of selected file names
68
69 TGFileInfo() = default;
71
72 void SetFilename(const char *fname);
73 void SetIniDir(const char *inidir);
75
76 void SetMultipleSelection(Bool_t option);
77};
78
79
81
82protected:
83 TGTextBuffer *fTbfname; // text buffer of file name
84 TGTextEntry *fName; // file name text entry
85 TGComboBox *fTypes; // file type combo box
86 TGFSComboBox *fTreeLB; // file system path combo box
87 TGPictureButton *fCdup; // top toolbar button
88 TGPictureButton *fNewf; // top toolbar button
89 TGPictureButton *fList; // top toolbar button
90 TGPictureButton *fDetails; // top toolbar button
91 TGCheckButton *fCheckB; // set on/off file overwriting for Open dialog
92 // OR set on/off multiple file selection for SaveAs dialog
93 const TGPicture *fPcdup; // picture for fCdup
94 const TGPicture *fPnewf; // picture for fNewf
95 const TGPicture *fPlist; // picture for fList
96 const TGPicture *fPdetails; // picture for fDetails
97 TGTextButton *fOk; // ok button
98 TGTextButton *fCancel; // cancel button
99 TGListView *fFv; // file list view
100 TGFileContainer *fFc; // file list view container (containing the files)
101 TGFileInfo *fFileInfo; // file info passed to this dialog
102
103private:
104 TGFileDialog(const TGFileDialog&); // not implemented
105 TGFileDialog& operator=(const TGFileDialog&); // not implemented
106
107public:
108 TGFileDialog(const TGWindow *p = 0, const TGWindow *main = 0,
109 EFileDialogMode dlg_type = kFDOpen, TGFileInfo *file_info = 0);
110 virtual ~TGFileDialog();
111
112 virtual Bool_t ProcessMessage(Long_t msg, Long_t parm1, Long_t parm2);
113 virtual void CloseWindow();
114
115 ClassDef(TGFileDialog,0) //File selection dialog
116};
117
118#endif
int Int_t
Definition: RtypesCore.h:43
const Bool_t kFALSE
Definition: RtypesCore.h:90
long Long_t
Definition: RtypesCore.h:52
bool Bool_t
Definition: RtypesCore.h:61
#define ClassDef(name, id)
Definition: Rtypes.h:322
EFileDialogMode
Definition: TGFileDialog.h:37
@ kFDOpen
Definition: TGFileDialog.h:38
@ kFDSave
Definition: TGFileDialog.h:39
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
Definition: TGFileDialog.h:93
const TGPicture * fPdetails
Definition: TGFileDialog.h:96
TGFileContainer * fFc
Definition: TGFileDialog.h:100
TGPictureButton * fDetails
Definition: TGFileDialog.h:90
TGPictureButton * fNewf
Definition: TGFileDialog.h:88
TGTextBuffer * fTbfname
Definition: TGFileDialog.h:83
TGTextButton * fCancel
Definition: TGFileDialog.h:98
TGFSComboBox * fTreeLB
Definition: TGFileDialog.h:86
virtual void CloseWindow()
Close file dialog.
TGFileInfo * fFileInfo
Definition: TGFileDialog.h:101
TGTextEntry * fName
Definition: TGFileDialog.h:84
const TGPicture * fPnewf
Definition: TGFileDialog.h:94
TGPictureButton * fList
Definition: TGFileDialog.h:89
TGPictureButton * fCdup
Definition: TGFileDialog.h:87
TGListView * fFv
Definition: TGFileDialog.h:99
const TGPicture * fPlist
Definition: TGFileDialog.h:95
TGFileDialog(const TGFileDialog &)
virtual ~TGFileDialog()
Delete file dialog.
TGTextButton * fOk
Definition: TGFileDialog.h:97
TGCheckButton * fCheckB
Definition: TGFileDialog.h:91
TGFileDialog & operator=(const TGFileDialog &)
TGComboBox * fTypes
Definition: TGFileDialog.h:85
TList * fFileNamesList
Definition: TGFileDialog.h:67
TGFileInfo & operator=(const TGFileInfo &)=delete
char * fFilename
Definition: TGFileDialog.h:61
void SetMultipleSelection(Bool_t option)
Turn on/off multiple selection.
Int_t fFileTypeIdx
Definition: TGFileDialog.h:64
const char ** fFileTypes
Definition: TGFileDialog.h:63
char * fIniDir
Definition: TGFileDialog.h:62
~TGFileInfo()
TGFileInfo Destructor.
TGFileInfo(const TGFileInfo &)=delete
Bool_t fOverwrite
Definition: TGFileDialog.h:65
void DeleteFileNamesList()
Delete file names list.
void SetFilename(const char *fname)
Set file name.
Bool_t fMultipleSelection
Definition: TGFileDialog.h:66
void SetIniDir(const char *inidir)
Set directory name.
TGFileInfo()=default
A doubly linked list.
Definition: TList.h:44
int main(int argc, char **argv)