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();
76 /// Filter the inputs -- return true if entries are valid
77 virtual bool input(FL_OBJECT *, long);
80 /// control which feedback message is output
81 void feedback( FL_OBJECT * );
82 /// The handler for the preemptive feedback
83 void Feedback(FL_OBJECT *, int);
85 virtual FL_FORM * form() const;
87 /** Helper functions available to the various tab folders.
91 bool WriteableDir( string const & );
93 bool ReadableDir( string const & );
95 bool WriteableFile( string const &, string const & = string() );
97 bool ReadableFile( string const &, string const & = string() );
99 void setPreHandler( FL_OBJECT * ) const;
101 void printWarning( string const & );
103 /** title: filedlg title, pattern: *.ps etc
104 extra buttons on filedlg: dir1 = (name, dir), dir2 = (name, dir)
108 bool browse(FL_OBJECT * input,
109 string const & title, string const & pattern,
110 std::pair<string,string> const & dir1 //=
111 //std::pair<string,string>()
113 std::pair<string,string> const & dir2 //=
114 //std::pair<string,string>()
116 /// called from browse()
117 string const browseFile( string const & filename,
118 string const & title, string const & pattern,
119 std::pair<string,string> const & dir1,
120 std::pair<string,string> const & dir2 ) const;
122 /// Type definitions from the fdesign produced header file.
123 FD_form_preferences * build_preferences();
125 FD_form_outer_tab * build_outer_tab();
127 FD_form_colors * build_colors();
129 FD_form_converters * build_converters();
131 FD_form_formats * build_formats();
133 FD_form_inputs_misc * build_inputs_misc();
135 FD_form_interface * build_interface();
137 FD_form_language * build_language();
139 FD_form_lnf_misc * build_lnf_misc();
141 FD_form_outputs_misc * build_outputs_misc();
143 FD_form_paths * build_paths();
145 FD_form_printer * build_printer();
147 FD_form_screen_fonts * build_screen_fonts();
149 FD_form_spellchecker * build_spellchecker();
151 /// Real GUI implementation.
152 FD_form_preferences * dialog_;
153 /// Converters tabfolder
154 FD_form_outer_tab * converters_tab_;
155 /// reLyX and other import/input stuff
156 FD_form_outer_tab * inputs_tab_;
157 /// HCI configuration
158 FD_form_outer_tab * look_n_feel_tab_;
159 /// Outputs tabfolder
160 FD_form_outer_tab * outputs_tab_;
161 /// Spellchecker, language stuff, etc
162 FD_form_outer_tab * usage_tab_;
164 /** Flag whether a warning has been posted to the text window.
165 If so, don't redraw the window when the mouse leaves an object. */
168 /** Each tab folder is encapsulated in its own class.
174 Colors( FormPreferences & p ) : parent_(p), dialog_(0) {}
178 FD_form_colors const * dialog() { return dialog_; }
180 void apply(); // not const as modifies modifiedXformPrefs.
184 string const feedback(FL_OBJECT const * const) const;
186 bool input(FL_OBJECT const * const);
189 /// Flag whether Xforms colors have changed since last file save
190 bool modifiedXformPrefs;
194 void AdjustVal( int, int, double ) const;
196 bool BrowserLyX() const;
198 bool BrowserX11() const;
202 void LoadBrowserLyX();
204 bool LoadBrowserX11(string const &) const;
210 int SearchEntry(RGBColor const &) const;
213 FormPreferences & parent_;
215 FD_form_colors * dialog_;
216 /// A vector of RGB colors and associated name.
217 static std::vector<X11Color> colorDB;
218 /// A vector of xform RGB colors and associated name.
219 static std::vector<XformColor> xformColorDB;
228 Converters( FormPreferences & p ) : parent_(p), dialog_(0) {}
232 FD_form_converters const * dialog() { return dialog_; }
238 string const feedback(FL_OBJECT const * const) const;
240 bool input( FL_OBJECT const * const );
244 void UpdateBrowser();
246 void UpdateChoices() const;
258 string const GetFrom() const;
260 string const GetTo() const;
263 FormPreferences & parent_;
265 FD_form_converters * dialog_;
268 friend class Converters;
274 Formats( FormPreferences & p ) : parent_(p), dialog_(0) {}
278 FD_form_formats const * dialog() { return dialog_; }
284 string const feedback(FL_OBJECT const * const) const;
286 bool input( FL_OBJECT const * const );
296 void UpdateBrowser();
303 FormPreferences & parent_;
305 FD_form_formats * dialog_;
308 friend class Formats;
314 InputsMisc( FormPreferences & p ) : parent_(p), dialog_(0) {}
318 FD_form_inputs_misc const * dialog() { return dialog_; }
324 string const feedback(FL_OBJECT const * const) const;
330 FormPreferences & parent_;
332 FD_form_inputs_misc * dialog_;
335 friend class InputsMisc;
341 Interface( FormPreferences & p ) : parent_(p), dialog_(0) {}
345 FD_form_interface const * dialog() { return dialog_; }
351 string const feedback(FL_OBJECT const * const) const;
353 bool input( FL_OBJECT const * const );
359 FormPreferences & parent_;
361 FD_form_interface * dialog_;
364 friend class Interface;
370 Language( FormPreferences & p )
371 : parent_(p), dialog_(0), combo_default_lang(0) {}
375 FD_form_language const * dialog() { return dialog_; }
377 void apply(); // not const because calls update()
381 string const feedback(FL_OBJECT const * const) const;
383 bool input( FL_OBJECT const * const );
387 static void ComboCB(int, void *, Combox *);
391 FormPreferences & parent_;
393 FD_form_language * dialog_;
395 Combox * combo_default_lang;
398 friend class Language;
404 LnFmisc( FormPreferences & p ) : parent_(p), dialog_(0) {}
408 FD_form_lnf_misc const * dialog() { return dialog_; }
414 string const feedback(FL_OBJECT const * const) const;
420 FormPreferences & parent_;
422 FD_form_lnf_misc * dialog_;
425 friend class LnFmisc;
431 OutputsMisc( FormPreferences & p ) : parent_(p), dialog_(0) {}
435 FD_form_outputs_misc const * dialog() { return dialog_; }
441 string const feedback(FL_OBJECT const * const) const;
447 FormPreferences & parent_;
449 FD_form_outputs_misc * dialog_;
452 friend class OutputsMisc;
458 Paths( FormPreferences & p ) : parent_(p), dialog_(0) {}
462 FD_form_paths const * dialog() { return dialog_; }
468 string const feedback(FL_OBJECT const * const) const;
470 bool input(FL_OBJECT const * const);
476 FormPreferences & parent_;
478 FD_form_paths * dialog_;
487 Printer( FormPreferences & p ) : parent_(p), dialog_(0) {}
491 FD_form_printer const * dialog() { return dialog_; }
497 string const feedback(FL_OBJECT const * const) const;
503 FormPreferences & parent_;
505 FD_form_printer * dialog_;
508 friend class Printer;
514 ScreenFonts( FormPreferences & p ) : parent_(p), dialog_(0) {}
518 FD_form_screen_fonts const * dialog() { return dialog_; }
524 string const feedback(FL_OBJECT const * const) const;
532 FormPreferences & parent_;
534 FD_form_screen_fonts * dialog_;
537 friend class ScreenFonts;
543 SpellChecker( FormPreferences & p ) : parent_(p), dialog_(0) {}
547 FD_form_spellchecker const * dialog() { return dialog_; }
549 void apply(); // not const because calls update()!
553 string const feedback(FL_OBJECT const * const) const;
555 bool input(FL_OBJECT const * const);
561 FormPreferences & parent_;
563 FD_form_spellchecker * dialog_;
566 friend class SpellChecker;
575 Converters converters_;
577 InputsMisc inputs_misc_;
581 Interface interface_;
587 OutputsMisc outputs_misc_;
593 ScreenFonts screen_fonts_;
595 SpellChecker spellchecker_;