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
31 struct FD_form_colours;
32 struct FD_form_converters;
33 struct FD_form_formats;
34 struct FD_form_inputs_misc;
35 struct FD_form_interface;
36 struct FD_form_language;
37 struct FD_form_lnf_misc;
38 struct FD_form_outer_tab;
39 struct FD_form_outputs_misc;
41 struct FD_form_preferences;
42 struct FD_form_printer;
43 struct FD_form_screen_fonts;
44 struct FD_form_spellchecker;
46 /** This class provides an XForms implementation of the FormPreferences Dialog.
47 The preferences dialog allows users to set/save their preferences.
49 class FormPreferences : public FormBaseBI {
51 /// #FormPreferences x(LyXFunc ..., Dialogs ...);#
52 FormPreferences(LyXView *, Dialogs *);
56 static void ComboLanguageCB(int, void *, Combox *);
58 static int FeedbackCB(FL_OBJECT *, int,
59 FL_Coord, FL_Coord, int, void *);
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 * );
91 /// The handler for the preemptive feedback
92 void Feedback(FL_OBJECT *, int);
94 virtual FL_FORM * form() const;
96 /** Folder specific apply functions.
100 void applyColours() const;
102 void applyConverters() const;
104 void applyFormats() const;
106 void applyInputsMisc() const;
108 void applyInterface() const;
110 void applyLanguage(); // not const because calls updateLanguage!
112 void applyLnFmisc() const;
114 void applyOutputsMisc() const;
116 void applyPaths(); // not const because calls updatePaths!
118 void applyPrinter() const;
120 void applyScreenFonts() const;
122 void applySpellChecker(); // not const because calls updateSpellChecker!
124 /** Folder specific build functions.
130 void buildConverters();
134 void buildInputsMisc();
136 void buildInterface();
138 void buildLanguage();
142 void buildOutputsMisc();
148 void buildScreenFonts();
150 void buildSpellchecker();
152 /** Folder specific feedback functions.
156 string const feedbackColours(FL_OBJECT const * const) const;
158 string const feedbackConverters(FL_OBJECT const * const) const;
160 string const feedbackFormats( FL_OBJECT const * const ) const;
162 string const feedbackInputsMisc(FL_OBJECT const * const) const;
164 string const feedbackInterface(FL_OBJECT const * const) const;
166 string const feedbackLanguage(FL_OBJECT const * const) const;
168 string const feedbackLnFmisc(FL_OBJECT const * const) const;
170 string const feedbackOutputsMisc(FL_OBJECT const * const) const;
172 string const feedbackPaths(FL_OBJECT const * const) const;
174 string const feedbackPrinter(FL_OBJECT const * const) const;
176 string const feedbackScreenFonts(FL_OBJECT const * const) const;
178 string const feedbackSpellChecker(FL_OBJECT const * const) const;
180 /** Folder specific input functions. Not all folders require one.
184 bool inputColours(FL_OBJECT const * const);
186 bool inputConverters( FL_OBJECT const * const );
188 bool inputFormats( FL_OBJECT const * const );
190 bool inputLanguage(FL_OBJECT const * const);
192 bool inputPaths(FL_OBJECT const * const);
194 bool inputScreenFonts();
196 bool inputSpellChecker(FL_OBJECT const * const);
198 /** Folder specific update functions.
202 void updateColours();
204 void updateConverters();
206 void updateFormats();
208 void updateInputsMisc();
210 void updateInterface();
212 void updateLanguage();
214 void updateLnFmisc();
216 void updateOutputsMisc();
220 void updatePrinter();
222 void updateScreenFonts();
224 void updateSpellChecker();
226 /** Some helper functions for specific folders.
230 bool ColoursLoadBrowser( string const & );
232 int ColoursSearchEntry(RGB const & ) const;
234 void ColoursUpdateBrowser( int );
236 void ColoursUpdateRGB();
239 bool ConvertersAdd();
241 bool ConvertersBrowser();
243 void ConvertersClear() const;
245 bool ConvertersContainFormat( Format const &) const;
247 bool ConvertersDelete();
249 bool ConvertersInput();
251 bool ConvertersSetCommand( Command & ) const;
253 void ConvertersUpdateChoices();
257 bool FormatsBrowser();
259 void FormatsClear() const;
261 bool FormatsDelete();
266 bool WriteableDir( string const & );
268 bool ReadableDir( string const & );
270 bool WriteableFile( string const &, string const & = string() );
273 void setPreHandler( FL_OBJECT * ) const;
275 void printWarning( string const & );
277 /// Type definitions from the fdesign produced header file.
278 FD_form_preferences * build_preferences();
280 FD_form_outer_tab * build_outer_tab();
282 FD_form_colours * build_colours();
284 FD_form_converters * build_converters();
286 FD_form_formats * build_formats();
288 FD_form_inputs_misc * build_inputs_misc();
290 FD_form_interface * build_interface();
292 FD_form_language * build_language();
294 FD_form_lnf_misc * build_lnf_misc();
296 FD_form_outputs_misc * build_outputs_misc();
298 FD_form_paths * build_paths();
300 FD_form_printer * build_printer();
302 FD_form_screen_fonts * build_screen_fonts();
304 FD_form_spellchecker * build_spellchecker();
306 /// Real GUI implementation.
307 FD_form_preferences * dialog_;
308 /// Converters tabfolder
309 FD_form_outer_tab * converters_tab_;
310 /// reLyX and other import/input stuff
311 FD_form_outer_tab * inputs_tab_;
312 /// HCI configuration
313 FD_form_outer_tab * look_n_feel_tab_;
314 /// Outputs tabfolder
315 FD_form_outer_tab * outputs_tab_;
316 /// Spellchecker, language stuff, etc
317 FD_form_outer_tab * usage_tab_;
319 FD_form_colours * colours_;
321 FD_form_converters * converters_;
323 FD_form_formats * formats_;
325 FD_form_inputs_misc * inputs_misc_;
327 FD_form_interface * interface_;
329 FD_form_language * language_;
331 FD_form_lnf_misc * lnf_misc_;
333 FD_form_outputs_misc * outputs_misc_;
335 FD_form_paths * paths_;
337 FD_form_printer * printer_;
339 FD_form_screen_fonts * screen_fonts_;
341 FD_form_spellchecker * spellchecker_;
343 Combox * combo_default_lang;
345 Combox * combo_kbmap_1;
347 Combox * combo_kbmap_2;
349 /// A vector of Formats, to be manipulated in the Format browser.
350 std::vector<Format> formats_vec;
351 /// A vector of Commands, to be manipulated in the Converter browser.
352 std::vector<Command> commands_vec;
353 /// A vector of RGB colours and associated name.
354 static std::vector<X11Colour> colourDB;
355 /** A collection of kmap files.
356 First entry is the file name, full path.
357 Second entry is the shorthand, as appears in the fl_choice.
358 Eg, system_lyxdir/kbd/american2.kmap, american2
360 static std::pair<std::vector<string>, std::vector<string> > dirlist;
366 bool operator==(FormPreferences::RGB const & c1,
367 FormPreferences::RGB const & c2)
369 return (c1.r == c2.r && c1.g == c2.g && c1.b == c2.b);
374 bool operator!=(FormPreferences::RGB const & c1,
375 FormPreferences::RGB const & c2)