3 * \file FormPreferences.h
4 * Copyright 1999-2001 Allan Rae
5 * Read 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
20 #include "FormBaseDeprecated.h"
21 #include "Color.h" // NamedColor
22 #include "xforms_helpers.h" // XformColor
24 #include <boost/scoped_ptr.hpp>
26 #include FORMS_H_LOCATION
27 #include <utility> // pair
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_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 FormBaseBI {
55 FormPreferences(LyXView &, Dialogs &);
58 /// Pointer to the actual instantiation of the ButtonController.
59 virtual xformsBC & bc();
60 /** Redraw the form (on receipt of a Signal indicating, for example,
61 that the xforms colours have been re-mapped). */
62 virtual void redraw();
63 /// Update the dialog.
64 virtual void update();
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 /// Real GUI implementation.
86 boost::scoped_ptr<FD_preferences> dialog_;
87 /// Converters tabfolder
88 boost::scoped_ptr<FD_preferences_inner_tab> converters_tab_;
89 /// reLyX and other import/input stuff
90 boost::scoped_ptr<FD_preferences_inner_tab> inputs_tab_;
92 boost::scoped_ptr<FD_preferences_inner_tab> look_n_feel_tab_;
94 boost::scoped_ptr<FD_preferences_inner_tab> outputs_tab_;
95 /// Spellchecker, language stuff, etc
96 boost::scoped_ptr<FD_preferences_inner_tab> lang_opts_tab_;
98 /** Each tab folder is encapsulated in its own class.
105 GUI_COLOR_CHOICE = FL_FREE_COL14,
106 GUI_COLOR_HUE_DIAL = FL_FREE_COL15,
107 GUI_COLOR_CURSOR = FL_FREE_COL16
110 Colors(FormPreferences & p);
112 FD_preferences_colors const * dialog();
114 void apply(); // not const as modifies modifiedXformsPrefs.
118 string const feedback(FL_OBJECT const * const) const;
120 void input(FL_OBJECT const * const);
122 void update() { LoadBrowserLyX(); }
124 /// Flag whether Xforms colors have changed since last file save
125 bool modifiedXformsPrefs;
129 void AdjustVal(int, int, double) const;
131 void InputBrowserLyX() const;
137 void LoadBrowserLyX();
141 void SwitchColorSpace() const;
143 string const X11hexname(RGBColor const &) const;
146 FormPreferences & parent_;
148 boost::scoped_ptr<FD_preferences_colors> dialog_;
150 /// A vector of LyX LColor GUI name and associated RGB color.
151 std::vector<NamedColor> lyxColorDB;
152 /// A vector of xforms color ID, RGB colors and associated name.
153 std::vector<XformsColor> xformsColorDB;
162 Converters(FormPreferences & p);
164 FD_preferences_converters const * dialog();
170 string const feedback(FL_OBJECT const * const) const;
172 bool input(FL_OBJECT const * const);
176 void UpdateBrowser();
178 void UpdateChoices() const;
190 string const GetFrom() const;
192 string const GetTo() const;
195 FormPreferences & parent_;
197 boost::scoped_ptr<FD_preferences_converters> dialog_;
200 friend class Converters;
206 Formats(FormPreferences & p);
208 FD_preferences_formats const * dialog();
214 string const feedback(FL_OBJECT const * const) const;
216 bool input(FL_OBJECT const * const);
226 void UpdateBrowser();
233 FormPreferences & parent_;
235 boost::scoped_ptr<FD_preferences_formats> dialog_;
238 friend class Formats;
244 InputsMisc(FormPreferences & p);
246 FD_preferences_inputs_misc const * dialog();
252 string const feedback(FL_OBJECT const * const) const;
258 FormPreferences & parent_;
260 boost::scoped_ptr<FD_preferences_inputs_misc> dialog_;
263 friend class InputsMisc;
269 Interface(FormPreferences & p);
271 FD_preferences_interface const * dialog();
277 string const feedback(FL_OBJECT const * const) const;
279 bool input(FL_OBJECT const * const);
285 FormPreferences & parent_;
287 boost::scoped_ptr<FD_preferences_interface> dialog_;
290 friend class Interface;
296 Language(FormPreferences & p);
298 FD_preferences_language const * dialog();
300 void apply(); // not const because calls update()
304 string const feedback(FL_OBJECT const * const) const;
306 bool input(FL_OBJECT const * const);
310 static void ComboCB(int, void *, Combox *);
314 FormPreferences & parent_;
316 boost::scoped_ptr<FD_preferences_language> dialog_;
318 boost::scoped_ptr<Combox> combo_default_lang;
320 std::vector<string> lang_;
323 friend class Language;
329 LnFmisc(FormPreferences & p);
331 FD_preferences_lnf_misc const * dialog();
337 string const feedback(FL_OBJECT const * const) const;
343 FormPreferences & parent_;
345 boost::scoped_ptr<FD_preferences_lnf_misc> dialog_;
348 friend class LnFmisc;
354 OutputsMisc(FormPreferences & p);
356 FD_preferences_outputs_misc const * dialog();
362 string const feedback(FL_OBJECT const * const) const;
368 FormPreferences & parent_;
370 boost::scoped_ptr<FD_preferences_outputs_misc> dialog_;
373 friend class OutputsMisc;
379 Paths(FormPreferences & p);
381 FD_preferences_paths const * dialog();
387 string const feedback(FL_OBJECT const * const) const;
389 bool input(FL_OBJECT const * const);
395 FormPreferences & parent_;
397 boost::scoped_ptr<FD_preferences_paths> dialog_;
406 Printer(FormPreferences & p);
408 FD_preferences_printer const * dialog();
414 string const feedback(FL_OBJECT const * const) const;
420 FormPreferences & parent_;
422 boost::scoped_ptr<FD_preferences_printer> dialog_;
425 friend class Printer;
431 ScreenFonts(FormPreferences & p);
433 FD_preferences_screen_fonts const * dialog();
439 string const feedback(FL_OBJECT const * const) const;
447 FormPreferences & parent_;
449 boost::scoped_ptr<FD_preferences_screen_fonts> dialog_;
452 friend class ScreenFonts;
458 SpellOptions(FormPreferences & p);
460 FD_preferences_spelloptions const * dialog();
462 void apply(); // not const because calls update()!
466 string const feedback(FL_OBJECT const * const) const;
468 bool input(FL_OBJECT const * const);
474 FormPreferences & parent_;
476 boost::scoped_ptr<FD_preferences_spelloptions> dialog_;
479 friend class SpellOptions;
487 Converters converters_;
489 InputsMisc inputs_misc_;
493 Interface interface_;
499 OutputsMisc outputs_misc_;
505 ScreenFonts screen_fonts_;
507 SpellOptions spelloptions_;
509 /** A couple of helper structs to enable colors to be sorted by name
512 struct SortColorsByName {
514 int operator()(NamedColor const & a, NamedColor const & b) const
515 { return (a.getname() < b.getname()); }
518 struct SortColorsByColor {
520 SortColorsByColor(RGBColor c) : col(c) {}
522 int operator()(RGBColor const &, RGBColor const &) const;
526 /// The ButtonController
527 ButtonController<PreferencesPolicy, xformsBC> bc_;
532 xformsBC & FormPreferences::bc()