3 * \file FormPreferences.h
4 * Copyright 1999-2001 Allan Rae
5 * This file is part of LyX, the document processor.
6 * Licence details can be found in the file COPYING.
9 * \author Angus Leeming
11 * Full author contact details are available in file CREDITS
14 #ifndef FORMPREFERENCES_H
15 #define FORMPREFERENCES_H
21 #include "FormBaseDeprecated.h"
22 #include "Color.h" // NamedColor
23 #include "xforms_helpers.h" // XformColor
25 #include <boost/scoped_ptr.hpp>
27 #include FORMS_H_LOCATION
28 #include <utility> // pair
34 struct FD_preferences;
35 struct FD_preferences_colors;
36 struct FD_preferences_converters;
37 struct FD_preferences_formats;
38 struct FD_preferences_inputs_misc;
39 struct FD_preferences_interface;
40 struct FD_preferences_language;
41 struct FD_preferences_lnf_misc;
42 struct FD_preferences_inner_tab;
43 struct FD_preferences_outputs_misc;
44 struct FD_preferences_paths;
45 struct FD_preferences_printer;
46 struct FD_preferences_screen_fonts;
47 struct FD_preferences_spelloptions;
50 /** This class provides an XForms implementation of the FormPreferences Dialog.
51 The preferences dialog allows users to set/save their preferences.
53 class FormPreferences : public FormBaseBI {
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();
68 /// OK (Save) from dialog
72 /// Filter the inputs -- return true if entries are valid
73 virtual bool input(FL_OBJECT *, long);
76 /// Pointer to the actual instantiation of the xforms form.
77 virtual FL_FORM * form() const;
78 /// control which feedback message is output
79 string const getFeedback(FL_OBJECT *);
81 void browse(FL_OBJECT * input,
82 string const & title, string const & pattern,
83 std::pair<string,string> const & dir1= std::make_pair(string(),string()),
84 std::pair<string,string> const & dir2 = std::make_pair(string(),string()));
86 /// Real GUI implementation.
87 boost::scoped_ptr<FD_preferences> dialog_;
88 /// Converters tabfolder
89 boost::scoped_ptr<FD_preferences_inner_tab> converters_tab_;
90 /// reLyX and other import/input stuff
91 boost::scoped_ptr<FD_preferences_inner_tab> inputs_tab_;
93 boost::scoped_ptr<FD_preferences_inner_tab> look_n_feel_tab_;
95 boost::scoped_ptr<FD_preferences_inner_tab> outputs_tab_;
96 /// Spellchecker, language stuff, etc
97 boost::scoped_ptr<FD_preferences_inner_tab> lang_opts_tab_;
99 /** Each tab folder is encapsulated in its own class.
106 GUI_COLOR_CHOICE = FL_FREE_COL14,
107 GUI_COLOR_HUE_DIAL = FL_FREE_COL15,
108 GUI_COLOR_CURSOR = FL_FREE_COL16
111 Colors(FormPreferences & p);
113 FD_preferences_colors const * dialog();
115 void apply(); // not const as modifies modifiedXformsPrefs.
119 string const feedback(FL_OBJECT const * const) const;
121 void input(FL_OBJECT const * const);
123 void update() { LoadBrowserLyX(); }
125 /// Flag whether Xforms colors have changed since last file save
126 bool modifiedXformsPrefs;
130 void AdjustVal(int, int, double) const;
132 void InputBrowserLyX() const;
138 void LoadBrowserLyX();
142 void SwitchColorSpace() const;
144 string const X11hexname(RGBColor const &) const;
147 FormPreferences & parent_;
149 boost::scoped_ptr<FD_preferences_colors> dialog_;
151 /// A vector of LyX LColor GUI name and associated RGB color.
152 std::vector<NamedColor> lyxColorDB;
153 /// A vector of xforms color ID, RGB colors and associated name.
154 std::vector<XformsColor> xformsColorDB;
163 Converters(FormPreferences & p);
165 FD_preferences_converters const * dialog();
171 string const feedback(FL_OBJECT const * const) const;
173 bool input(FL_OBJECT const * const);
177 void UpdateBrowser();
179 void UpdateChoices() const;
191 string const GetFrom() const;
193 string const GetTo() const;
196 FormPreferences & parent_;
198 boost::scoped_ptr<FD_preferences_converters> dialog_;
201 friend class Converters;
207 Formats(FormPreferences & p);
209 FD_preferences_formats const * dialog();
215 string const feedback(FL_OBJECT const * const) const;
217 bool input(FL_OBJECT const * const);
227 void UpdateBrowser();
234 FormPreferences & parent_;
236 boost::scoped_ptr<FD_preferences_formats> dialog_;
239 friend class Formats;
245 InputsMisc(FormPreferences & p);
247 FD_preferences_inputs_misc const * dialog();
253 string const feedback(FL_OBJECT const * const) const;
259 FormPreferences & parent_;
261 boost::scoped_ptr<FD_preferences_inputs_misc> dialog_;
264 friend class InputsMisc;
270 Interface(FormPreferences & p);
272 FD_preferences_interface const * dialog();
278 string const feedback(FL_OBJECT const * const) const;
280 bool input(FL_OBJECT const * const);
286 FormPreferences & parent_;
288 boost::scoped_ptr<FD_preferences_interface> dialog_;
291 friend class Interface;
297 Language(FormPreferences & p);
299 FD_preferences_language const * dialog();
301 void apply(); // not const because calls update()
305 string const feedback(FL_OBJECT const * const) const;
307 bool input(FL_OBJECT const * const);
311 static void ComboCB(int, void *, Combox *);
315 FormPreferences & parent_;
317 boost::scoped_ptr<FD_preferences_language> dialog_;
319 boost::scoped_ptr<Combox> combo_default_lang;
321 std::vector<string> lang_;
324 friend class Language;
330 LnFmisc(FormPreferences & p);
332 FD_preferences_lnf_misc const * dialog();
338 string const feedback(FL_OBJECT const * const) const;
344 FormPreferences & parent_;
346 boost::scoped_ptr<FD_preferences_lnf_misc> dialog_;
349 friend class LnFmisc;
355 OutputsMisc(FormPreferences & p);
357 FD_preferences_outputs_misc const * dialog();
363 string const feedback(FL_OBJECT const * const) const;
369 FormPreferences & parent_;
371 boost::scoped_ptr<FD_preferences_outputs_misc> dialog_;
374 friend class OutputsMisc;
380 Paths(FormPreferences & p);
382 FD_preferences_paths const * dialog();
388 string const feedback(FL_OBJECT const * const) const;
390 bool input(FL_OBJECT const * const);
396 FormPreferences & parent_;
398 boost::scoped_ptr<FD_preferences_paths> dialog_;
407 Printer(FormPreferences & p);
409 FD_preferences_printer const * dialog();
415 string const feedback(FL_OBJECT const * const) const;
421 FormPreferences & parent_;
423 boost::scoped_ptr<FD_preferences_printer> dialog_;
426 friend class Printer;
432 ScreenFonts(FormPreferences & p);
434 FD_preferences_screen_fonts const * dialog();
440 string const feedback(FL_OBJECT const * const) const;
448 FormPreferences & parent_;
450 boost::scoped_ptr<FD_preferences_screen_fonts> dialog_;
453 friend class ScreenFonts;
459 SpellOptions(FormPreferences & p);
461 FD_preferences_spelloptions const * dialog();
463 void apply(); // not const because calls update()!
467 string const feedback(FL_OBJECT const * const) const;
469 bool input(FL_OBJECT const * const);
475 FormPreferences & parent_;
477 boost::scoped_ptr<FD_preferences_spelloptions> dialog_;
480 friend class SpellOptions;
488 Converters converters_;
490 InputsMisc inputs_misc_;
494 Interface interface_;
500 OutputsMisc outputs_misc_;
506 ScreenFonts screen_fonts_;
508 SpellOptions spelloptions_;
510 /** A couple of helper structs to enable colors to be sorted by name
513 struct SortColorsByName {
515 int operator()(NamedColor const & a, NamedColor const & b) const
516 { return (a.getname() < b.getname()); }
519 struct SortColorsByColor {
521 SortColorsByColor(RGBColor c) : col(c) {}
523 int operator()(RGBColor const &, RGBColor const &) const;
527 /// The ButtonController
528 ButtonController<PreferencesPolicy, xformsBC> bc_;
533 xformsBC & FormPreferences::bc()