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