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