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