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