3 * \file FormPreferences.h
4 * Copyright 1999-2001 Allan Rae
5 * This file is part of LyX, the document processor.
6 * Licence details can be found in the file COPYING.
9 * \author Angus Leeming
11 * Full author contact details are available in file CREDITS
14 #ifndef FORMPREFERENCES_H
15 #define FORMPREFERENCES_H
19 #include "Color.h" // NamedColor
20 #include "xforms_helpers.h" // XformColor
22 #include <boost/scoped_ptr.hpp>
24 #include "lyx_forms.h"
25 #include <utility> // pair
32 struct FD_preferences;
33 struct FD_preferences_colors;
34 struct FD_preferences_converters;
35 struct FD_preferences_formats;
36 struct FD_preferences_inputs_misc;
37 struct FD_preferences_interface;
38 struct FD_preferences_language;
39 struct FD_preferences_lnf_misc;
40 struct FD_preferences_identity;
41 struct FD_preferences_inner_tab;
42 struct FD_preferences_outputs_misc;
43 struct FD_preferences_paths;
44 struct FD_preferences_printer;
45 struct FD_preferences_screen_fonts;
46 struct FD_preferences_spelloptions;
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 FormCB<ControlPrefs, FormDB<FD_preferences> > {
57 /** Redraw the form (on receipt of a Signal indicating, for example,
58 that the xforms colours have been re-mapped). */
59 virtual void redraw();
60 /// Update the dialog.
61 virtual void update();
66 /// Filter the inputs -- return true if entries are valid
67 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
70 /// control which feedback message is output
71 string const getFeedback(FL_OBJECT *);
73 /// Converters tabfolder
74 boost::scoped_ptr<FD_preferences_inner_tab> converters_tab_;
75 /// reLyX and other import/input stuff
76 boost::scoped_ptr<FD_preferences_inner_tab> inputs_tab_;
78 boost::scoped_ptr<FD_preferences_inner_tab> look_n_feel_tab_;
80 boost::scoped_ptr<FD_preferences_inner_tab> outputs_tab_;
81 /// Spellchecker, language stuff, etc
82 boost::scoped_ptr<FD_preferences_inner_tab> lang_opts_tab_;
84 /** Each tab folder is encapsulated in its own class.
91 GUI_COLOR_CHOICE = FL_FREE_COL14,
92 GUI_COLOR_HUE_DIAL = 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;
123 void LoadBrowserLyX();
127 void SwitchColorSpace() const;
130 FormPreferences & parent_;
132 boost::scoped_ptr<FD_preferences_colors> dialog_;
134 /// A vector of LyX LColor GUI name and associated RGB color.
135 std::vector<NamedColor> lyxColorDB;
136 /// A vector of xforms color ID, RGB colors and associated name.
137 std::vector<XformsColor> xformsColorDB;
146 Converters(FormPreferences & p);
148 FD_preferences_converters const * dialog();
154 string const feedback(FL_OBJECT const * const) const;
156 bool input(FL_OBJECT const * const);
160 void UpdateBrowser();
162 void UpdateChoices() const;
174 string const GetFrom() const;
176 string const GetTo() const;
179 FormPreferences & parent_;
181 boost::scoped_ptr<FD_preferences_converters> dialog_;
184 friend class Converters;
190 Formats(FormPreferences & p);
192 FD_preferences_formats const * dialog();
198 string const feedback(FL_OBJECT const * const) const;
200 bool input(FL_OBJECT const * const);
210 void UpdateBrowser();
217 FormPreferences & parent_;
219 boost::scoped_ptr<FD_preferences_formats> dialog_;
222 friend class Formats;
228 InputsMisc(FormPreferences & p);
230 FD_preferences_inputs_misc const * dialog();
232 void apply(LyXRC & rc) const;
236 string const feedback(FL_OBJECT const * const) const;
238 void update(LyXRC const & rc);
242 FormPreferences & parent_;
244 boost::scoped_ptr<FD_preferences_inputs_misc> dialog_;
247 friend class InputsMisc;
253 Interface(FormPreferences & p);
255 FD_preferences_interface const * dialog();
257 void apply(LyXRC & rc) const;
261 string const feedback(FL_OBJECT const * const) const;
263 bool input(FL_OBJECT const * const);
265 void update(LyXRC const & rc);
269 FormPreferences & parent_;
271 boost::scoped_ptr<FD_preferences_interface> dialog_;
274 friend class Interface;
280 Language(FormPreferences & p);
282 FD_preferences_language const * dialog();
284 void apply(LyXRC & rc); // not const because calls update()
288 string const feedback(FL_OBJECT const * const) const;
290 bool input(FL_OBJECT const * const);
292 void update(LyXRC const & rc);
296 FormPreferences & parent_;
298 boost::scoped_ptr<FD_preferences_language> dialog_;
300 std::vector<string> lang_;
303 friend class Language;
309 LnFmisc(FormPreferences & p);
311 FD_preferences_lnf_misc const * dialog();
313 void apply(LyXRC & rc) const;
317 string const feedback(FL_OBJECT const * const) const;
319 void update(LyXRC const & rc);
323 FormPreferences & parent_;
325 boost::scoped_ptr<FD_preferences_lnf_misc> dialog_;
328 friend class LnFmisc;
333 Identity(FormPreferences & p);
335 FD_preferences_identity const * dialog();
337 void apply(LyXRC & rc) const;
341 string const feedback(FL_OBJECT const * const) const;
343 void update(LyXRC const & rc);
347 FormPreferences & parent_;
349 boost::scoped_ptr<FD_preferences_identity> dialog_;
351 friend class Identity;
357 OutputsMisc(FormPreferences & p);
359 FD_preferences_outputs_misc const * dialog();
361 void apply(LyXRC & rc) const;
365 string const feedback(FL_OBJECT const * const) const;
367 void update(LyXRC const & rc);
371 FormPreferences & parent_;
373 boost::scoped_ptr<FD_preferences_outputs_misc> dialog_;
376 friend class OutputsMisc;
382 Paths(FormPreferences & p);
384 FD_preferences_paths const * dialog();
386 void apply(LyXRC & rc);
390 string const feedback(FL_OBJECT const * const) const;
392 bool input(FL_OBJECT const * const);
394 void update(LyXRC const & rc);
398 FormPreferences & parent_;
400 boost::scoped_ptr<FD_preferences_paths> dialog_;
409 Printer(FormPreferences & p);
411 FD_preferences_printer const * dialog();
413 void apply(LyXRC & rc) const;
417 string const feedback(FL_OBJECT const * const) const;
419 void update(LyXRC const & rc);
423 FormPreferences & parent_;
425 boost::scoped_ptr<FD_preferences_printer> dialog_;
428 friend class Printer;
434 ScreenFonts(FormPreferences & p);
436 FD_preferences_screen_fonts const * dialog();
438 void apply(LyXRC & rc) const;
442 string const feedback(FL_OBJECT const * const) const;
446 void update(LyXRC const & rc);
450 FormPreferences & parent_;
452 boost::scoped_ptr<FD_preferences_screen_fonts> dialog_;
455 friend class ScreenFonts;
461 SpellOptions(FormPreferences & p);
463 FD_preferences_spelloptions const * dialog();
465 void apply(LyXRC & rc); // not const because calls update()!
469 string const feedback(FL_OBJECT const * const) const;
471 bool input(FL_OBJECT const * const);
473 void update(LyXRC const & rc);
477 FormPreferences & parent_;
479 boost::scoped_ptr<FD_preferences_spelloptions> dialog_;
482 friend class SpellOptions;
490 Converters converters_;
492 InputsMisc inputs_misc_;
496 Interface interface_;
504 OutputsMisc outputs_misc_;
510 ScreenFonts screen_fonts_;
512 SpellOptions spelloptions_;
514 /** A couple of helper structs to enable colors to be sorted by name
517 struct SortColorsByName {
519 int operator()(NamedColor const & a, NamedColor const & b) const
520 { return (a.getname() < b.getname()); }
523 struct SortColorsByColor {
525 SortColorsByColor(RGBColor c) : col(c) {}
527 int operator()(RGBColor const &, RGBColor const &) const;
533 #endif // FORMPREFERENCES_H