]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormFiledialog.h
Introduce LFUN_PRINT.
[lyx.git] / src / frontends / xforms / FormFiledialog.h
1 // -*- C++ -*-
2 /**
3  * \file FormFiledialog.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 FORMFILEDIALOG_H
14 #define FORMFILEDIALOG_H
15
16 #include "forms_fwd.h"
17
18 #include "frontends/FileDialog.h"
19
20 #include <boost/signals/connection.hpp>
21 #include <boost/signals/trackable.hpp>
22
23 #include <vector>
24
25 class Dialogs;
26
27 /// DirEntry internal structure definition
28 class DirEntry {
29 public:
30         ///
31         std::string name_;
32         ///
33         std::string displayed_;
34         ///
35         std::string ls_entry_;
36 };
37
38
39 //extern "C" {
40 //      void C_LyXFileDlg_FileDlgCB(FL_OBJECT * ob, long data);
41 //      void C_LyXFileDlg_DoubleClickCB(FL_OBJECT * ob, long data);
42 //      int C_LyXFileDlg_CancelCB(FL_FORM *fl, void *xev);
43 //}
44
45
46 class FD_filedialog;
47
48 namespace lyx {
49 namespace support {
50
51 class FileFilterList;
52
53 } // namespace support
54 } // namespace lyx
55
56
57 class FileDialog::Private : public boost::signals::trackable {
58 public:
59         ///
60         Private();
61         ///
62         ~Private();
63
64         /// sets file selector user button action
65         void SetButton(int iIndex, std::string const & pszName = std::string(),
66                        std::string const & pszPath = std::string());
67         /// gets last dialog directory
68         std::string const GetDirectory() const;
69         /// launches dialog and returns selected file
70         std::string const Select(std::string const & pszTitle,
71                                  std::string const & pszPath,
72                                  lyx::support::FileFilterList const & filters,
73                                  std::string const & pszSuggested);
74         /// launches dialog and returns selected directory
75         std::string const SelectDir(std::string const & pszTitle = std::string(),
76                        std::string const & pszPath = std::string(),
77                        std::string const & pszSuggested = std::string());
78         /// XForms objects callback (static)
79         static void FileDlgCB(FL_OBJECT *, long);
80         /// Callback for double click in list
81         static void DoubleClickCB(FL_OBJECT *, long);
82         /// Handle Cancel CB from WM close
83         static int CancelCB(FL_FORM *, void *);
84
85 private:
86         /// data
87         static FD_filedialog * file_dlg_form_;
88         ///
89         static FileDialog::Private * current_dlg_;
90         ///
91         static int minw_;
92         ///
93         static int minh_;
94         ///
95         std::string user_path1_;
96         ///
97         std::string user_path2_;
98         ///
99         std::string directory_;
100         ///
101         std::string mask_;
102         ///
103         std::string file_name_;
104         ///
105         int depth_;
106         ///
107         int last_sel_;
108         ///
109         long last_time_;
110         ///
111         std::string info_line_;
112         ///
113         typedef std::vector<DirEntry> DirEntries;
114         ///
115         DirEntries dir_entries_;
116         ///
117         bool force_cancel_;
118         ///
119         bool force_ok_;
120
121         /** Redraw the form (on receipt of a Signal indicating, for example,
122             that the xform colors have been re-mapped).
123         */
124         void redraw();
125         /// updates dialog list to match class directory
126         void Reread();
127         /// sets dialog current directory
128         void SetDirectory(std::string const & pszPath);
129         /// sets dialog file mask
130         void SetFilters(std::string const & filters);
131         void SetFilters(lyx::support::FileFilterList const & filters);
132         /// sets dialog information line
133         void SetInfoLine(std::string const & pszLine);
134         /// handle dialog during file selection
135         bool RunDialog();
136         /// Handle callback from list
137         void HandleListHit();
138         /// Handle double click from list
139         bool HandleDoubleClick();
140         /// Handle OK button call
141         bool HandleOK();
142         /// Simulates a click on OK/Cancel
143         void Force(bool);
144         /// Redraw connection.
145         boost::signals::connection r_;
146 };
147
148 #endif // FORMFILEDIALOG_H