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);
62 /// helper struct for Colours
67 RGB() : r(0), g(0), b(0) {}
68 RGB(int red, int green, int blue) : r(red), g(green), b(blue) {}
71 friend bool operator==(RGB const &, RGB const &);
73 friend bool operator!=(RGB const &, RGB const &);
75 typedef std::pair<string, RGB> X11Colour;
77 /// Update the dialog.
78 virtual void update();
85 /// Filter the inputs -- return true if entries are valid
86 virtual bool input(FL_OBJECT *, long);
89 /// control which feedback message is output
90 void feedback( FL_OBJECT * );
92 virtual FL_FORM * form() const;
94 /** Folder specific apply functions.
98 void applyColours() const;
100 void applyConverters() const;
102 void applyFormats() const;
104 void applyInputsMisc() const;
106 void applyInterface() const;
108 void applyLanguage(); // not const because calls updateLanguage!
110 void applyLnFmisc() const;
112 void applyOutputsMisc() const;
114 void applyPaths(); // not const because calls updatePaths!
116 void applyPrinter() const;
118 void applyScreenFonts() const;
120 void applySpellChecker(); // not const because calls updateSpellChecker!
122 /** Folder specific build functions.
128 void buildConverters();
132 void buildInputsMisc();
134 void buildInterface();
136 void buildLanguage();
140 void buildOutputsMisc();
146 void buildScreenFonts();
148 void buildSpellchecker();
150 /** Folder specific feedback functions.
154 string const feedbackColours(FL_OBJECT const * const) const;
156 string const feedbackConverters(FL_OBJECT const * const) const;
158 string const feedbackFormats( FL_OBJECT const * const ) const;
160 string const feedbackInputsMisc(FL_OBJECT const * const) const;
162 string const feedbackInterface(FL_OBJECT const * const) const;
164 string const feedbackLanguage(FL_OBJECT const * const) const;
166 string const feedbackLnFmisc(FL_OBJECT const * const) const;
168 string const feedbackOutputsMisc(FL_OBJECT const * const) const;
170 string const feedbackPaths(FL_OBJECT const * const) const;
172 string const feedbackPrinter(FL_OBJECT const * const) const;
174 string const feedbackScreenFonts(FL_OBJECT const * const) const;
176 string const feedbackSpellChecker(FL_OBJECT const * const) const;
178 /** Folder specific input functions. Not all folders require one.
182 bool inputColours(FL_OBJECT const * const);
184 bool inputFormats( FL_OBJECT const * const );
186 bool inputLanguage(FL_OBJECT const * const);
188 bool inputPaths(FL_OBJECT const * const);
190 bool inputScreenFonts();
192 bool inputSpellChecker(FL_OBJECT const * const);
194 /** Folder specific update functions.
198 void updateColours();
200 void updateConverters();
202 void updateFormats();
204 void updateInputsMisc();
206 void updateInterface();
208 void updateLanguage();
210 void updateLnFmisc();
212 void updateOutputsMisc();
216 void updatePrinter();
218 void updateScreenFonts();
220 void updateSpellChecker();
222 /** Some helper functions for specific folders.
226 bool ColoursLoadBrowser( string const & );
228 int ColoursSearchEntry(RGB const & ) const;
230 void ColoursUpdateBrowser( int );
232 void ColoursUpdateRGB();
234 bool FormatsInputAdd();
236 bool FormatsInputBrowser();
238 bool FormatsInputDelete();
240 bool FormatsInputInput();
243 bool WriteableDir( string const & ) const;
245 bool ReadableDir( string const & ) const;
247 bool WriteableFile( string const &, string const & = string() ) const;
249 /// The timer post handler.
250 void setPostHandler( FL_OBJECT * ) const;
252 /// Type definitions from the fdesign produced header file.
253 FD_form_preferences * build_preferences();
255 FD_form_outer_tab * build_outer_tab();
257 FD_form_colours * build_colours();
259 FD_form_converters * build_converters();
261 FD_form_formats * build_formats();
263 FD_form_inputs_misc * build_inputs_misc();
265 FD_form_interface * build_interface();
267 FD_form_language * build_language();
269 FD_form_lnf_misc * build_lnf_misc();
271 FD_form_outputs_misc * build_outputs_misc();
273 FD_form_paths * build_paths();
275 FD_form_printer * build_printer();
277 FD_form_screen_fonts * build_screen_fonts();
279 FD_form_spellchecker * build_spellchecker();
281 /// Real GUI implementation.
282 FD_form_preferences * dialog_;
283 /// Converters tabfolder
284 FD_form_outer_tab * converters_tab_;
285 /// reLyX and other import/input stuff
286 FD_form_outer_tab * inputs_tab_;
287 /// HCI configuration
288 FD_form_outer_tab * look_n_feel_tab_;
289 /// Outputs tabfolder
290 FD_form_outer_tab * outputs_tab_;
291 /// Spellchecker, language stuff, etc
292 FD_form_outer_tab * usage_tab_;
294 FD_form_colours * colours_;
296 FD_form_converters * converters_;
298 FD_form_formats * formats_;
300 FD_form_inputs_misc * inputs_misc_;
302 FD_form_interface * interface_;
304 FD_form_language * language_;
306 FD_form_lnf_misc * lnf_misc_;
308 FD_form_outputs_misc * outputs_misc_;
310 FD_form_paths * paths_;
312 FD_form_printer * printer_;
314 FD_form_screen_fonts * screen_fonts_;
316 FD_form_spellchecker * spellchecker_;
318 Combox * combo_default_lang;
320 Combox * combo_kbmap_1;
322 Combox * combo_kbmap_2;
324 FL_OBJECT * feedbackObj;
326 /// A vector of Formats, to be manipulated in the Format browser.
327 std::vector<Format> formats_vec;
328 /// A vector of RGB colours and associated name.
329 static std::vector<X11Colour> colourDB;
330 /** A collection of kmap files.
331 First entry is the file name, full path.
332 Second entry is the shorthand, as appears in the fl_choice.
333 Eg, system_lyxdir/kbd/american2.kmap, american2
335 static std::pair<std::vector<string>, std::vector<string> > dirlist;
339 bool operator==(FormPreferences::RGB const & c1,
340 FormPreferences::RGB const & c2)
342 return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
347 bool operator!=(FormPreferences::RGB const & c1,
348 FormPreferences::RGB const & c2)