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