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
20 #include <utility> // for pair
34 struct FD_form_colors;
35 struct FD_form_converters;
36 struct FD_form_formats;
37 struct FD_form_inputs_misc;
38 struct FD_form_interface;
39 struct FD_form_language;
40 struct FD_form_lnf_misc;
41 struct FD_form_outer_tab;
42 struct FD_form_outputs_misc;
44 struct FD_form_preferences;
45 struct FD_form_printer;
46 struct FD_form_screen_fonts;
47 struct FD_form_spellchecker;
50 /** This class provides an XForms implementation of the FormPreferences Dialog.
51 The preferences dialog allows users to set/save their preferences.
53 class FormPreferences : public FormBaseBI {
55 /// #FormPreferences x(LyXFunc ..., Dialogs ...);#
56 FormPreferences(LyXView *, Dialogs *);
60 static void ComboLanguageCB(int, void *, Combox *);
62 static int FeedbackCB(FL_OBJECT *, int,
63 FL_Coord, FL_Coord, int, void *);
66 /** Redraw the form (on receipt of a Signal indicating, for example,
67 that the xform colours have been re-mapped). */
68 virtual void redraw();
69 /// Update the dialog.
70 virtual void update();
77 /// Filter the inputs -- return true if entries are valid
78 virtual bool input(FL_OBJECT *, long);
81 /// control which feedback message is output
82 void feedback( FL_OBJECT * );
83 /// The handler for the preemptive feedback
84 void Feedback(FL_OBJECT *, int);
86 virtual FL_FORM * form() const;
88 /** Folder specific apply functions.
92 void applyColors(); // not const as modifies modifiedXformPrefs.
94 void applyConverters() const;
96 void applyFormats() const;
98 void applyInputsMisc() const;
100 void applyInterface() const;
102 void applyLanguage(); // not const because calls updateLanguage!
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 feedbackColors(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 inputColors(FL_OBJECT const * const);
178 bool inputConverters( FL_OBJECT const * const );
180 bool inputFormats( FL_OBJECT const * const );
182 bool inputLanguage(FL_OBJECT const * const);
184 bool inputPaths(FL_OBJECT const * const);
186 bool inputScreenFonts();
188 bool inputSpellChecker(FL_OBJECT const * const);
190 /** Folder specific update functions.
196 void updateConverters();
198 void updateFormats();
200 void updateInputsMisc();
202 void updateInterface();
204 void updateLanguage();
206 void updateLnFmisc();
208 void updateOutputsMisc();
212 void updatePrinter();
214 void updateScreenFonts();
216 void updateSpellChecker();
218 /** Some helper functions for specific folders.
222 void ColorsAdjustVal( int, int, double ) const;
224 bool ColorsBrowserLyX() const;
226 bool ColorsBrowserX11() const;
228 bool ColorsBrowseDatabase() const;
230 bool ColorsDatabase() const;
232 void ColorsLoadBrowserLyX();
234 bool ColorsLoadBrowserX11(string const &) const;
236 bool ColorsModify() const;
238 bool ColorsRGB() const;
240 int ColorsSearchEntry(RGBColor const &) const;
243 bool ConvertersAdd();
245 bool ConvertersBrowser();
247 void ConvertersUpdateBrowser();
249 bool ConvertersDelete();
251 bool ConvertersInput();
253 string const ConverterGetFrom() const;
255 string const ConverterGetTo() const;
257 void ConvertersUpdateChoices() const;
261 bool FormatsBrowser();
263 void FormatsUpdateBrowser();
265 bool FormatsDelete();
270 bool WriteableDir( string const & );
272 bool ReadableDir( string const & );
274 bool WriteableFile( string const &, string const & = string() );
277 void setPreHandler( FL_OBJECT * ) const;
279 void printWarning( string const & );
281 /// Type definitions from the fdesign produced header file.
282 FD_form_preferences * build_preferences();
284 FD_form_outer_tab * build_outer_tab();
286 FD_form_colors * build_colors();
288 FD_form_converters * build_converters();
290 FD_form_formats * build_formats();
292 FD_form_inputs_misc * build_inputs_misc();
294 FD_form_interface * build_interface();
296 FD_form_language * build_language();
298 FD_form_lnf_misc * build_lnf_misc();
300 FD_form_outputs_misc * build_outputs_misc();
302 FD_form_paths * build_paths();
304 FD_form_printer * build_printer();
306 FD_form_screen_fonts * build_screen_fonts();
308 FD_form_spellchecker * build_spellchecker();
310 /// Real GUI implementation.
311 FD_form_preferences * dialog_;
312 /// Converters tabfolder
313 FD_form_outer_tab * converters_tab_;
314 /// reLyX and other import/input stuff
315 FD_form_outer_tab * inputs_tab_;
316 /// HCI configuration
317 FD_form_outer_tab * look_n_feel_tab_;
318 /// Outputs tabfolder
319 FD_form_outer_tab * outputs_tab_;
320 /// Spellchecker, language stuff, etc
321 FD_form_outer_tab * usage_tab_;
323 FD_form_colors * colors_;
325 FD_form_converters * converters_;
327 FD_form_formats * formats_;
329 FD_form_inputs_misc * inputs_misc_;
331 FD_form_interface * interface_;
333 FD_form_language * language_;
335 FD_form_lnf_misc * lnf_misc_;
337 FD_form_outputs_misc * outputs_misc_;
339 FD_form_paths * paths_;
341 FD_form_printer * printer_;
343 FD_form_screen_fonts * screen_fonts_;
345 FD_form_spellchecker * spellchecker_;
347 Combox * combo_default_lang;
349 Combox * combo_kbmap_1;
351 Combox * combo_kbmap_2;
353 /// A vector of RGB colors and associated name.
354 static std::vector<X11Color> colorDB;
355 /// A vector of xform RGB colors and associated name.
356 static std::vector<XformColor> xformColorDB;
357 /** A collection of kmap files.
358 First entry is the file name, full path.
359 Second entry is the shorthand, as appears in the fl_choice.
360 Eg, system_lyxdir/kbd/american2.kmap, american2
362 static std::pair<std::vector<string>, std::vector<string> > dirlist;
363 /** Flag whether a warning has been posted to the text window.
364 If so, don't redraw the window when the mouse leaves an object. */
366 /// Flag whether Xforms colors have been changed since last file save.
367 bool modifiedXformPrefs;