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