2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 The LyX Team.
10 * This file copyright 1999-2000
12 *======================================================*/
14 * FormPreferences Interface Class
17 #ifndef FORMPREFERENCES_H
18 #define FORMPREFERENCES_H
20 #include <utility> // for pair
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_outer_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_spellchecker;
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 {
56 /// #FormPreferences x(LyXFunc ..., Dialogs ...);#
57 FormPreferences(LyXView *, Dialogs *);
61 static int FeedbackCB(FL_OBJECT *, int,
62 FL_Coord, FL_Coord, int, void *);
65 /** Redraw the form (on receipt of a Signal indicating, for example,
66 that the xform colours have been re-mapped). */
67 virtual void redraw();
68 /// Update the dialog.
69 virtual void update();
72 /// OK (Save) from dialog
76 /// Filter the inputs -- return true if entries are valid
77 virtual bool input(FL_OBJECT *, long);
80 /// Pointer to the actual instantiation of xform's form.
81 virtual FL_FORM * form() const;
82 /// control which feedback message is output
83 void feedback(FL_OBJECT *);
85 /// Set the preemptive handler for each FL_OBJECT.
86 static void setPreHandler(FL_OBJECT *);
87 /// The preemptive handler for feedback messages.
88 void Feedback(FL_OBJECT *, int);
89 /// Print a warning message and set warning flag.
90 void printWarning( string const & );
91 /** Launch a file dialog and modify input if it returns a new file.
92 For an explanation of the various parameters, see xform_helpers.h.
94 void browse( FL_OBJECT * input,
95 string const & title, string const & pattern,
96 std::pair<string,string> const & dir1,
97 std::pair<string,string> const & dir2 );
99 /// Type definitions from the fdesign produced header file.
100 FD_form_preferences * build_preferences();
102 FD_form_outer_tab * build_outer_tab();
104 FD_form_colors * build_colors();
106 FD_form_converters * build_converters();
108 FD_form_formats * build_formats();
110 FD_form_inputs_misc * build_inputs_misc();
112 FD_form_interface * build_interface();
114 FD_form_language * build_language();
116 FD_form_lnf_misc * build_lnf_misc();
118 FD_form_outputs_misc * build_outputs_misc();
120 FD_form_paths * build_paths();
122 FD_form_printer * build_printer();
124 FD_form_screen_fonts * build_screen_fonts();
126 FD_form_spellchecker * build_spellchecker();
128 /// Real GUI implementation.
129 FD_form_preferences * dialog_;
130 /// Converters tabfolder
131 FD_form_outer_tab * converters_tab_;
132 /// reLyX and other import/input stuff
133 FD_form_outer_tab * inputs_tab_;
134 /// HCI configuration
135 FD_form_outer_tab * look_n_feel_tab_;
136 /// Outputs tabfolder
137 FD_form_outer_tab * outputs_tab_;
138 /// Spellchecker, language stuff, etc
139 FD_form_outer_tab * usage_tab_;
141 /** Flag whether a warning has been posted to the text window.
142 If so, don't redraw the window when the mouse leaves an object. */
145 /** Each tab folder is encapsulated in its own class.
151 Colors( FormPreferences & p ) : parent_(p), dialog_(0) {}
155 FD_form_colors const * dialog() { return dialog_; }
157 void apply(); // not const as modifies modifiedXformPrefs.
161 string const feedback(FL_OBJECT const * const) const;
163 bool input(FL_OBJECT const * const);
166 /// Flag whether Xforms colors have changed since last file save
167 bool modifiedXformPrefs;
171 void AdjustVal( int, int, double ) const;
173 bool BrowserLyX() const;
175 bool BrowserX11() const;
179 void LoadBrowserLyX();
181 bool LoadBrowserX11(string const &) const;
187 int SearchEntry(RGBColor const &) const;
190 FormPreferences & parent_;
192 FD_form_colors * dialog_;
193 /// A vector of RGB colors and associated name.
194 static std::vector<NamedColor> colorDB;
195 /// A vector of xform RGB colors and associated name.
196 static std::vector<XformColor> xformColorDB;
205 Converters( FormPreferences & p ) : parent_(p), dialog_(0) {}
209 FD_form_converters const * dialog() { return dialog_; }
215 string const feedback(FL_OBJECT const * const) const;
217 bool input( FL_OBJECT const * const );
221 void UpdateBrowser();
223 void UpdateChoices() const;
235 string const GetFrom() const;
237 string const GetTo() const;
240 FormPreferences & parent_;
242 FD_form_converters * dialog_;
245 friend class Converters;
251 Formats( FormPreferences & p ) : parent_(p), dialog_(0) {}
255 FD_form_formats const * dialog() { return dialog_; }
261 string const feedback(FL_OBJECT const * const) const;
263 bool input( FL_OBJECT const * const );
273 void UpdateBrowser();
280 FormPreferences & parent_;
282 FD_form_formats * dialog_;
285 friend class Formats;
291 InputsMisc( FormPreferences & p ) : parent_(p), dialog_(0) {}
295 FD_form_inputs_misc const * dialog() { return dialog_; }
301 string const feedback(FL_OBJECT const * const) const;
307 FormPreferences & parent_;
309 FD_form_inputs_misc * dialog_;
312 friend class InputsMisc;
318 Interface( FormPreferences & p ) : parent_(p), dialog_(0) {}
322 FD_form_interface const * dialog() { return dialog_; }
328 string const feedback(FL_OBJECT const * const) const;
330 bool input( FL_OBJECT const * const );
336 FormPreferences & parent_;
338 FD_form_interface * dialog_;
341 friend class Interface;
347 Language( FormPreferences & p )
348 : parent_(p), dialog_(0), combo_default_lang(0) {}
352 FD_form_language const * dialog() { return dialog_; }
354 void apply(); // not const because calls update()
358 string const feedback(FL_OBJECT const * const) const;
360 bool input( FL_OBJECT const * const );
364 static void ComboCB(int, void *, Combox *);
368 FormPreferences & parent_;
370 FD_form_language * dialog_;
372 Combox * combo_default_lang;
375 friend class Language;
381 LnFmisc( FormPreferences & p ) : parent_(p), dialog_(0) {}
385 FD_form_lnf_misc const * dialog() { return dialog_; }
391 string const feedback(FL_OBJECT const * const) const;
397 FormPreferences & parent_;
399 FD_form_lnf_misc * dialog_;
402 friend class LnFmisc;
408 OutputsMisc( FormPreferences & p ) : parent_(p), dialog_(0) {}
412 FD_form_outputs_misc const * dialog() { return dialog_; }
418 string const feedback(FL_OBJECT const * const) const;
424 FormPreferences & parent_;
426 FD_form_outputs_misc * dialog_;
429 friend class OutputsMisc;
435 Paths( FormPreferences & p ) : parent_(p), dialog_(0) {}
439 FD_form_paths const * dialog() { return dialog_; }
445 string const feedback(FL_OBJECT const * const) const;
447 bool input(FL_OBJECT const * const);
453 FormPreferences & parent_;
455 FD_form_paths * dialog_;
464 Printer( FormPreferences & p ) : parent_(p), dialog_(0) {}
468 FD_form_printer const * dialog() { return dialog_; }
474 string const feedback(FL_OBJECT const * const) const;
480 FormPreferences & parent_;
482 FD_form_printer * dialog_;
485 friend class Printer;
491 ScreenFonts( FormPreferences & p ) : parent_(p), dialog_(0) {}
495 FD_form_screen_fonts const * dialog() { return dialog_; }
501 string const feedback(FL_OBJECT const * const) const;
509 FormPreferences & parent_;
511 FD_form_screen_fonts * dialog_;
514 friend class ScreenFonts;
520 SpellChecker( FormPreferences & p ) : parent_(p), dialog_(0) {}
524 FD_form_spellchecker const * dialog() { return dialog_; }
526 void apply(); // not const because calls update()!
530 string const feedback(FL_OBJECT const * const) const;
532 bool input(FL_OBJECT const * const);
538 FormPreferences & parent_;
540 FD_form_spellchecker * dialog_;
543 friend class SpellChecker;
551 Converters converters_;
553 InputsMisc inputs_misc_;
557 Interface interface_;
563 OutputsMisc outputs_misc_;
569 ScreenFonts screen_fonts_;
571 SpellChecker spellchecker_;