]> git.lyx.org Git - lyx.git/blob - src/filedlg.h
a8a75ebd17c86ec596c10748aa19c376d57119b2
[lyx.git] / src / filedlg.h
1 // -*- C++ -*-
2 /* This file is part of
3 * ======================================================
4
5 *           LyX, The Document Processor
6 *        
7 *           Copyright (C) 1995 1996 Matthias Ettrich
8 *           and 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(LString const & pszName = LString(), uid_t ID = 0, 
32                   UserCache *pRoot = NULL);
33         ///
34         ~UserCache();
35         // interface
36         /// seeks user name from user ID
37         LString Find(uid_t ID);
38 private:
39         ///
40         uid_t ID;
41         ///
42         LString 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(LString const & pszName = LString(), gid_t ID = 0,
58                    GroupCache *pRoot = NULL);
59         ///
60         ~GroupCache();
61         // interface
62         /// seeks group name from group ID
63         LString Find(gid_t ID);
64
65 private:
66         ///
67         gid_t ID;
68         ///
69         LString 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         LString pszName;
85         LString pszDisplayed;
86         LString 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, LString const & pszName = LString(), 
103                        LString const & pszPath = LString());
104         /// gets last dialog directory
105         LString GetDirectory();
106         /// launches dialog and returns selected file
107         LString Select(LString const & pszTitle = LString(),
108                        LString const & pszPath = LString(),
109                        LString const & pszMask = LString(), 
110                        LString const & pszSuggested = LString());
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         LString pszUserPath1;
120         LString pszUserPath2;
121         LString pszDirectory;
122         LString pszMask;
123         LString pszFileName;
124         int iDepth;
125         int iLastSel;
126         long lLastTime;
127         LString 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(LString const & pszPath);
139         /// sets dialog file mask
140         void SetMask(LString const & pszNewMask);
141         /// sets dialog information line
142         void SetInfoLine(LString 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