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