2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 The LyX Team.
10 * This file copyright 1999-2000
12 *======================================================*/
14 * FormPreferences Interface Class
17 #ifndef FORMPREFERENCES_H
18 #define FORMPREFERENCES_H
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;
38 struct FD_form_preferences;
39 struct FD_form_printer;
40 struct FD_form_screen_fonts;
41 struct FD_form_spellchecker;
45 /** This class provides an XForms implementation of the FormPreferences Dialog.
46 The preferences dialog allows users to set/save their preferences.
48 class FormPreferences : public FormBaseBI {
50 /// #FormPreferences x(LyXFunc ..., Dialogs ...);#
51 FormPreferences(LyXView *, Dialogs *);
55 static void ComboLanguageCB(int, void *, Combox *);
57 static void FeedbackCB(FL_OBJECT *, long);
59 void feedbackPost(FL_OBJECT *, int);
61 /// helper struct for Colours
66 RGB() : r(0), g(0), b(0) {}
67 RGB(int red, int green, int blue) : r(red), g(green), b(blue) {}
71 /// Update the dialog.
72 virtual void update();
79 /// Filter the inputs -- return true if entries are valid
80 virtual bool input(FL_OBJECT *, long);
83 /// control which feedback message is output
84 void feedback( FL_OBJECT * );
86 virtual FL_FORM * form() const;
88 /** Folder specific apply functions.
92 void applyColours() const;
94 void applyConverters() const;
96 void applyFormats() const;
98 void applyInputsMisc() const;
100 void applyInterface() const;
102 void applyLanguage() const;
104 void applyLnFmisc() const;
106 void applyOutputsMisc() const;
108 void applyPaths(); // not const because calls updatePaths!
110 void applyPrinter() const;
112 void applyScreenFonts() const;
114 void applySpellChecker(); // not const because calls updateSpellChecker!
116 /** Folder specific build functions.
122 void buildConverters();
126 void buildInputsMisc();
128 void buildInterface();
130 void buildLanguage();
134 void buildOutputsMisc();
140 void buildScreenFonts();
142 void buildSpellchecker();
144 /** Folder specific feedback functions.
148 string const feedbackColours(FL_OBJECT const * const) const;
150 string const feedbackConverters(FL_OBJECT const * const) const;
152 string const feedbackFormats( FL_OBJECT const * const ) const;
154 string const feedbackInputsMisc(FL_OBJECT const * const) const;
156 string const feedbackInterface(FL_OBJECT const * const) const;
158 string const feedbackLanguage(FL_OBJECT const * const) const;
160 string const feedbackLnFmisc(FL_OBJECT const * const) const;
162 string const feedbackOutputsMisc(FL_OBJECT const * const) const;
164 string const feedbackPaths(FL_OBJECT const * const) const;
166 string const feedbackPrinter(FL_OBJECT const * const) const;
168 string const feedbackScreenFonts(FL_OBJECT const * const) const;
170 string const feedbackSpellChecker(FL_OBJECT const * const) const;
172 /** Folder specific input functions. Not all folders require one.
176 bool inputColours(FL_OBJECT const * const);
178 bool inputFormats( FL_OBJECT const * const );
180 bool inputLanguage(FL_OBJECT const * const);
182 bool inputPaths(FL_OBJECT const * const);
184 bool inputScreenFonts();
186 bool inputSpellChecker(FL_OBJECT const * const);
188 /** Folder specific update functions.
192 void updateColours();
194 void updateConverters();
196 void updateFormats();
198 void updateInputsMisc();
200 void updateInterface();
202 void updateLanguage();
204 void updateLnFmisc();
206 void updateOutputsMisc();
210 void updatePrinter();
212 void updateScreenFonts();
214 void updateSpellChecker();
216 /** Some helper functions for specific folders.
220 void LanguagesAdd( Combox & ) const;
222 bool ColoursLoadBrowser( string const & );
224 int ColoursSearchEntry(RGB const & ) const;
226 void ColoursUpdateBrowser( int );
228 void ColoursUpdateRGB();
231 bool WriteableDir( string const & ) const;
233 bool ReadableDir( string const & ) const;
235 bool WriteableFile( string const &, string const & = string() ) const;
237 /// The timer post handler.
238 void setPostHandler( FL_OBJECT * ) const;
240 /// Type definitions from the fdesign produced header file.
241 FD_form_preferences * build_preferences();
243 FD_form_outer_tab * build_outer_tab();
245 FD_form_colours * build_colours();
247 FD_form_converters * build_converters();
249 FD_form_formats * build_formats();
251 FD_form_inputs_misc * build_inputs_misc();
253 FD_form_interface * build_interface();
255 FD_form_language * build_language();
257 FD_form_lnf_misc * build_lnf_misc();
259 FD_form_outputs_misc * build_outputs_misc();
261 FD_form_paths * build_paths();
263 FD_form_printer * build_printer();
265 FD_form_screen_fonts * build_screen_fonts();
267 FD_form_spellchecker * build_spellchecker();
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_;
282 FD_form_colours * colours_;
284 FD_form_converters * converters_;
286 FD_form_formats * formats_;
288 FD_form_inputs_misc * inputs_misc_;
290 FD_form_interface * interface_;
292 FD_form_language * language_;
294 FD_form_lnf_misc * lnf_misc_;
296 FD_form_outputs_misc * outputs_misc_;
298 FD_form_paths * paths_;
300 FD_form_printer * printer_;
302 FD_form_screen_fonts * screen_fonts_;
304 FD_form_spellchecker * spellchecker_;
306 Combox * combo_default_lang;
308 Combox * combo_kbmap_1;
310 Combox * combo_kbmap_2;
312 FL_OBJECT * feedbackObj;
314 std::vector<Format> formats_vec;
320 bool operator==(FormPreferences::RGB const & c1,
321 FormPreferences::RGB const & c2)
323 return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
328 bool operator!=(FormPreferences::RGB const & c1,
329 FormPreferences::RGB const & c2)