]> git.lyx.org Git - lyx.git/blob - src/frontends/FileDialog.h
Lars says _(_(b)) is a bug ... fix
[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 #ifdef __GNUG__
17 #pragma interface
18 #endif
19
20 #include <utility>
21
22 #include "commandtags.h"
23
24 #include "LString.h"
25
26 class LyXView;
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<string, string> 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, string> Result;
46
47         /**
48          * Constructs a file dialog attached to LyXView \param lv, with
49          * title \param title. If \param a is \const LFUN_SELECT_FILE_SYNC
50          * then a value 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(LyXView * lv, string const & title,
59                    kb_action a = LFUN_SELECT_FILE_SYNC,
60                    Button b1 = Button(string(), string()),
61                    Button b2 = Button(string(), string()));
62
63
64         ~FileDialog();
65
66         /**
67          * Choose a file for opening, starting in directory \param
68          * path, with the file selection \param mask. The \param mask
69          * string is of the form :
70          *
71          * <glob to match> | <description>
72          *
73          * for example, "*.ps | PostScript files (*.ps)".
74          *
75          * FIXME: should support multiple lines of these for different file types.
76          */
77         Result const open(string const & path = string(),
78                 string const & mask = string(),
79                 string const & suggested = string());
80
81         /**
82          * Choose a file for saving, starting in directory \param
83          * path, with the file selection \param mask. The \param mask
84          * string is of the form :
85          *
86          * <glob to match> | <description>
87          *
88          * for example, "*.ps | PostScript files (*.ps)".
89          */
90         Result const save(string const & path = string(),
91                 string const & mask = string(),
92                 string const & suggested = string());
93
94
95         /* This *has* to be public because there is no way to specify extern "C" functions
96          * as friends of Private implementation for the xforms implementation ... grr
97          */
98         class Private;
99         friend class Private;
100         Private * private_;
101
102 private:
103         /// our LyXView
104         LyXView * lv_;
105
106         /// the dialog title
107         string title_;
108
109         /// success action to perform if not synchronous
110         kb_action success_;
111
112 };
113
114 #endif // FILEDIALOG_H