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
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
36 struct FD_preferences;
37 struct FD_preferences_colors;
38 struct FD_preferences_converters;
39 struct FD_preferences_formats;
40 struct FD_preferences_inputs_misc;
41 struct FD_preferences_interface;
42 struct FD_preferences_language;
43 struct FD_preferences_lnf_misc;
44 struct FD_preferences_inner_tab;
45 struct FD_preferences_outputs_misc;
46 struct FD_preferences_paths;
47 struct FD_preferences_printer;
48 struct FD_preferences_screen_fonts;
49 struct FD_preferences_spelloptions;
52 /** This class provides an XForms implementation of the FormPreferences Dialog.
53 The preferences dialog allows users to set/save their preferences.
55 class FormPreferences : public FormCB<ControlPrefs, FormDB<FD_preferences> > {
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();
69 /// Filter the inputs -- return true if entries are valid
70 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
73 /// control which feedback message is output
74 string const getFeedback(FL_OBJECT *);
76 /// Converters tabfolder
77 boost::scoped_ptr<FD_preferences_inner_tab> converters_tab_;
78 /// reLyX and other import/input stuff
79 boost::scoped_ptr<FD_preferences_inner_tab> inputs_tab_;
81 boost::scoped_ptr<FD_preferences_inner_tab> look_n_feel_tab_;
83 boost::scoped_ptr<FD_preferences_inner_tab> outputs_tab_;
84 /// Spellchecker, language stuff, etc
85 boost::scoped_ptr<FD_preferences_inner_tab> lang_opts_tab_;
87 /** Each tab folder is encapsulated in its own class.
94 GUI_COLOR_CHOICE = FL_FREE_COL14,
95 GUI_COLOR_HUE_DIAL = FL_FREE_COL15,
96 GUI_COLOR_CURSOR = FL_FREE_COL16
99 Colors(FormPreferences & p);
101 FD_preferences_colors const * dialog();
103 void apply(); // not const as modifies modifiedXformsPrefs.
107 string const feedback(FL_OBJECT const * const) const;
109 void input(FL_OBJECT const * const);
111 void update() { LoadBrowserLyX(); }
113 /// Flag whether Xforms colors have changed since last file save
114 bool modifiedXformsPrefs;
118 void AdjustVal(int, int, double) const;
120 void InputBrowserLyX() const;
126 void LoadBrowserLyX();
130 void SwitchColorSpace() const;
132 string const X11hexname(RGBColor const &) const;
135 FormPreferences & parent_;
137 boost::scoped_ptr<FD_preferences_colors> dialog_;
139 /// A vector of LyX LColor GUI name and associated RGB color.
140 std::vector<NamedColor> lyxColorDB;
141 /// A vector of xforms color ID, RGB colors and associated name.
142 std::vector<XformsColor> xformsColorDB;
151 Converters(FormPreferences & p);
153 FD_preferences_converters const * dialog();
159 string const feedback(FL_OBJECT const * const) const;
161 bool input(FL_OBJECT const * const);
165 void UpdateBrowser();
167 void UpdateChoices() const;
179 string const GetFrom() const;
181 string const GetTo() const;
184 FormPreferences & parent_;
186 boost::scoped_ptr<FD_preferences_converters> dialog_;
189 friend class Converters;
195 Formats(FormPreferences & p);
197 FD_preferences_formats const * dialog();
203 string const feedback(FL_OBJECT const * const) const;
205 bool input(FL_OBJECT const * const);
215 void UpdateBrowser();
222 FormPreferences & parent_;
224 boost::scoped_ptr<FD_preferences_formats> dialog_;
227 friend class Formats;
233 InputsMisc(FormPreferences & p);
235 FD_preferences_inputs_misc const * dialog();
237 void apply(LyXRC & rc) const;
241 string const feedback(FL_OBJECT const * const) const;
243 void update(LyXRC const & rc);
247 FormPreferences & parent_;
249 boost::scoped_ptr<FD_preferences_inputs_misc> dialog_;
252 friend class InputsMisc;
258 Interface(FormPreferences & p);
260 FD_preferences_interface const * dialog();
262 void apply(LyXRC & rc) const;
266 string const feedback(FL_OBJECT const * const) const;
268 bool input(FL_OBJECT const * const);
270 void update(LyXRC const & rc);
274 FormPreferences & parent_;
276 boost::scoped_ptr<FD_preferences_interface> dialog_;
279 friend class Interface;
285 Language(FormPreferences & p);
287 FD_preferences_language const * dialog();
289 void apply(LyXRC & rc); // not const because calls update()
293 string const feedback(FL_OBJECT const * const) const;
295 bool input(FL_OBJECT const * const);
297 void update(LyXRC const & rc);
299 static void ComboCB(int, void *, Combox *);
303 FormPreferences & parent_;
305 boost::scoped_ptr<FD_preferences_language> dialog_;
307 boost::scoped_ptr<Combox> combo_default_lang;
309 std::vector<string> lang_;
312 friend class Language;
318 LnFmisc(FormPreferences & p);
320 FD_preferences_lnf_misc const * dialog();
322 void apply(LyXRC & rc) const;
326 string const feedback(FL_OBJECT const * const) const;
328 void update(LyXRC const & rc);
332 FormPreferences & parent_;
334 boost::scoped_ptr<FD_preferences_lnf_misc> dialog_;
337 friend class LnFmisc;
343 OutputsMisc(FormPreferences & p);
345 FD_preferences_outputs_misc const * dialog();
347 void apply(LyXRC & rc) const;
351 string const feedback(FL_OBJECT const * const) const;
353 void update(LyXRC const & rc);
357 FormPreferences & parent_;
359 boost::scoped_ptr<FD_preferences_outputs_misc> dialog_;
362 friend class OutputsMisc;
368 Paths(FormPreferences & p);
370 FD_preferences_paths const * dialog();
372 void apply(LyXRC & rc);
376 string const feedback(FL_OBJECT const * const) const;
378 bool input(FL_OBJECT const * const);
380 void update(LyXRC const & rc);
384 FormPreferences & parent_;
386 boost::scoped_ptr<FD_preferences_paths> dialog_;
395 Printer(FormPreferences & p);
397 FD_preferences_printer const * dialog();
399 void apply(LyXRC & rc) const;
403 string const feedback(FL_OBJECT const * const) const;
405 void update(LyXRC const & rc);
409 FormPreferences & parent_;
411 boost::scoped_ptr<FD_preferences_printer> dialog_;
414 friend class Printer;
420 ScreenFonts(FormPreferences & p);
422 FD_preferences_screen_fonts const * dialog();
424 void apply(LyXRC & rc) const;
428 string const feedback(FL_OBJECT const * const) const;
432 void update(LyXRC const & rc);
436 FormPreferences & parent_;
438 boost::scoped_ptr<FD_preferences_screen_fonts> dialog_;
441 friend class ScreenFonts;
447 SpellOptions(FormPreferences & p);
449 FD_preferences_spelloptions const * dialog();
451 void apply(LyXRC & rc); // not const because calls update()!
455 string const feedback(FL_OBJECT const * const) const;
457 bool input(FL_OBJECT const * const);
459 void update(LyXRC const & rc);
463 FormPreferences & parent_;
465 boost::scoped_ptr<FD_preferences_spelloptions> dialog_;
468 friend class SpellOptions;
476 Converters converters_;
478 InputsMisc inputs_misc_;
482 Interface interface_;
488 OutputsMisc outputs_misc_;
494 ScreenFonts screen_fonts_;
496 SpellOptions spelloptions_;
498 /** A couple of helper structs to enable colors to be sorted by name
501 struct SortColorsByName {
503 int operator()(NamedColor const & a, NamedColor const & b) const
504 { return (a.getname() < b.getname()); }
507 struct SortColorsByColor {
509 SortColorsByColor(RGBColor c) : col(c) {}
511 int operator()(RGBColor const &, RGBColor const &) const;
517 #endif // FORMPREFERENCES_H