]> git.lyx.org Git - lyx.git/blob - src/frontends/FileDialog.h
reverse last change
[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 directory, starting in directory \param
83          * path.
84          */
85         Result const opendir(string const & path = string(),
86                 string const & suggested = string());
87
88         /**
89          * Choose a file for saving, starting in directory \param
90          * path, with the file selection \param mask. The \param mask
91          * string is of the form :
92          *
93          * <glob to match> | <description>
94          *
95          * for example, "*.ps | PostScript files (*.ps)".
96          */
97         Result const save(string const & path = string(),
98                 string const & mask = string(),
99                 string const & suggested = string());
100
101
102         /* This *has* to be public because there is no way to specify extern "C" functions
103          * as friends of Private implementation for the xforms implementation ... grr
104          */
105         class Private;
106         friend class Private;
107         Private * private_;
108
109 private:
110         /// our LyXView
111         LyXView * lv_;
112
113         /// the dialog title
114         string title_;
115
116         /// success action to perform if not synchronous
117         kb_action success_;
118
119 };
120
121 #endif // FILEDIALOG_H