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_identity;
45 struct FD_preferences_inner_tab;
46 struct FD_preferences_outputs_misc;
47 struct FD_preferences_paths;
48 struct FD_preferences_printer;
49 struct FD_preferences_screen_fonts;
50 struct FD_preferences_spelloptions;
53 /** This class provides an XForms implementation of the FormPreferences Dialog.
54 The preferences dialog allows users to set/save their preferences.
56 class FormPreferences : public FormCB<ControlPrefs, FormDB<FD_preferences> > {
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();
70 /// Filter the inputs -- return true if entries are valid
71 virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
74 /// control which feedback message is output
75 string const getFeedback(FL_OBJECT *);
77 /// Converters tabfolder
78 boost::scoped_ptr<FD_preferences_inner_tab> converters_tab_;
79 /// reLyX and other import/input stuff
80 boost::scoped_ptr<FD_preferences_inner_tab> inputs_tab_;
82 boost::scoped_ptr<FD_preferences_inner_tab> look_n_feel_tab_;
84 boost::scoped_ptr<FD_preferences_inner_tab> outputs_tab_;
85 /// Spellchecker, language stuff, etc
86 boost::scoped_ptr<FD_preferences_inner_tab> lang_opts_tab_;
88 /** Each tab folder is encapsulated in its own class.
95 GUI_COLOR_CHOICE = FL_FREE_COL14,
96 GUI_COLOR_HUE_DIAL = FL_FREE_COL15,
97 GUI_COLOR_CURSOR = FL_FREE_COL16
100 Colors(FormPreferences & p);
102 FD_preferences_colors const * dialog();
104 void apply(); // not const as modifies modifiedXformsPrefs.
108 string const feedback(FL_OBJECT const * const) const;
110 void input(FL_OBJECT const * const);
112 void update() { LoadBrowserLyX(); }
114 /// Flag whether Xforms colors have changed since last file save
115 bool modifiedXformsPrefs;
119 void AdjustVal(int, int, double) const;
121 void InputBrowserLyX() const;
127 void LoadBrowserLyX();
131 void SwitchColorSpace() const;
134 FormPreferences & parent_;
136 boost::scoped_ptr<FD_preferences_colors> dialog_;
138 /// A vector of LyX LColor GUI name and associated RGB color.
139 std::vector<NamedColor> lyxColorDB;
140 /// A vector of xforms color ID, RGB colors and associated name.
141 std::vector<XformsColor> xformsColorDB;
150 Converters(FormPreferences & p);
152 FD_preferences_converters const * dialog();
158 string const feedback(FL_OBJECT const * const) const;
160 bool input(FL_OBJECT const * const);
164 void UpdateBrowser();
166 void UpdateChoices() const;
178 string const GetFrom() const;
180 string const GetTo() const;
183 FormPreferences & parent_;
185 boost::scoped_ptr<FD_preferences_converters> dialog_;
188 friend class Converters;
194 Formats(FormPreferences & p);
196 FD_preferences_formats const * dialog();
202 string const feedback(FL_OBJECT const * const) const;
204 bool input(FL_OBJECT const * const);
214 void UpdateBrowser();
221 FormPreferences & parent_;
223 boost::scoped_ptr<FD_preferences_formats> dialog_;
226 friend class Formats;
232 InputsMisc(FormPreferences & p);
234 FD_preferences_inputs_misc const * dialog();
236 void apply(LyXRC & rc) const;
240 string const feedback(FL_OBJECT const * const) const;
242 void update(LyXRC const & rc);
246 FormPreferences & parent_;
248 boost::scoped_ptr<FD_preferences_inputs_misc> dialog_;
251 friend class InputsMisc;
257 Interface(FormPreferences & p);
259 FD_preferences_interface const * dialog();
261 void apply(LyXRC & rc) const;
265 string const feedback(FL_OBJECT const * const) const;
267 bool input(FL_OBJECT const * const);
269 void update(LyXRC const & rc);
273 FormPreferences & parent_;
275 boost::scoped_ptr<FD_preferences_interface> dialog_;
278 friend class Interface;
284 Language(FormPreferences & p);
286 FD_preferences_language const * dialog();
288 void apply(LyXRC & rc); // not const because calls update()
292 string const feedback(FL_OBJECT const * const) const;
294 bool input(FL_OBJECT const * const);
296 void update(LyXRC const & rc);
298 static void ComboCB(int, void *, Combox *);
302 FormPreferences & parent_;
304 boost::scoped_ptr<FD_preferences_language> dialog_;
306 boost::scoped_ptr<Combox> combo_default_lang;
308 std::vector<string> lang_;
311 friend class Language;
317 LnFmisc(FormPreferences & p);
319 FD_preferences_lnf_misc const * dialog();
321 void apply(LyXRC & rc) const;
325 string const feedback(FL_OBJECT const * const) const;
327 void update(LyXRC const & rc);
331 FormPreferences & parent_;
333 boost::scoped_ptr<FD_preferences_lnf_misc> dialog_;
336 friend class LnFmisc;
341 Identity(FormPreferences & p);
343 FD_preferences_identity const * dialog();
345 void apply(LyXRC & rc) const;
349 string const feedback(FL_OBJECT const * const) const;
351 void update(LyXRC const & rc);
355 FormPreferences & parent_;
357 boost::scoped_ptr<FD_preferences_identity> dialog_;
359 friend class Identity;
365 OutputsMisc(FormPreferences & p);
367 FD_preferences_outputs_misc const * dialog();
369 void apply(LyXRC & rc) const;
373 string const feedback(FL_OBJECT const * const) const;
375 void update(LyXRC const & rc);
379 FormPreferences & parent_;
381 boost::scoped_ptr<FD_preferences_outputs_misc> dialog_;
384 friend class OutputsMisc;
390 Paths(FormPreferences & p);
392 FD_preferences_paths const * dialog();
394 void apply(LyXRC & rc);
398 string const feedback(FL_OBJECT const * const) const;
400 bool input(FL_OBJECT const * const);
402 void update(LyXRC const & rc);
406 FormPreferences & parent_;
408 boost::scoped_ptr<FD_preferences_paths> dialog_;
417 Printer(FormPreferences & p);
419 FD_preferences_printer const * dialog();
421 void apply(LyXRC & rc) const;
425 string const feedback(FL_OBJECT const * const) const;
427 void update(LyXRC const & rc);
431 FormPreferences & parent_;
433 boost::scoped_ptr<FD_preferences_printer> dialog_;
436 friend class Printer;
442 ScreenFonts(FormPreferences & p);
444 FD_preferences_screen_fonts const * dialog();
446 void apply(LyXRC & rc) const;
450 string const feedback(FL_OBJECT const * const) const;
454 void update(LyXRC const & rc);
458 FormPreferences & parent_;
460 boost::scoped_ptr<FD_preferences_screen_fonts> dialog_;
463 friend class ScreenFonts;
469 SpellOptions(FormPreferences & p);
471 FD_preferences_spelloptions const * dialog();
473 void apply(LyXRC & rc); // not const because calls update()!
477 string const feedback(FL_OBJECT const * const) const;
479 bool input(FL_OBJECT const * const);
481 void update(LyXRC const & rc);
485 FormPreferences & parent_;
487 boost::scoped_ptr<FD_preferences_spelloptions> dialog_;
490 friend class SpellOptions;
498 Converters converters_;
500 InputsMisc inputs_misc_;
504 Interface interface_;
512 OutputsMisc outputs_misc_;
518 ScreenFonts screen_fonts_;
520 SpellOptions spelloptions_;
522 /** A couple of helper structs to enable colors to be sorted by name
525 struct SortColorsByName {
527 int operator()(NamedColor const & a, NamedColor const & b) const
528 { return (a.getname() < b.getname()); }
531 struct SortColorsByColor {
533 SortColorsByColor(RGBColor c) : col(c) {}
535 int operator()(RGBColor const &, RGBColor const &) const;
541 #endif // FORMPREFERENCES_H