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