]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormFiledialog.h
Switch from SigC signals to boost::signals
[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_H_LOCATION
22 #include "form_filedialog.h"
23
24 #include "frontends/FileDialog.h"
25
26 #include <boost/signals/connection.hpp>
27 #include <boost/signals/trackable.hpp>
28
29 #include <vector>
30
31 /// DirEntry internal structure definition
32 class DirEntry {
33 public:
34         ///
35         string pszName;
36         ///
37         string pszDisplayed;
38         ///
39         string pszLsEntry;
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 FileDialog::Private : public boost::signals::trackable {
51 public:
52         ///
53         Private();
54         ///
55         ~Private();
56
57         /// sets file selector user button action
58         void SetButton(int iIndex, string const & pszName = string(),
59                        string const & pszPath = string());
60         /// gets last dialog directory
61         string const GetDirectory() const;
62         /// launches dialog and returns selected file
63         string const Select(string const & pszTitle = string(),
64                        string const & pszPath = string(),
65                        string const & pszMask = string(),
66                        string const & pszSuggested = string());
67         /// XForms objects callback (static)
68         static void FileDlgCB(FL_OBJECT *, long);
69         /// Callback for double click in list
70         static void DoubleClickCB(FL_OBJECT *, long);
71         /// Handle Cancel CB from WM close
72         static int CancelCB(FL_FORM *, void *);
73
74 private:
75         /// data
76         static FD_form_filedialog * pFileDlgForm;
77         ///
78         static FileDialog::Private * pCurrentDlg;
79         ///
80         string pszUserPath1;
81         ///
82         string pszUserPath2;
83         ///
84         string pszDirectory;
85         ///
86         string pszMask;
87         ///
88         string pszFileName;
89         ///
90         int iDepth;
91         ///
92         int iLastSel;
93         ///
94         long lLastTime;
95         ///
96         string pszInfoLine;
97         ///
98         typedef std::vector<DirEntry> DirEntries;
99         ///
100         DirEntries direntries;
101         ///
102         bool force_cancel;
103         ///
104         bool force_ok;
105
106         /// build the dialog
107         FD_form_filedialog * build_filedialog();
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