]> git.lyx.org Git - features.git/blob - src/frontends/xforms/FormPreferences.h
Converter patch from Dekel, Preference patch from Angus, menu patch from Rob
[features.git] / src / frontends / xforms / FormPreferences.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  *          This file copyright 1999-2000
11  *          Allan Rae
12  *======================================================*/
13 /* FormPreferences.h
14  * FormPreferences Interface Class
15  */
16
17 #ifndef FORMPREFERENCES_H
18 #define FORMPREFERENCES_H
19
20 #include <utility> // for pair
21
22 #include "FormBase.h"
23 #include "Color.h"
24
25 #ifdef __GNUG_
26 #pragma interface
27 #endif
28
29 class Combox;
30 class Command;
31 class Dialogs;
32 class Format;
33 class LyXView;
34 struct FD_form_colors;
35 struct FD_form_converters;
36 struct FD_form_formats;
37 struct FD_form_inputs_misc;
38 struct FD_form_interface;
39 struct FD_form_language;
40 struct FD_form_lnf_misc;
41 struct FD_form_outer_tab;
42 struct FD_form_outputs_misc;
43 struct FD_form_paths;
44 struct FD_form_preferences;
45 struct FD_form_printer;
46 struct FD_form_screen_fonts;
47 struct FD_form_spellchecker;
48
49
50 /** This class provides an XForms implementation of the FormPreferences Dialog.
51     The preferences dialog allows users to set/save their preferences.
52  */
53 class FormPreferences : public FormBaseBI {
54 public:
55         /// #FormPreferences x(LyXFunc ..., Dialogs ...);#
56         FormPreferences(LyXView *, Dialogs *);
57         ///
58         ~FormPreferences();
59         ///
60         static void ComboLanguageCB(int, void *, Combox *);
61         ///
62         static int FeedbackCB(FL_OBJECT *, int,
63                               FL_Coord, FL_Coord, int, void *);
64
65 private:
66         /** Redraw the form (on receipt of a Signal indicating, for example,
67             that the xform colours have been re-mapped). */
68         virtual void redraw();
69         /// Update the dialog.
70         virtual void update();
71         ///
72         virtual void hide();
73         /// OK from dialog
74         virtual void ok();
75         /// Apply from dialog
76         virtual void apply();
77         /// Filter the inputs -- return true if entries are valid
78         virtual bool input(FL_OBJECT *, long);
79         /// Build the dialog
80         virtual void build();
81         /// control which feedback message is output
82         void feedback( FL_OBJECT * );
83         /// The handler for the preemptive feedback
84         void Feedback(FL_OBJECT *, int);
85         ///
86         virtual FL_FORM * form() const;
87
88         /** Folder specific apply functions.
89          */
90         
91         ///
92         void applyColors(); // not const as modifies modifiedXformPrefs.
93         ///
94         void applyConverters() const;
95         ///
96         void applyFormats() const;
97         ///
98         void applyInputsMisc() const;
99         ///
100         void applyInterface() const;
101         ///
102         void applyLanguage(); // not const because calls updateLanguage!
103         ///
104         void applyLnFmisc() const;
105         ///
106         void applyOutputsMisc() const;
107         ///
108         void applyPaths(); // not const because calls updatePaths!
109         ///
110         void applyPrinter() const;
111         ///
112         void applyScreenFonts() const;
113         ///
114         void applySpellChecker(); // not const because calls updateSpellChecker!
115
116         /** Folder specific build functions.
117          */
118         
119         ///
120         void buildColors();
121         ///
122         void buildConverters();
123         ///
124         void buildFormats();
125         ///
126         void buildInputsMisc();
127         ///
128         void buildInterface();
129         ///
130         void buildLanguage();
131         ///
132         void buildLnFmisc();
133         ///
134         void buildOutputsMisc();
135         ///
136         void buildPaths();
137         ///
138         void buildPrinter();
139         ///
140         void buildScreenFonts();
141         ///
142         void buildSpellchecker();
143
144         /** Folder specific feedback functions.
145          */
146         
147         ///
148         string const feedbackColors(FL_OBJECT const * const) const;
149         ///
150         string const feedbackConverters(FL_OBJECT const * const) const;
151         ///
152         string const feedbackFormats( FL_OBJECT const * const ) const;
153         ///
154         string const feedbackInputsMisc(FL_OBJECT const * const) const;
155         ///
156         string const feedbackInterface(FL_OBJECT const * const) const;
157         ///
158         string const feedbackLanguage(FL_OBJECT const * const) const;
159         ///
160         string const feedbackLnFmisc(FL_OBJECT const * const) const;
161         ///
162         string const feedbackOutputsMisc(FL_OBJECT const * const) const;
163         ///
164         string const feedbackPaths(FL_OBJECT const * const) const;
165         ///
166         string const feedbackPrinter(FL_OBJECT const * const) const;
167         ///
168         string const feedbackScreenFonts(FL_OBJECT const * const) const;
169         ///
170         string const feedbackSpellChecker(FL_OBJECT const * const) const;
171
172         /** Folder specific input functions. Not all folders require one.
173          */
174         
175         ///
176         bool inputColors(FL_OBJECT const * const);
177         ///
178         bool inputConverters( FL_OBJECT const * const );
179         ///
180         bool inputFormats( FL_OBJECT const * const );
181         ///
182         bool inputLanguage(FL_OBJECT const * const);
183         ///
184         bool inputPaths(FL_OBJECT const * const);
185         ///
186         bool inputScreenFonts();
187         ///
188         bool inputSpellChecker(FL_OBJECT const * const);
189
190         /** Folder specific update functions.
191          */
192         
193         ///
194         void updateColors();
195         ///
196         void updateConverters();
197         ///
198         void updateFormats();
199         ///
200         void updateInputsMisc();
201         ///
202         void updateInterface();
203         ///
204         void updateLanguage();
205         ///
206         void updateLnFmisc();
207         ///
208         void updateOutputsMisc();
209         ///
210         void updatePaths();
211         ///
212         void updatePrinter();
213         ///
214         void updateScreenFonts();
215         ///
216         void updateSpellChecker();
217
218         /** Some helper functions for specific folders.
219          */
220         
221         ///
222         void ColorsAdjustVal( int, int, double ) const;
223         ///
224         bool ColorsBrowserLyX() const;
225         ///
226         bool ColorsBrowserX11() const;
227         ///
228         bool ColorsBrowseDatabase() const;
229         ///
230         bool ColorsDatabase() const;
231         ///
232         void ColorsLoadBrowserLyX();
233         ///
234         bool ColorsLoadBrowserX11(string const &) const;
235         ///
236         bool ColorsModify() const;
237         ///
238         bool ColorsRGB() const;
239         ///
240         int ColorsSearchEntry(RGBColor const &) const;
241
242         ///
243         bool ConvertersAdd();
244         ///
245         bool ConvertersBrowser();
246         ///
247         void ConvertersUpdateBrowser();
248         ///
249         bool ConvertersDelete();
250         ///
251         bool ConvertersInput();
252         ///
253         string const ConverterGetFrom() const;
254         ///
255         string const ConverterGetTo() const;
256         ///
257         void ConvertersUpdateChoices() const;
258
259         bool FormatsAdd();
260         ///
261         bool FormatsBrowser();
262         ///
263         void FormatsUpdateBrowser();
264         ///
265         bool FormatsDelete();
266         ///
267         bool FormatsInput();
268
269         ///
270         bool WriteableDir( string const & );
271         ///
272         bool ReadableDir( string const & );
273         ///
274         bool WriteableFile( string const &, string const & = string() );
275
276         ///
277         void setPreHandler( FL_OBJECT * ) const;
278         ///
279         void printWarning( string const & );
280
281         /// Type definitions from the fdesign produced header file.
282         FD_form_preferences * build_preferences();
283         ///
284         FD_form_outer_tab * build_outer_tab();
285         ///
286         FD_form_colors * build_colors();
287         ///
288         FD_form_converters * build_converters();
289         ///
290         FD_form_formats * build_formats();
291         ///
292         FD_form_inputs_misc * build_inputs_misc();
293         ///
294         FD_form_interface * build_interface();
295         ///
296         FD_form_language * build_language();
297         ///
298         FD_form_lnf_misc * build_lnf_misc();
299         ///
300         FD_form_outputs_misc * build_outputs_misc();
301         ///
302         FD_form_paths * build_paths();
303         ///
304         FD_form_printer * build_printer();
305         ///
306         FD_form_screen_fonts * build_screen_fonts();
307         ///
308         FD_form_spellchecker * build_spellchecker();
309
310         /// Real GUI implementation.
311         FD_form_preferences * dialog_;
312         /// Converters tabfolder
313         FD_form_outer_tab * converters_tab_;
314         /// reLyX and other import/input stuff
315         FD_form_outer_tab * inputs_tab_;
316         /// HCI configuration
317         FD_form_outer_tab * look_n_feel_tab_;
318         /// Outputs tabfolder
319         FD_form_outer_tab * outputs_tab_;
320         /// Spellchecker, language stuff, etc
321         FD_form_outer_tab * usage_tab_;
322         ///
323         FD_form_colors * colors_;
324         ///
325         FD_form_converters * converters_;
326         ///
327         FD_form_formats * formats_;
328         ///
329         FD_form_inputs_misc * inputs_misc_;
330         ///
331         FD_form_interface * interface_;
332         ///
333         FD_form_language * language_;
334         ///
335         FD_form_lnf_misc * lnf_misc_;
336         ///
337         FD_form_outputs_misc * outputs_misc_;
338         ///
339         FD_form_paths * paths_;
340         ///
341         FD_form_printer * printer_;
342         ///
343         FD_form_screen_fonts * screen_fonts_;
344         ///
345         FD_form_spellchecker * spellchecker_;
346         ///
347         Combox * combo_default_lang;
348         ///
349         Combox * combo_kbmap_1;
350         ///
351         Combox * combo_kbmap_2;
352
353         /// A vector of RGB colors and associated name.
354         static std::vector<X11Color> colorDB;
355         /// A vector of xform RGB colors and associated name.
356         static std::vector<XformColor> xformColorDB;
357         /** A collection of kmap files.
358             First entry is the file name, full path.
359             Second entry is the shorthand, as appears in the fl_choice.
360             Eg, system_lyxdir/kbd/american2.kmap, american2
361         */
362         static std::pair<std::vector<string>, std::vector<string> > dirlist;
363         /** Flag whether a warning has been posted to the text window.
364             If so, don't redraw the window when the mouse leaves an object. */
365         bool warningPosted;
366         /// Flag whether Xforms colors have been changed since last file save.
367         bool modifiedXformPrefs;
368 };
369
370 #endif