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