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
34 struct FD_form_colors;
35 struct FD_form_converters;
36 struct FD_form_formats;
37 struct FD_form_inputs_misc;
38 struct FD_form_interface;
39 struct FD_form_language;
40 struct FD_form_lnf_misc;
41 struct FD_form_outer_tab;
42 struct FD_form_outputs_misc;
44 struct FD_form_preferences;
45 struct FD_form_printer;
46 struct FD_form_screen_fonts;
47 struct FD_form_spellchecker;
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 {
55 /// #FormPreferences x(LyXFunc ..., Dialogs ...);#
56 FormPreferences(LyXView *, Dialogs *);
60 static int FeedbackCB(FL_OBJECT *, int,
61 FL_Coord, FL_Coord, int, void *);
64 /** Redraw the form (on receipt of a Signal indicating, for example,
65 that the xform colours have been re-mapped). */
66 virtual void redraw();
67 /// Update the dialog.
68 virtual void update();
75 /// Filter the inputs -- return true if entries are valid
76 virtual bool input(FL_OBJECT *, long);
79 /// control which feedback message is output
80 void feedback( FL_OBJECT * );
81 /// The handler for the preemptive feedback
82 void Feedback(FL_OBJECT *, int);
84 virtual FL_FORM * form() const;
86 /** Helper functions available to the various tab folders.
90 bool WriteableDir( string const & );
92 bool ReadableDir( string const & );
94 bool WriteableFile( string const &, string const & = string() );
96 bool ReadableFile( string const &, string const & = string() );
98 void setPreHandler( FL_OBJECT * ) const;
100 void printWarning( string const & );
102 /** title: filedlg title, pattern: *.ps etc
103 extra buttons on filedlg: dir1 = (name, dir), dir2 = (name, dir)
107 bool browse( FL_OBJECT * input,
108 string const & title, string const & pattern,
109 std::pair<string,string> const & dir1 =
110 std::pair<string,string>(),
111 std::pair<string,string> const & dir2 =
112 std::pair<string,string>() );
113 /// called from browse()
114 string const browseFile( string const & filename,
115 string const & title, string const & pattern,
116 std::pair<string,string> const & dir1,
117 std::pair<string,string> const & dir2 ) const;
119 /** Flag whether a warning has been posted to the text window.
120 If so, don't redraw the window when the mouse leaves an object. */
123 /// Type definitions from the fdesign produced header file.
124 FD_form_preferences * build_preferences();
126 FD_form_outer_tab * build_outer_tab();
128 FD_form_colors * build_colors();
130 FD_form_converters * build_converters();
132 FD_form_formats * build_formats();
134 FD_form_inputs_misc * build_inputs_misc();
136 FD_form_interface * build_interface();
138 FD_form_language * build_language();
140 FD_form_lnf_misc * build_lnf_misc();
142 FD_form_outputs_misc * build_outputs_misc();
144 FD_form_paths * build_paths();
146 FD_form_printer * build_printer();
148 FD_form_screen_fonts * build_screen_fonts();
150 FD_form_spellchecker * build_spellchecker();
152 /// Real GUI implementation.
153 FD_form_preferences * dialog_;
154 /// reLyX and other import/input stuff
155 FD_form_outer_tab * inputs_tab_;
156 /// HCI configuration
157 FD_form_outer_tab * look_n_feel_tab_;
158 /// Converters tabfolder
159 FD_form_outer_tab * converters_tab_;
160 /// Outputs tabfolder
161 FD_form_outer_tab * outputs_tab_;
162 /// Spellchecker, language stuff, etc
163 FD_form_outer_tab * usage_tab_;
165 /** Each tab folder is encapsulated in its own class.
171 Colors( FormPreferences & p ) : parent_(p), dialog_(0) {}
175 FD_form_colors const * dialog() { return dialog_; }
177 void apply(); // not const as modifies modifiedXformPrefs.
181 string const feedback(FL_OBJECT const * const) const;
183 bool input(FL_OBJECT const * const);
186 /// Flag whether Xforms colors have changed since last file save
187 bool modifiedXformPrefs;
191 void AdjustVal( int, int, double ) const;
193 bool BrowserLyX() const;
195 bool BrowserX11() const;
199 void LoadBrowserLyX();
201 bool LoadBrowserX11(string const &) const;
207 int SearchEntry(RGBColor const &) const;
210 FormPreferences & parent_;
212 FD_form_colors * dialog_;
213 /// A vector of RGB colors and associated name.
214 static std::vector<X11Color> colorDB;
215 /// A vector of xform RGB colors and associated name.
216 static std::vector<XformColor> xformColorDB;
225 Converters( FormPreferences & p ) : parent_(p), dialog_(0) {}
229 FD_form_converters const * dialog() { return dialog_; }
235 string const feedback(FL_OBJECT const * const) const;
237 bool input( FL_OBJECT const * const );
241 void UpdateBrowser();
243 void UpdateChoices() const;
255 string const GetFrom() const;
257 string const GetTo() const;
260 FormPreferences & parent_;
262 FD_form_converters * dialog_;
265 friend class Converters;
271 Formats( FormPreferences & p ) : parent_(p), dialog_(0) {}
275 FD_form_formats const * dialog() { return dialog_; }
281 string const feedback(FL_OBJECT const * const) const;
283 bool input( FL_OBJECT const * const );
293 void UpdateBrowser();
300 FormPreferences & parent_;
302 FD_form_formats * dialog_;
305 friend class Formats;
311 InputsMisc( FormPreferences & p ) : parent_(p), dialog_(0) {}
315 FD_form_inputs_misc const * dialog() { return dialog_; }
321 string const feedback(FL_OBJECT const * const) const;
327 FormPreferences & parent_;
329 FD_form_inputs_misc * dialog_;
332 friend class InputsMisc;
338 Interface( FormPreferences & p ) : parent_(p), dialog_(0) {}
342 FD_form_interface const * dialog() { return dialog_; }
348 string const feedback(FL_OBJECT const * const) const;
350 bool input( FL_OBJECT const * const );
356 FormPreferences & parent_;
358 FD_form_interface * dialog_;
361 friend class Interface;
367 Language( FormPreferences & p )
368 : parent_(p), dialog_(0), combo_default_lang(0) {}
372 FD_form_language const * dialog() { return dialog_; }
374 void apply(); // not const because calls update()
378 string const feedback(FL_OBJECT const * const) const;
380 bool input( FL_OBJECT const * const );
384 static void ComboCB(int, void *, Combox *);
388 FormPreferences & parent_;
390 FD_form_language * dialog_;
392 Combox * combo_default_lang;
395 friend class Language;
401 LnFmisc( FormPreferences & p ) : parent_(p), dialog_(0) {}
405 FD_form_lnf_misc const * dialog() { return dialog_; }
411 string const feedback(FL_OBJECT const * const) const;
417 FormPreferences & parent_;
419 FD_form_lnf_misc * dialog_;
422 friend class LnFmisc;
428 OutputsMisc( FormPreferences & p ) : parent_(p), dialog_(0) {}
432 FD_form_outputs_misc const * dialog() { return dialog_; }
438 string const feedback(FL_OBJECT const * const) const;
444 FormPreferences & parent_;
446 FD_form_outputs_misc * dialog_;
449 friend class OutputsMisc;
455 Paths( FormPreferences & p ) : parent_(p), dialog_(0) {}
459 FD_form_paths const * dialog() { return dialog_; }
465 string const feedback(FL_OBJECT const * const) const;
467 bool input(FL_OBJECT const * const);
473 FormPreferences & parent_;
475 FD_form_paths * dialog_;
484 Printer( FormPreferences & p ) : parent_(p), dialog_(0) {}
488 FD_form_printer const * dialog() { return dialog_; }
494 string const feedback(FL_OBJECT const * const) const;
500 FormPreferences & parent_;
502 FD_form_printer * dialog_;
505 friend class Printer;
511 ScreenFonts( FormPreferences & p ) : parent_(p), dialog_(0) {}
515 FD_form_screen_fonts const * dialog() { return dialog_; }
521 string const feedback(FL_OBJECT const * const) const;
529 FormPreferences & parent_;
531 FD_form_screen_fonts * dialog_;
534 friend class ScreenFonts;
540 SpellChecker( FormPreferences & p ) : parent_(p), dialog_(0) {}
544 FD_form_spellchecker const * dialog() { return dialog_; }
546 void apply(); // not const because calls update()!
550 string const feedback(FL_OBJECT const * const) const;
552 bool input(FL_OBJECT const * const);
558 FormPreferences & parent_;
560 FD_form_spellchecker * dialog_;
563 friend class SpellChecker;
572 Converters converters_;
576 InputsMisc inputs_misc_;
578 Interface interface_;
584 OutputsMisc outputs_misc_;
590 ScreenFonts screen_fonts_;
592 SpellChecker spellchecker_;