3 * \file FormPreferences.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Angus Leeming
10 * Full author contact details are available in file CREDITS.
13 #ifndef FORMPREFERENCES_H
14 #define FORMPREFERENCES_H
18 #include "Color.h" // NamedColor
19 #include "xforms_helpers.h" // XformColor
21 #include <boost/scoped_ptr.hpp>
23 #include "lyx_forms.h"
24 #include <utility> // pair
31 class FormColorpicker;
33 struct FD_preferences;
34 struct FD_preferences_colors;
35 struct FD_preferences_converters;
36 struct FD_preferences_formats;
37 struct FD_preferences_inputs_misc;
38 struct FD_preferences_interface;
39 struct FD_preferences_language;
40 struct FD_preferences_lnf_misc;
41 struct FD_preferences_identity;
42 struct FD_preferences_inner_tab;
43 struct FD_preferences_outputs_misc;
44 struct FD_preferences_paths;
45 struct FD_preferences_printer;
46 struct FD_preferences_screen_fonts;
47 struct FD_preferences_spelloptions;
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 FormCB<ControlPrefs, FormDB<FD_preferences> > {
58 /** Redraw the form (on receipt of a Signal indicating, for example,
59 that the xforms colours have been re-mapped). */
60 virtual void redraw();
61 /// Update the dialog.
62 virtual void update();
67 /// Filter the inputs -- return true if entries are valid
68 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
71 /// control which feedback message is output
72 string const getFeedback(FL_OBJECT *);
74 /// Converters tabfolder
75 boost::scoped_ptr<FD_preferences_inner_tab> converters_tab_;
76 /// reLyX and other import/input stuff
77 boost::scoped_ptr<FD_preferences_inner_tab> inputs_tab_;
79 boost::scoped_ptr<FD_preferences_inner_tab> look_n_feel_tab_;
81 boost::scoped_ptr<FD_preferences_inner_tab> outputs_tab_;
82 /// Spellchecker, language stuff, etc
83 boost::scoped_ptr<FD_preferences_inner_tab> lang_opts_tab_;
85 /** Each tab folder is encapsulated in its own class.
92 GUI_COLOR_CHOICE = FL_FREE_COL15,
93 GUI_COLOR_CURSOR = FL_FREE_COL16
96 Colors(FormPreferences & p);
98 FD_preferences_colors const * dialog();
100 void apply(); // not const as modifies modifiedXformsPrefs.
104 string const feedback(FL_OBJECT const * const) const;
106 void input(FL_OBJECT const * const);
108 void update() { LoadBrowserLyX(); }
110 /// Flag whether Xforms colors have changed since last file save
111 bool modifiedXformsPrefs;
115 void AdjustVal(int, int, double) const;
117 void InputBrowserLyX() const;
119 void LoadBrowserLyX();
124 FormPreferences & parent_;
126 boost::scoped_ptr<FD_preferences_colors> dialog_;
128 boost::scoped_ptr<FormColorpicker> picker_;
130 /// A vector of LyX LColor GUI name and associated RGB color.
131 std::vector<NamedColor> lyxColorDB;
132 /// A vector of xforms color ID, RGB colors and associated name.
133 std::vector<XformsColor> xformsColorDB;
142 Converters(FormPreferences & p);
144 FD_preferences_converters const * dialog();
150 string const feedback(FL_OBJECT const * const) const;
152 bool input(FL_OBJECT const * const);
156 void UpdateBrowser();
158 void UpdateChoices() const;
170 string const GetFrom() const;
172 string const GetTo() const;
175 FormPreferences & parent_;
177 boost::scoped_ptr<FD_preferences_converters> dialog_;
180 friend class Converters;
186 Formats(FormPreferences & p);
188 FD_preferences_formats const * dialog();
194 string const feedback(FL_OBJECT const * const) const;
196 bool input(FL_OBJECT const * const);
206 void UpdateBrowser();
213 FormPreferences & parent_;
215 boost::scoped_ptr<FD_preferences_formats> dialog_;
218 friend class Formats;
224 InputsMisc(FormPreferences & p);
226 FD_preferences_inputs_misc const * dialog();
228 void apply(LyXRC & rc) const;
232 string const feedback(FL_OBJECT const * const) const;
234 void update(LyXRC const & rc);
238 FormPreferences & parent_;
240 boost::scoped_ptr<FD_preferences_inputs_misc> dialog_;
243 friend class InputsMisc;
249 Interface(FormPreferences & p);
251 FD_preferences_interface const * dialog();
253 void apply(LyXRC & rc) const;
257 string const feedback(FL_OBJECT const * const) const;
259 bool input(FL_OBJECT const * const);
261 void update(LyXRC const & rc);
265 FormPreferences & parent_;
267 boost::scoped_ptr<FD_preferences_interface> dialog_;
270 friend class Interface;
276 Language(FormPreferences & p);
278 FD_preferences_language const * dialog();
280 void apply(LyXRC & rc); // not const because calls update()
284 string const feedback(FL_OBJECT const * const) const;
286 bool input(FL_OBJECT const * const);
288 void update(LyXRC const & rc);
292 FormPreferences & parent_;
294 boost::scoped_ptr<FD_preferences_language> dialog_;
296 std::vector<string> lang_;
299 friend class Language;
305 LnFmisc(FormPreferences & p);
307 FD_preferences_lnf_misc const * dialog();
309 void apply(LyXRC & rc) const;
313 string const feedback(FL_OBJECT const * const) const;
315 void update(LyXRC const & rc);
319 FormPreferences & parent_;
321 boost::scoped_ptr<FD_preferences_lnf_misc> dialog_;
324 friend class LnFmisc;
329 Identity(FormPreferences & p);
331 FD_preferences_identity const * dialog();
333 void apply(LyXRC & rc) const;
337 string const feedback(FL_OBJECT const * const) const;
339 void update(LyXRC const & rc);
343 FormPreferences & parent_;
345 boost::scoped_ptr<FD_preferences_identity> dialog_;
347 friend class Identity;
353 OutputsMisc(FormPreferences & p);
355 FD_preferences_outputs_misc const * dialog();
357 void apply(LyXRC & rc) const;
361 string const feedback(FL_OBJECT const * const) const;
363 void update(LyXRC const & rc);
367 FormPreferences & parent_;
369 boost::scoped_ptr<FD_preferences_outputs_misc> dialog_;
372 friend class OutputsMisc;
378 Paths(FormPreferences & p);
380 FD_preferences_paths const * dialog();
382 void apply(LyXRC & rc);
386 string const feedback(FL_OBJECT const * const) const;
388 bool input(FL_OBJECT const * const);
390 void update(LyXRC const & rc);
394 FormPreferences & parent_;
396 boost::scoped_ptr<FD_preferences_paths> dialog_;
405 Printer(FormPreferences & p);
407 FD_preferences_printer const * dialog();
409 void apply(LyXRC & rc) const;
413 string const feedback(FL_OBJECT const * const) const;
415 void update(LyXRC const & rc);
419 FormPreferences & parent_;
421 boost::scoped_ptr<FD_preferences_printer> dialog_;
424 friend class Printer;
430 ScreenFonts(FormPreferences & p);
432 FD_preferences_screen_fonts const * dialog();
434 void apply(LyXRC & rc) const;
438 string const feedback(FL_OBJECT const * const) const;
442 void update(LyXRC const & rc);
446 FormPreferences & parent_;
448 boost::scoped_ptr<FD_preferences_screen_fonts> dialog_;
451 friend class ScreenFonts;
457 SpellOptions(FormPreferences & p);
459 FD_preferences_spelloptions const * dialog();
461 void apply(LyXRC & rc); // not const because calls update()!
465 string const feedback(FL_OBJECT const * const) const;
467 bool input(FL_OBJECT const * const);
469 void update(LyXRC const & rc);
473 FormPreferences & parent_;
475 boost::scoped_ptr<FD_preferences_spelloptions> dialog_;
478 friend class SpellOptions;
486 Converters converters_;
488 InputsMisc inputs_misc_;
492 Interface interface_;
500 OutputsMisc outputs_misc_;
506 ScreenFonts screen_fonts_;
508 SpellOptions spelloptions_;
510 /** A couple of helper structs to enable colors to be sorted by name
513 struct SortColorsByName {
515 int operator()(NamedColor const & a, NamedColor const & b) const
516 { return (a.getname() < b.getname()); }
519 struct SortColorsByColor {
521 SortColorsByColor(RGBColor c) : col(c) {}
523 int operator()(RGBColor const &, RGBColor const &) const;
529 #endif // FORMPREFERENCES_H