]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormPreferences.h
99e50a30cff4e1fcfff56bba51a6530cf3c067a5
[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                 bool operator==(RGB const & o) const
68                         { return( r == o.r && g == o.g && b == o.b ); }
69                 bool operator!=(RGB const & o) const
70                         { return( r != o.r || g != o.g || b != o.b ); }
71         };
72
73 private:
74         /// Update the dialog.
75         virtual void update();
76         ///
77         virtual void hide();
78         /// OK from dialog
79         virtual void ok();
80         /// Apply from dialog
81         virtual void apply();
82         /// Filter the inputs -- return true if entries are valid
83         virtual bool input(FL_OBJECT *, long);
84         /// Build the dialog
85         virtual void build();
86         /// control which feedback message is output
87         void feedback( FL_OBJECT * );
88         ///
89         virtual FL_FORM * form() const;
90
91         /** Folder specific apply functions.
92          */
93         
94         ///
95         void applyColours() const;
96         ///
97         void applyConverters() const;
98         ///
99         void applyFormats() const;
100         ///
101         void applyInputsMisc() const;
102         ///
103         void applyInterface() const;
104         ///
105         void applyLanguage() const;
106         ///
107         void applyLnFmisc() const;
108         ///
109         void applyOutputsMisc() const;
110         ///
111         void applyPaths(); // not const because calls updatePaths!
112         ///
113         void applyPrinter() const;
114         ///
115         void applyScreenFonts() const;
116         ///
117         void applySpellChecker(); // not const because calls updateSpellChecker!
118
119         /** Folder specific build functions.
120          */
121         
122         ///
123         void buildColours();
124         ///
125         void buildConverters();
126         ///
127         void buildFormats();
128         ///
129         void buildInputsMisc();
130         ///
131         void buildInterface();
132         ///
133         void buildLanguage();
134         ///
135         void buildLnFmisc();
136         ///
137         void buildOutputsMisc();
138         ///
139         void buildPaths();
140         ///
141         void buildPrinter();
142         ///
143         void buildScreenFonts();
144         ///
145         void buildSpellchecker();
146
147         /** Folder specific feedback functions.
148          */
149         
150         ///
151         string feedbackColours(FL_OBJECT const * const) const;
152         ///
153         string feedbackConverters(FL_OBJECT const * const) const;
154         ///
155         string feedbackFormats( FL_OBJECT const * const ) const;
156         ///
157         string feedbackInputsMisc(FL_OBJECT const * const) const;
158         ///
159         string feedbackInterface(FL_OBJECT const * const) const;
160         ///
161         string feedbackLanguage(FL_OBJECT const * const) const;
162         ///
163         string feedbackLnFmisc(FL_OBJECT const * const) const;
164         ///
165         string feedbackOutputsMisc(FL_OBJECT const * const) const;
166         ///
167         string feedbackPaths(FL_OBJECT const * const) const;
168         ///
169         string feedbackPrinter(FL_OBJECT const * const) const;
170         ///
171         string feedbackScreenFonts(FL_OBJECT const * const) const;
172         ///
173         string feedbackSpellChecker(FL_OBJECT const * const) const;
174
175         /** Folder specific input functions. Not all folders require one.
176          */
177         
178         ///
179         bool inputColours(FL_OBJECT const * const);
180         ///
181         bool inputFormats( FL_OBJECT const * const );
182         ///
183         bool inputLanguage(FL_OBJECT const * const);
184         ///
185         bool inputPaths(FL_OBJECT const * const);
186         ///
187         bool inputScreenFonts();
188         ///
189         bool inputSpellChecker(FL_OBJECT const * const);
190
191         /** Folder specific update functions.
192          */
193         
194         ///
195         void updateColours();
196         ///
197         void updateConverters();
198         ///
199         void updateFormats();
200         ///
201         void updateInputsMisc();
202         ///
203         void updateInterface();
204         ///
205         void updateLanguage();
206         ///
207         void updateLnFmisc();
208         ///
209         void updateOutputsMisc();
210         ///
211         void updatePaths();
212         ///
213         void updatePrinter();
214         ///
215         void updateScreenFonts();
216         ///
217         void updateSpellChecker();
218
219         /** Some helper functions for specific folders.
220          */
221         
222         ///
223         void LanguagesAdd( Combox & ) const;
224         ///
225         bool ColoursLoadBrowser( string const & );
226         ///
227         int  ColoursSearchEntry(RGB const & ) const;
228         ///
229         void ColoursUpdateBrowser( int );
230         ///
231         void ColoursUpdateRGB();
232
233         ///
234         bool WriteableDir( string const & ) const;
235         ///
236         bool ReadableDir( string const & ) const;
237         ///
238         bool WriteableFile( string const &, string const & = string() ) const;
239
240         /// The timer post handler.
241         void setPostHandler( FL_OBJECT * ) const;
242
243         /// Type definitions from the fdesign produced header file.
244         FD_form_preferences * build_preferences();
245         ///
246         FD_form_outer_tab * build_outer_tab();
247         ///
248         FD_form_colours * build_colours();
249         ///
250         FD_form_converters * build_converters();
251         ///
252         FD_form_formats * build_formats();
253         ///
254         FD_form_inputs_misc * build_inputs_misc();
255         ///
256         FD_form_interface * build_interface();
257         ///
258         FD_form_language * build_language();
259         ///
260         FD_form_lnf_misc * build_lnf_misc();
261         ///
262         FD_form_outputs_misc * build_outputs_misc();
263         ///
264         FD_form_paths * build_paths();
265         ///
266         FD_form_printer * build_printer();
267         ///
268         FD_form_screen_fonts * build_screen_fonts();
269         ///
270         FD_form_spellchecker * build_spellchecker();
271
272         /// Real GUI implementation.
273         FD_form_preferences * dialog_;
274         /// Converters tabfolder
275         FD_form_outer_tab * converters_tab_;
276         /// reLyX and other import/input stuff
277         FD_form_outer_tab * inputs_tab_;
278         /// HCI configuration
279         FD_form_outer_tab * look_n_feel_tab_;
280         /// Outputs tabfolder
281         FD_form_outer_tab * outputs_tab_;
282         /// Spellchecker, language stuff, etc
283         FD_form_outer_tab * usage_tab_;
284         ///
285         FD_form_converters * converters_;
286         ///
287         FD_form_colours * colours_;
288         ///
289         FD_form_formats * formats_;
290         ///
291         FD_form_inputs_misc * inputs_misc_;
292         ///
293         FD_form_interface * interface_;
294         ///
295         FD_form_language * language_;
296         ///
297         FD_form_lnf_misc * lnf_misc_;
298         ///
299         FD_form_outputs_misc * outputs_misc_;
300         ///
301         FD_form_paths * paths_;
302         ///
303         FD_form_printer * printer_;
304         ///
305         FD_form_screen_fonts * screen_fonts_;
306         ///
307         FD_form_spellchecker * spellchecker_;
308         ///
309         Combox * combo_default_lang;
310         ///
311         Combox * combo_kbmap_1;
312         ///
313         Combox * combo_kbmap_2;
314         ///
315         FL_OBJECT * feedbackObj;
316 };
317
318 #endif