]> git.lyx.org Git - lyx.git/blob - src/filedlg.h
9a82773932c62edadafda1374e78f838fd7bd6ec
[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-1999 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 "LString.h"
20
21 // necessary for xForms related stuff
22 #include FORMS_H_LOCATION
23 #include "form1.h"
24
25
26 /// User cache class definition
27 class UserCache
28 {
29 public:
30         ///
31         UserCache(string const & pszName = string(), uid_t ID = 0, 
32                   UserCache *pRoot = 0);
33         ///
34         ~UserCache();
35         // interface
36         /// seeks user name from user ID
37         string Find(uid_t ID);
38 private:
39         ///
40         uid_t ID;
41         ///
42         string pszName;
43         ///
44         UserCache *pNext, *pRoot;
45         // internal methods
46         /// creates a new user entry
47         UserCache *Add(uid_t ID);
48 };
49 extern UserCache lyxUserCache;
50
51
52 /// Group cache class definition
53 class GroupCache
54 {
55 public:
56         ///
57         GroupCache(string const & pszName = string(), gid_t ID = 0,
58                    GroupCache *pRoot = 0);
59         ///
60         ~GroupCache();
61         // interface
62         /// seeks group name from group ID
63         string Find(gid_t ID);
64
65 private:
66         ///
67         gid_t ID;
68         ///
69         string pszName;
70         ///
71         GroupCache *pNext, *pRoot;
72         // internal methods
73         /// creates a new group entry
74         GroupCache *Add(gid_t ID);
75 };
76 extern GroupCache lyxGroupCache;
77
78
79 /// LyXDirEntry internal structure definition
80 class LyXDirEntry
81 {
82 private:
83         friend class LyXFileDlg;    
84         string pszName;
85         string pszDisplayed;
86         string pszLsEntry;
87         /// compares two LyXDirEntry objects content (used by qsort)
88         static int ldeCompProc(const LyXDirEntry *r1, const LyXDirEntry *r2);
89         LyXDirEntry() {};
90 };
91
92
93 /// FileDlg class definition
94 class LyXFileDlg 
95 {
96 public:
97         ///
98         LyXFileDlg();
99         ///
100         ~LyXFileDlg();
101         /// sets file selector user button action
102         void SetButton(int iIndex, string const & pszName = string(), 
103                        string const & pszPath = string());
104         /// gets last dialog directory
105         string GetDirectory();
106         /// launches dialog and returns selected file
107         string Select(string const & pszTitle = string(),
108                        string const & pszPath = string(),
109                        string const & pszMask = string(), 
110                        string const & pszSuggested = string());
111         /// XForms objects callback (static)
112         static void FileDlgCB(FL_OBJECT *, long);
113         /// Callback for double click in list
114         static void DoubleClickCB(FL_OBJECT *, long);
115 private:
116         // data
117         static FD_FileDlg *pFileDlgForm;
118         static LyXFileDlg *pCurrentDlg;
119         string pszUserPath1;
120         string pszUserPath2;
121         string pszDirectory;
122         string pszMask;
123         string pszFileName;
124         int iDepth;
125         int iLastSel;
126         long lLastTime;
127         string pszInfoLine;
128         LyXDirEntry *pCurrentNames;
129         int iNumNames;
130
131         bool force_cancel;
132         bool force_ok;
133
134         // internal functions
135         /// updates dialog list to match class directory
136         void Reread();
137         /// sets dialog current directory
138         void SetDirectory(string const & pszPath);
139         /// sets dialog file mask
140         void SetMask(string const & pszNewMask);
141         /// sets dialog information line
142         void SetInfoLine(string const & pszLine);
143         /// handle dialog during file selection
144         bool RunDialog();
145         /// Handle callback from list
146         void HandleListHit();
147         /// Handle double click from list
148         bool HandleDoubleClick();
149         /// Handle OK button call
150         bool HandleOK();
151         /// Handle Cancel CB from WM close
152         static int CancelCB(FL_FORM *, void *);
153         /// Simulates a click on OK/Cancel
154         void Force(bool);
155 };
156
157 #endif