]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormFiledialog.h
xforms clean-up, described in detail in my mail of 31 May. See
[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 /// DirEntry internal structure definition
31 class DirEntry {
32 public:
33         ///
34         string pszName;
35         ///
36         string pszDisplayed;
37         ///
38         string pszLsEntry;
39 };
40
41
42 //extern "C" {
43 //      void C_LyXFileDlg_FileDlgCB(FL_OBJECT * ob, long data);
44 //      void C_LyXFileDlg_DoubleClickCB(FL_OBJECT * ob, long data);
45 //      int C_LyXFileDlg_CancelCB(FL_FORM *fl, void *xev);
46 //}
47
48
49 class FD_filedialog;
50
51 class FileDialog::Private : public boost::signals::trackable {
52 public:
53         ///
54         Private();
55         ///
56         ~Private();
57
58         /// sets file selector user button action
59         void SetButton(int iIndex, string const & pszName = string(),
60                        string const & pszPath = string());
61         /// gets last dialog directory
62         string const GetDirectory() const;
63         /// launches dialog and returns selected file
64         string const Select(string const & pszTitle = string(),
65                        string const & pszPath = string(),
66                        string const & pszMask = string(),
67                        string const & pszSuggested = string());
68         /// XForms objects callback (static)
69         static void FileDlgCB(FL_OBJECT *, long);
70         /// Callback for double click in list
71         static void DoubleClickCB(FL_OBJECT *, long);
72         /// Handle Cancel CB from WM close
73         static int CancelCB(FL_FORM *, void *);
74
75 private:
76         /// data
77         static FD_filedialog * pFileDlgForm;
78         ///
79         static FileDialog::Private * pCurrentDlg;
80         ///
81         string pszUserPath1;
82         ///
83         string pszUserPath2;
84         ///
85         string pszDirectory;
86         ///
87         string pszMask;
88         ///
89         string pszFileName;
90         ///
91         int iDepth;
92         ///
93         int iLastSel;
94         ///
95         long lLastTime;
96         ///
97         string pszInfoLine;
98         ///
99         typedef std::vector<DirEntry> DirEntries;
100         ///
101         DirEntries direntries;
102         ///
103         bool force_cancel;
104         ///
105         bool force_ok;
106
107         /** Redraw the form (on receipt of a Signal indicating, for example,
108             that the xform colors have been re-mapped).
109         */
110         void redraw();
111         /// updates dialog list to match class directory
112         void Reread();
113         /// sets dialog current directory
114         void SetDirectory(string const & pszPath);
115         /// sets dialog file mask
116         void SetMask(string const & pszNewMask);
117         /// sets dialog information line
118         void SetInfoLine(string const & pszLine);
119         /// handle dialog during file selection
120         bool RunDialog();
121         /// Handle callback from list
122         void HandleListHit();
123         /// Handle double click from list
124         bool HandleDoubleClick();
125         /// Handle OK button call
126         bool HandleOK();
127         /// Simulates a click on OK/Cancel
128         void Force(bool);
129         /// Redraw connection.
130         boost::signals::connection r_;
131 };
132
133 #endif // FORMFILEDIALOG_H