]> git.lyx.org Git - lyx.git/blob - src/frontends/FileDialog.h
Minipage is no more (long live the box inset)
[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 <utility>
19 #include <string>
20
21
22 /**
23  * \class FileDialog
24  * \brief GUI-I definition of file dialog interface
25  */
26 class FileDialog
27 {
28 public:
29         /// label, directory path button
30         typedef std::pair<std::string, std::string> Button;
31
32         /// result type
33         enum ResultType {
34                 Later, /**< modeless chooser, no result */
35                 Chosen /**< string contains filename */
36         };
37
38         /// result return
39         typedef std::pair<FileDialog::ResultType, std::string> Result;
40
41         /**
42          * Constructs a file dialog with title \param title.
43          * If \param a is \const LFUN_SELECT_FILE_SYNC then a value
44          * will be returned immediately upon performing a open(),
45          * otherwise a callback Dispatch() will be invoked with the filename as
46          * argument, of action \param a.
47          *
48          * Up to two optional extra buttons are allowed for specifying
49          * additional directories in the navigation (an empty
50          * directory is interpreted as getcwd())
51          */
52         FileDialog(std::string const & title,
53                    kb_action a = LFUN_SELECT_FILE_SYNC,
54                    Button b1 = Button(std::string(), std::string()),
55                    Button b2 = Button(std::string(), std::string()));
56
57
58         ~FileDialog();
59
60         /**
61          * Choose a file for opening, starting in directory \param
62          * path, with the file selection \param mask. The \param mask
63          * string is of the form :
64          *
65          * <glob to match> | <description>
66          *
67          * for example, "*.ps | PostScript files (*.ps)".
68          *
69          * FIXME: should support multiple lines of these for different file types.
70          */
71         Result const open(std::string const & path = std::string(),
72                 std::string const & mask = std::string(),
73                 std::string const & suggested = std::string());
74
75         /**
76          * Choose a directory, starting in directory \param
77          * path.
78          */
79         Result const opendir(std::string const & path = std::string(),
80                 std::string const & suggested = std::string());
81
82         /**
83          * Choose a file for saving, starting in directory \param
84          * path, with the file selection \param mask. The \param mask
85          * string is of the form :
86          *
87          * <glob to match> | <description>
88          *
89          * for example, "*.ps | PostScript files (*.ps)".
90          */
91         Result const save(std::string const & path = std::string(),
92                 std::string const & mask = std::string(),
93                 std::string const & suggested = std::string());
94
95
96         /* This *has* to be public because there is no way to specify extern "C" functions
97          * as friends of Private implementation for the xforms implementation ... grr
98          */
99         class Private;
100         friend class Private;
101         Private * private_;
102
103 private:
104         /// the dialog title
105         std::string title_;
106
107         /// success action to perform if not synchronous
108         kb_action success_;
109
110 };
111
112 #endif // FILEDIALOG_H