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;
44 /** This class provides an XForms implementation of the FormPreferences Dialog.
45 The preferences dialog allows users to set/save their preferences.
47 class FormPreferences : public FormBaseBI {
49 /// #FormPreferences x(LyXFunc ..., Dialogs ...);#
50 FormPreferences(LyXView *, Dialogs *);
54 static void ComboLanguageCB(int, void *, Combox *);
56 static void FeedbackCB(FL_OBJECT *, long);
58 void feedbackPost(FL_OBJECT *, int);
60 /// helper struct for Colours
65 RGB() : r(0), g(0), b(0) {}
66 RGB(int red, int green, int blue) : r(red), g(green), b(blue) {}
70 /// Update the dialog.
71 virtual void update();
78 /// Filter the inputs -- return true if entries are valid
79 virtual bool input(FL_OBJECT *, long);
82 /// control which feedback message is output
83 void feedback( FL_OBJECT * );
85 virtual FL_FORM * form() const;
87 /** Folder specific apply functions.
91 void applyColours() const;
93 void applyConverters() const;
95 void applyFormats() const;
97 void applyInputsMisc() const;
99 void applyInterface() const;
101 void applyLanguage() const;
103 void applyLnFmisc() const;
105 void applyOutputsMisc() const;
107 void applyPaths(); // not const because calls updatePaths!
109 void applyPrinter() const;
111 void applyScreenFonts() const;
113 void applySpellChecker(); // not const because calls updateSpellChecker!
115 /** Folder specific build functions.
121 void buildConverters();
125 void buildInputsMisc();
127 void buildInterface();
129 void buildLanguage();
133 void buildOutputsMisc();
139 void buildScreenFonts();
141 void buildSpellchecker();
143 /** Folder specific feedback functions.
147 string const feedbackColours(FL_OBJECT const * const) const;
149 string const feedbackConverters(FL_OBJECT const * const) const;
151 string const feedbackFormats( FL_OBJECT const * const ) const;
153 string const feedbackInputsMisc(FL_OBJECT const * const) const;
155 string const feedbackInterface(FL_OBJECT const * const) const;
157 string const feedbackLanguage(FL_OBJECT const * const) const;
159 string const feedbackLnFmisc(FL_OBJECT const * const) const;
161 string const feedbackOutputsMisc(FL_OBJECT const * const) const;
163 string const feedbackPaths(FL_OBJECT const * const) const;
165 string const feedbackPrinter(FL_OBJECT const * const) const;
167 string const feedbackScreenFonts(FL_OBJECT const * const) const;
169 string const feedbackSpellChecker(FL_OBJECT const * const) const;
171 /** Folder specific input functions. Not all folders require one.
175 bool inputColours(FL_OBJECT const * const);
177 bool inputFormats( FL_OBJECT const * const );
179 bool inputLanguage(FL_OBJECT const * const);
181 bool inputPaths(FL_OBJECT const * const);
183 bool inputScreenFonts();
185 bool inputSpellChecker(FL_OBJECT const * const);
187 /** Folder specific update functions.
191 void updateColours();
193 void updateConverters();
195 void updateFormats();
197 void updateInputsMisc();
199 void updateInterface();
201 void updateLanguage();
203 void updateLnFmisc();
205 void updateOutputsMisc();
209 void updatePrinter();
211 void updateScreenFonts();
213 void updateSpellChecker();
215 /** Some helper functions for specific folders.
219 void LanguagesAdd( Combox & ) const;
221 bool ColoursLoadBrowser( string const & );
223 int ColoursSearchEntry(RGB const & ) const;
225 void ColoursUpdateBrowser( int );
227 void ColoursUpdateRGB();
230 bool WriteableDir( string const & ) const;
232 bool ReadableDir( string const & ) const;
234 bool WriteableFile( string const &, string const & = string() ) const;
236 /// The timer post handler.
237 void setPostHandler( FL_OBJECT * ) const;
239 /// Type definitions from the fdesign produced header file.
240 FD_form_preferences * build_preferences();
242 FD_form_outer_tab * build_outer_tab();
244 FD_form_colours * build_colours();
246 FD_form_converters * build_converters();
248 FD_form_formats * build_formats();
250 FD_form_inputs_misc * build_inputs_misc();
252 FD_form_interface * build_interface();
254 FD_form_language * build_language();
256 FD_form_lnf_misc * build_lnf_misc();
258 FD_form_outputs_misc * build_outputs_misc();
260 FD_form_paths * build_paths();
262 FD_form_printer * build_printer();
264 FD_form_screen_fonts * build_screen_fonts();
266 FD_form_spellchecker * build_spellchecker();
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_;
281 FD_form_colours * colours_;
283 FD_form_converters * converters_;
285 FD_form_formats * formats_;
287 FD_form_inputs_misc * inputs_misc_;
289 FD_form_interface * interface_;
291 FD_form_language * language_;
293 FD_form_lnf_misc * lnf_misc_;
295 FD_form_outputs_misc * outputs_misc_;
297 FD_form_paths * paths_;
299 FD_form_printer * printer_;
301 FD_form_screen_fonts * screen_fonts_;
303 FD_form_spellchecker * spellchecker_;
305 Combox * combo_default_lang;
307 Combox * combo_kbmap_1;
309 Combox * combo_kbmap_2;
311 FL_OBJECT * feedbackObj;
316 bool operator==(FormPreferences::RGB const & c1,
317 FormPreferences::RGB const & c2)
319 return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
324 bool operator!=(FormPreferences::RGB const & c1,
325 FormPreferences::RGB const & c2)