]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormPreferences.C
remove defaults stuff, let Qt handle no toolbar
[lyx.git] / src / frontends / xforms / FormPreferences.C
1 /**
2  * \file FormPreferences.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13
14 #include "ControlPrefs.h"
15 #include "FormPreferences.h"
16 #include "forms/form_preferences.h"
17 #include "xformsBC.h"
18 #include "ButtonController.h"
19
20 #include "Color.h"
21 #include "input_validators.h"
22 #include "forms_gettext.h"
23 #include "xforms_helpers.h"
24 #include "helper_funcs.h" // getSecond
25
26 #include "buffer.h"
27 #include "converter.h"
28 #include "format.h"
29 #include "debug.h"
30 #include "language.h"
31 #include "frnt_lang.h"
32 #include "lyxlex.h"
33 #include "lyxrc.h"
34 #include "LColor.h"
35 #include "Lsstream.h"
36 #include "funcrequest.h"
37 #include "author.h"
38
39 #include "support/lyxfunctional.h"
40 #include "support/lyxmanip.h"
41 #include "support/filetools.h"
42 #include "support/LAssert.h"
43
44 #include "graphics/GraphicsCache.h"
45 #include "graphics/GraphicsTypes.h"
46
47 #include <boost/bind.hpp>
48
49 #include FORMS_H_LOCATION
50 #include "combox.h"
51
52 #include <utility>
53 #include <iomanip>
54 #include <X11/Xlib.h>
55
56 using std::endl;
57 using std::pair;
58 using std::make_pair;
59 using std::max;
60 using std::min;
61 using std::vector;
62 using std::setw;
63 using std::setfill;
64
65 extern string system_lyxdir;
66 extern string user_lyxdir;
67
68 namespace {
69
70 // These should probably go inside the class definition...
71 Formats    local_formats;
72 Converters local_converters;
73
74 string makeFontName(string const & family, string const & foundry)
75 {
76         if (foundry.empty())
77                 return family;
78         return family + ',' + foundry;
79 }
80
81
82 pair<string,string> parseFontName(string const & name)
83 {
84         string::size_type const idx = name.find(',');
85         if (idx == string::npos)
86                 return make_pair(name, string());
87         return make_pair(name.substr(0, idx),
88                          name.substr(idx+1));
89 }
90
91
92 string const X11hexname(RGBColor const & col)
93 {
94         ostringstream ostr;
95
96         ostr << '#' << std::setbase(16) << setfill('0')
97              << setw(2) << col.r
98              << setw(2) << col.g
99              << setw(2) << col.b;
100
101         return STRCONV(ostr.str());
102 }
103
104 } // namespace anon
105
106
107 typedef FormCB<ControlPrefs, FormDB<FD_preferences> > base_class;
108
109 FormPreferences::FormPreferences()
110         : base_class(_("Preferences"), false),
111           colors_(*this), converters_(*this), inputs_misc_(*this),
112           formats_(*this), interface_(*this), language_(*this),
113           lnf_misc_(*this), identity_(*this), outputs_misc_(*this),
114           paths_(*this), printer_(*this), screen_fonts_(*this),
115           spelloptions_(*this)
116 {
117 }
118
119
120 void FormPreferences::redraw()
121 {
122         if (!(form() && form()->visible))
123                 return;
124         fl_redraw_form(form());
125
126         FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
127         if (!(form2 && form2->visible))
128                 return;
129         fl_redraw_form(form2);
130
131         FL_FORM * form3 = 0;
132         if (form2 == converters_tab_->form)
133                 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
134
135         else if (form2 == look_n_feel_tab_->form)
136                 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
137
138         else if (form2 == inputs_tab_->form)
139                 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
140
141         else if (form2 == outputs_tab_->form)
142                 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
143
144         else if (form2 == lang_opts_tab_->form)
145                 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
146
147         if (form3 && form3->visible)
148                 fl_redraw_form(form3);
149 }
150
151
152 void FormPreferences::hide()
153 {
154         // We need to hide the active tabfolder otherwise we get a
155         // BadDrawable error from X window and LyX crashes without saving.
156         FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
157         if (inner_form && inner_form->visible)
158                 fl_hide_form(inner_form);
159         FormBase::hide();
160 }
161
162
163 void FormPreferences::build()
164 {
165         dialog_.reset(build_preferences(this));
166
167         // Manage the restore, save, apply and cancel/close buttons
168         bcview().setOK(dialog_->button_ok);
169         bcview().setApply(dialog_->button_apply);
170         bcview().setCancel(dialog_->button_close);
171         bcview().setRestore(dialog_->button_restore);
172
173         // Allow the base class to control messages
174         setMessageWidget(dialog_->text_warning);
175
176         // build the tab folders
177         converters_tab_.reset(build_preferences_inner_tab(this));
178         look_n_feel_tab_.reset(build_preferences_inner_tab(this));
179         inputs_tab_.reset(build_preferences_inner_tab(this));
180         outputs_tab_.reset(build_preferences_inner_tab(this));
181         lang_opts_tab_.reset(build_preferences_inner_tab(this));
182
183         // build actual tabfolder contents
184         // these will become nested tabfolders
185         colors_.build();
186         converters_.build();
187         formats_.build();
188         inputs_misc_.build();
189         interface_.build();
190         language_.build();
191         lnf_misc_.build();
192         identity_.build();
193         outputs_misc_.build();
194         paths_.build();
195         printer_.build();
196         screen_fonts_.build();
197         spelloptions_.build();
198
199         // Now add them to the tabfolder
200         fl_addto_tabfolder(dialog_->tabfolder_prefs,
201                            _("Look & Feel"),
202                            look_n_feel_tab_->form);
203         fl_addto_tabfolder(dialog_->tabfolder_prefs,
204                            _("Lang Opts"),
205                            lang_opts_tab_->form);
206         fl_addto_tabfolder(dialog_->tabfolder_prefs,
207                            _("Conversion"),
208                            converters_tab_->form);
209         fl_addto_tabfolder(dialog_->tabfolder_prefs,
210                            _("Inputs"),
211                            inputs_tab_->form);
212         fl_addto_tabfolder(dialog_->tabfolder_prefs,
213                            _("Outputs"),
214                            outputs_tab_->form);
215
216         // now build the nested tabfolders
217         // Starting with look and feel
218         fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
219                            _("Screen Fonts"),
220                            screen_fonts_.dialog()->form);
221         fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
222                            _("Interface"),
223                            interface_.dialog()->form);
224         fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
225                            _("Colors"),
226                            colors_.dialog()->form);
227         fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
228                            _("Misc"),
229                            lnf_misc_.dialog()->form);
230         fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
231                            _("Identity"),
232                            identity_.dialog()->form);
233
234         // then build converters
235         fl_addto_tabfolder(converters_tab_->tabfolder_inner,
236                            _("Formats"),
237                            formats_.dialog()->form);
238         fl_addto_tabfolder(converters_tab_->tabfolder_inner,
239                            _("Converters"),
240                            converters_.dialog()->form);
241
242         // then build inputs
243         // Paths should probably go in a few inner_tab called Files
244         fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
245                            _("Paths"),
246                            paths_.dialog()->form);
247         fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
248                            _("Misc"),
249                            inputs_misc_.dialog()->form);
250
251         // then building outputs
252         fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
253                            _("Printer"),
254                            printer_.dialog()->form);
255         fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
256                            _("Misc"),
257                            outputs_misc_.dialog()->form);
258
259         // then building usage
260         fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
261                            _("Spell checker"),
262                            spelloptions_.dialog()->form);
263         fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
264                            _("Language"),
265                            language_.dialog()->form);
266
267         // work-around xforms bug re update of folder->x, folder->y coords.
268         setPrehandler(look_n_feel_tab_->tabfolder_inner);
269         setPrehandler(converters_tab_->tabfolder_inner);
270         setPrehandler(inputs_tab_->tabfolder_inner);
271         setPrehandler(outputs_tab_->tabfolder_inner);
272         setPrehandler(lang_opts_tab_->tabfolder_inner);
273 }
274
275
276 void FormPreferences::apply()
277 {
278         // set the new lyxrc entries
279         // many of these need to trigger other functions when the assignment
280         // is made.  For example, screen zoom and font types.  These could be
281         // handled either by signals/slots in lyxrc or just directly call the
282         // associated functions here.
283         // There are other problems with this scheme.  We really should check
284         // what we copy to make sure that it really is necessary to do things
285         // like update the screen fonts because that flushes the textcache
286         // and other stuff which may cost us a lot on slower/high-load
287         // machines.
288
289         LyXRC & rc(controller().rc());
290
291         colors_.apply();
292         formats_.apply();    // Must be before converters_.apply()
293         converters_.apply();
294         inputs_misc_.apply(rc);
295         interface_.apply(rc);
296         language_.apply(rc);
297         lnf_misc_.apply(rc);
298         identity_.apply(rc);
299         outputs_misc_.apply(rc);
300         paths_.apply(rc);
301         printer_.apply(rc);
302         screen_fonts_.apply(rc);
303         spelloptions_.apply(rc);
304
305         // The "Save" button has been pressed.
306         if (controller().isClosing() && colors_.modifiedXformsPrefs) {
307                 string const filename =
308                         AddName(user_lyxdir, "preferences.xform");
309                 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
310         }
311 }
312
313
314 string const FormPreferences::getFeedback(FL_OBJECT * ob)
315 {
316         lyx::Assert(ob);
317
318         if (ob->form->fdui == colors_.dialog())
319                 return colors_.feedback(ob);
320         if (ob->form->fdui == converters_.dialog())
321                 return converters_.feedback(ob);
322         if (ob->form->fdui == formats_.dialog())
323                 return formats_.feedback(ob);
324         if (ob->form->fdui == inputs_misc_.dialog())
325                 return inputs_misc_.feedback(ob);
326         if (ob->form->fdui == interface_.dialog())
327                 return interface_.feedback(ob);
328         if (ob->form->fdui == language_.dialog())
329                 return language_.feedback(ob);
330         if (ob->form->fdui == lnf_misc_.dialog())
331                 return lnf_misc_.feedback(ob);
332         if (ob->form->fdui == outputs_misc_.dialog())
333                 return outputs_misc_.feedback(ob);
334         if (ob->form->fdui == paths_.dialog())
335                 return paths_.feedback(ob);
336         if (ob->form->fdui == printer_.dialog())
337                 return printer_.feedback(ob);
338         if (ob->form->fdui == screen_fonts_.dialog())
339                 return screen_fonts_.feedback(ob);
340         if (ob->form->fdui == spelloptions_.dialog())
341                 return spelloptions_.feedback(ob);
342
343         return string();
344 }
345
346
347 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
348 {
349         lyx::Assert(ob);
350
351         bool valid = true;
352
353         // whatever checks you need to ensure the user hasn't entered
354         // some totally ridiculous value somewhere.  Change activate to suit.
355         // comments before each test describe what is _valid_
356
357         if (ob->form->fdui == colors_.dialog()) {
358                 colors_.input(ob);
359         } else if (ob->form->fdui == converters_.dialog()) {
360                 valid = converters_.input(ob);
361         } else if (ob->form->fdui == formats_.dialog()) {
362                 valid = formats_.input(ob);
363         } else if  (ob->form->fdui == interface_.dialog()) {
364                 valid = interface_.input(ob);
365         } else if  (ob->form->fdui == language_.dialog()) {
366                 valid = language_.input(ob);
367         } else if  (ob->form->fdui == paths_.dialog()) {
368                 valid = paths_.input(ob);
369         } else if  (ob->form->fdui == screen_fonts_.dialog()) {
370                 valid = screen_fonts_.input();
371         } else if  (ob->form->fdui == spelloptions_.dialog()) {
372                 valid = spelloptions_.input(ob);
373         }
374
375         return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
376 }
377
378
379 void FormPreferences::update()
380 {
381         if (!dialog_.get()) return;
382
383         LyXRC const & rc(controller().rc());
384
385         // read lyxrc entries
386         colors_.update();
387         formats_.update();   // Must be before converters_.update()
388         converters_.update();
389         inputs_misc_.update(rc);
390         interface_.update(rc);
391         language_.update(rc);
392         lnf_misc_.update(rc);
393         identity_.update(rc);
394         outputs_misc_.update(rc);
395         paths_.update(rc);
396         printer_.update(rc);
397         screen_fonts_.update(rc);
398         spelloptions_.update(rc);
399 }
400
401
402 FormPreferences::Colors::Colors(FormPreferences & p)
403         : modifiedXformsPrefs(false), parent_(p)
404 {}
405
406
407 FD_preferences_colors const * FormPreferences::Colors::dialog()
408 {
409         return dialog_.get();
410 }
411
412
413 void FormPreferences::Colors::apply()
414 {
415         bool modifiedText = false;
416         bool modifiedBackground = false;
417
418         for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
419              cit != xformsColorDB.end(); ++cit) {
420                 RGBColor col;
421                 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
422                 if (col != cit->color()) {
423                         modifiedXformsPrefs = true;
424                         if (cit->colorID == FL_BLACK)
425                                 modifiedText = true;
426                         if (cit->colorID == FL_COL1)
427                                 modifiedBackground = true;
428                 }
429         }
430
431         if (modifiedXformsPrefs) {
432                 for (vector<XformsColor>::const_iterator cit =
433                              xformsColorDB.begin();
434                      cit != xformsColorDB.end(); ++cit) {
435                         fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
436
437                         if (modifiedText && cit->colorID == FL_BLACK) {
438                                 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
439                         }
440
441                         if (modifiedBackground && cit->colorID == FL_COL1) {
442                                 AdjustVal(FL_MCOL,      FL_COL1, 0.1);
443                                 AdjustVal(FL_TOP_BCOL,  FL_COL1, 0.1);
444                                 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
445
446                                 AdjustVal(FL_RIGHT_BCOL,  FL_COL1, -0.5);
447                                 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
448                         }
449
450                         if (cit->colorID == GUI_COLOR_CURSOR) {
451                                 fl_mapcolor(GUI_COLOR_CURSOR,
452                                             cit->r, cit->g, cit->b);
453                                 setCursorColor(GUI_COLOR_CURSOR);
454                         }
455                 }
456                 parent_.controller().redrawGUI();
457         }
458
459         // Now do the same for the LyX LColors...
460         for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
461              cit != lyxColorDB.end(); ++cit) {
462                 LColor::color lc = lcolor.getFromGUIName(cit->getname());
463                 if (lc == LColor::inherit) continue;
464
465                 // Create a valid X11 name of the form "#rrggbb"
466                 string const hexname = X11hexname(cit->color());
467
468                 if (lcolor.getX11Name(lc) != hexname) {
469                         lyxerr[Debug::GUI]
470                                 << "FormPreferences::Colors::apply: "
471                                 << "resetting LColor " << lcolor.getGUIName(lc)
472                                 << " from \"" << lcolor.getX11Name(lc)
473                                 << "\" to \"" << hexname << "\"."
474                                 << endl;
475
476                         parent_.controller().setColor(lc, hexname);
477                 }
478         }
479 }
480
481
482 void FormPreferences::Colors::build()
483 {
484         dialog_.reset(build_preferences_colors(&parent_));
485
486         fl_set_object_color(dialog_->button_color,
487                             GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
488
489         fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
490         fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
491         fl_set_dial_step(dialog_->dial_hue, 1.0);
492         fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
493
494         fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
495         fl_set_slider_step(dialog_->slider_saturation, 0.01);
496         fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
497
498         fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
499         fl_set_slider_step(dialog_->slider_value, 0.01);
500         fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
501
502         fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
503         fl_set_slider_step(dialog_->slider_red, 1.0);
504         fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
505
506         fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
507         fl_set_slider_step(dialog_->slider_green, 1.0);
508         fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
509
510         fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
511         fl_set_slider_step(dialog_->slider_blue, 1.0);
512         fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
513
514         // set up the feedback mechanism
515         setPrehandler(dialog_->browser_lyx_objs);
516         setPrehandler(dialog_->button_color);
517         setPrehandler(dialog_->button_modify);
518         setPrehandler(dialog_->dial_hue);
519         setPrehandler(dialog_->slider_saturation);
520         setPrehandler(dialog_->slider_value);
521         setPrehandler(dialog_->slider_red);
522         setPrehandler(dialog_->slider_green);
523         setPrehandler(dialog_->slider_blue);
524         setPrehandler(dialog_->radio_rgb);
525         setPrehandler(dialog_->radio_hsv);
526 }
527
528
529 string const
530 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
531 {
532         if (ob == dialog_->browser_lyx_objs)
533                 return _("LyX objects that can be assigned a color.");
534
535         if (ob == dialog_->button_modify)
536                 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
537
538         if (ob == dialog_->dial_hue ||
539             ob == dialog_->slider_saturation ||
540             ob == dialog_->slider_value ||
541             ob == dialog_->slider_red ||
542             ob == dialog_->slider_green ||
543             ob == dialog_->slider_blue)
544                 return  _("Find a new color.");
545
546         if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
547                 return _("Toggle between RGB and HSV color spaces.");
548
549         return string();
550 }
551
552
553 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
554 {
555         if (ob == dialog_->browser_lyx_objs) {
556                 InputBrowserLyX();
557
558         } else if (ob == dialog_->dial_hue ||
559                    ob == dialog_->slider_saturation ||
560                    ob == dialog_->slider_value) {
561                 InputHSV();
562
563         } else if (ob == dialog_->slider_red ||
564                    ob == dialog_->slider_green ||
565                    ob == dialog_->slider_blue) {
566                 InputRGB();
567
568         } else if (ob == dialog_->radio_rgb ||
569                    ob == dialog_->radio_hsv) {
570                 SwitchColorSpace();
571
572         } else if (ob == dialog_->button_modify) {
573                 Modify();
574         }
575 }
576
577
578 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
579                                         double addVal) const
580 {
581         RGBColor rgb;
582         fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
583
584         HSVColor hsv(rgb);
585         hsv.v += addVal;
586         hsv.v = min(1.0, max(0.0, hsv.v));
587
588         rgb = RGBColor(hsv);
589         fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
590 }
591
592
593 void FormPreferences::Colors::InputBrowserLyX() const
594 {
595         vector<NamedColor>::size_type const selLyX =
596                 fl_get_browser(dialog_->browser_lyx_objs);
597         if (selLyX < 1) return;
598
599         // Is the choice an Xforms color...
600         RGBColor col;
601
602         if (selLyX - 1 < xformsColorDB.size()) {
603                 vector<XformsColor>::size_type const i = selLyX - 1;
604                 col = xformsColorDB[i].color();
605         }
606         // or a LyX Logical color?
607         else {
608                 vector<NamedColor>::size_type const i = selLyX - 1 -
609                         xformsColorDB.size();
610                 col = lyxColorDB[i].color();
611         }
612
613         fl_freeze_form(dialog_->form);
614
615         fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
616         fl_redraw_object(dialog_->button_color);
617
618         // Display either RGB or HSV but not both!
619         SwitchColorSpace();
620
621         // Deactivate the modify button to begin with...
622         setEnabled(dialog_->button_modify, false);
623
624         fl_unfreeze_form(dialog_->form);
625 }
626
627
628 void FormPreferences::Colors::InputHSV()
629 {
630         double const hue = fl_get_dial_value(dialog_->dial_hue);
631         double const sat = fl_get_slider_value(dialog_->slider_saturation);
632         double const val = fl_get_slider_value(dialog_->slider_value);
633
634         int const h = int(hue);
635         int const s = int(100.0 * sat);
636         int const v = int(100.0 * val);
637
638         string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
639                 tostr(v);
640         fl_set_object_label(dialog_->text_color_values, label.c_str());
641
642         RGBColor col = HSVColor(hue, sat, val);
643
644         fl_freeze_form(dialog_->form);
645
646         fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
647         fl_redraw_object(dialog_->button_color);
648
649         col = HSVColor(hue, 1.0, 1.0);
650         col.r = max(col.r, 0u);
651         fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
652         fl_redraw_object(dialog_->dial_hue);
653
654         // Ascertain whether to activate the Modify button.
655         vector<NamedColor>::size_type const selLyX =
656                 fl_get_browser(dialog_->browser_lyx_objs);
657
658         fl_unfreeze_form(dialog_->form);
659         if (selLyX < 1) return;
660
661         fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
662         bool modify = false;
663
664         // Is the choice an Xforms color...
665         if (selLyX - 1 < xformsColorDB.size()) {
666                 vector<XformsColor>::size_type const i = selLyX - 1;
667                 modify = (xformsColorDB[i].color() != col);
668         }
669         // or a LyX Logical color?
670         else {
671                 vector<NamedColor>::size_type const i = selLyX - 1 -
672                         xformsColorDB.size();
673                 modify = (lyxColorDB[i].color() != col);
674         }
675
676         setEnabled(dialog_->button_modify, modify);
677 }
678
679
680 void FormPreferences::Colors::InputRGB()
681 {
682         int const red   = int(fl_get_slider_value(dialog_->slider_red));
683         int const green = int(fl_get_slider_value(dialog_->slider_green));
684         int const blue  = int(fl_get_slider_value(dialog_->slider_blue));
685
686         string const label = tostr(red) + string(", ") + tostr(green) +
687                 string(", ") + tostr(blue);
688         fl_set_object_label(dialog_->text_color_values, label.c_str());
689
690         fl_freeze_form(dialog_->form);
691
692         RGBColor col = RGBColor(red, green, blue);
693         fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
694         fl_redraw_object(dialog_->button_color);
695
696         // Ascertain whether to activate the Modify button.
697         vector<NamedColor>::size_type const selLyX =
698                 fl_get_browser(dialog_->browser_lyx_objs);
699
700         fl_unfreeze_form(dialog_->form);
701         if (selLyX < 1) return;
702
703         bool modify = false;
704
705         // Is the choice an Xforms color...
706         if (selLyX - 1 < xformsColorDB.size()) {
707                 vector<XformsColor>::size_type const i = selLyX - 1;
708                 modify = (xformsColorDB[i].color() != col);
709         }
710         // or a LyX Logical color?
711         else {
712                 vector<NamedColor>::size_type const i = selLyX - 1 -
713                         xformsColorDB.size();
714                 modify = (lyxColorDB[i].color() != col);
715         }
716
717         setEnabled(dialog_->button_modify, modify);
718 }
719
720
721 void FormPreferences::Colors::LoadBrowserLyX()
722 {
723         if (!dialog_->browser_lyx_objs->visible)
724                 return;
725
726         // First, define the modifiable xforms colors
727         xformsColorDB.clear();
728         XformsColor xcol;
729
730         xcol.name = _("GUI background");
731         xcol.colorID = FL_COL1;
732         fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
733
734         xformsColorDB.push_back(xcol);
735
736         xcol.name = _("GUI text");
737         xcol.colorID = FL_BLACK;
738         fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
739
740         xformsColorDB.push_back(xcol);
741
742         xcol.name = _("GUI selection");
743         xcol.colorID = FL_YELLOW;
744         fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
745
746         xformsColorDB.push_back(xcol);
747
748         xcol.name = _("GUI pointer");
749         xcol.colorID = GUI_COLOR_CURSOR;
750         fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
751
752         xformsColorDB.push_back(xcol);
753
754         // Now create the the LyX LColors database
755         lyxColorDB.clear();
756         for (int i=0; i<LColor::ignore; ++i) {
757                 LColor::color lc = static_cast<LColor::color>(i);
758                 if (lc == LColor::none
759                     || lc == LColor::black
760                     || lc == LColor::white
761                     || lc == LColor::red
762                     || lc == LColor::green
763                     || lc == LColor::blue
764                     || lc == LColor::cyan
765                     || lc == LColor::magenta
766                     || lc == LColor::yellow
767                     || lc == LColor::inherit
768                     || lc == LColor::ignore) continue;
769
770                 RGBColor col;
771                 bool const success = getRGBColor(lc, col.r, col.g, col.b);
772                 if (!success) {
773                         lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
774                                << "LColor " << lcolor.getLyXName(lc)
775                                << ": X can't find color \""
776                                << lcolor.getX11Name(lc)
777                                << "\". Set to \"black\"!" << endl;
778
779                         string const arg = lcolor.getLyXName(lc) + " black";
780                         parent_.controller().setColor(lc, "black");
781                         continue;
782                 }
783
784                 // Create a valid X11 name of the form "#rrggbb" and change the
785                 // LColor X11name to this. Don't want to trigger a redraw,
786                 // as we're just changing the name not the RGB values.
787                 // Also reset the system_lcolor names, so that we don't output
788                 // unnecessary changes.
789                 string const hexname = X11hexname(col);
790
791                 if (lcolor.getX11Name(lc) != hexname) {
792                         lcolor.setColor(lc, hexname);
793                         system_lcolor.setColor(lc, hexname);
794                 }
795
796                 // Finally, push the color onto the database
797                 NamedColor ncol(lcolor.getGUIName(lc), col);
798                 lyxColorDB.push_back(ncol);
799         }
800
801         // Now construct the browser
802         FL_OBJECT * colbr = dialog_->browser_lyx_objs;
803         fl_freeze_form(dialog_->form);
804         fl_clear_browser(colbr);
805         for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
806              cit != xformsColorDB.end(); ++cit) {
807                 fl_addto_browser(colbr, cit->getname().c_str());
808         }
809         for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
810              cit != lyxColorDB.end(); ++cit) {
811                 fl_addto_browser(colbr, cit->getname().c_str());
812         }
813
814         // just to be safe...
815         fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
816         fl_select_browser_line(dialog_->browser_lyx_objs, 1);
817         fl_unfreeze_form(dialog_->form);
818
819         InputBrowserLyX();
820 }
821
822
823 void FormPreferences::Colors::Modify()
824 {
825         vector<NamedColor>::size_type const selLyX =
826                 fl_get_browser(dialog_->browser_lyx_objs);
827         if (selLyX < 1)
828                 return;
829
830         RGBColor col;
831         fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
832
833         // Is the choice an Xforms color...
834         if (selLyX - 1 < xformsColorDB.size()) {
835                 vector<XformsColor>::size_type const i = selLyX - 1;
836                 xformsColorDB[i].r  = col.r;
837                 xformsColorDB[i].g  = col.g;
838                 xformsColorDB[i].b  = col.b;
839         }
840         // or a LyX Logical color?
841         else {
842                 vector<NamedColor>::size_type const i = selLyX - 1 -
843                         xformsColorDB.size();
844                 lyxColorDB[i].r  = col.r;
845                 lyxColorDB[i].g  = col.g;
846                 lyxColorDB[i].b  = col.b;
847         }
848
849         fl_freeze_form(dialog_->form);
850         setEnabled(dialog_->button_modify, false);
851         fl_unfreeze_form(dialog_->form);
852 }
853
854
855 void FormPreferences::Colors::SwitchColorSpace() const
856 {
857         bool const hsv = fl_get_button(dialog_->radio_hsv);
858
859         RGBColor col;
860         fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
861
862         fl_freeze_form(dialog_->form);
863
864         if (hsv) {
865                 fl_hide_object(dialog_->slider_red);
866                 fl_hide_object(dialog_->slider_blue);
867                 fl_hide_object(dialog_->slider_green);
868                 fl_show_object(dialog_->dial_hue);
869                 fl_show_object(dialog_->slider_saturation);
870                 fl_show_object(dialog_->slider_value);
871
872                 HSVColor hsv = HSVColor(col);
873                 hsv.h = max(hsv.h, 0.0);
874
875                 fl_set_dial_value(dialog_->dial_hue, hsv.h);
876                 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
877                 fl_set_slider_value(dialog_->slider_value, hsv.v);
878
879                 col = HSVColor(hsv.h, 1.0, 1.0);
880                 col.r = max(col.r, 0u);
881                 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
882                 fl_redraw_object(dialog_->dial_hue);
883
884                 // Adjust the label a bit, but not the actual values.
885                 // Means that toggling from one space to the other has no
886                 // effect on the final color.
887                 int const h = int(hsv.h);
888                 int const s = int(100 * hsv.s);
889                 int const v = int(100 * hsv.v);
890                 string const label = tostr(h) + ", " + tostr(s) +
891                         ", " + tostr(v);
892                 fl_set_object_label(dialog_->text_color_values, label.c_str());
893
894         } else {
895                 fl_show_object(dialog_->slider_red);
896                 fl_show_object(dialog_->slider_blue);
897                 fl_show_object(dialog_->slider_green);
898                 fl_hide_object(dialog_->dial_hue);
899                 fl_hide_object(dialog_->slider_saturation);
900                 fl_hide_object(dialog_->slider_value);
901
902                 fl_set_slider_value(dialog_->slider_red,   col.r);
903                 fl_set_slider_value(dialog_->slider_green, col.g);
904                 fl_set_slider_value(dialog_->slider_blue,  col.b);
905
906                 // Adjust the label a bit. Same reasoning as above.
907                 int const r = int(col.r);
908                 int const g = int(col.g);
909                 int const b = int(col.b);
910                 string const label = tostr(r) + ", " + tostr(g) +
911                         ", " + tostr(b);
912                 fl_set_object_label(dialog_->text_color_values, label.c_str());
913         }
914
915         fl_unfreeze_form(dialog_->form);
916 }
917
918
919 FormPreferences::Converters::Converters(FormPreferences & p)
920         : parent_(p)
921 {}
922
923
924 FD_preferences_converters const * FormPreferences::Converters::dialog()
925 {
926         return dialog_.get();
927 }
928
929
930 void FormPreferences::Converters::apply() const
931 {
932         parent_.controller().setConverters(local_converters);
933 }
934
935
936 void FormPreferences::Converters::build()
937 {
938         dialog_.reset(build_preferences_converters(&parent_));
939
940         fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
941         fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
942
943         // set up the feedback mechanism
944         setPrehandler(dialog_->browser_all);
945         setPrehandler(dialog_->button_delete);
946         setPrehandler(dialog_->button_add);
947         setPrehandler(dialog_->input_converter);
948         setPrehandler(dialog_->choice_from);
949         setPrehandler(dialog_->choice_to);
950         setPrehandler(dialog_->input_flags);
951 }
952
953
954 string const
955 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
956 {
957         if (ob == dialog_->browser_all)
958                 return _("All the currently defined converters known to LyX.");
959
960         if (ob == dialog_->choice_from)
961                 return _("Convert \"from\" this format");
962
963         if (ob == dialog_->choice_to)
964                 return _("Convert \"to\" this format");
965
966         if (ob == dialog_->input_converter)
967                 return _("The conversion command. $$i is the input file name, "
968                          "$$b is the file name without its extension and $$o is "
969                          "the name of the output file. $$s can be used as path to "
970                          "LyX's own collection of conversion scripts.");
971
972         if (ob == dialog_->input_flags)
973                 return _("Extra information for the Converter class, whether and "
974                          "how to parse the result, and various other things.");
975
976         if (ob == dialog_->button_delete)
977                 return _("Remove the current converter from the list of available "
978                          "converters. Note: you must then \"Apply\" the change.");
979
980         if (ob == dialog_->button_add) {
981                 if (string(ob->label) == _("Add"))
982                         return _("Add the current converter to the list of available "
983                                  "converters. Note: you must then \"Apply\" the change.");
984                 else
985                         return _("Modify the contents of the current converter. "
986                                  "Note: you must then \"Apply\" the change.");
987         }
988
989         return string();
990 }
991
992
993 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
994 {
995         if (ob == dialog_->browser_all)
996                 return Browser();
997
998         if (ob == dialog_->choice_from
999             || ob == dialog_->choice_to
1000             || ob == dialog_->input_converter
1001             || ob == dialog_->input_flags)
1002                 return Input();
1003
1004         if (ob == dialog_->button_add)
1005                 return Add();
1006
1007         if (ob == dialog_->button_delete)
1008                 return erase();
1009
1010         return true;
1011 }
1012
1013
1014 void FormPreferences::Converters::update()
1015 {
1016         local_converters = converters;
1017         local_converters.update(local_formats);
1018         UpdateBrowser();
1019 }
1020
1021
1022 void FormPreferences::Converters::UpdateBrowser()
1023 {
1024         local_converters.sort();
1025
1026         fl_freeze_form(dialog_->form);
1027         fl_clear_browser(dialog_->browser_all);
1028         for (::Converters::const_iterator cit = local_converters.begin();
1029              cit != local_converters.end(); ++cit) {
1030                 string const name = cit->From->prettyname() + " -> "
1031                         + cit->To->prettyname();
1032                 fl_addto_browser(dialog_->browser_all, name.c_str());
1033         }
1034         Input();
1035         fl_unfreeze_form(dialog_->form);
1036 }
1037
1038
1039 bool FormPreferences::Converters::Add()
1040 {
1041         string const from = GetFrom();
1042         string const to = GetTo();
1043         string const command = fl_get_input(dialog_->input_converter);
1044         string const flags = fl_get_input(dialog_->input_flags);
1045
1046         Converter const * old = local_converters.getConverter(from, to);
1047         local_converters.add(from, to, command, flags);
1048         if (!old) {
1049                 local_converters.updateLast(local_formats);
1050                 UpdateBrowser();
1051         }
1052         setEnabled(dialog_->button_add, false);
1053
1054         return true;
1055 }
1056
1057
1058 bool FormPreferences::Converters::Browser()
1059 {
1060         int const i = fl_get_browser(dialog_->browser_all);
1061         if (i <= 0) return false;
1062
1063         fl_freeze_form(dialog_->form);
1064
1065         Converter const & c = local_converters.get(i - 1);
1066         int j = local_formats.getNumber(c.from);
1067         if (j >= 0)
1068                 fl_set_choice(dialog_->choice_from, j + 1);
1069
1070         j = local_formats.getNumber(c.to);
1071         if (j >= 0)
1072                 fl_set_choice(dialog_->choice_to, j + 1);
1073
1074         fl_set_input(dialog_->input_converter, c.command.c_str());
1075         fl_set_input(dialog_->input_flags, c.flags.c_str());
1076
1077         fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
1078         fl_set_button_shortcut(dialog_->button_add,
1079                                scex(_("Modify|#M")).c_str(), 1);
1080
1081         setEnabled(dialog_->button_add,    false);
1082         setEnabled(dialog_->button_delete, true);
1083
1084         fl_unfreeze_form(dialog_->form);
1085         return false;
1086 }
1087
1088
1089 bool FormPreferences::Converters::erase()
1090 {
1091         string const from = GetFrom();
1092         string const to = GetTo();
1093
1094         local_converters.erase(from, to);
1095         UpdateBrowser();
1096         return true;
1097 }
1098
1099
1100 bool FormPreferences::Converters::Input()
1101 {
1102         string const from = GetFrom();
1103         string const to = GetTo();
1104         int const sel = local_converters.getNumber(from, to);
1105
1106         fl_freeze_form(dialog_->form);
1107
1108         if (sel < 0) {
1109                 fl_set_object_label(dialog_->button_add,
1110                                     idex(_("Add|#A")).c_str());
1111                 fl_set_button_shortcut(dialog_->button_add,
1112                                        scex(_("Add|#A")).c_str(), 1);
1113
1114                 fl_deselect_browser(dialog_->browser_all);
1115                 setEnabled(dialog_->button_delete, false);
1116
1117         } else {
1118                 fl_set_object_label(dialog_->button_add,
1119                                     idex(_("Modify|#M")).c_str());
1120                 fl_set_button_shortcut(dialog_->button_add,
1121                                        scex(_("Modify|#M")).c_str(), 1);
1122
1123                 int top = max(sel-5, 0);
1124                 fl_set_browser_topline(dialog_->browser_all, top);
1125                 fl_select_browser_line(dialog_->browser_all, sel+1);
1126                 setEnabled(dialog_->button_delete, true);
1127         }
1128
1129         string const command = rtrim(fl_get_input(dialog_->input_converter));
1130         bool const enable = !(command.empty() || from == to);
1131         setEnabled(dialog_->button_add, enable);
1132
1133         fl_unfreeze_form(dialog_->form);
1134         return false;
1135 }
1136
1137
1138 string const FormPreferences::Converters::GetFrom() const
1139 {
1140         ::Formats::FormatList::size_type const i =
1141                   fl_get_choice(dialog_->choice_from);
1142
1143         if (i > 0 && i <= local_formats.size())
1144                 return local_formats.get(i - 1).name();
1145
1146         lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1147         return "???";
1148 }
1149
1150
1151 string const FormPreferences::Converters::GetTo() const
1152 {
1153         ::Formats::FormatList::size_type const i =
1154                   fl_get_choice(dialog_->choice_to);
1155
1156         if (i > 0 && i <= local_formats.size())
1157                 return local_formats.get(i - 1).name();
1158
1159         lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1160         return "???";
1161 }
1162
1163
1164 void FormPreferences::Converters::UpdateChoices() const
1165 {
1166         string choice;
1167         for (::Formats::const_iterator cit = local_formats.begin();
1168              cit != local_formats.end(); ++cit) {
1169                 if (!choice.empty())
1170                         choice += " | ";
1171                 else
1172                         choice += ' ';
1173                 choice += cit->prettyname();
1174         }
1175         choice += ' ';
1176
1177         fl_clear_choice(dialog_->choice_from);
1178         fl_addto_choice(dialog_->choice_from, choice.c_str());
1179
1180         fl_clear_choice(dialog_->choice_to);
1181         fl_addto_choice(dialog_->choice_to, choice.c_str());
1182 }
1183
1184
1185 FormPreferences::Formats::Formats(FormPreferences &  p)
1186         : parent_(p)
1187 {}
1188
1189
1190 FD_preferences_formats const * FormPreferences::Formats::dialog()
1191 {
1192         return dialog_.get();
1193 }
1194
1195
1196 void FormPreferences::Formats::apply() const
1197 {
1198         parent_.controller().setFormats(local_formats);
1199 }
1200
1201
1202 void FormPreferences::Formats::build()
1203 {
1204         dialog_.reset(build_preferences_formats(&parent_));
1205
1206         fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1207         fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1208         fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1209         fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1210         fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1211
1212         fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1213
1214         // set up the feedback mechanism
1215         setPrehandler(dialog_->browser_all);
1216         setPrehandler(dialog_->input_format);
1217         setPrehandler(dialog_->input_gui_name);
1218         setPrehandler(dialog_->button_delete);
1219         setPrehandler(dialog_->button_add);
1220         setPrehandler(dialog_->input_extension);
1221         setPrehandler(dialog_->input_viewer);
1222         setPrehandler(dialog_->input_shrtcut);
1223 }
1224
1225
1226 string const
1227 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1228 {
1229         if (ob == dialog_->browser_all)
1230                 return  _("All the currently defined formats known to LyX.");
1231
1232         if (ob == dialog_->input_format)
1233                 return  _("The format identifier.");
1234
1235         if (ob == dialog_->input_gui_name)
1236                 return  _("The format name as it will appear in the menus.");
1237
1238         if (ob == dialog_->input_shrtcut)
1239                 return  _("The keyboard accelerator. Use a letter in the GUI name. "
1240                           "Case sensitive.");
1241
1242         if (ob == dialog_->input_extension)
1243                 return  _("Used to recognize the file. E.g., ps, pdf, tex.");
1244
1245         if (ob == dialog_->input_viewer)
1246                 return  _("The command used to launch the viewer application.");
1247
1248         if (ob == dialog_->button_delete)
1249                 return  _("Remove the current format from the list of available "
1250                           "formats. Note: you must then \"Apply\" the change.");
1251
1252         if (ob == dialog_->button_add) {
1253                 if (string(ob->label) == _("Add"))
1254                         return  _("Add the current format to the list of available "
1255                                   "formats. Note: you must then \"Apply\" the change.");
1256                 else
1257                         return  _("Modify the contents of the current format. Note: "
1258                                   "you must then \"Apply\" the change.");
1259         }
1260
1261         return string();
1262 }
1263
1264
1265 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1266 {
1267         if (ob == dialog_->browser_all)
1268                 return Browser();
1269
1270         if (ob == dialog_->input_format
1271             || ob == dialog_->input_gui_name
1272             || ob == dialog_->input_shrtcut
1273             || ob == dialog_->input_extension
1274             || ob == dialog_->input_viewer)
1275                 return Input();
1276
1277         if (ob == dialog_->button_add)
1278                 return Add();
1279
1280         if (ob == dialog_->button_delete)
1281                 return erase();
1282
1283         return false;
1284 }
1285
1286
1287 void FormPreferences::Formats::update()
1288 {
1289         local_formats = formats;
1290         UpdateBrowser();
1291 }
1292
1293
1294 void FormPreferences::Formats::UpdateBrowser()
1295 {
1296         local_formats.sort();
1297
1298         fl_freeze_form(dialog_->form);
1299         fl_deselect_browser(dialog_->browser_all);
1300         fl_clear_browser(dialog_->browser_all);
1301         for (::Formats::const_iterator cit = local_formats.begin();
1302              cit != local_formats.end(); ++cit)
1303                 fl_addto_browser(dialog_->browser_all,
1304                                  cit->prettyname().c_str());
1305
1306         Input();
1307         fl_unfreeze_form(dialog_->form);
1308
1309         // Mustn't forget to update the Formats available to the converters_
1310         parent_.converters_.UpdateChoices();
1311         local_converters.update(local_formats);
1312 }
1313
1314
1315 bool FormPreferences::Formats::Add()
1316 {
1317         string const name = fl_get_input(dialog_->input_format);
1318         string const prettyname = fl_get_input(dialog_->input_gui_name);
1319         string const extension = fl_get_input(dialog_->input_extension);
1320         string const shortcut =  fl_get_input(dialog_->input_shrtcut);
1321         string const viewer =  fl_get_input(dialog_->input_viewer);
1322
1323         Format const * old = local_formats.getFormat(name);
1324         string const old_prettyname = old ? old->prettyname() : string();
1325         local_formats.add(name, extension, prettyname, shortcut);
1326         local_formats.setViewer(name, viewer);
1327         if (!old || prettyname != old_prettyname) {
1328                 UpdateBrowser();
1329                 if (old)
1330                         parent_.converters_.UpdateBrowser();
1331         }
1332         setEnabled(dialog_->button_add, false);
1333
1334         return true;
1335 }
1336
1337
1338 bool FormPreferences::Formats::Browser()
1339 {
1340         int const i = fl_get_browser(dialog_->browser_all);
1341         if (i <= 0)
1342                 return false;
1343
1344         fl_freeze_form(dialog_->form);
1345
1346         Format const & f = local_formats.get(i - 1);
1347
1348         fl_set_input(dialog_->input_format, f.name().c_str());
1349         fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1350         fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1351         fl_set_input(dialog_->input_extension, f.extension().c_str());
1352         fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1353
1354         fl_set_object_label(dialog_->button_add,
1355                             idex(_("Modify|#M")).c_str());
1356         fl_set_button_shortcut(dialog_->button_add,
1357                                scex(_("Modify|#M")).c_str(), 1);
1358
1359         setEnabled(dialog_->button_add,    false);
1360         setEnabled(dialog_->button_delete, true);
1361
1362         fl_unfreeze_form(dialog_->form);
1363         return false;
1364 }
1365
1366
1367 bool FormPreferences::Formats::erase()
1368 {
1369         string const name = fl_get_input(dialog_->input_format);
1370
1371         if (local_converters.formatIsUsed(name)) {
1372                 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1373                                       "Remove the converter first."));
1374                 setEnabled(dialog_->button_delete, false);
1375                 return false;
1376         }
1377
1378         local_formats.erase(name);
1379         UpdateBrowser();
1380         return true;
1381 }
1382
1383
1384 bool FormPreferences::Formats::Input()
1385 {
1386         string const name = fl_get_input(dialog_->input_format);
1387         int const sel = local_formats.getNumber(name);
1388         fl_freeze_form(dialog_->form);
1389
1390         if (sel < 0) {
1391                 fl_set_object_label(dialog_->button_add,
1392                                     idex(_("Add|#A")).c_str());
1393                 fl_set_button_shortcut(dialog_->button_add,
1394                                        scex(_("Add|#A")).c_str(), 1);
1395
1396                 fl_deselect_browser(dialog_->browser_all);
1397                 setEnabled(dialog_->button_delete, false);
1398
1399         } else {
1400                 fl_set_object_label(dialog_->button_add,
1401                                     idex(_("Modify|#M")).c_str());
1402                 fl_set_button_shortcut(dialog_->button_add,
1403                                        scex(_("Modify|#M")).c_str(), 1);
1404
1405                 int const top = max(sel-5, 0);
1406                 fl_set_browser_topline(dialog_->browser_all, top);
1407                 fl_select_browser_line(dialog_->browser_all, sel+1);
1408
1409                 setEnabled(dialog_->button_add, true);
1410                 setEnabled(dialog_->button_delete, true);
1411         }
1412
1413         string const prettyname = fl_get_input(dialog_->input_gui_name);
1414         bool const enable = !(name.empty() || prettyname.empty());
1415         setEnabled(dialog_->button_add, enable);
1416
1417         fl_unfreeze_form(dialog_->form);
1418         return false;
1419 }
1420
1421
1422 FormPreferences::Identity::Identity(FormPreferences & p)
1423         : parent_(p)
1424 {}
1425
1426
1427 FD_preferences_identity const * FormPreferences::Identity::dialog()
1428 {
1429         return dialog_.get();
1430 }
1431
1432
1433 void FormPreferences::Identity::apply(LyXRC & rc) const
1434 {
1435         rc.user_name = fl_get_input(dialog_->input_user_name);
1436         rc.user_email = fl_get_input(dialog_->input_user_email);
1437 }
1438
1439
1440 void FormPreferences::Identity::build()
1441 {
1442         dialog_.reset(build_preferences_identity(&parent_));
1443         fl_set_input_return(dialog_->input_user_name, FL_RETURN_CHANGED);
1444         fl_set_input_return(dialog_->input_user_email, FL_RETURN_CHANGED);
1445 }
1446
1447
1448 void FormPreferences::Identity::update(LyXRC const & rc)
1449 {
1450         fl_set_input(dialog_->input_user_name, rc.user_name.c_str());
1451         fl_set_input(dialog_->input_user_email, rc.user_email.c_str());
1452 }
1453
1454
1455 FormPreferences::InputsMisc::InputsMisc(FormPreferences &  p)
1456         : parent_(p)
1457 {}
1458
1459
1460 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1461 {
1462         return dialog_.get();
1463 }
1464
1465
1466 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1467 {
1468         rc.date_insert_format =
1469                 fl_get_input(dialog_->input_date_format);
1470 }
1471
1472
1473 void FormPreferences::InputsMisc::build()
1474 {
1475         dialog_.reset(build_preferences_inputs_misc(&parent_));
1476
1477         fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1478
1479         // set up the feedback mechanism
1480         setPrehandler(dialog_->input_date_format);
1481 }
1482
1483
1484 string const
1485 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1486 {
1487         if (ob == dialog_->input_date_format)
1488                 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1489         return string();
1490 }
1491
1492
1493 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1494 {
1495         fl_set_input(dialog_->input_date_format,
1496                      rc.date_insert_format.c_str());
1497 }
1498
1499
1500 FormPreferences::Interface::Interface(FormPreferences &  p)
1501         : parent_(p)
1502 {}
1503
1504
1505 FD_preferences_interface const * FormPreferences::Interface::dialog()
1506 {
1507         return dialog_.get();
1508 }
1509
1510
1511 void FormPreferences::Interface::apply(LyXRC & rc) const
1512 {
1513         rc.popup_normal_font =
1514                 fl_get_input(dialog_->input_popup_normal_font);
1515         rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1516         rc.popup_font_encoding =
1517                 fl_get_input(dialog_->input_popup_font_encoding);
1518         rc.bind_file = fl_get_input(dialog_->input_bind_file);
1519         rc.ui_file = fl_get_input(dialog_->input_ui_file);
1520 }
1521
1522
1523 void FormPreferences::Interface::build()
1524 {
1525         dialog_.reset(build_preferences_interface(&parent_));
1526
1527         fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1528         fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1529         fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1530         fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1531         fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1532
1533         // set up the feedback mechanism
1534         setPrehandler(dialog_->input_popup_normal_font);
1535         setPrehandler(dialog_->input_popup_bold_font);
1536         setPrehandler(dialog_->input_popup_font_encoding);
1537         setPrehandler(dialog_->input_bind_file);
1538         setPrehandler(dialog_->button_bind_file_browse);
1539         setPrehandler(dialog_->input_ui_file);
1540         setPrehandler(dialog_->button_ui_file_browse);
1541 }
1542
1543
1544 string const
1545 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1546 {
1547         if (ob == dialog_->input_popup_normal_font)
1548                 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1549         if (ob == dialog_->input_popup_bold_font)
1550                 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1551         if (ob == dialog_->input_popup_font_encoding)
1552                 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1553         if (ob == dialog_->input_bind_file)
1554                 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1555         if (ob == dialog_->input_ui_file)
1556                 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1557         return string();
1558 }
1559
1560
1561 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1562 {
1563         if (ob == dialog_->button_bind_file_browse) {
1564                 string f = parent_.controller().browsebind(
1565                         fl_get_input(dialog_->input_bind_file));
1566
1567                 fl_set_input(dialog_->input_bind_file, f.c_str());
1568         } else if (ob == dialog_->button_ui_file_browse) {
1569                 string f = parent_.controller().browseUI(
1570                         fl_get_input(dialog_->input_ui_file));
1571
1572                 fl_set_input(dialog_->input_ui_file, f.c_str());
1573         }
1574
1575         return true;
1576 }
1577
1578
1579 void FormPreferences::Interface::update(LyXRC const & rc)
1580 {
1581         fl_set_input(dialog_->input_popup_normal_font,
1582                      rc.popup_normal_font.c_str());
1583         fl_set_input(dialog_->input_popup_bold_font,
1584                      rc.popup_bold_font.c_str());
1585         fl_set_input(dialog_->input_popup_font_encoding,
1586                      rc.popup_font_encoding.c_str());
1587         fl_set_input(dialog_->input_bind_file,
1588                      rc.bind_file.c_str());
1589         fl_set_input(dialog_->input_ui_file,
1590                      rc.ui_file.c_str());
1591 }
1592
1593
1594 FormPreferences::Language::Language(FormPreferences &  p)
1595         : parent_(p)
1596 {}
1597
1598
1599 FD_preferences_language const * FormPreferences::Language::dialog()
1600 {
1601         return dialog_.get();
1602 }
1603
1604
1605 void FormPreferences::Language::apply(LyXRC & rc)
1606 {
1607         int const pos = fl_get_combox(dialog_->combox_default_lang);
1608         rc.default_language = lang_[pos-1];
1609
1610         int button = fl_get_button(dialog_->check_use_kbmap);
1611         string const name_1 = fl_get_input(dialog_->input_kbmap1);
1612         string const name_2 = fl_get_input(dialog_->input_kbmap2);
1613         if (button)
1614                 button = !(name_1.empty() && name_2.empty());
1615         rc.use_kbmap = static_cast<bool>(button);
1616
1617         if (rc.use_kbmap) {
1618                 rc.primary_kbmap = name_1;
1619                 rc.secondary_kbmap = name_2;
1620         }
1621
1622         button = fl_get_button(dialog_->check_rtl_support);
1623         rc.rtl_support = static_cast<bool>(button);
1624
1625         button = fl_get_button(dialog_->check_mark_foreign);
1626         rc.mark_foreign_language = static_cast<bool>(button);
1627
1628         button = fl_get_button(dialog_->check_auto_begin);
1629         rc.language_auto_begin = static_cast<bool>(button);
1630
1631         button = fl_get_button(dialog_->check_auto_end);
1632         rc.language_auto_end = static_cast<bool>(button);
1633
1634         button = fl_get_button(dialog_->check_use_babel);
1635         rc.language_use_babel = static_cast<bool>(button);
1636
1637         button = fl_get_button(dialog_->check_global_options);
1638         rc.language_global_options = static_cast<bool>(button);
1639
1640         rc.language_package = fl_get_input(dialog_->input_package);
1641         rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1642         rc.language_command_end = fl_get_input(dialog_->input_command_end);
1643
1644         // Ensure that all is self-consistent.
1645         update(rc);
1646 }
1647
1648
1649 void FormPreferences::Language::build()
1650 {
1651         dialog_.reset(build_preferences_language(&parent_));
1652
1653         fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1654         fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1655         fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1656
1657         // Store the lang identifiers for later
1658         vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1659         lang_ = getSecond(langs);
1660
1661         FL_OBJECT * obj = dialog_->combox_default_lang;
1662         vector<frnt::LanguagePair>::const_iterator lit  = langs.begin();
1663         vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1664         for (; lit != lend; ++lit) {
1665                 fl_addto_combox(obj, lit->first.c_str());
1666         }
1667         fl_set_combox_browser_height(obj, 400);
1668
1669         // set up the feedback mechanism
1670         setPrehandler(dialog_->input_package);
1671         setPrehandler(dialog_->check_use_kbmap);
1672         setPrehandler(dialog_->combox_default_lang);
1673         setPrehandler(dialog_->input_kbmap1);
1674         setPrehandler(dialog_->input_kbmap2);
1675         setPrehandler(dialog_->check_rtl_support);
1676         setPrehandler(dialog_->check_mark_foreign);
1677         setPrehandler(dialog_->check_auto_begin);
1678         setPrehandler(dialog_->check_auto_end);
1679         setPrehandler(dialog_->check_use_babel);
1680         setPrehandler(dialog_->check_global_options);
1681         setPrehandler(dialog_->input_command_begin);
1682         setPrehandler(dialog_->input_command_end);
1683
1684         // Activate/Deactivate the input fields dependent on the state of the
1685         // buttons.
1686         input(0);
1687 }
1688
1689
1690 string const
1691 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1692 {
1693         if (ob == dialog_->combox_default_lang)
1694                 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1695         if (ob == dialog_->check_use_kbmap)
1696                 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1697         if (ob == dialog_->input_kbmap1)
1698                 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1699         if (ob == dialog_->input_kbmap2)
1700                 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1701         if (ob == dialog_->check_rtl_support)
1702                 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1703         if (ob == dialog_->check_mark_foreign)
1704                 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1705         if (ob == dialog_->check_auto_begin)
1706                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1707         if (ob == dialog_->check_auto_end)
1708                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1709         if (ob == dialog_->check_use_babel)
1710                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1711         if (ob == dialog_->check_global_options)
1712                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1713         if (ob == dialog_->input_package)
1714                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1715         if (ob == dialog_->input_command_begin)
1716                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1717         if (ob == dialog_->input_command_end)
1718                 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1719         return string();
1720 }
1721
1722
1723 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1724 {
1725         bool activate = true;
1726
1727         // !ob if function is called from Language::build() to de/activate
1728         // objects,
1729         // otherwise the function is called by an xforms CB via input().
1730         if (!ob || ob == dialog_->check_use_kbmap) {
1731                 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1732                 setEnabled(dialog_->button_kbmap1_browse, enable);
1733                 setEnabled(dialog_->button_kbmap2_browse, enable);
1734                 setEnabled(dialog_->input_kbmap1, enable);
1735                 setEnabled(dialog_->input_kbmap2, enable);
1736         }
1737
1738         if (ob == dialog_->button_kbmap1_browse) {
1739                 string f = parent_.controller().browsekbmap(
1740                         fl_get_input(dialog_->input_kbmap1));
1741
1742                 fl_set_input(dialog_->input_kbmap1, f.c_str());
1743         } else if (ob == dialog_->button_kbmap2_browse) {
1744                 string f = parent_.controller().browsekbmap(
1745                         fl_get_input(dialog_->input_kbmap2));
1746
1747                 fl_set_input(dialog_->input_kbmap2, f.c_str());
1748         }
1749
1750         return activate;
1751 }
1752
1753
1754 void FormPreferences::Language::update(LyXRC const & rc)
1755 {
1756         fl_set_button(dialog_->check_use_kbmap,
1757                       rc.use_kbmap);
1758
1759         int const pos = int(findPos(lang_, rc.default_language));
1760         fl_set_combox(dialog_->combox_default_lang, pos + 1);
1761
1762         if (rc.use_kbmap) {
1763                 fl_set_input(dialog_->input_kbmap1,
1764                              rc.primary_kbmap.c_str());
1765                 fl_set_input(dialog_->input_kbmap2,
1766                              rc.secondary_kbmap.c_str());
1767         } else {
1768                 fl_set_input(dialog_->input_kbmap1, "");
1769                 fl_set_input(dialog_->input_kbmap2, "");
1770         }
1771
1772         fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1773         fl_set_button(dialog_->check_mark_foreign,
1774                       rc.mark_foreign_language);
1775         fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1776         fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1777         fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1778         fl_set_button(dialog_->check_global_options,
1779                       rc.language_global_options);
1780
1781         fl_set_input(dialog_->input_package,
1782                      rc.language_package.c_str());
1783         fl_set_input(dialog_->input_command_begin,
1784                      rc.language_command_begin.c_str());
1785         fl_set_input(dialog_->input_command_end,
1786                      rc.language_command_end.c_str());
1787
1788         // Activate/Deactivate the input fields dependent on the state of the
1789         // buttons.
1790         input(0);
1791 }
1792
1793
1794 FormPreferences::LnFmisc::LnFmisc(FormPreferences &  p)
1795         : parent_(p)
1796 {}
1797
1798
1799 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1800 {
1801         return dialog_.get();
1802 }
1803
1804
1805 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1806 {
1807         rc.auto_region_delete =
1808                 fl_get_button(dialog_->check_auto_region_delete);
1809         rc.cursor_follows_scrollbar =
1810                 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1811         rc.dialogs_iconify_with_main =
1812                 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1813         rc.preview = fl_get_button(dialog_->check_preview_latex);
1814         rc.autosave = static_cast<unsigned int>
1815                 (fl_get_counter_value(dialog_->counter_autosave));
1816         rc.wheel_jump = static_cast<unsigned int>
1817                 (fl_get_counter_value(dialog_->counter_wm_jump));
1818
1819         // See FIXME below
1820         // grfx::DisplayType old_value = rc.display_graphics;
1821         switch (fl_get_choice(dialog_->choice_display)) {
1822         case 4:
1823                 rc.display_graphics = grfx::NoDisplay;
1824                 break;
1825         case 3:
1826                 rc.display_graphics = grfx::ColorDisplay;
1827                 break;
1828         case 2:
1829                 rc.display_graphics = grfx::GrayscaleDisplay;
1830                 break;
1831         case 1:
1832                 rc.display_graphics = grfx::MonochromeDisplay;
1833                 break;
1834         default:
1835                 rc.display_graphics = grfx::ColorDisplay;
1836                 break;
1837         }
1838
1839 #ifdef WITH_WARNINGS
1840 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1841 #endif
1842 #if 0
1843         if (old_value != rc.display_graphics) {
1844                 grfx::GCache & gc = grfx::GCache::get();
1845                 gc.changeDisplay();
1846         }
1847 #endif
1848 }
1849
1850
1851 void FormPreferences::LnFmisc::build()
1852 {
1853         dialog_.reset(build_preferences_lnf_misc(&parent_));
1854
1855         fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1856         fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1857
1858         fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1859         fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1860
1861         // set up the feedback mechanism
1862         setPrehandler(dialog_->check_auto_region_delete);
1863         setPrehandler(dialog_->counter_autosave);
1864         setPrehandler(dialog_->check_cursor_follows_scrollbar);
1865         setPrehandler(dialog_->check_dialogs_iconify_with_main);
1866         setPrehandler(dialog_->check_preview_latex);
1867         setPrehandler(dialog_->counter_wm_jump);
1868
1869         fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
1870 }
1871
1872
1873 string const
1874 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1875 {
1876         if (ob == dialog_->check_auto_region_delete)
1877                 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
1878         if (ob == dialog_->check_cursor_follows_scrollbar)
1879                 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1880         if (ob == dialog_->check_dialogs_iconify_with_main)
1881                 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1882         if (ob == dialog_->check_preview_latex)
1883                 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
1884         if (ob == dialog_->counter_autosave)
1885                 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
1886         if (ob == dialog_->counter_wm_jump)
1887                 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
1888         if (ob == dialog_->choice_display)
1889                 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1890         return string();
1891 }
1892
1893
1894 void FormPreferences::LnFmisc::update(LyXRC const & rc)
1895 {
1896         fl_set_button(dialog_->check_auto_region_delete,
1897                       rc.auto_region_delete);
1898         fl_set_button(dialog_->check_cursor_follows_scrollbar,
1899                       rc.cursor_follows_scrollbar);
1900         fl_set_button(dialog_->check_dialogs_iconify_with_main,
1901                       rc.dialogs_iconify_with_main);
1902         fl_set_button(dialog_->check_preview_latex,
1903                       rc.preview);
1904         fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
1905         fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
1906
1907         switch (rc.display_graphics) {
1908         case grfx::NoDisplay:
1909                 fl_set_choice(dialog_->choice_display, 4);
1910                 break;
1911         case grfx::ColorDisplay:
1912                 fl_set_choice(dialog_->choice_display, 3);
1913                 break;
1914         case grfx::GrayscaleDisplay:
1915                 fl_set_choice(dialog_->choice_display, 2);
1916                 break;
1917         case grfx::MonochromeDisplay:
1918                 fl_set_choice(dialog_->choice_display, 1);
1919                 break;
1920         default:
1921                 fl_set_choice(dialog_->choice_display, 3);
1922                 break;
1923         }
1924 }
1925
1926
1927 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences &  p)
1928         : parent_(p)
1929 {}
1930
1931
1932 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1933 {
1934         return dialog_.get();
1935 }
1936
1937
1938 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
1939 {
1940         rc.ascii_linelen = static_cast<unsigned int>
1941                 (fl_get_counter_value(dialog_->counter_line_len));
1942         rc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1943
1944         int const choice =
1945                 fl_get_choice(dialog_->choice_default_papersize) - 1;
1946         rc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1947
1948         rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1949         rc.chktex_command = fl_get_input(dialog_->input_checktex);
1950         rc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1951         rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1952 }
1953
1954
1955 void FormPreferences::OutputsMisc::build()
1956 {
1957         dialog_.reset(build_preferences_outputs_misc(&parent_));
1958
1959         fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1960
1961         fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1962         fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1963         fl_set_input_return(dialog_->input_ascii_roff,   FL_RETURN_CHANGED);
1964         fl_set_input_return(dialog_->input_checktex,     FL_RETURN_CHANGED);
1965         fl_set_input_return(dialog_->input_paperoption,  FL_RETURN_CHANGED);
1966
1967         fl_addto_choice(dialog_->choice_default_papersize,
1968                         _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1969
1970         // set up the feedback mechanism
1971         setPrehandler(dialog_->counter_line_len);
1972         setPrehandler(dialog_->input_tex_encoding);
1973         setPrehandler(dialog_->choice_default_papersize);
1974         setPrehandler(dialog_->input_ascii_roff);
1975         setPrehandler(dialog_->input_checktex);
1976         setPrehandler(dialog_->input_paperoption);
1977         setPrehandler(dialog_->check_autoreset_classopt);
1978 }
1979
1980
1981 string const
1982 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1983 {
1984         if (ob == dialog_->counter_line_len)
1985                 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
1986         if (ob == dialog_->input_tex_encoding)
1987                 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
1988         if (ob == dialog_->input_ascii_roff)
1989                 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1990         if (ob == dialog_->input_checktex)
1991                 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
1992         if (ob == dialog_->choice_default_papersize)
1993                 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1994         if (ob == dialog_->input_paperoption)
1995                 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
1996         if (ob == dialog_->check_autoreset_classopt)
1997                 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
1998         return string();
1999 }
2000
2001
2002 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
2003 {
2004         fl_set_counter_value(dialog_->counter_line_len,
2005                              rc.ascii_linelen);
2006         fl_set_input(dialog_->input_tex_encoding,
2007                      rc.fontenc.c_str());
2008         fl_set_choice(dialog_->choice_default_papersize,
2009                       rc.default_papersize + 1);
2010         fl_set_input(dialog_->input_ascii_roff,
2011                      rc.ascii_roff_command.c_str());
2012         fl_set_input(dialog_->input_checktex,
2013                      rc.chktex_command.c_str());
2014         fl_set_input(dialog_->input_paperoption,
2015                      rc.view_dvi_paper_option.c_str());
2016         fl_set_button(dialog_->check_autoreset_classopt,
2017                       rc.auto_reset_options);
2018
2019 }
2020
2021
2022 FormPreferences::Paths::Paths(FormPreferences &  p)
2023         : parent_(p)
2024 {}
2025
2026
2027 FD_preferences_paths const * FormPreferences::Paths::dialog()
2028 {
2029         return dialog_.get();
2030 }
2031
2032
2033 void FormPreferences::Paths::apply(LyXRC & rc)
2034 {
2035         rc.document_path = fl_get_input(dialog_->input_default_path);
2036         rc.template_path = fl_get_input(dialog_->input_template_path);
2037
2038         int button = fl_get_button(dialog_->check_use_temp_dir);
2039         string str  = fl_get_input(dialog_->input_temp_dir);
2040         if (!button)
2041                 str.erase();
2042
2043         rc.use_tempdir = button;
2044         rc.tempdir_path = str;
2045
2046         button = fl_get_button(dialog_->check_last_files);
2047         str = fl_get_input(dialog_->input_lastfiles);
2048         if (!button) str.erase();
2049
2050         rc.check_lastfiles = button;
2051         rc.lastfiles = str;
2052         rc.num_lastfiles = static_cast<unsigned int>
2053                 (fl_get_counter_value(dialog_->counter_lastfiles));
2054
2055         button = fl_get_button(dialog_->check_make_backups);
2056         str = fl_get_input(dialog_->input_backup_path);
2057         if (!button)
2058                 str.erase();
2059
2060         rc.make_backup = button;
2061         rc.backupdir_path = str;
2062
2063         rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2064
2065         // update view
2066         update(rc);
2067 }
2068
2069
2070 void FormPreferences::Paths::build()
2071 {
2072         dialog_.reset(build_preferences_paths(&parent_));
2073
2074         fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2075         fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2076         fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2077         fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2078         fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2079         fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2080         fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2081
2082         // set up the feedback mechanism
2083         setPrehandler(dialog_->input_default_path);
2084         setPrehandler(dialog_->counter_lastfiles);
2085         setPrehandler(dialog_->input_template_path);
2086         setPrehandler(dialog_->check_last_files);
2087         setPrehandler(dialog_->input_lastfiles);
2088         setPrehandler(dialog_->check_make_backups);
2089         setPrehandler(dialog_->input_backup_path);
2090         setPrehandler(dialog_->input_serverpipe);
2091         setPrehandler(dialog_->input_temp_dir);
2092         setPrehandler(dialog_->check_use_temp_dir);
2093 }
2094
2095
2096 string const
2097 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2098 {
2099         if (ob == dialog_->input_default_path)
2100                 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2101         if (ob == dialog_->input_template_path)
2102                 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2103         if (ob == dialog_->check_use_temp_dir)
2104                 return LyXRC::getDescription(LyXRC::RC_USETEMPDIR);
2105         if (ob == dialog_->input_temp_dir)
2106                 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2107         if (ob == dialog_->check_last_files)
2108                 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2109         if (ob == dialog_->input_lastfiles)
2110                 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
2111         if (ob == dialog_->counter_lastfiles)
2112                 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2113         if (ob == dialog_->check_make_backups)
2114                 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2115         if (ob == dialog_->input_backup_path)
2116                 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2117         if (ob == dialog_->input_serverpipe)
2118                 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2119         return string();
2120 }
2121
2122
2123 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2124 {
2125         bool activate = true;
2126
2127         // !ob if function is called from Paths::update() to de/activate
2128         // objects,
2129         // otherwise the function is called by an xforms CB via input().
2130         if (!ob || ob == dialog_->check_use_temp_dir) {
2131                 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2132                 setEnabled(dialog_->input_temp_dir, enable);
2133         }
2134
2135         if (!ob || ob == dialog_->check_last_files) {
2136                 bool const enable = fl_get_button(dialog_->check_last_files);
2137                 setEnabled(dialog_->input_lastfiles, enable);
2138         }
2139
2140         if (!ob || ob == dialog_->check_make_backups) {
2141                 bool const enable = fl_get_button(dialog_->check_make_backups);
2142                 setEnabled(dialog_->input_backup_path, enable);
2143         }
2144
2145         if (!ob || ob == dialog_->input_default_path) {
2146                 string const name = fl_get_input(dialog_->input_default_path);
2147                 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2148                         parent_.postWarning(RWInfo::ErrorMessage());
2149                         return false;
2150                 }
2151         }
2152
2153         if (!ob || ob == dialog_->input_template_path) {
2154                 string const name = fl_get_input(dialog_->input_template_path);
2155                 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2156                         parent_.postWarning(RWInfo::ErrorMessage());
2157                         return false;
2158                 }
2159         }
2160
2161         if (!ob || ob == dialog_->input_temp_dir) {
2162                 string const name = fl_get_input(dialog_->input_temp_dir);
2163                 if (fl_get_button(dialog_->check_make_backups)
2164                     && !name.empty()
2165                     && !RWInfo::WriteableDir(name)) {
2166                         parent_.postWarning(RWInfo::ErrorMessage());
2167                         return false;
2168                 }
2169         }
2170
2171         if (!ob || ob == dialog_->input_backup_path) {
2172                 string const name = fl_get_input(dialog_->input_backup_path);
2173                 if (fl_get_button(dialog_->check_make_backups)
2174                     && !name.empty()
2175                     && !RWInfo::WriteableDir(name)) {
2176                         parent_.postWarning(RWInfo::ErrorMessage());
2177                         return false;
2178                 }
2179         }
2180
2181         if (!ob || ob == dialog_->input_lastfiles) {
2182                 string const name = fl_get_input(dialog_->input_lastfiles);
2183                 if (fl_get_button(dialog_->check_last_files)
2184                     && !name.empty()
2185                     && !RWInfo::WriteableFile(name)) {
2186                         parent_.postWarning(RWInfo::ErrorMessage());
2187                         return false;
2188                 }
2189         }
2190
2191         if (!ob || ob == dialog_->input_serverpipe) {
2192                 string const name = fl_get_input(dialog_->input_serverpipe);
2193                 if (!name.empty()) {
2194                         // strip off the extension
2195                         string const str = ChangeExtension(name, "");
2196                         if (!RWInfo::WriteableFile(str + ".in")) {
2197                                 parent_.postWarning(RWInfo::ErrorMessage());
2198                                 return false;
2199                         }
2200                         if (!RWInfo::WriteableFile(str + ".out")) {
2201                                 parent_.postWarning(RWInfo::ErrorMessage());
2202                                 return false;
2203                         }
2204                 }
2205         }
2206
2207         if (ob == dialog_->button_default_path_browse) {
2208                 string f = parent_.controller().browsedir(
2209                         fl_get_input(dialog_->input_default_path), _("Default path"));
2210                 if (!f.empty())
2211                         fl_set_input(dialog_->input_default_path, f.c_str());
2212         } else if (ob == dialog_->button_template_path_browse) {
2213                 string f = parent_.controller().browsedir(
2214                         fl_get_input(dialog_->input_template_path), _("Template path"));
2215                 if (!f.empty())
2216                         fl_set_input(dialog_->input_template_path, f.c_str());
2217         } else if (ob == dialog_->button_temp_dir_browse) {
2218                 string f = parent_.controller().browsedir(
2219                         fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2220                 if (!f.empty())
2221                         fl_set_input(dialog_->input_temp_dir, f.c_str());
2222         } else if (ob == dialog_->button_lastfiles_browse) {
2223                 string f = parent_.controller().browse(
2224                         fl_get_input(dialog_->input_lastfiles), _("Last files"));
2225                 if (!f.empty())
2226                         fl_set_input(dialog_->input_lastfiles, f.c_str());
2227         } else if (ob == dialog_->button_backup_path_browse) {
2228                 string f = parent_.controller().browsedir(
2229                         fl_get_input(dialog_->input_backup_path), _("Backup path"));
2230                 if (!f.empty())
2231                         fl_set_input(dialog_->input_backup_path, f.c_str());
2232         } else if (ob == dialog_->button_serverpipe_browse) {
2233                 string f = parent_.controller().browse(
2234                         fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2235                 if (!f.empty())
2236                         fl_set_input(dialog_->input_serverpipe, f.c_str());
2237         }
2238
2239         return activate;
2240 }
2241
2242
2243 void FormPreferences::Paths::update(LyXRC const & rc)
2244 {
2245         fl_set_input(dialog_->input_default_path,
2246                      rc.document_path.c_str());
2247         fl_set_input(dialog_->input_template_path,
2248                      rc.template_path.c_str());
2249
2250         string str;
2251         if (rc.make_backup)
2252                 str = rc.backupdir_path;
2253
2254         fl_set_button(dialog_->check_make_backups,
2255                       rc.make_backup);
2256         fl_set_input(dialog_->input_backup_path, str.c_str());
2257
2258         str.erase();
2259         if (rc.use_tempdir)
2260                 str = rc.tempdir_path;
2261
2262         fl_set_button(dialog_->check_use_temp_dir,
2263                       rc.use_tempdir);
2264         fl_set_input(dialog_->input_temp_dir, str.c_str());
2265
2266         str.erase();
2267         if (rc.check_lastfiles)
2268                 str = rc.lastfiles;
2269
2270         fl_set_button(dialog_->check_last_files,
2271                       rc.check_lastfiles);
2272         fl_set_input(dialog_->input_lastfiles, str.c_str());
2273         fl_set_counter_value(dialog_->counter_lastfiles,
2274                              rc.num_lastfiles);
2275
2276         fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2277
2278         // Activate/Deactivate the input fields dependent on the state of the
2279         // buttons.
2280         input(0);
2281 }
2282
2283
2284 FormPreferences::Printer::Printer(FormPreferences &  p)
2285         : parent_(p)
2286 {}
2287
2288
2289 FD_preferences_printer const * FormPreferences::Printer::dialog()
2290 {
2291         return dialog_.get();
2292 }
2293
2294
2295 void FormPreferences::Printer::apply(LyXRC & rc) const
2296 {
2297         rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2298         rc.print_command = fl_get_input(dialog_->input_command);
2299         rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2300         rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2301         rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2302         rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2303         rc.print_file_extension =
2304                 fl_get_input(dialog_->input_file_extension);
2305         rc.print_spool_command =
2306                 fl_get_input(dialog_->input_spool_command);
2307         rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2308         rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2309         rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2310         rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2311         rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2312         rc.print_to_file = fl_get_input(dialog_->input_to_file);
2313         rc.print_extra_options =
2314                 fl_get_input(dialog_->input_extra_options);
2315         rc.print_spool_printerprefix =
2316                 fl_get_input(dialog_->input_spool_prefix);
2317         rc.print_paper_dimension_flag =
2318                 fl_get_input(dialog_->input_paper_size);
2319         rc.printer = fl_get_input(dialog_->input_name);
2320 }
2321
2322
2323 string const
2324 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2325 {
2326         if (ob == dialog_->input_command)
2327                 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2328         if (ob == dialog_->check_adapt_output)
2329                 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2330         if (ob == dialog_->input_to_printer)
2331                 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2332         if (ob == dialog_->input_to_file)
2333                 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2334         if (ob == dialog_->input_file_extension)
2335                 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2336         if (ob == dialog_->input_extra_options)
2337                 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2338         if (ob == dialog_->input_spool_command)
2339                 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2340         if (ob == dialog_->input_spool_prefix)
2341                 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2342         if (ob == dialog_->input_name)
2343                 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2344         if (ob == dialog_->input_even_pages)
2345                 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2346         if (ob == dialog_->input_odd_pages)
2347                 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2348         if (ob == dialog_->input_page_range)
2349                 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2350         if (ob == dialog_->input_reverse)
2351                 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2352         if (ob == dialog_->input_landscape)
2353                 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2354         if (ob == dialog_->input_copies)
2355                 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2356         if (ob == dialog_->input_collated)
2357                 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2358         if (ob == dialog_->input_paper_type)
2359                 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2360         if (ob == dialog_->input_paper_size)
2361                 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2362         return string();
2363 }
2364
2365
2366 void FormPreferences::Printer::build()
2367 {
2368         dialog_.reset(build_preferences_printer(&parent_));
2369
2370         fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2371         fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2372         fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2373         fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2374         fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2375         fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2376         fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2377         fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2378         fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2379         fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2380         fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2381         fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2382         fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2383         fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2384         fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2385         fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2386         fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2387
2388         // set up the feedback mechanism
2389         setPrehandler(dialog_->input_command);
2390         setPrehandler(dialog_->input_page_range);
2391         setPrehandler(dialog_->input_copies);
2392         setPrehandler(dialog_->input_reverse);
2393         setPrehandler(dialog_->input_to_printer);
2394         setPrehandler(dialog_->input_file_extension);
2395         setPrehandler(dialog_->input_spool_command);
2396         setPrehandler(dialog_->input_paper_type);
2397         setPrehandler(dialog_->input_even_pages);
2398         setPrehandler(dialog_->input_odd_pages);
2399         setPrehandler(dialog_->input_collated);
2400         setPrehandler(dialog_->input_landscape);
2401         setPrehandler(dialog_->input_to_file);
2402         setPrehandler(dialog_->input_extra_options);
2403         setPrehandler(dialog_->input_spool_prefix);
2404         setPrehandler(dialog_->input_paper_size);
2405         setPrehandler(dialog_->input_name);
2406         setPrehandler(dialog_->check_adapt_output);
2407 }
2408
2409
2410 void FormPreferences::Printer::update(LyXRC const & rc)
2411 {
2412         fl_set_button(dialog_->check_adapt_output,
2413                       rc.print_adapt_output);
2414         fl_set_input(dialog_->input_command,
2415                      rc.print_command.c_str());
2416         fl_set_input(dialog_->input_page_range,
2417                      rc.print_pagerange_flag.c_str());
2418         fl_set_input(dialog_->input_copies,
2419                      rc.print_copies_flag.c_str());
2420         fl_set_input(dialog_->input_reverse,
2421                      rc.print_reverse_flag.c_str());
2422         fl_set_input(dialog_->input_to_printer,
2423                      rc.print_to_printer.c_str());
2424         fl_set_input(dialog_->input_file_extension,
2425                      rc.print_file_extension.c_str());
2426         fl_set_input(dialog_->input_spool_command,
2427                      rc.print_spool_command.c_str());
2428         fl_set_input(dialog_->input_paper_type,
2429                      rc.print_paper_flag.c_str());
2430         fl_set_input(dialog_->input_even_pages,
2431                      rc.print_evenpage_flag.c_str());
2432         fl_set_input(dialog_->input_odd_pages,
2433                      rc.print_oddpage_flag.c_str());
2434         fl_set_input(dialog_->input_collated,
2435                      rc.print_collcopies_flag.c_str());
2436         fl_set_input(dialog_->input_landscape,
2437                      rc.print_landscape_flag.c_str());
2438         fl_set_input(dialog_->input_to_file,
2439                      rc.print_to_file.c_str());
2440         fl_set_input(dialog_->input_extra_options,
2441                      rc.print_extra_options.c_str());
2442         fl_set_input(dialog_->input_spool_prefix,
2443                      rc.print_spool_printerprefix.c_str());
2444         fl_set_input(dialog_->input_paper_size,
2445                      rc.print_paper_dimension_flag.c_str());
2446         fl_set_input(dialog_->input_name,
2447                      rc.printer.c_str());
2448 }
2449
2450
2451 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences &  p)
2452         : parent_(p)
2453 {}
2454
2455
2456 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2457 {
2458         return dialog_.get();
2459 }
2460
2461
2462 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2463 {
2464         bool changed = false;
2465
2466         pair<string, string> tmp =
2467                 parseFontName(fl_get_input(dialog_->input_roman));
2468         if (rc.roman_font_name != tmp.first ||
2469             rc.roman_font_foundry != tmp.second) {
2470                 changed = true;
2471                 rc.roman_font_name = tmp.first;
2472                 rc.roman_font_foundry = tmp.second;
2473         }
2474
2475         tmp = parseFontName(fl_get_input(dialog_->input_sans));
2476         if (rc.sans_font_name != tmp.first ||
2477             rc.sans_font_foundry != tmp.second) {
2478                 changed = true;
2479                 rc.sans_font_name = tmp.first;
2480                 rc.sans_font_foundry = tmp.second;
2481         }
2482
2483         tmp = parseFontName(fl_get_input(dialog_->input_typewriter));
2484         if (rc.typewriter_font_name != tmp.first ||
2485             rc.typewriter_font_foundry != tmp.second) {
2486                 changed = true;
2487                 rc.typewriter_font_name = tmp.first;
2488                 rc.typewriter_font_foundry = tmp.second;
2489         }
2490
2491         string str = fl_get_input(dialog_->input_screen_encoding);
2492         if (rc.font_norm != str) {
2493                 changed = true;
2494                 rc.font_norm = str;
2495                 rc.set_font_norm_type();
2496         }
2497
2498         bool button = fl_get_button(dialog_->check_scalable);
2499         if (rc.use_scalable_fonts != button) {
2500                 changed = true;
2501                 rc.use_scalable_fonts = button;
2502         }
2503
2504         unsigned int ivalue = static_cast<unsigned int>
2505                 (fl_get_counter_value(dialog_->counter_zoom));
2506         if (rc.zoom != ivalue) {
2507                 changed = true;
2508                 rc.zoom = ivalue;
2509         }
2510
2511         ivalue = static_cast<unsigned int>
2512                 (fl_get_counter_value(dialog_->counter_dpi));
2513         if (rc.dpi != ivalue) {
2514                 changed = true;
2515                 rc.dpi = ivalue;
2516         }
2517
2518         double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2519         if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2520                 changed = true;
2521                 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2522         }
2523
2524         dvalue = strToDbl(fl_get_input(dialog_->input_script));
2525         if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2526                 changed = true;
2527                 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2528         }
2529
2530         dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2531         if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2532                 changed = true;
2533                 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2534         }
2535
2536         dvalue = strToDbl(fl_get_input(dialog_->input_small));
2537         if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2538                 changed = true;
2539                 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2540         }
2541
2542         dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2543         if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2544                 changed = true;
2545                 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2546         }
2547
2548         dvalue = strToDbl(fl_get_input(dialog_->input_large));
2549         if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2550                 changed = true;
2551                 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2552         }
2553
2554         dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2555         if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2556                 changed = true;
2557                 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2558         }
2559
2560         dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2561         if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2562                 changed = true;
2563                 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2564         }
2565
2566         dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2567         if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2568                 changed = true;
2569                 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2570         }
2571
2572         dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2573         if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2574                 changed = true;
2575                 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2576         }
2577
2578         if (changed) {
2579                 // Now update the buffers
2580                 // Can anything below here affect the redraw process?
2581                 parent_.controller().updateScreenFonts();
2582         }
2583 }
2584
2585
2586 void FormPreferences::ScreenFonts::build()
2587 {
2588         dialog_.reset(build_preferences_screen_fonts(&parent_));
2589
2590         fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2591         fl_set_counter_step(dialog_->counter_dpi,  1, 10);
2592
2593         fl_set_input_return(dialog_->input_roman,           FL_RETURN_CHANGED);
2594         fl_set_input_return(dialog_->input_sans,            FL_RETURN_CHANGED);
2595         fl_set_input_return(dialog_->input_typewriter,      FL_RETURN_CHANGED);
2596         fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2597         fl_set_counter_return(dialog_->counter_zoom,        FL_RETURN_CHANGED);
2598         fl_set_counter_return(dialog_->counter_dpi,         FL_RETURN_CHANGED);
2599         fl_set_input_return(dialog_->input_tiny,            FL_RETURN_CHANGED);
2600         fl_set_input_return(dialog_->input_script,          FL_RETURN_CHANGED);
2601         fl_set_input_return(dialog_->input_footnote,        FL_RETURN_CHANGED);
2602         fl_set_input_return(dialog_->input_small,           FL_RETURN_CHANGED);
2603         fl_set_input_return(dialog_->input_normal,          FL_RETURN_CHANGED);
2604         fl_set_input_return(dialog_->input_large,           FL_RETURN_CHANGED);
2605         fl_set_input_return(dialog_->input_larger,          FL_RETURN_CHANGED);
2606         fl_set_input_return(dialog_->input_largest,         FL_RETURN_CHANGED);
2607         fl_set_input_return(dialog_->input_huge,            FL_RETURN_CHANGED);
2608         fl_set_input_return(dialog_->input_huger,           FL_RETURN_CHANGED);
2609
2610         fl_set_input_filter(dialog_->input_tiny,     fl_unsigned_float_filter);
2611         fl_set_input_filter(dialog_->input_script,   fl_unsigned_float_filter);
2612         fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2613         fl_set_input_filter(dialog_->input_small,    fl_unsigned_float_filter);
2614         fl_set_input_filter(dialog_->input_normal,   fl_unsigned_float_filter);
2615         fl_set_input_filter(dialog_->input_large,    fl_unsigned_float_filter);
2616         fl_set_input_filter(dialog_->input_larger,   fl_unsigned_float_filter);
2617         fl_set_input_filter(dialog_->input_largest,  fl_unsigned_float_filter);
2618         fl_set_input_filter(dialog_->input_huge,     fl_unsigned_float_filter);
2619         fl_set_input_filter(dialog_->input_huger,    fl_unsigned_float_filter);
2620
2621         // set up the feedback mechanism
2622         setPrehandler(dialog_->input_roman);
2623         setPrehandler(dialog_->input_sans);
2624         setPrehandler(dialog_->input_typewriter);
2625         setPrehandler(dialog_->counter_zoom);
2626         setPrehandler(dialog_->counter_dpi);
2627         setPrehandler(dialog_->check_scalable);
2628         setPrehandler(dialog_->input_screen_encoding);
2629         setPrehandler(dialog_->input_tiny);
2630         setPrehandler(dialog_->input_script);
2631         setPrehandler(dialog_->input_footnote);
2632         setPrehandler(dialog_->input_small);
2633         setPrehandler(dialog_->input_large);
2634         setPrehandler(dialog_->input_larger);
2635         setPrehandler(dialog_->input_largest);
2636         setPrehandler(dialog_->input_normal);
2637         setPrehandler(dialog_->input_huge);
2638         setPrehandler(dialog_->input_huger);
2639 }
2640
2641
2642 string const
2643 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2644 {
2645         if (ob == dialog_->input_roman)
2646                 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2647         if (ob == dialog_->input_sans)
2648                 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2649         if (ob == dialog_->input_typewriter)
2650                 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2651         if (ob == dialog_->check_scalable)
2652                 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2653         if (ob == dialog_->input_screen_encoding)
2654                 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2655         if (ob == dialog_->counter_zoom)
2656                 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2657         if (ob == dialog_->counter_dpi)
2658                 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2659         if (ob == dialog_->input_tiny
2660             || ob == dialog_->input_script
2661             || ob == dialog_->input_footnote
2662             || ob == dialog_->input_small
2663             || ob == dialog_->input_large
2664             || ob == dialog_->input_larger
2665             || ob == dialog_->input_larger
2666             || ob == dialog_->input_largest
2667             || ob == dialog_->input_normal
2668             || ob == dialog_->input_huge
2669             || ob == dialog_->input_huger)
2670                 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2671         return string();
2672 }
2673
2674
2675 bool FormPreferences::ScreenFonts::input()
2676 {
2677         bool activate = true;
2678         string str;
2679
2680         // Make sure that all fonts all have positive entries
2681         // Also note that an empty entry is returned as 0.0 by strToDbl
2682         if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2683             || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2684             || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2685             || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2686             || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2687             || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2688             || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2689             || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2690             || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2691             || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2692                 activate = false;
2693                 str = _("Fonts must be positive!");
2694
2695         } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2696                    // Fontsizes -- tiny < script < footnote etc.
2697                    strToDbl(fl_get_input(dialog_->input_script)) ||
2698                    strToDbl(fl_get_input(dialog_->input_script)) >
2699                    strToDbl(fl_get_input(dialog_->input_footnote)) ||
2700                    strToDbl(fl_get_input(dialog_->input_footnote)) >
2701                    strToDbl(fl_get_input(dialog_->input_small)) ||
2702                    strToDbl(fl_get_input(dialog_->input_small)) >
2703                    strToDbl(fl_get_input(dialog_->input_normal)) ||
2704                    strToDbl(fl_get_input(dialog_->input_normal)) >
2705                    strToDbl(fl_get_input(dialog_->input_large)) ||
2706                    strToDbl(fl_get_input(dialog_->input_large)) >
2707                    strToDbl(fl_get_input(dialog_->input_larger)) ||
2708                    strToDbl(fl_get_input(dialog_->input_larger)) >
2709                    strToDbl(fl_get_input(dialog_->input_largest)) ||
2710                    strToDbl(fl_get_input(dialog_->input_largest)) >
2711                    strToDbl(fl_get_input(dialog_->input_huge)) ||
2712                    strToDbl(fl_get_input(dialog_->input_huge)) >
2713                    strToDbl(fl_get_input(dialog_->input_huger))) {
2714                 activate = false;
2715
2716                 str = _("Fonts must be input in the order Tiny > Smallest > Smaller > Small > Normal > Large > Larger > Largest > Huge > Huger.");
2717         }
2718
2719         if (!activate)
2720                 parent_.postWarning(str);
2721
2722         return activate;
2723 }
2724
2725
2726 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2727 {
2728         fl_set_input(dialog_->input_roman,
2729                      makeFontName(rc.roman_font_name,
2730                                   rc.roman_font_foundry).c_str());
2731         fl_set_input(dialog_->input_sans,
2732                      makeFontName(rc.sans_font_name,
2733                                   rc.sans_font_foundry).c_str());
2734         fl_set_input(dialog_->input_typewriter,
2735                      makeFontName(rc.typewriter_font_name,
2736                                   rc.typewriter_font_foundry).c_str());
2737         fl_set_input(dialog_->input_screen_encoding,
2738                      rc.font_norm.c_str());
2739         fl_set_button(dialog_->check_scalable,
2740                       rc.use_scalable_fonts);
2741         fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2742         fl_set_counter_value(dialog_->counter_dpi,  rc.dpi);
2743         fl_set_input(dialog_->input_tiny,
2744                      tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2745         fl_set_input(dialog_->input_script,
2746                      tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2747         fl_set_input(dialog_->input_footnote,
2748                      tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2749         fl_set_input(dialog_->input_small,
2750                      tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2751         fl_set_input(dialog_->input_normal,
2752                      tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2753         fl_set_input(dialog_->input_large,
2754                      tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2755         fl_set_input(dialog_->input_larger,
2756                      tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2757         fl_set_input(dialog_->input_largest,
2758                      tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2759         fl_set_input(dialog_->input_huge,
2760                      tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2761         fl_set_input(dialog_->input_huger,
2762                      tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2763 }
2764
2765
2766
2767 FormPreferences::SpellOptions::SpellOptions(FormPreferences &  p)
2768         : parent_(p)
2769 {}
2770
2771
2772 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2773 {
2774         return dialog_.get();
2775 }
2776
2777
2778 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2779 {
2780         string choice = fl_get_choice_text(dialog_->choice_spell_command);
2781         choice = trim(choice);
2782
2783         rc.isp_command = choice;
2784
2785 #if 0
2786         // If spell checker == "none", all other input set to off.
2787         if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2788                 rc.isp_use_alt_lang = false;
2789                 rc.isp_alt_lang.erase();
2790
2791                 rc.isp_use_esc_chars = false;
2792                 rc.isp_esc_chars.erase();
2793
2794                 rc.isp_use_pers_dict = false;
2795                 rc.isp_pers_dict.erase();
2796
2797                 rc.isp_accept_compound = false;
2798                 rc.isp_use_input_encoding = false;
2799         } else {
2800 #else
2801                 int button = fl_get_button(dialog_->check_alt_lang);
2802                 choice = fl_get_input(dialog_->input_alt_lang);
2803                 if (button && choice.empty()) button = 0;
2804                 if (!button) choice.erase();
2805
2806                 rc.isp_use_alt_lang = static_cast<bool>(button);
2807                 rc.isp_alt_lang = choice;
2808
2809                 button = fl_get_button(dialog_->check_escape_chars);
2810                 choice = fl_get_input(dialog_->input_escape_chars);
2811                 if (button && choice.empty()) button = 0;
2812                 if (!button) choice.erase();
2813
2814                 rc.isp_use_esc_chars = static_cast<bool>(button);
2815                 rc.isp_esc_chars = choice;
2816
2817                 button = fl_get_button(dialog_->check_personal_dict);
2818                 choice = fl_get_input(dialog_->input_personal_dict);
2819                 if (button && choice.empty()) button = 0;
2820                 if (!button) choice.erase();
2821
2822                 rc.isp_use_pers_dict = static_cast<bool>(button);
2823                 rc.isp_pers_dict = choice;
2824
2825                 button = fl_get_button(dialog_->check_compound_words);
2826                 rc.isp_accept_compound = static_cast<bool>(button);
2827
2828                 button = fl_get_button(dialog_->check_input_enc);
2829                 rc.isp_use_input_encoding = static_cast<bool>(button);
2830 #endif
2831 #if 0
2832         }
2833 #endif
2834
2835         // Reset view
2836         update(rc);
2837 }
2838
2839
2840 void FormPreferences::SpellOptions::build()
2841 {
2842         dialog_.reset(build_preferences_spelloptions(&parent_));
2843
2844         fl_addto_choice(dialog_->choice_spell_command,
2845                         _(" ispell | aspell "));
2846         fl_set_input_return(dialog_->input_alt_lang,      FL_RETURN_CHANGED);
2847         fl_set_input_return(dialog_->input_escape_chars,  FL_RETURN_CHANGED);
2848         fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2849
2850         // set up the feedback mechanism
2851         setPrehandler(dialog_->choice_spell_command);
2852         setPrehandler(dialog_->check_alt_lang);
2853         setPrehandler(dialog_->input_alt_lang);
2854         setPrehandler(dialog_->check_escape_chars);
2855         setPrehandler(dialog_->input_escape_chars);
2856         setPrehandler(dialog_->check_personal_dict);
2857         setPrehandler(dialog_->input_personal_dict);
2858         setPrehandler(dialog_->button_personal_dict);
2859         setPrehandler(dialog_->check_compound_words);
2860         setPrehandler(dialog_->check_input_enc);
2861 }
2862
2863
2864 string const
2865 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2866 {
2867         if (ob == dialog_->choice_spell_command)
2868                 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2869         if (ob == dialog_->check_alt_lang)
2870                 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2871         if (ob == dialog_->input_alt_lang)
2872                 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2873         if (ob == dialog_->check_escape_chars)
2874                 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2875         if (ob == dialog_->input_escape_chars)
2876                 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2877         if (ob == dialog_->check_personal_dict)
2878                 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2879         if (ob == dialog_->input_personal_dict)
2880                 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2881         if (ob == dialog_->check_compound_words)
2882                 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2883         if (ob == dialog_->check_input_enc)
2884                 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
2885         return string();
2886 }
2887
2888
2889 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2890 {
2891         // !ob if function is called from updateSpellOptions() to de/activate
2892         // objects,
2893         // otherwise the function is called by an xforms CB via input().
2894
2895 #if 0
2896         // If spell checker == "none", disable all input.
2897         if (!ob || ob == dialog_->choice_spell_command) {
2898                 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2899                         fl_deactivate_object(dialog_->check_alt_lang);
2900                         fl_deactivate_object(dialog_->input_alt_lang);
2901                         fl_deactivate_object(dialog_->check_escape_chars);
2902                         fl_deactivate_object(dialog_->input_escape_chars);
2903                         fl_deactivate_object(dialog_->check_personal_dict);
2904                         fl_deactivate_object(dialog_->input_personal_dict);
2905                         fl_deactivate_object(dialog_->check_compound_words);
2906                         fl_deactivate_object(dialog_->check_input_enc);
2907                         return true;
2908                 } else {
2909                         fl_activate_object(dialog_->check_alt_lang);
2910                         fl_activate_object(dialog_->check_escape_chars);
2911                         fl_activate_object(dialog_->check_personal_dict);
2912                         fl_activate_object(dialog_->check_compound_words);
2913                         fl_activate_object(dialog_->check_input_enc);
2914                 }
2915         }
2916 #endif
2917
2918         if (!ob || ob == dialog_->check_alt_lang) {
2919                 bool const enable = fl_get_button(dialog_->check_alt_lang);
2920                 setEnabled(dialog_->input_alt_lang, enable);
2921         }
2922
2923         if (!ob || ob == dialog_->check_escape_chars) {
2924                 bool const enable = fl_get_button(dialog_->check_escape_chars);
2925                 setEnabled(dialog_->input_escape_chars, enable);
2926         }
2927
2928         if (!ob || ob == dialog_->check_personal_dict) {
2929                 bool const enable = fl_get_button(dialog_->check_personal_dict);
2930                 setEnabled(dialog_->input_personal_dict, enable);
2931         }
2932
2933         if (ob == dialog_->button_personal_dict) {
2934                 string f = parent_.controller().browsedict(
2935                         fl_get_input(dialog_->input_personal_dict));
2936                 fl_set_input(dialog_->input_personal_dict, f.c_str());
2937         }
2938
2939         return true; // All input is valid!
2940 }
2941
2942
2943 void FormPreferences::SpellOptions::update(LyXRC const & rc)
2944 {
2945         int choice = 1;
2946 #if 0
2947         if (rc.isp_command == "none")
2948                 choice = 1;
2949         else if (rc.isp_command == "ispell")
2950                 choice = 2;
2951         else if (rc.isp_command == "aspell")
2952                 choice = 3;
2953 #else
2954         if (rc.isp_command == "ispell")
2955                 choice = 1;
2956         else if (rc.isp_command == "aspell")
2957                 choice = 2;
2958 #endif
2959         fl_set_choice(dialog_->choice_spell_command, choice);
2960
2961         string str;
2962         if (rc.isp_use_alt_lang)
2963                 str = rc.isp_alt_lang;
2964
2965         fl_set_button(dialog_->check_alt_lang,
2966                       rc.isp_use_alt_lang);
2967         fl_set_input(dialog_->input_alt_lang, str.c_str());
2968
2969         str.erase();
2970         if (rc.isp_use_esc_chars)
2971                 str = rc.isp_esc_chars;
2972
2973         fl_set_button(dialog_->check_escape_chars,
2974                       rc.isp_use_esc_chars);
2975         fl_set_input(dialog_->input_escape_chars, str.c_str());
2976
2977         str.erase();
2978         if (rc.isp_use_pers_dict)
2979                 str = rc.isp_pers_dict;
2980
2981         fl_set_button(dialog_->check_personal_dict,
2982                       rc.isp_use_pers_dict);
2983         fl_set_input(dialog_->input_personal_dict, str.c_str());
2984
2985         fl_set_button(dialog_->check_compound_words,
2986                       rc.isp_accept_compound);
2987         fl_set_button(dialog_->check_input_enc,
2988                       rc.isp_use_input_encoding);
2989
2990         // Activate/Deactivate the input fields dependent on the state of the
2991         // buttons.
2992         input(0);
2993 }