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