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