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