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