]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormPreferences.h
8abec739bdc6d68cbbca6ca66a2f91f338a46f77
[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 "FormBase.h"
21
22 #ifdef __GNUG_
23 #pragma interface
24 #endif
25
26 class LyXView;
27 class Dialogs;
28 struct FD_form_colours;
29 struct FD_form_converters;
30 struct FD_form_formats;
31 struct FD_form_inputs_misc;
32 struct FD_form_interface;
33 struct FD_form_language;
34 struct FD_form_lnf_misc;
35 struct FD_form_outer_tab;
36 struct FD_form_outputs_misc;
37 struct FD_form_paths;
38 struct FD_form_preferences;
39 struct FD_form_printer;
40 struct FD_form_screen_fonts;
41 struct FD_form_spellchecker;
42 class  Combox;
43
44 /** This class provides an XForms implementation of the FormPreferences Dialog.
45     The preferences dialog allows users to set/save their preferences.
46  */
47 class FormPreferences : public FormBaseBI {
48 public:
49         /// #FormPreferences x(LyXFunc ..., Dialogs ...);#
50         FormPreferences(LyXView *, Dialogs *);
51         ///
52         ~FormPreferences();
53         ///
54         static void ComboLanguageCB(int, void *, Combox *);
55         ///
56         static void FeedbackCB(FL_OBJECT *, long);
57         ///
58         void feedbackPost(FL_OBJECT *, int);
59
60         /// helper struct for Colours
61         struct RGB {
62                 int r;
63                 int g;
64                 int b;
65                 RGB() : r(0), g(0), b(0) {}
66                 RGB(int red, int green, int blue) : r(red), g(green), b(blue) {}
67         };
68
69 private:
70         /// Update the dialog.
71         virtual void update();
72         ///
73         virtual void hide();
74         /// OK from dialog
75         virtual void ok();
76         /// Apply from dialog
77         virtual void apply();
78         /// Filter the inputs -- return true if entries are valid
79         virtual bool input(FL_OBJECT *, long);
80         /// Build the dialog
81         virtual void build();
82         /// control which feedback message is output
83         void feedback( FL_OBJECT * );
84         ///
85         virtual FL_FORM * form() const;
86
87         /** Folder specific apply functions.
88          */
89         
90         ///
91         void applyColours() 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() const;
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 buildColours();
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 feedbackColours(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 inputColours(FL_OBJECT const * const);
176         ///
177         bool inputFormats( FL_OBJECT const * const );
178         ///
179         bool inputLanguage(FL_OBJECT const * const);
180         ///
181         bool inputPaths(FL_OBJECT const * const);
182         ///
183         bool inputScreenFonts();
184         ///
185         bool inputSpellChecker(FL_OBJECT const * const);
186
187         /** Folder specific update functions.
188          */
189         
190         ///
191         void updateColours();
192         ///
193         void updateConverters();
194         ///
195         void updateFormats();
196         ///
197         void updateInputsMisc();
198         ///
199         void updateInterface();
200         ///
201         void updateLanguage();
202         ///
203         void updateLnFmisc();
204         ///
205         void updateOutputsMisc();
206         ///
207         void updatePaths();
208         ///
209         void updatePrinter();
210         ///
211         void updateScreenFonts();
212         ///
213         void updateSpellChecker();
214
215         /** Some helper functions for specific folders.
216          */
217         
218         ///
219         void LanguagesAdd( Combox & ) const;
220         ///
221         bool ColoursLoadBrowser( string const & );
222         ///
223         int  ColoursSearchEntry(RGB const & ) const;
224         ///
225         void ColoursUpdateBrowser( int );
226         ///
227         void ColoursUpdateRGB();
228
229         ///
230         bool WriteableDir( string const & ) const;
231         ///
232         bool ReadableDir( string const & ) const;
233         ///
234         bool WriteableFile( string const &, string const & = string() ) const;
235
236         /// The timer post handler.
237         void setPostHandler( FL_OBJECT * ) const;
238
239         /// Type definitions from the fdesign produced header file.
240         FD_form_preferences * build_preferences();
241         ///
242         FD_form_outer_tab * build_outer_tab();
243         ///
244         FD_form_colours * build_colours();
245         ///
246         FD_form_converters * build_converters();
247         ///
248         FD_form_formats * build_formats();
249         ///
250         FD_form_inputs_misc * build_inputs_misc();
251         ///
252         FD_form_interface * build_interface();
253         ///
254         FD_form_language * build_language();
255         ///
256         FD_form_lnf_misc * build_lnf_misc();
257         ///
258         FD_form_outputs_misc * build_outputs_misc();
259         ///
260         FD_form_paths * build_paths();
261         ///
262         FD_form_printer * build_printer();
263         ///
264         FD_form_screen_fonts * build_screen_fonts();
265         ///
266         FD_form_spellchecker * build_spellchecker();
267
268         /// Real GUI implementation.
269         FD_form_preferences * dialog_;
270         /// Converters tabfolder
271         FD_form_outer_tab * converters_tab_;
272         /// reLyX and other import/input stuff
273         FD_form_outer_tab * inputs_tab_;
274         /// HCI configuration
275         FD_form_outer_tab * look_n_feel_tab_;
276         /// Outputs tabfolder
277         FD_form_outer_tab * outputs_tab_;
278         /// Spellchecker, language stuff, etc
279         FD_form_outer_tab * usage_tab_;
280         ///
281         FD_form_colours * colours_;
282         ///
283         FD_form_converters * converters_;
284         ///
285         FD_form_formats * formats_;
286         ///
287         FD_form_inputs_misc * inputs_misc_;
288         ///
289         FD_form_interface * interface_;
290         ///
291         FD_form_language * language_;
292         ///
293         FD_form_lnf_misc * lnf_misc_;
294         ///
295         FD_form_outputs_misc * outputs_misc_;
296         ///
297         FD_form_paths * paths_;
298         ///
299         FD_form_printer * printer_;
300         ///
301         FD_form_screen_fonts * screen_fonts_;
302         ///
303         FD_form_spellchecker * spellchecker_;
304         ///
305         Combox * combo_default_lang;
306         ///
307         Combox * combo_kbmap_1;
308         ///
309         Combox * combo_kbmap_2;
310         ///
311         FL_OBJECT * feedbackObj;
312 };
313
314
315 inline
316 bool operator==(FormPreferences::RGB const & c1,
317                 FormPreferences::RGB const & c2)
318 {
319         return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
320 }
321
322
323 inline
324 bool operator!=(FormPreferences::RGB const & c1,
325                 FormPreferences::RGB const & c2)
326 {
327         return !(c1 == c2);
328 }
329
330 #endif