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