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