]> git.lyx.org Git - lyx.git/blob - src/frontends/FileDialog.h
* Doxy: polish html output.
[lyx.git] / src / frontends / FileDialog.h
1 // -*- C++ -*-
2 /**
3  * \file FileDialog.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author unknown
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef FILEDIALOG_H
14 #define FILEDIALOG_H
15
16 #include "lfuns.h"
17 #include "support/docstring.h"
18
19 #include <string>
20
21
22 namespace lyx {
23
24 namespace support { class FileFilterList; }
25
26
27 /**
28  * \class FileDialog
29  * \brief GUI-I definition of file dialog interface
30  */
31 class FileDialog
32 {
33 public:
34         /// label, directory path button
35         typedef std::pair<docstring, docstring> Button;
36
37         /// result type
38         enum ResultType {
39                 Later, /**< modeless chooser, no result */
40                 Chosen /**< string contains filename */
41         };
42
43         /// result return
44         typedef std::pair<FileDialog::ResultType, docstring> Result;
45
46         /**
47          * Constructs a file dialog with title \param title.
48          * If \param a is \const LFUN_SELECT_FILE_SYNC then a value
49          * will be returned immediately upon performing a open(),
50          * otherwise a callback Dispatch() will be invoked with the filename as
51          * argument, of action \param a.
52          *
53          * Up to two optional extra buttons are allowed for specifying
54          * additional directories in the navigation (an empty
55          * directory is interpreted as FileName::getcwd())
56          */
57         FileDialog(docstring const & title, kb_action a = LFUN_SELECT_FILE_SYNC);
58
59         ~FileDialog();
60
61         void setButton1(docstring const & label, docstring const & dir);
62         void setButton2(docstring const & label, docstring const & dir);
63
64         /// Choose a file for opening, starting in directory \c path.
65         Result const open(docstring const & path,
66                           support::FileFilterList const & filters,
67                           docstring const & suggested);
68
69         /// Choose a directory, starting in directory \c path.
70         Result const opendir(docstring const & path = docstring(),
71                              docstring const & suggested = docstring());
72
73         /// Choose a file for saving, starting in directory \c  path.
74         Result const save(docstring const & path,
75                           support::FileFilterList const & filters,
76                           docstring const & suggested);
77
78 private:
79         class Private;
80         friend class Private;
81         Private * private_;
82
83         /// the dialog title
84         docstring title_;
85
86         /// success action to perform if not synchronous
87         kb_action success_;
88 };
89
90 } // namespace lyx
91
92 #endif // FILEDIALOG_H