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 <utility> // pair
31 struct FD_form_colors;
32 struct FD_form_converters;
33 struct FD_form_formats;
34 struct FD_form_inputs_misc;
35 struct FD_form_interface;
36 struct FD_form_language;
37 struct FD_form_lnf_misc;
38 struct FD_form_inner_tab;
39 struct FD_form_outputs_misc;
41 struct FD_form_preferences;
42 struct FD_form_printer;
43 struct FD_form_screen_fonts;
44 struct FD_form_spelloptions;
47 /** This class provides an XForms implementation of the FormPreferences Dialog.
48 The preferences dialog allows users to set/save their preferences.
50 class FormPreferences : public FormBaseBI {
53 FormPreferences(LyXView *, Dialogs *);
56 /// Pointer to the actual instantiation of the ButtonController.
57 virtual xformsBC & bc();
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();
63 /// show the spellchecker tab
67 /// OK (Save) from dialog
71 /// Filter the inputs -- return true if entries are valid
72 virtual bool input(FL_OBJECT *, long);
75 /// Pointer to the actual instantiation of the xforms form.
76 virtual FL_FORM * form() const;
77 /// control which feedback message is output
78 string const getFeedback(FL_OBJECT *);
80 void browse(FL_OBJECT * input,
81 string const & title, string const & pattern,
82 std::pair<string,string> const & dir1= std::make_pair(string(),string()),
83 std::pair<string,string> const & dir2 = std::make_pair(string(),string()));
85 /// Fdesign generated methods
86 FD_form_preferences * build_preferences();
88 FD_form_inner_tab * build_inner_tab();
90 FD_form_colors * build_colors();
92 FD_form_converters * build_converters();
94 FD_form_formats * build_formats();
96 FD_form_inputs_misc * build_inputs_misc();
98 FD_form_interface * build_interface();
100 FD_form_language * build_language();
102 FD_form_lnf_misc * build_lnf_misc();
104 FD_form_outputs_misc * build_outputs_misc();
106 FD_form_paths * build_paths();
108 FD_form_printer * build_printer();
110 FD_form_screen_fonts * build_screen_fonts();
112 FD_form_spelloptions * build_spelloptions();
114 /// Real GUI implementation.
115 boost::scoped_ptr<FD_form_preferences> dialog_;
116 /// Converters tabfolder
117 boost::scoped_ptr<FD_form_inner_tab> converters_tab_;
118 /// reLyX and other import/input stuff
119 boost::scoped_ptr<FD_form_inner_tab> inputs_tab_;
120 /// HCI configuration
121 boost::scoped_ptr<FD_form_inner_tab> look_n_feel_tab_;
122 /// Outputs tabfolder
123 boost::scoped_ptr<FD_form_inner_tab> outputs_tab_;
124 /// Spellchecker, language stuff, etc
125 boost::scoped_ptr<FD_form_inner_tab> lang_opts_tab_;
127 /** Each tab folder is encapsulated in its own class.
134 GUI_COLOR_CHOICE = FL_FREE_COL14,
135 GUI_COLOR_HUE_DIAL = FL_FREE_COL15,
136 GUI_COLOR_CURSOR = FL_FREE_COL16
139 Colors(FormPreferences & p);
141 FD_form_colors const * dialog();
143 void apply(); // not const as modifies modifiedXformsPrefs.
147 string const feedback(FL_OBJECT const * const) const;
149 void input(FL_OBJECT const * const);
151 void update() { LoadBrowserLyX(); }
153 /// Flag whether Xforms colors have changed since last file save
154 bool modifiedXformsPrefs;
158 void AdjustVal(int, int, double) const;
160 void InputBrowserLyX() const;
166 void LoadBrowserLyX();
170 void SwitchColorSpace() const;
172 string const X11hexname(RGBColor const &) const;
175 FormPreferences & parent_;
177 boost::scoped_ptr<FD_form_colors> dialog_;
179 /// A vector of LyX LColor GUI name and associated RGB color.
180 std::vector<NamedColor> lyxColorDB;
181 /// A vector of xforms color ID, RGB colors and associated name.
182 std::vector<XformsColor> xformsColorDB;
191 Converters(FormPreferences & p);
193 FD_form_converters const * dialog();
199 string const feedback(FL_OBJECT const * const) const;
201 bool input(FL_OBJECT const * const);
205 void UpdateBrowser();
207 void UpdateChoices() const;
219 string const GetFrom() const;
221 string const GetTo() const;
224 FormPreferences & parent_;
226 boost::scoped_ptr<FD_form_converters> dialog_;
229 friend class Converters;
235 Formats(FormPreferences & p);
237 FD_form_formats const * dialog();
243 string const feedback(FL_OBJECT const * const) const;
245 bool input(FL_OBJECT const * const);
255 void UpdateBrowser();
262 FormPreferences & parent_;
264 boost::scoped_ptr<FD_form_formats> dialog_;
267 friend class Formats;
273 InputsMisc(FormPreferences & p);
275 FD_form_inputs_misc const * dialog();
281 string const feedback(FL_OBJECT const * const) const;
287 FormPreferences & parent_;
289 boost::scoped_ptr<FD_form_inputs_misc> dialog_;
292 friend class InputsMisc;
298 Interface(FormPreferences & p);
300 FD_form_interface const * dialog();
306 string const feedback(FL_OBJECT const * const) const;
308 bool input(FL_OBJECT const * const);
314 FormPreferences & parent_;
316 boost::scoped_ptr<FD_form_interface> dialog_;
319 friend class Interface;
325 Language(FormPreferences & p);
327 FD_form_language const * dialog();
329 void apply(); // not const because calls update()
333 string const feedback(FL_OBJECT const * const) const;
335 bool input(FL_OBJECT const * const);
339 static void ComboCB(int, void *, Combox *);
343 FormPreferences & parent_;
345 boost::scoped_ptr<FD_form_language> dialog_;
347 boost::scoped_ptr<Combox> combo_default_lang;
349 std::vector<string> lang_;
352 friend class Language;
358 LnFmisc(FormPreferences & p);
360 FD_form_lnf_misc const * dialog();
366 string const feedback(FL_OBJECT const * const) const;
372 FormPreferences & parent_;
374 boost::scoped_ptr<FD_form_lnf_misc> dialog_;
377 friend class LnFmisc;
383 OutputsMisc(FormPreferences & p);
385 FD_form_outputs_misc const * dialog();
391 string const feedback(FL_OBJECT const * const) const;
397 FormPreferences & parent_;
399 boost::scoped_ptr<FD_form_outputs_misc> dialog_;
402 friend class OutputsMisc;
408 Paths(FormPreferences & p);
410 FD_form_paths const * dialog();
416 string const feedback(FL_OBJECT const * const) const;
418 bool input(FL_OBJECT const * const);
424 FormPreferences & parent_;
426 boost::scoped_ptr<FD_form_paths> dialog_;
435 Printer(FormPreferences & p);
437 FD_form_printer const * dialog();
443 string const feedback(FL_OBJECT const * const) const;
449 FormPreferences & parent_;
451 boost::scoped_ptr<FD_form_printer> dialog_;
454 friend class Printer;
460 ScreenFonts(FormPreferences & p);
462 FD_form_screen_fonts const * dialog();
468 string const feedback(FL_OBJECT const * const) const;
476 FormPreferences & parent_;
478 boost::scoped_ptr<FD_form_screen_fonts> dialog_;
481 friend class ScreenFonts;
487 SpellOptions(FormPreferences & p);
489 FD_form_spelloptions const * dialog();
491 void apply(); // not const because calls update()!
495 string const feedback(FL_OBJECT const * const) const;
497 bool input(FL_OBJECT const * const);
503 FormPreferences & parent_;
505 boost::scoped_ptr<FD_form_spelloptions> dialog_;
508 friend class SpellOptions;
516 Converters converters_;
518 InputsMisc inputs_misc_;
522 Interface interface_;
528 OutputsMisc outputs_misc_;
534 ScreenFonts screen_fonts_;
536 SpellOptions spelloptions_;
538 /** A couple of helper structs to enable colors to be sorted by name
541 struct SortColorsByName {
543 int operator()(NamedColor const & a, NamedColor const & b) const
544 { return (a.getname() < b.getname()); }
547 struct SortColorsByColor {
549 SortColorsByColor(RGBColor c) : col(c) {}
551 int operator()(RGBColor const &, RGBColor const &) const;
555 /// The ButtonController
556 ButtonController<PreferencesPolicy, xformsBC> bc_;
561 xformsBC & FormPreferences::bc()