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;
49 /** This class provides an XForms implementation of the FormPreferences Dialog.
50 The preferences dialog allows users to set/save their preferences.
52 class FormPreferences : public FormBaseBI {
54 /// #FormPreferences x(LyXFunc ..., Dialogs ...);#
55 FormPreferences(LyXView *, Dialogs *);
59 static void ComboLanguageCB(int, void *, Combox *);
61 static int FeedbackCB(FL_OBJECT *, int,
62 FL_Coord, FL_Coord, int, void *);
65 /** Redraw the form (on receipt of a Signal indicating, for example,
66 that the xform colours have been re-mapped). */
67 virtual void redraw();
68 /// Update the dialog.
69 virtual void update();
76 /// Filter the inputs -- return true if entries are valid
77 virtual bool input(FL_OBJECT *, long);
80 /// control which feedback message is output
81 void feedback( FL_OBJECT * );
82 /// The handler for the preemptive feedback
83 void Feedback(FL_OBJECT *, int);
85 virtual FL_FORM * form() const;
87 /** Folder specific apply functions.
91 void applyColors() const;
93 void applyConverters() const;
95 void applyFormats() const;
97 void applyInputsMisc() const;
99 void applyInterface() const;
101 void applyLanguage(); // not const because calls updateLanguage!
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 feedbackColors(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 inputColors(FL_OBJECT const * const);
177 bool inputConverters( FL_OBJECT const * const );
179 bool inputFormats( FL_OBJECT const * const );
181 bool inputLanguage(FL_OBJECT const * const);
183 bool inputPaths(FL_OBJECT const * const);
185 bool inputScreenFonts();
187 bool inputSpellChecker(FL_OBJECT const * const);
189 /** Folder specific update functions.
195 void updateConverters();
197 void updateFormats();
199 void updateInputsMisc();
201 void updateInterface();
203 void updateLanguage();
205 void updateLnFmisc();
207 void updateOutputsMisc();
211 void updatePrinter();
213 void updateScreenFonts();
215 void updateSpellChecker();
217 /** Some helper functions for specific folders.
221 void ColorsAdjustVal( int, int, double ) const;
223 bool ColorsBrowserLyX() const;
225 bool ColorsBrowserX11() const;
227 bool ColorsDatabase() const;
229 void ColorsLoadBrowserLyX();
231 bool ColorsLoadBrowserX11(string const &) const;
233 bool ColorsModify() const;
235 bool ColorsRGB() const;
237 int ColorsSearchEntry(RGB const &) const;
240 bool ConvertersAdd();
242 bool ConvertersBrowser();
244 void ConvertersClear() const;
246 bool ConvertersContainFormat( Format const &) const;
248 bool ConvertersDelete();
250 bool ConvertersInput();
252 bool ConvertersSetCommand( Command & ) const;
254 void ConvertersUpdateChoices();
258 bool FormatsBrowser();
260 void FormatsClear() const;
262 bool FormatsDelete();
267 bool WriteableDir( string const & );
269 bool ReadableDir( string const & );
271 bool WriteableFile( string const &, string const & = string() );
274 void setPreHandler( FL_OBJECT * ) const;
276 void printWarning( string const & );
278 /// Type definitions from the fdesign produced header file.
279 FD_form_preferences * build_preferences();
281 FD_form_outer_tab * build_outer_tab();
283 FD_form_colors * build_colors();
285 FD_form_converters * build_converters();
287 FD_form_formats * build_formats();
289 FD_form_inputs_misc * build_inputs_misc();
291 FD_form_interface * build_interface();
293 FD_form_language * build_language();
295 FD_form_lnf_misc * build_lnf_misc();
297 FD_form_outputs_misc * build_outputs_misc();
299 FD_form_paths * build_paths();
301 FD_form_printer * build_printer();
303 FD_form_screen_fonts * build_screen_fonts();
305 FD_form_spellchecker * build_spellchecker();
307 /// Real GUI implementation.
308 FD_form_preferences * dialog_;
309 /// Converters tabfolder
310 FD_form_outer_tab * converters_tab_;
311 /// reLyX and other import/input stuff
312 FD_form_outer_tab * inputs_tab_;
313 /// HCI configuration
314 FD_form_outer_tab * look_n_feel_tab_;
315 /// Outputs tabfolder
316 FD_form_outer_tab * outputs_tab_;
317 /// Spellchecker, language stuff, etc
318 FD_form_outer_tab * usage_tab_;
320 FD_form_colors * colors_;
322 FD_form_converters * converters_;
324 FD_form_formats * formats_;
326 FD_form_inputs_misc * inputs_misc_;
328 FD_form_interface * interface_;
330 FD_form_language * language_;
332 FD_form_lnf_misc * lnf_misc_;
334 FD_form_outputs_misc * outputs_misc_;
336 FD_form_paths * paths_;
338 FD_form_printer * printer_;
340 FD_form_screen_fonts * screen_fonts_;
342 FD_form_spellchecker * spellchecker_;
344 Combox * combo_default_lang;
346 Combox * combo_kbmap_1;
348 Combox * combo_kbmap_2;
350 /// A vector of Formats, to be manipulated in the Format browser.
351 std::vector<Format> formats_vec;
352 /// A vector of Commands, to be manipulated in the Converter browser.
353 std::vector<Command> commands_vec;
354 /// A vector of RGB colors and associated name.
355 static std::vector<X11Color> colorDB;
356 /// A vector of xform RGB colors and associated name.
357 static std::vector<XFormColor> xformColorDB;
358 /** A collection of kmap files.
359 First entry is the file name, full path.
360 Second entry is the shorthand, as appears in the fl_choice.
361 Eg, system_lyxdir/kbd/american2.kmap, american2
363 static std::pair<std::vector<string>, std::vector<string> > dirlist;