2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2001 The LyX Team.
10 * This file copyright 1999-2001
12 *======================================================*/
14 * FormPreferences Interface Class
17 #ifndef FORMPREFERENCES_H
18 #define FORMPREFERENCES_H
20 #include <utility> // pair
21 #include <boost/smart_ptr.hpp>
27 #include "FormBaseDeprecated.h"
28 #include "Color.h" // NamedColor
29 #include "xforms_helpers.h" // XformColor
35 struct FD_form_colors;
36 struct FD_form_converters;
37 struct FD_form_formats;
38 struct FD_form_inputs_misc;
39 struct FD_form_interface;
40 struct FD_form_language;
41 struct FD_form_lnf_misc;
42 struct FD_form_inner_tab;
43 struct FD_form_outputs_misc;
45 struct FD_form_preferences;
46 struct FD_form_printer;
47 struct FD_form_screen_fonts;
48 struct FD_form_spelloptions;
51 /** This class provides an XForms implementation of the FormPreferences Dialog.
52 The preferences dialog allows users to set/save their preferences.
54 class FormPreferences : public FormBaseBI {
57 FormPreferences(LyXView *, Dialogs *);
60 /// Pointer to the actual instantiation of the ButtonController.
61 virtual xformsBC & bc();
62 /** Redraw the form (on receipt of a Signal indicating, for example,
63 that the xforms colours have been re-mapped). */
64 virtual void redraw();
65 /// Update the dialog.
66 virtual void update();
67 /// show the spellchecker tab
71 /// OK (Save) from dialog
75 /// Filter the inputs -- return true if entries are valid
76 virtual bool input(FL_OBJECT *, long);
79 /// Pointer to the actual instantiation of the xforms form.
80 virtual FL_FORM * form() const;
81 /// control which feedback message is output
82 string const getFeedback(FL_OBJECT *);
84 void browse(FL_OBJECT * input,
85 string const & title, string const & pattern,
86 std::pair<string,string> const & dir1= std::make_pair(string(),string()),
87 std::pair<string,string> const & dir2 = std::make_pair(string(),string()));
89 /// Fdesign generated methods
90 FD_form_preferences * build_preferences();
92 FD_form_inner_tab * build_inner_tab();
94 FD_form_colors * build_colors();
96 FD_form_converters * build_converters();
98 FD_form_formats * build_formats();
100 FD_form_inputs_misc * build_inputs_misc();
102 FD_form_interface * build_interface();
104 FD_form_language * build_language();
106 FD_form_lnf_misc * build_lnf_misc();
108 FD_form_outputs_misc * build_outputs_misc();
110 FD_form_paths * build_paths();
112 FD_form_printer * build_printer();
114 FD_form_screen_fonts * build_screen_fonts();
116 FD_form_spelloptions * build_spelloptions();
118 /// Real GUI implementation.
119 boost::scoped_ptr<FD_form_preferences> dialog_;
120 /// Converters tabfolder
121 boost::scoped_ptr<FD_form_inner_tab> converters_tab_;
122 /// reLyX and other import/input stuff
123 boost::scoped_ptr<FD_form_inner_tab> inputs_tab_;
124 /// HCI configuration
125 boost::scoped_ptr<FD_form_inner_tab> look_n_feel_tab_;
126 /// Outputs tabfolder
127 boost::scoped_ptr<FD_form_inner_tab> outputs_tab_;
128 /// Spellchecker, language stuff, etc
129 boost::scoped_ptr<FD_form_inner_tab> lang_opts_tab_;
131 /** Each tab folder is encapsulated in its own class.
138 GUI_COLOR_CHOICE = FL_FREE_COL14,
139 GUI_COLOR_HUE_DIAL = FL_FREE_COL15,
140 GUI_COLOR_CURSOR = FL_FREE_COL16
143 Colors(FormPreferences & p);
145 FD_form_colors const * dialog();
147 void apply(); // not const as modifies modifiedXformsPrefs.
151 string const feedback(FL_OBJECT const * const) const;
153 void input(FL_OBJECT const * const);
155 void update() { LoadBrowserLyX(); }
157 /// Flag whether Xforms colors have changed since last file save
158 bool modifiedXformsPrefs;
162 void AdjustVal(int, int, double) const;
164 void InputBrowserLyX() const;
170 void LoadBrowserLyX();
174 void SwitchColorSpace() const;
176 string const X11hexname(RGBColor const &) const;
179 FormPreferences & parent_;
181 boost::scoped_ptr<FD_form_colors> dialog_;
183 /// A vector of LyX LColor GUI name and associated RGB color.
184 std::vector<NamedColor> lyxColorDB;
185 /// A vector of xforms color ID, RGB colors and associated name.
186 std::vector<XformsColor> xformsColorDB;
195 Converters(FormPreferences & p);
197 FD_form_converters const * dialog();
203 string const feedback(FL_OBJECT const * const) const;
205 bool input(FL_OBJECT const * const);
209 void UpdateBrowser();
211 void UpdateChoices() const;
223 string const GetFrom() const;
225 string const GetTo() const;
228 FormPreferences & parent_;
230 boost::scoped_ptr<FD_form_converters> dialog_;
233 friend class Converters;
239 Formats(FormPreferences & p);
241 FD_form_formats const * dialog();
247 string const feedback(FL_OBJECT const * const) const;
249 bool input(FL_OBJECT const * const);
259 void UpdateBrowser();
266 FormPreferences & parent_;
268 boost::scoped_ptr<FD_form_formats> dialog_;
271 friend class Formats;
277 InputsMisc(FormPreferences & p);
279 FD_form_inputs_misc const * dialog();
285 string const feedback(FL_OBJECT const * const) const;
291 FormPreferences & parent_;
293 boost::scoped_ptr<FD_form_inputs_misc> dialog_;
296 friend class InputsMisc;
302 Interface(FormPreferences & p);
304 FD_form_interface const * dialog();
310 string const feedback(FL_OBJECT const * const) const;
312 bool input(FL_OBJECT const * const);
318 FormPreferences & parent_;
320 boost::scoped_ptr<FD_form_interface> dialog_;
323 friend class Interface;
329 Language(FormPreferences & p);
331 FD_form_language const * dialog();
333 void apply(); // not const because calls update()
337 string const feedback(FL_OBJECT const * const) const;
339 bool input(FL_OBJECT const * const);
343 static void ComboCB(int, void *, Combox *);
347 FormPreferences & parent_;
349 boost::scoped_ptr<FD_form_language> dialog_;
351 boost::scoped_ptr<Combox> combo_default_lang;
354 friend class Language;
360 LnFmisc(FormPreferences & p);
362 FD_form_lnf_misc const * dialog();
368 string const feedback(FL_OBJECT const * const) const;
374 FormPreferences & parent_;
376 boost::scoped_ptr<FD_form_lnf_misc> dialog_;
379 friend class LnFmisc;
385 OutputsMisc(FormPreferences & p);
387 FD_form_outputs_misc const * dialog();
393 string const feedback(FL_OBJECT const * const) const;
399 FormPreferences & parent_;
401 boost::scoped_ptr<FD_form_outputs_misc> dialog_;
404 friend class OutputsMisc;
410 Paths(FormPreferences & p);
412 FD_form_paths const * dialog();
418 string const feedback(FL_OBJECT const * const) const;
420 bool input(FL_OBJECT const * const);
426 FormPreferences & parent_;
428 boost::scoped_ptr<FD_form_paths> dialog_;
437 Printer(FormPreferences & p);
439 FD_form_printer const * dialog();
445 string const feedback(FL_OBJECT const * const) const;
451 FormPreferences & parent_;
453 boost::scoped_ptr<FD_form_printer> dialog_;
456 friend class Printer;
462 ScreenFonts(FormPreferences & p);
464 FD_form_screen_fonts const * dialog();
470 string const feedback(FL_OBJECT const * const) const;
478 FormPreferences & parent_;
480 boost::scoped_ptr<FD_form_screen_fonts> dialog_;
483 friend class ScreenFonts;
489 SpellOptions(FormPreferences & p);
491 FD_form_spelloptions const * dialog();
493 void apply(); // not const because calls update()!
497 string const feedback(FL_OBJECT const * const) const;
499 bool input(FL_OBJECT const * const);
505 FormPreferences & parent_;
507 boost::scoped_ptr<FD_form_spelloptions> dialog_;
510 friend class SpellOptions;
518 Converters converters_;
520 InputsMisc inputs_misc_;
524 Interface interface_;
530 OutputsMisc outputs_misc_;
536 ScreenFonts screen_fonts_;
538 SpellOptions spelloptions_;
540 /** A couple of helper structs to enable colors to be sorted by name
543 struct SortColorsByName {
545 int operator()(NamedColor const & a, NamedColor const & b) const
546 { return (a.getname() < b.getname()); }
549 struct SortColorsByColor {
551 SortColorsByColor(RGBColor c) : col(c) {}
553 int operator()(RGBColor const &, RGBColor const &) const;
557 /// The ButtonController
558 ButtonController<PreferencesPolicy, xformsBC> bc_;
563 xformsBC & FormPreferences::bc()