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