]> git.lyx.org Git - lyx.git/blob - src/frontends/FileDialog.h
* src/frontends/qt4/ui/TextLayoutUi.ui:
[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 <utility>
20 #include <string>
21
22
23 namespace lyx {
24
25 namespace support { class FileFilterList; }
26
27
28 /**
29  * \class FileDialog
30  * \brief GUI-I definition of file dialog interface
31  */
32 class FileDialog
33 {
34 public:
35         /// label, directory path button
36         typedef std::pair<docstring, docstring> Button;
37
38         /// result type
39         enum ResultType {
40                 Later, /**< modeless chooser, no result */
41                 Chosen /**< string contains filename */
42         };
43
44         /// result return
45         typedef std::pair<FileDialog::ResultType, docstring> Result;
46
47         /**
48          * Constructs a file dialog with title \param title.
49          * If \param a is \const LFUN_SELECT_FILE_SYNC then a value
50          * will be returned immediately upon performing a open(),
51          * otherwise a callback Dispatch() will be invoked with the filename as
52          * argument, of action \param a.
53          *
54          * Up to two optional extra buttons are allowed for specifying
55          * additional directories in the navigation (an empty
56          * directory is interpreted as getcwd())
57          */
58         FileDialog(docstring const & title,
59                    kb_action a = LFUN_SELECT_FILE_SYNC,
60                    Button b1 = Button(docstring(), docstring()),
61                    Button b2 = Button(docstring(), docstring()));
62
63
64         ~FileDialog();
65
66         /// Choose a file for opening, starting in directory \c path.
67         Result const open(docstring const & path,
68                           support::FileFilterList const & filters,
69                           docstring const & suggested);
70
71         /// Choose a directory, starting in directory \c path.
72         Result const opendir(docstring const & path = docstring(),
73                              docstring const & suggested = docstring());
74
75         /// Choose a file for saving, starting in directory \c  path.
76         Result const save(docstring const & path,
77                           support::FileFilterList const & filters,
78                           docstring const & suggested);
79
80 private:
81         class Private;
82         friend class Private;
83         Private * private_;
84
85         /// the dialog title
86         docstring title_;
87
88         /// success action to perform if not synchronous
89         kb_action success_;
90 };
91
92 } // namespace lyx
93
94 #endif // FILEDIALOG_H