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
15 #include <utility> // pair
16 #include <boost/smart_ptr.hpp>
22 #include "FormBaseDeprecated.h"
23 #include "Color.h" // NamedColor
24 #include "xforms_helpers.h" // XformColor
30 struct FD_form_colors;
31 struct FD_form_converters;
32 struct FD_form_formats;
33 struct FD_form_inputs_misc;
34 struct FD_form_interface;
35 struct FD_form_language;
36 struct FD_form_lnf_misc;
37 struct FD_form_inner_tab;
38 struct FD_form_outputs_misc;
40 struct FD_form_preferences;
41 struct FD_form_printer;
42 struct FD_form_screen_fonts;
43 struct FD_form_spelloptions;
46 /** This class provides an XForms implementation of the FormPreferences Dialog.
47 The preferences dialog allows users to set/save their preferences.
49 class FormPreferences : public FormBaseBI {
52 FormPreferences(LyXView *, Dialogs *);
55 /// Pointer to the actual instantiation of the ButtonController.
56 virtual xformsBC & bc();
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();
62 /// show the spellchecker tab
66 /// OK (Save) from dialog
70 /// Filter the inputs -- return true if entries are valid
71 virtual bool input(FL_OBJECT *, long);
74 /// Pointer to the actual instantiation of the xforms form.
75 virtual FL_FORM * form() const;
76 /// control which feedback message is output
77 string const getFeedback(FL_OBJECT *);
79 void browse(FL_OBJECT * input,
80 string const & title, string const & pattern,
81 std::pair<string,string> const & dir1= std::make_pair(string(),string()),
82 std::pair<string,string> const & dir2 = std::make_pair(string(),string()));
84 /// Fdesign generated methods
85 FD_form_preferences * build_preferences();
87 FD_form_inner_tab * build_inner_tab();
89 FD_form_colors * build_colors();
91 FD_form_converters * build_converters();
93 FD_form_formats * build_formats();
95 FD_form_inputs_misc * build_inputs_misc();
97 FD_form_interface * build_interface();
99 FD_form_language * build_language();
101 FD_form_lnf_misc * build_lnf_misc();
103 FD_form_outputs_misc * build_outputs_misc();
105 FD_form_paths * build_paths();
107 FD_form_printer * build_printer();
109 FD_form_screen_fonts * build_screen_fonts();
111 FD_form_spelloptions * build_spelloptions();
113 /// Real GUI implementation.
114 boost::scoped_ptr<FD_form_preferences> dialog_;
115 /// Converters tabfolder
116 boost::scoped_ptr<FD_form_inner_tab> converters_tab_;
117 /// reLyX and other import/input stuff
118 boost::scoped_ptr<FD_form_inner_tab> inputs_tab_;
119 /// HCI configuration
120 boost::scoped_ptr<FD_form_inner_tab> look_n_feel_tab_;
121 /// Outputs tabfolder
122 boost::scoped_ptr<FD_form_inner_tab> outputs_tab_;
123 /// Spellchecker, language stuff, etc
124 boost::scoped_ptr<FD_form_inner_tab> lang_opts_tab_;
126 /** Each tab folder is encapsulated in its own class.
133 GUI_COLOR_CHOICE = FL_FREE_COL14,
134 GUI_COLOR_HUE_DIAL = FL_FREE_COL15,
135 GUI_COLOR_CURSOR = FL_FREE_COL16
138 Colors(FormPreferences & p);
140 FD_form_colors const * dialog();
142 void apply(); // not const as modifies modifiedXformsPrefs.
146 string const feedback(FL_OBJECT const * const) const;
148 void input(FL_OBJECT const * const);
150 void update() { LoadBrowserLyX(); }
152 /// Flag whether Xforms colors have changed since last file save
153 bool modifiedXformsPrefs;
157 void AdjustVal(int, int, double) const;
159 void InputBrowserLyX() const;
165 void LoadBrowserLyX();
169 void SwitchColorSpace() const;
171 string const X11hexname(RGBColor const &) const;
174 FormPreferences & parent_;
176 boost::scoped_ptr<FD_form_colors> dialog_;
178 /// A vector of LyX LColor GUI name and associated RGB color.
179 std::vector<NamedColor> lyxColorDB;
180 /// A vector of xforms color ID, RGB colors and associated name.
181 std::vector<XformsColor> xformsColorDB;
190 Converters(FormPreferences & p);
192 FD_form_converters const * dialog();
198 string const feedback(FL_OBJECT const * const) const;
200 bool input(FL_OBJECT const * const);
204 void UpdateBrowser();
206 void UpdateChoices() const;
218 string const GetFrom() const;
220 string const GetTo() const;
223 FormPreferences & parent_;
225 boost::scoped_ptr<FD_form_converters> dialog_;
228 friend class Converters;
234 Formats(FormPreferences & p);
236 FD_form_formats const * dialog();
242 string const feedback(FL_OBJECT const * const) const;
244 bool input(FL_OBJECT const * const);
254 void UpdateBrowser();
261 FormPreferences & parent_;
263 boost::scoped_ptr<FD_form_formats> dialog_;
266 friend class Formats;
272 InputsMisc(FormPreferences & p);
274 FD_form_inputs_misc const * dialog();
280 string const feedback(FL_OBJECT const * const) const;
286 FormPreferences & parent_;
288 boost::scoped_ptr<FD_form_inputs_misc> dialog_;
291 friend class InputsMisc;
297 Interface(FormPreferences & p);
299 FD_form_interface const * dialog();
305 string const feedback(FL_OBJECT const * const) const;
307 bool input(FL_OBJECT const * const);
313 FormPreferences & parent_;
315 boost::scoped_ptr<FD_form_interface> dialog_;
318 friend class Interface;
324 Language(FormPreferences & p);
326 FD_form_language const * dialog();
328 void apply(); // not const because calls update()
332 string const feedback(FL_OBJECT const * const) const;
334 bool input(FL_OBJECT const * const);
338 static void ComboCB(int, void *, Combox *);
342 FormPreferences & parent_;
344 boost::scoped_ptr<FD_form_language> dialog_;
346 boost::scoped_ptr<Combox> combo_default_lang;
349 friend class Language;
355 LnFmisc(FormPreferences & p);
357 FD_form_lnf_misc const * dialog();
363 string const feedback(FL_OBJECT const * const) const;
369 FormPreferences & parent_;
371 boost::scoped_ptr<FD_form_lnf_misc> dialog_;
374 friend class LnFmisc;
380 OutputsMisc(FormPreferences & p);
382 FD_form_outputs_misc const * dialog();
388 string const feedback(FL_OBJECT const * const) const;
394 FormPreferences & parent_;
396 boost::scoped_ptr<FD_form_outputs_misc> dialog_;
399 friend class OutputsMisc;
405 Paths(FormPreferences & p);
407 FD_form_paths const * dialog();
413 string const feedback(FL_OBJECT const * const) const;
415 bool input(FL_OBJECT const * const);
421 FormPreferences & parent_;
423 boost::scoped_ptr<FD_form_paths> dialog_;
432 Printer(FormPreferences & p);
434 FD_form_printer const * dialog();
440 string const feedback(FL_OBJECT const * const) const;
446 FormPreferences & parent_;
448 boost::scoped_ptr<FD_form_printer> dialog_;
451 friend class Printer;
457 ScreenFonts(FormPreferences & p);
459 FD_form_screen_fonts const * dialog();
465 string const feedback(FL_OBJECT const * const) const;
473 FormPreferences & parent_;
475 boost::scoped_ptr<FD_form_screen_fonts> dialog_;
478 friend class ScreenFonts;
484 SpellOptions(FormPreferences & p);
486 FD_form_spelloptions const * dialog();
488 void apply(); // not const because calls update()!
492 string const feedback(FL_OBJECT const * const) const;
494 bool input(FL_OBJECT const * const);
500 FormPreferences & parent_;
502 boost::scoped_ptr<FD_form_spelloptions> dialog_;
505 friend class SpellOptions;
513 Converters converters_;
515 InputsMisc inputs_misc_;
519 Interface interface_;
525 OutputsMisc outputs_misc_;
531 ScreenFonts screen_fonts_;
533 SpellOptions spelloptions_;
535 /** A couple of helper structs to enable colors to be sorted by name
538 struct SortColorsByName {
540 int operator()(NamedColor const & a, NamedColor const & b) const
541 { return (a.getname() < b.getname()); }
544 struct SortColorsByColor {
546 SortColorsByColor(RGBColor c) : col(c) {}
548 int operator()(RGBColor const &, RGBColor const &) const;
552 /// The ButtonController
553 ButtonController<PreferencesPolicy, xformsBC> bc_;
558 xformsBC & FormPreferences::bc()