3 * \file FormPreferences.h
4 * Copyright 1995-2002 the LyX Team
5 * Copyright 1999-2001 Allan Rae
6 * Read the file COPYING
8 * \author Allan Rae, rae@lyx.org
9 * \author Angus Leeming, a.leeming@ic.ac.uk
12 #ifndef FORMPREFERENCES_H
13 #define FORMPREFERENCES_H
19 #include "FormBaseDeprecated.h"
20 #include "Color.h" // NamedColor
21 #include "xforms_helpers.h" // XformColor
23 #include <boost/scoped_ptr.hpp>
25 #include FORMS_H_LOCATION
26 #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_inner_tab;
41 struct FD_preferences_outputs_misc;
42 struct FD_preferences_paths;
43 struct FD_preferences_printer;
44 struct FD_preferences_screen_fonts;
45 struct FD_preferences_spelloptions;
48 /** This class provides an XForms implementation of the FormPreferences Dialog.
49 The preferences dialog allows users to set/save their preferences.
51 class FormPreferences : public FormBaseBI {
53 friend void gui_ShowPreferences(LyXView &, Dialogs &);
54 friend void gui_ShowSpellcheckerPreferences(LyXView &, Dialogs &);
56 FormPreferences(LyXView &, Dialogs &);
59 /// Pointer to the actual instantiation of the ButtonController.
60 virtual xformsBC & bc();
61 /** Redraw the form (on receipt of a Signal indicating, for example,
62 that the xforms colours have been re-mapped). */
63 virtual void redraw();
64 /// Update the dialog.
65 virtual void update();
66 /// show the spellchecker tab
70 /// OK (Save) from dialog
74 /// Filter the inputs -- return true if entries are valid
75 virtual bool input(FL_OBJECT *, long);
78 /// Pointer to the actual instantiation of the xforms form.
79 virtual FL_FORM * form() const;
80 /// control which feedback message is output
81 string const getFeedback(FL_OBJECT *);
83 void browse(FL_OBJECT * input,
84 string const & title, string const & pattern,
85 std::pair<string,string> const & dir1= std::make_pair(string(),string()),
86 std::pair<string,string> const & dir2 = std::make_pair(string(),string()));
88 /// Real GUI implementation.
89 boost::scoped_ptr<FD_preferences> dialog_;
90 /// Converters tabfolder
91 boost::scoped_ptr<FD_preferences_inner_tab> converters_tab_;
92 /// reLyX and other import/input stuff
93 boost::scoped_ptr<FD_preferences_inner_tab> inputs_tab_;
95 boost::scoped_ptr<FD_preferences_inner_tab> look_n_feel_tab_;
97 boost::scoped_ptr<FD_preferences_inner_tab> outputs_tab_;
98 /// Spellchecker, language stuff, etc
99 boost::scoped_ptr<FD_preferences_inner_tab> lang_opts_tab_;
101 /** Each tab folder is encapsulated in its own class.
108 GUI_COLOR_CHOICE = FL_FREE_COL14,
109 GUI_COLOR_HUE_DIAL = FL_FREE_COL15,
110 GUI_COLOR_CURSOR = FL_FREE_COL16
113 Colors(FormPreferences & p);
115 FD_preferences_colors const * dialog();
117 void apply(); // not const as modifies modifiedXformsPrefs.
121 string const feedback(FL_OBJECT const * const) const;
123 void input(FL_OBJECT const * const);
125 void update() { LoadBrowserLyX(); }
127 /// Flag whether Xforms colors have changed since last file save
128 bool modifiedXformsPrefs;
132 void AdjustVal(int, int, double) const;
134 void InputBrowserLyX() const;
140 void LoadBrowserLyX();
144 void SwitchColorSpace() const;
146 string const X11hexname(RGBColor const &) const;
149 FormPreferences & parent_;
151 boost::scoped_ptr<FD_preferences_colors> dialog_;
153 /// A vector of LyX LColor GUI name and associated RGB color.
154 std::vector<NamedColor> lyxColorDB;
155 /// A vector of xforms color ID, RGB colors and associated name.
156 std::vector<XformsColor> xformsColorDB;
165 Converters(FormPreferences & p);
167 FD_preferences_converters const * dialog();
173 string const feedback(FL_OBJECT const * const) const;
175 bool input(FL_OBJECT const * const);
179 void UpdateBrowser();
181 void UpdateChoices() const;
193 string const GetFrom() const;
195 string const GetTo() const;
198 FormPreferences & parent_;
200 boost::scoped_ptr<FD_preferences_converters> dialog_;
203 friend class Converters;
209 Formats(FormPreferences & p);
211 FD_preferences_formats const * dialog();
217 string const feedback(FL_OBJECT const * const) const;
219 bool input(FL_OBJECT const * const);
229 void UpdateBrowser();
236 FormPreferences & parent_;
238 boost::scoped_ptr<FD_preferences_formats> dialog_;
241 friend class Formats;
247 InputsMisc(FormPreferences & p);
249 FD_preferences_inputs_misc const * dialog();
255 string const feedback(FL_OBJECT const * const) const;
261 FormPreferences & parent_;
263 boost::scoped_ptr<FD_preferences_inputs_misc> dialog_;
266 friend class InputsMisc;
272 Interface(FormPreferences & p);
274 FD_preferences_interface const * dialog();
280 string const feedback(FL_OBJECT const * const) const;
282 bool input(FL_OBJECT const * const);
288 FormPreferences & parent_;
290 boost::scoped_ptr<FD_preferences_interface> dialog_;
293 friend class Interface;
299 Language(FormPreferences & p);
301 FD_preferences_language const * dialog();
303 void apply(); // not const because calls update()
307 string const feedback(FL_OBJECT const * const) const;
309 bool input(FL_OBJECT const * const);
313 static void ComboCB(int, void *, Combox *);
317 FormPreferences & parent_;
319 boost::scoped_ptr<FD_preferences_language> dialog_;
321 boost::scoped_ptr<Combox> combo_default_lang;
323 std::vector<string> lang_;
326 friend class Language;
332 LnFmisc(FormPreferences & p);
334 FD_preferences_lnf_misc const * dialog();
340 string const feedback(FL_OBJECT const * const) const;
346 FormPreferences & parent_;
348 boost::scoped_ptr<FD_preferences_lnf_misc> dialog_;
351 friend class LnFmisc;
357 OutputsMisc(FormPreferences & p);
359 FD_preferences_outputs_misc const * dialog();
365 string const feedback(FL_OBJECT const * const) const;
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();
390 string const feedback(FL_OBJECT const * const) const;
392 bool input(FL_OBJECT const * const);
398 FormPreferences & parent_;
400 boost::scoped_ptr<FD_preferences_paths> dialog_;
409 Printer(FormPreferences & p);
411 FD_preferences_printer const * dialog();
417 string const feedback(FL_OBJECT const * const) const;
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();
442 string const feedback(FL_OBJECT const * const) const;
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(); // not const because calls update()!
469 string const feedback(FL_OBJECT const * const) const;
471 bool input(FL_OBJECT const * const);
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_;
502 OutputsMisc outputs_misc_;
508 ScreenFonts screen_fonts_;
510 SpellOptions spelloptions_;
512 /** A couple of helper structs to enable colors to be sorted by name
515 struct SortColorsByName {
517 int operator()(NamedColor const & a, NamedColor const & b) const
518 { return (a.getname() < b.getname()); }
521 struct SortColorsByColor {
523 SortColorsByColor(RGBColor c) : col(c) {}
525 int operator()(RGBColor const &, RGBColor const &) const;
529 /// The ButtonController
530 ButtonController<PreferencesPolicy, xformsBC> bc_;
535 xformsBC & FormPreferences::bc()