]> git.lyx.org Git - lyx.git/blob - src/frontends/FileDialog.h
0edb3687adb211ffcb6672aadef7b1833c33a038
[lyx.git] / src / frontends / FileDialog.h
1 // -*- C++ -*-
2 /**
3  * \file FileDialog.h
4  * Read the file COPYING
5  *
6  * \author unknown
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #ifndef FILEDIALOG_H
13 #define FILEDIALOG_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include <utility>
20
21 #include "commandtags.h"
22
23 #include "LString.h"
24
25 class LyXView;
26
27 /**
28  * \class FileDialog
29  * \brief GUI-I definition of file dialog interface
30  */
31 class FileDialog
32 {
33 public:
34         /// label, directory path button
35         typedef std::pair<string, string> Button;
36
37         /// result type
38         enum ResultType {
39                 Later, /**< modeless chooser, no result */
40                 Chosen /**< string contains filename */
41         };
42
43         /// result return
44         typedef std::pair<FileDialog::ResultType, string> Result;
45
46         /**
47          * Constructs a file dialog attached to LyXView \param lv, with
48          * title \param title. If \param a is \const LFUN_SELECT_FILE_SYNC
49          * then a value will be returned immediately upon performing a Select(),
50          * otherwise a callback Dispatch() will be invoked with the filename as
51          * argument, of action \param a.
52          *
53          * Up to two optional extra buttons are allowed for specifying
54          * additional directories in the navigation (an empty
55          * directory is interpreted as getcwd())
56          */
57         FileDialog(LyXView * lv, string const & title,
58                    kb_action a = LFUN_SELECT_FILE_SYNC,
59                    Button b1 = Button(string(), string()),
60                    Button b2 = Button(string(), string()));
61
62
63         ~FileDialog();
64
65         /**
66          * Choose a file for selection, starting in directory \param
67          * path, with the file selection \param mask. The \param mask
68          * string is of the form :
69          *
70          * <glob to match> | <description>
71          *
72          * for example, "*.ps | PostScript files (*.ps)".
73          *
74          * FIXME: should support multiple lines of these for different file types.
75          */
76         Result const Select(string const & path = string(),
77                 string const & mask = string(),
78                 string const & suggested = string());
79
80
81         /* This *has* to be public because there is no way to specify extern "C" functions
82          * as friends of Private implementation for the xforms implementation ... grr
83          */
84         class Private;
85         friend class Private;
86         Private * private_;
87
88 private:
89         /// our LyXView
90         LyXView * lv_;
91
92         /// the dialog title
93         string title_;
94
95         /// success action to perform if not synchronous
96         kb_action success_;
97
98 };
99
100 #endif // FILEDIALOG_H