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 <leeming@lyx.org>
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 {
54 FormPreferences(LyXView &, Dialogs &);
57 /// Pointer to the actual instantiation of the ButtonController.
58 virtual xformsBC & bc();
59 /** Redraw the form (on receipt of a Signal indicating, for example,
60 that the xforms colours have been re-mapped). */
61 virtual void redraw();
62 /// Update the dialog.
63 virtual void update();
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 /// Real GUI implementation.
85 boost::scoped_ptr<FD_preferences> dialog_;
86 /// Converters tabfolder
87 boost::scoped_ptr<FD_preferences_inner_tab> converters_tab_;
88 /// reLyX and other import/input stuff
89 boost::scoped_ptr<FD_preferences_inner_tab> inputs_tab_;
91 boost::scoped_ptr<FD_preferences_inner_tab> look_n_feel_tab_;
93 boost::scoped_ptr<FD_preferences_inner_tab> outputs_tab_;
94 /// Spellchecker, language stuff, etc
95 boost::scoped_ptr<FD_preferences_inner_tab> lang_opts_tab_;
97 /** Each tab folder is encapsulated in its own class.
104 GUI_COLOR_CHOICE = FL_FREE_COL14,
105 GUI_COLOR_HUE_DIAL = FL_FREE_COL15,
106 GUI_COLOR_CURSOR = FL_FREE_COL16
109 Colors(FormPreferences & p);
111 FD_preferences_colors const * dialog();
113 void apply(); // not const as modifies modifiedXformsPrefs.
117 string const feedback(FL_OBJECT const * const) const;
119 void input(FL_OBJECT const * const);
121 void update() { LoadBrowserLyX(); }
123 /// Flag whether Xforms colors have changed since last file save
124 bool modifiedXformsPrefs;
128 void AdjustVal(int, int, double) const;
130 void InputBrowserLyX() const;
136 void LoadBrowserLyX();
140 void SwitchColorSpace() const;
142 string const X11hexname(RGBColor const &) const;
145 FormPreferences & parent_;
147 boost::scoped_ptr<FD_preferences_colors> dialog_;
149 /// A vector of LyX LColor GUI name and associated RGB color.
150 std::vector<NamedColor> lyxColorDB;
151 /// A vector of xforms color ID, RGB colors and associated name.
152 std::vector<XformsColor> xformsColorDB;
161 Converters(FormPreferences & p);
163 FD_preferences_converters const * dialog();
169 string const feedback(FL_OBJECT const * const) const;
171 bool input(FL_OBJECT const * const);
175 void UpdateBrowser();
177 void UpdateChoices() const;
189 string const GetFrom() const;
191 string const GetTo() const;
194 FormPreferences & parent_;
196 boost::scoped_ptr<FD_preferences_converters> dialog_;
199 friend class Converters;
205 Formats(FormPreferences & p);
207 FD_preferences_formats const * dialog();
213 string const feedback(FL_OBJECT const * const) const;
215 bool input(FL_OBJECT const * const);
225 void UpdateBrowser();
232 FormPreferences & parent_;
234 boost::scoped_ptr<FD_preferences_formats> dialog_;
237 friend class Formats;
243 InputsMisc(FormPreferences & p);
245 FD_preferences_inputs_misc const * dialog();
251 string const feedback(FL_OBJECT const * const) const;
257 FormPreferences & parent_;
259 boost::scoped_ptr<FD_preferences_inputs_misc> dialog_;
262 friend class InputsMisc;
268 Interface(FormPreferences & p);
270 FD_preferences_interface const * dialog();
276 string const feedback(FL_OBJECT const * const) const;
278 bool input(FL_OBJECT const * const);
284 FormPreferences & parent_;
286 boost::scoped_ptr<FD_preferences_interface> dialog_;
289 friend class Interface;
295 Language(FormPreferences & p);
297 FD_preferences_language const * dialog();
299 void apply(); // not const because calls update()
303 string const feedback(FL_OBJECT const * const) const;
305 bool input(FL_OBJECT const * const);
309 static void ComboCB(int, void *, Combox *);
313 FormPreferences & parent_;
315 boost::scoped_ptr<FD_preferences_language> dialog_;
317 boost::scoped_ptr<Combox> combo_default_lang;
319 std::vector<string> lang_;
322 friend class Language;
328 LnFmisc(FormPreferences & p);
330 FD_preferences_lnf_misc const * dialog();
336 string const feedback(FL_OBJECT const * const) const;
342 FormPreferences & parent_;
344 boost::scoped_ptr<FD_preferences_lnf_misc> dialog_;
347 friend class LnFmisc;
353 OutputsMisc(FormPreferences & p);
355 FD_preferences_outputs_misc const * dialog();
361 string const feedback(FL_OBJECT const * const) const;
367 FormPreferences & parent_;
369 boost::scoped_ptr<FD_preferences_outputs_misc> dialog_;
372 friend class OutputsMisc;
378 Paths(FormPreferences & p);
380 FD_preferences_paths const * dialog();
386 string const feedback(FL_OBJECT const * const) const;
388 bool input(FL_OBJECT const * const);
394 FormPreferences & parent_;
396 boost::scoped_ptr<FD_preferences_paths> dialog_;
405 Printer(FormPreferences & p);
407 FD_preferences_printer const * dialog();
413 string const feedback(FL_OBJECT const * const) const;
419 FormPreferences & parent_;
421 boost::scoped_ptr<FD_preferences_printer> dialog_;
424 friend class Printer;
430 ScreenFonts(FormPreferences & p);
432 FD_preferences_screen_fonts const * dialog();
438 string const feedback(FL_OBJECT const * const) const;
446 FormPreferences & parent_;
448 boost::scoped_ptr<FD_preferences_screen_fonts> dialog_;
451 friend class ScreenFonts;
457 SpellOptions(FormPreferences & p);
459 FD_preferences_spelloptions const * dialog();
461 void apply(); // not const because calls update()!
465 string const feedback(FL_OBJECT const * const) const;
467 bool input(FL_OBJECT const * const);
473 FormPreferences & parent_;
475 boost::scoped_ptr<FD_preferences_spelloptions> dialog_;
478 friend class SpellOptions;
486 Converters converters_;
488 InputsMisc inputs_misc_;
492 Interface interface_;
498 OutputsMisc outputs_misc_;
504 ScreenFonts screen_fonts_;
506 SpellOptions spelloptions_;
508 /** A couple of helper structs to enable colors to be sorted by name
511 struct SortColorsByName {
513 int operator()(NamedColor const & a, NamedColor const & b) const
514 { return (a.getname() < b.getname()); }
517 struct SortColorsByColor {
519 SortColorsByColor(RGBColor c) : col(c) {}
521 int operator()(RGBColor const &, RGBColor const &) const;
525 /// The ButtonController
526 ButtonController<PreferencesPolicy, xformsBC> bc_;
531 xformsBC & FormPreferences::bc()