2 * \file FormPreferences.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS
14 #include "ControlPrefs.h"
15 #include "FormPreferences.h"
16 #include "forms/form_preferences.h"
18 #include "ButtonController.h"
21 #include "input_validators.h"
22 #include "forms_gettext.h"
23 #include "xforms_helpers.h"
24 #include "helper_funcs.h" // getSecond
27 #include "converter.h"
31 #include "frnt_lang.h"
36 #include "funcrequest.h"
39 #include "support/lyxfunctional.h"
40 #include "support/lyxmanip.h"
41 #include "support/filetools.h"
42 #include "support/LAssert.h"
44 #include "graphics/GraphicsCache.h"
45 #include "graphics/GraphicsTypes.h"
47 #include <boost/bind.hpp>
49 #include FORMS_H_LOCATION
65 extern string system_lyxdir;
66 extern string user_lyxdir;
70 // These should probably go inside the class definition...
71 Formats local_formats;
72 Converters local_converters;
74 string makeFontName(string const & family, string const & foundry)
78 return family + ',' + foundry;
82 pair<string,string> parseFontName(string const & name)
84 string::size_type const idx = name.find(',');
85 if (idx == string::npos)
86 return make_pair(name, string());
87 return make_pair(name.substr(0, idx),
92 string const X11hexname(RGBColor const & col)
96 ostr << '#' << std::setbase(16) << setfill('0')
101 return STRCONV(ostr.str());
104 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
105 bool const scalableTabfolders = false;
107 bool const scalableTabfolders = true;
113 typedef FormCB<ControlPrefs, FormDB<FD_preferences> > base_class;
116 FormPreferences::FormPreferences()
117 : base_class(_("Preferences"), scalableTabfolders),
118 colors_(*this), converters_(*this), inputs_misc_(*this),
119 formats_(*this), interface_(*this), language_(*this),
120 lnf_misc_(*this), identity_(*this), outputs_misc_(*this),
121 paths_(*this), printer_(*this), screen_fonts_(*this),
127 void FormPreferences::redraw()
129 if (!(form() && form()->visible))
131 fl_redraw_form(form());
133 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
134 if (!(form2 && form2->visible))
136 fl_redraw_form(form2);
139 if (form2 == converters_tab_->form)
140 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
142 else if (form2 == look_n_feel_tab_->form)
143 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
145 else if (form2 == inputs_tab_->form)
146 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
148 else if (form2 == outputs_tab_->form)
149 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
151 else if (form2 == lang_opts_tab_->form)
152 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
154 if (form3 && form3->visible)
155 fl_redraw_form(form3);
159 void FormPreferences::hide()
161 // We need to hide the active tabfolder otherwise we get a
162 // BadDrawable error from X window and LyX crashes without saving.
163 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
164 if (inner_form && inner_form->visible)
165 fl_hide_form(inner_form);
170 void FormPreferences::build()
172 dialog_.reset(build_preferences(this));
174 // Manage the restore, save, apply and cancel/close buttons
175 bcview().setOK(dialog_->button_ok);
176 bcview().setApply(dialog_->button_apply);
177 bcview().setCancel(dialog_->button_close);
178 bcview().setRestore(dialog_->button_restore);
180 // Allow the base class to control messages
181 setMessageWidget(dialog_->text_warning);
183 // build the tab folders
184 converters_tab_.reset(build_preferences_inner_tab(this));
185 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
186 inputs_tab_.reset(build_preferences_inner_tab(this));
187 outputs_tab_.reset(build_preferences_inner_tab(this));
188 lang_opts_tab_.reset(build_preferences_inner_tab(this));
190 // build actual tabfolder contents
191 // these will become nested tabfolders
195 inputs_misc_.build();
200 outputs_misc_.build();
203 screen_fonts_.build();
204 spelloptions_.build();
206 // Enable the tabfolders to be rescaled correctly.
207 if (scalableTabfolders) {
208 FL_OBJECT * folder = dialog_->tabfolder_prefs;
209 fl_set_tabfolder_autofit(folder, FL_FIT);
211 folder = look_n_feel_tab_->tabfolder_inner;
212 fl_set_tabfolder_autofit(folder, FL_FIT);
214 folder = converters_tab_->tabfolder_inner;
215 fl_set_tabfolder_autofit(folder, FL_FIT);
217 folder = inputs_tab_->tabfolder_inner;
218 fl_set_tabfolder_autofit(folder, FL_FIT);
220 folder = outputs_tab_->tabfolder_inner;
221 fl_set_tabfolder_autofit(folder, FL_FIT);
223 folder = lang_opts_tab_->tabfolder_inner;
224 fl_set_tabfolder_autofit(folder, FL_FIT);
228 // Now add them to the tabfolder
229 fl_addto_tabfolder(dialog_->tabfolder_prefs,
231 look_n_feel_tab_->form);
232 fl_addto_tabfolder(dialog_->tabfolder_prefs,
234 lang_opts_tab_->form);
235 fl_addto_tabfolder(dialog_->tabfolder_prefs,
237 converters_tab_->form);
238 fl_addto_tabfolder(dialog_->tabfolder_prefs,
241 fl_addto_tabfolder(dialog_->tabfolder_prefs,
245 // now build the nested tabfolders
246 // Starting with look and feel
247 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
249 screen_fonts_.dialog()->form);
250 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
252 interface_.dialog()->form);
253 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
255 colors_.dialog()->form);
256 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
258 lnf_misc_.dialog()->form);
259 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
261 identity_.dialog()->form);
263 // then build converters
264 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
266 formats_.dialog()->form);
267 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
269 converters_.dialog()->form);
272 // Paths should probably go in a few inner_tab called Files
273 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
275 paths_.dialog()->form);
276 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
278 inputs_misc_.dialog()->form);
280 // then building outputs
281 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
283 printer_.dialog()->form);
284 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
286 outputs_misc_.dialog()->form);
288 // then building usage
289 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
291 spelloptions_.dialog()->form);
292 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
294 language_.dialog()->form);
298 void FormPreferences::apply()
300 // set the new lyxrc entries
301 // many of these need to trigger other functions when the assignment
302 // is made. For example, screen zoom and font types. These could be
303 // handled either by signals/slots in lyxrc or just directly call the
304 // associated functions here.
305 // There are other problems with this scheme. We really should check
306 // what we copy to make sure that it really is necessary to do things
307 // like update the screen fonts because that flushes the textcache
308 // and other stuff which may cost us a lot on slower/high-load
311 LyXRC & rc(controller().rc());
314 formats_.apply(); // Must be before converters_.apply()
316 inputs_misc_.apply(rc);
317 interface_.apply(rc);
321 outputs_misc_.apply(rc);
324 screen_fonts_.apply(rc);
325 spelloptions_.apply(rc);
327 // The "Save" button has been pressed.
328 if (controller().isClosing() && colors_.modifiedXformsPrefs) {
329 string const filename =
330 AddName(user_lyxdir, "preferences.xform");
331 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
336 string const FormPreferences::getFeedback(FL_OBJECT * ob)
340 if (ob->form->fdui == colors_.dialog())
341 return colors_.feedback(ob);
342 if (ob->form->fdui == converters_.dialog())
343 return converters_.feedback(ob);
344 if (ob->form->fdui == formats_.dialog())
345 return formats_.feedback(ob);
346 if (ob->form->fdui == inputs_misc_.dialog())
347 return inputs_misc_.feedback(ob);
348 if (ob->form->fdui == interface_.dialog())
349 return interface_.feedback(ob);
350 if (ob->form->fdui == language_.dialog())
351 return language_.feedback(ob);
352 if (ob->form->fdui == lnf_misc_.dialog())
353 return lnf_misc_.feedback(ob);
354 if (ob->form->fdui == outputs_misc_.dialog())
355 return outputs_misc_.feedback(ob);
356 if (ob->form->fdui == paths_.dialog())
357 return paths_.feedback(ob);
358 if (ob->form->fdui == printer_.dialog())
359 return printer_.feedback(ob);
360 if (ob->form->fdui == screen_fonts_.dialog())
361 return screen_fonts_.feedback(ob);
362 if (ob->form->fdui == spelloptions_.dialog())
363 return spelloptions_.feedback(ob);
369 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
375 // whatever checks you need to ensure the user hasn't entered
376 // some totally ridiculous value somewhere. Change activate to suit.
377 // comments before each test describe what is _valid_
379 if (ob->form->fdui == colors_.dialog()) {
381 } else if (ob->form->fdui == converters_.dialog()) {
382 valid = converters_.input(ob);
383 } else if (ob->form->fdui == formats_.dialog()) {
384 valid = formats_.input(ob);
385 } else if (ob->form->fdui == interface_.dialog()) {
386 valid = interface_.input(ob);
387 } else if (ob->form->fdui == language_.dialog()) {
388 valid = language_.input(ob);
389 } else if (ob->form->fdui == paths_.dialog()) {
390 valid = paths_.input(ob);
391 } else if (ob->form->fdui == screen_fonts_.dialog()) {
392 valid = screen_fonts_.input();
393 } else if (ob->form->fdui == spelloptions_.dialog()) {
394 valid = spelloptions_.input(ob);
397 return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
401 void FormPreferences::update()
403 if (!dialog_.get()) return;
405 LyXRC const & rc(controller().rc());
407 // read lyxrc entries
409 formats_.update(); // Must be before converters_.update()
410 converters_.update();
411 inputs_misc_.update(rc);
412 interface_.update(rc);
413 language_.update(rc);
414 lnf_misc_.update(rc);
415 identity_.update(rc);
416 outputs_misc_.update(rc);
419 screen_fonts_.update(rc);
420 spelloptions_.update(rc);
424 FormPreferences::Colors::Colors(FormPreferences & p)
425 : modifiedXformsPrefs(false), parent_(p)
429 FD_preferences_colors const * FormPreferences::Colors::dialog()
431 return dialog_.get();
435 void FormPreferences::Colors::apply()
437 bool modifiedText = false;
438 bool modifiedBackground = false;
440 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
441 cit != xformsColorDB.end(); ++cit) {
443 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
444 if (col != cit->color()) {
445 modifiedXformsPrefs = true;
446 if (cit->colorID == FL_BLACK)
448 if (cit->colorID == FL_COL1)
449 modifiedBackground = true;
453 if (modifiedXformsPrefs) {
454 for (vector<XformsColor>::const_iterator cit =
455 xformsColorDB.begin();
456 cit != xformsColorDB.end(); ++cit) {
457 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
459 if (modifiedText && cit->colorID == FL_BLACK) {
460 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
463 if (modifiedBackground && cit->colorID == FL_COL1) {
464 AdjustVal(FL_MCOL, FL_COL1, 0.1);
465 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
466 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
468 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
469 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
472 if (cit->colorID == GUI_COLOR_CURSOR) {
473 fl_mapcolor(GUI_COLOR_CURSOR,
474 cit->r, cit->g, cit->b);
475 setCursorColor(GUI_COLOR_CURSOR);
478 parent_.controller().redrawGUI();
481 // Now do the same for the LyX LColors...
482 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
483 cit != lyxColorDB.end(); ++cit) {
484 LColor::color lc = lcolor.getFromGUIName(cit->getname());
485 if (lc == LColor::inherit) continue;
487 // Create a valid X11 name of the form "#rrggbb"
488 string const hexname = X11hexname(cit->color());
490 if (lcolor.getX11Name(lc) != hexname) {
492 << "FormPreferences::Colors::apply: "
493 << "resetting LColor " << lcolor.getGUIName(lc)
494 << " from \"" << lcolor.getX11Name(lc)
495 << "\" to \"" << hexname << "\"."
498 parent_.controller().setColor(lc, hexname);
504 void FormPreferences::Colors::build()
506 dialog_.reset(build_preferences_colors(&parent_));
508 fl_set_object_color(dialog_->button_color,
509 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
511 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
512 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
513 fl_set_dial_step(dialog_->dial_hue, 1.0);
514 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
516 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
517 fl_set_slider_step(dialog_->slider_saturation, 0.01);
518 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
520 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
521 fl_set_slider_step(dialog_->slider_value, 0.01);
522 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
524 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
525 fl_set_slider_step(dialog_->slider_red, 1.0);
526 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
528 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
529 fl_set_slider_step(dialog_->slider_green, 1.0);
530 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
532 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
533 fl_set_slider_step(dialog_->slider_blue, 1.0);
534 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
536 // set up the feedback mechanism
537 setPrehandler(dialog_->browser_lyx_objs);
538 setPrehandler(dialog_->button_color);
539 setPrehandler(dialog_->button_modify);
540 setPrehandler(dialog_->dial_hue);
541 setPrehandler(dialog_->slider_saturation);
542 setPrehandler(dialog_->slider_value);
543 setPrehandler(dialog_->slider_red);
544 setPrehandler(dialog_->slider_green);
545 setPrehandler(dialog_->slider_blue);
546 setPrehandler(dialog_->radio_rgb);
547 setPrehandler(dialog_->radio_hsv);
552 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
554 if (ob == dialog_->browser_lyx_objs)
555 return _("LyX objects that can be assigned a color.");
557 if (ob == dialog_->button_modify)
558 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
560 if (ob == dialog_->dial_hue ||
561 ob == dialog_->slider_saturation ||
562 ob == dialog_->slider_value ||
563 ob == dialog_->slider_red ||
564 ob == dialog_->slider_green ||
565 ob == dialog_->slider_blue)
566 return _("Find a new color.");
568 if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
569 return _("Toggle between RGB and HSV color spaces.");
575 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
577 if (ob == dialog_->browser_lyx_objs) {
580 } else if (ob == dialog_->dial_hue ||
581 ob == dialog_->slider_saturation ||
582 ob == dialog_->slider_value) {
585 } else if (ob == dialog_->slider_red ||
586 ob == dialog_->slider_green ||
587 ob == dialog_->slider_blue) {
590 } else if (ob == dialog_->radio_rgb ||
591 ob == dialog_->radio_hsv) {
594 } else if (ob == dialog_->button_modify) {
600 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
604 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
608 hsv.v = min(1.0, max(0.0, hsv.v));
611 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
615 void FormPreferences::Colors::InputBrowserLyX() const
617 vector<NamedColor>::size_type const selLyX =
618 fl_get_browser(dialog_->browser_lyx_objs);
619 if (selLyX < 1) return;
621 // Is the choice an Xforms color...
624 if (selLyX - 1 < xformsColorDB.size()) {
625 vector<XformsColor>::size_type const i = selLyX - 1;
626 col = xformsColorDB[i].color();
628 // or a LyX Logical color?
630 vector<NamedColor>::size_type const i = selLyX - 1 -
631 xformsColorDB.size();
632 col = lyxColorDB[i].color();
635 fl_freeze_form(dialog_->form);
637 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
638 fl_redraw_object(dialog_->button_color);
640 // Display either RGB or HSV but not both!
643 // Deactivate the modify button to begin with...
644 setEnabled(dialog_->button_modify, false);
646 fl_unfreeze_form(dialog_->form);
650 void FormPreferences::Colors::InputHSV()
652 double const hue = fl_get_dial_value(dialog_->dial_hue);
653 double const sat = fl_get_slider_value(dialog_->slider_saturation);
654 double const val = fl_get_slider_value(dialog_->slider_value);
656 int const h = int(hue);
657 int const s = int(100.0 * sat);
658 int const v = int(100.0 * val);
660 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
662 fl_set_object_label(dialog_->text_color_values, label.c_str());
664 RGBColor col = HSVColor(hue, sat, val);
666 fl_freeze_form(dialog_->form);
668 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
669 fl_redraw_object(dialog_->button_color);
671 col = HSVColor(hue, 1.0, 1.0);
672 col.r = max(col.r, 0u);
673 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
674 fl_redraw_object(dialog_->dial_hue);
676 // Ascertain whether to activate the Modify button.
677 vector<NamedColor>::size_type const selLyX =
678 fl_get_browser(dialog_->browser_lyx_objs);
680 fl_unfreeze_form(dialog_->form);
681 if (selLyX < 1) return;
683 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
686 // Is the choice an Xforms color...
687 if (selLyX - 1 < xformsColorDB.size()) {
688 vector<XformsColor>::size_type const i = selLyX - 1;
689 modify = (xformsColorDB[i].color() != col);
691 // or a LyX Logical color?
693 vector<NamedColor>::size_type const i = selLyX - 1 -
694 xformsColorDB.size();
695 modify = (lyxColorDB[i].color() != col);
698 setEnabled(dialog_->button_modify, modify);
702 void FormPreferences::Colors::InputRGB()
704 int const red = int(fl_get_slider_value(dialog_->slider_red));
705 int const green = int(fl_get_slider_value(dialog_->slider_green));
706 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
708 string const label = tostr(red) + string(", ") + tostr(green) +
709 string(", ") + tostr(blue);
710 fl_set_object_label(dialog_->text_color_values, label.c_str());
712 fl_freeze_form(dialog_->form);
714 RGBColor col = RGBColor(red, green, blue);
715 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
716 fl_redraw_object(dialog_->button_color);
718 // Ascertain whether to activate the Modify button.
719 vector<NamedColor>::size_type const selLyX =
720 fl_get_browser(dialog_->browser_lyx_objs);
722 fl_unfreeze_form(dialog_->form);
723 if (selLyX < 1) return;
727 // Is the choice an Xforms color...
728 if (selLyX - 1 < xformsColorDB.size()) {
729 vector<XformsColor>::size_type const i = selLyX - 1;
730 modify = (xformsColorDB[i].color() != col);
732 // or a LyX Logical color?
734 vector<NamedColor>::size_type const i = selLyX - 1 -
735 xformsColorDB.size();
736 modify = (lyxColorDB[i].color() != col);
739 setEnabled(dialog_->button_modify, modify);
743 void FormPreferences::Colors::LoadBrowserLyX()
745 if (!dialog_->browser_lyx_objs->visible)
748 // First, define the modifiable xforms colors
749 xformsColorDB.clear();
752 xcol.name = _("GUI background");
753 xcol.colorID = FL_COL1;
754 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
756 xformsColorDB.push_back(xcol);
758 xcol.name = _("GUI text");
759 xcol.colorID = FL_BLACK;
760 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
762 xformsColorDB.push_back(xcol);
764 xcol.name = _("GUI selection");
765 xcol.colorID = FL_YELLOW;
766 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
768 xformsColorDB.push_back(xcol);
770 xcol.name = _("GUI pointer");
771 xcol.colorID = GUI_COLOR_CURSOR;
772 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
774 xformsColorDB.push_back(xcol);
776 // Now create the the LyX LColors database
778 for (int i=0; i<LColor::ignore; ++i) {
779 LColor::color lc = static_cast<LColor::color>(i);
780 if (lc == LColor::none
781 || lc == LColor::black
782 || lc == LColor::white
784 || lc == LColor::green
785 || lc == LColor::blue
786 || lc == LColor::cyan
787 || lc == LColor::magenta
788 || lc == LColor::yellow
789 || lc == LColor::inherit
790 || lc == LColor::ignore) continue;
793 bool const success = getRGBColor(lc, col.r, col.g, col.b);
795 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
796 << "LColor " << lcolor.getLyXName(lc)
797 << ": X can't find color \""
798 << lcolor.getX11Name(lc)
799 << "\". Set to \"black\"!" << endl;
801 string const arg = lcolor.getLyXName(lc) + " black";
802 parent_.controller().setColor(lc, "black");
806 // Create a valid X11 name of the form "#rrggbb" and change the
807 // LColor X11name to this. Don't want to trigger a redraw,
808 // as we're just changing the name not the RGB values.
809 // Also reset the system_lcolor names, so that we don't output
810 // unnecessary changes.
811 string const hexname = X11hexname(col);
813 if (lcolor.getX11Name(lc) != hexname) {
814 lcolor.setColor(lc, hexname);
815 system_lcolor.setColor(lc, hexname);
818 // Finally, push the color onto the database
819 NamedColor ncol(lcolor.getGUIName(lc), col);
820 lyxColorDB.push_back(ncol);
823 // Now construct the browser
824 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
825 fl_freeze_form(dialog_->form);
826 fl_clear_browser(colbr);
827 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
828 cit != xformsColorDB.end(); ++cit) {
829 fl_addto_browser(colbr, cit->getname().c_str());
831 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
832 cit != lyxColorDB.end(); ++cit) {
833 fl_addto_browser(colbr, cit->getname().c_str());
836 // just to be safe...
837 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
838 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
839 fl_unfreeze_form(dialog_->form);
845 void FormPreferences::Colors::Modify()
847 vector<NamedColor>::size_type const selLyX =
848 fl_get_browser(dialog_->browser_lyx_objs);
853 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
855 // Is the choice an Xforms color...
856 if (selLyX - 1 < xformsColorDB.size()) {
857 vector<XformsColor>::size_type const i = selLyX - 1;
858 xformsColorDB[i].r = col.r;
859 xformsColorDB[i].g = col.g;
860 xformsColorDB[i].b = col.b;
862 // or a LyX Logical color?
864 vector<NamedColor>::size_type const i = selLyX - 1 -
865 xformsColorDB.size();
866 lyxColorDB[i].r = col.r;
867 lyxColorDB[i].g = col.g;
868 lyxColorDB[i].b = col.b;
871 fl_freeze_form(dialog_->form);
872 setEnabled(dialog_->button_modify, false);
873 fl_unfreeze_form(dialog_->form);
877 void FormPreferences::Colors::SwitchColorSpace() const
879 bool const hsv = fl_get_button(dialog_->radio_hsv);
882 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
884 fl_freeze_form(dialog_->form);
887 fl_hide_object(dialog_->slider_red);
888 fl_hide_object(dialog_->slider_blue);
889 fl_hide_object(dialog_->slider_green);
890 fl_show_object(dialog_->dial_hue);
891 fl_show_object(dialog_->slider_saturation);
892 fl_show_object(dialog_->slider_value);
894 HSVColor hsv = HSVColor(col);
895 hsv.h = max(hsv.h, 0.0);
897 fl_set_dial_value(dialog_->dial_hue, hsv.h);
898 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
899 fl_set_slider_value(dialog_->slider_value, hsv.v);
901 col = HSVColor(hsv.h, 1.0, 1.0);
902 col.r = max(col.r, 0u);
903 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
904 fl_redraw_object(dialog_->dial_hue);
906 // Adjust the label a bit, but not the actual values.
907 // Means that toggling from one space to the other has no
908 // effect on the final color.
909 int const h = int(hsv.h);
910 int const s = int(100 * hsv.s);
911 int const v = int(100 * hsv.v);
912 string const label = tostr(h) + ", " + tostr(s) +
914 fl_set_object_label(dialog_->text_color_values, label.c_str());
917 fl_show_object(dialog_->slider_red);
918 fl_show_object(dialog_->slider_blue);
919 fl_show_object(dialog_->slider_green);
920 fl_hide_object(dialog_->dial_hue);
921 fl_hide_object(dialog_->slider_saturation);
922 fl_hide_object(dialog_->slider_value);
924 fl_set_slider_value(dialog_->slider_red, col.r);
925 fl_set_slider_value(dialog_->slider_green, col.g);
926 fl_set_slider_value(dialog_->slider_blue, col.b);
928 // Adjust the label a bit. Same reasoning as above.
929 int const r = int(col.r);
930 int const g = int(col.g);
931 int const b = int(col.b);
932 string const label = tostr(r) + ", " + tostr(g) +
934 fl_set_object_label(dialog_->text_color_values, label.c_str());
937 fl_unfreeze_form(dialog_->form);
941 FormPreferences::Converters::Converters(FormPreferences & p)
946 FD_preferences_converters const * FormPreferences::Converters::dialog()
948 return dialog_.get();
952 void FormPreferences::Converters::apply() const
954 parent_.controller().setConverters(local_converters);
958 void FormPreferences::Converters::build()
960 dialog_.reset(build_preferences_converters(&parent_));
962 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
963 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
965 // set up the feedback mechanism
966 setPrehandler(dialog_->browser_all);
967 setPrehandler(dialog_->button_delete);
968 setPrehandler(dialog_->button_add);
969 setPrehandler(dialog_->input_converter);
970 setPrehandler(dialog_->choice_from);
971 setPrehandler(dialog_->choice_to);
972 setPrehandler(dialog_->input_flags);
977 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
979 if (ob == dialog_->browser_all)
980 return _("All the currently defined converters known to LyX.");
982 if (ob == dialog_->choice_from)
983 return _("Convert \"from\" this format");
985 if (ob == dialog_->choice_to)
986 return _("Convert \"to\" this format");
988 if (ob == dialog_->input_converter)
989 return _("The conversion command. $$i is the input file name, "
990 "$$b is the file name without its extension and $$o is "
991 "the name of the output file. $$s can be used as path to "
992 "LyX's own collection of conversion scripts.");
994 if (ob == dialog_->input_flags)
995 return _("Extra information for the Converter class, whether and "
996 "how to parse the result, and various other things.");
998 if (ob == dialog_->button_delete)
999 return _("Remove the current converter from the list of available "
1000 "converters. Note: you must then \"Apply\" the change.");
1002 if (ob == dialog_->button_add) {
1003 if (string(ob->label) == _("Add"))
1004 return _("Add the current converter to the list of available "
1005 "converters. Note: you must then \"Apply\" the change.");
1007 return _("Modify the contents of the current converter. "
1008 "Note: you must then \"Apply\" the change.");
1015 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
1017 if (ob == dialog_->browser_all)
1020 if (ob == dialog_->choice_from
1021 || ob == dialog_->choice_to
1022 || ob == dialog_->input_converter
1023 || ob == dialog_->input_flags)
1026 if (ob == dialog_->button_add)
1029 if (ob == dialog_->button_delete)
1036 void FormPreferences::Converters::update()
1038 local_converters = converters;
1039 local_converters.update(local_formats);
1044 void FormPreferences::Converters::UpdateBrowser()
1046 local_converters.sort();
1048 fl_freeze_form(dialog_->form);
1049 fl_clear_browser(dialog_->browser_all);
1050 for (::Converters::const_iterator cit = local_converters.begin();
1051 cit != local_converters.end(); ++cit) {
1052 string const name = cit->From->prettyname() + " -> "
1053 + cit->To->prettyname();
1054 fl_addto_browser(dialog_->browser_all, name.c_str());
1057 fl_unfreeze_form(dialog_->form);
1061 bool FormPreferences::Converters::Add()
1063 string const from = GetFrom();
1064 string const to = GetTo();
1065 string const command = fl_get_input(dialog_->input_converter);
1066 string const flags = fl_get_input(dialog_->input_flags);
1068 Converter const * old = local_converters.getConverter(from, to);
1069 local_converters.add(from, to, command, flags);
1071 local_converters.updateLast(local_formats);
1074 setEnabled(dialog_->button_add, false);
1080 bool FormPreferences::Converters::Browser()
1082 int const i = fl_get_browser(dialog_->browser_all);
1083 if (i <= 0) return false;
1085 fl_freeze_form(dialog_->form);
1087 Converter const & c = local_converters.get(i - 1);
1088 int j = local_formats.getNumber(c.from);
1090 fl_set_choice(dialog_->choice_from, j + 1);
1092 j = local_formats.getNumber(c.to);
1094 fl_set_choice(dialog_->choice_to, j + 1);
1096 fl_set_input(dialog_->input_converter, c.command.c_str());
1097 fl_set_input(dialog_->input_flags, c.flags.c_str());
1099 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
1100 fl_set_button_shortcut(dialog_->button_add,
1101 scex(_("Modify|#M")).c_str(), 1);
1103 setEnabled(dialog_->button_add, false);
1104 setEnabled(dialog_->button_delete, true);
1106 fl_unfreeze_form(dialog_->form);
1111 bool FormPreferences::Converters::erase()
1113 string const from = GetFrom();
1114 string const to = GetTo();
1116 local_converters.erase(from, to);
1122 bool FormPreferences::Converters::Input()
1124 string const from = GetFrom();
1125 string const to = GetTo();
1126 int const sel = local_converters.getNumber(from, to);
1128 fl_freeze_form(dialog_->form);
1131 fl_set_object_label(dialog_->button_add,
1132 idex(_("Add|#A")).c_str());
1133 fl_set_button_shortcut(dialog_->button_add,
1134 scex(_("Add|#A")).c_str(), 1);
1136 fl_deselect_browser(dialog_->browser_all);
1137 setEnabled(dialog_->button_delete, false);
1140 fl_set_object_label(dialog_->button_add,
1141 idex(_("Modify|#M")).c_str());
1142 fl_set_button_shortcut(dialog_->button_add,
1143 scex(_("Modify|#M")).c_str(), 1);
1145 int top = max(sel-5, 0);
1146 fl_set_browser_topline(dialog_->browser_all, top);
1147 fl_select_browser_line(dialog_->browser_all, sel+1);
1148 setEnabled(dialog_->button_delete, true);
1151 string const command = rtrim(fl_get_input(dialog_->input_converter));
1152 bool const enable = !(command.empty() || from == to);
1153 setEnabled(dialog_->button_add, enable);
1155 fl_unfreeze_form(dialog_->form);
1160 string const FormPreferences::Converters::GetFrom() const
1162 ::Formats::FormatList::size_type const i =
1163 fl_get_choice(dialog_->choice_from);
1165 if (i > 0 && i <= local_formats.size())
1166 return local_formats.get(i - 1).name();
1168 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1173 string const FormPreferences::Converters::GetTo() const
1175 ::Formats::FormatList::size_type const i =
1176 fl_get_choice(dialog_->choice_to);
1178 if (i > 0 && i <= local_formats.size())
1179 return local_formats.get(i - 1).name();
1181 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1186 void FormPreferences::Converters::UpdateChoices() const
1189 for (::Formats::const_iterator cit = local_formats.begin();
1190 cit != local_formats.end(); ++cit) {
1191 if (!choice.empty())
1195 choice += cit->prettyname();
1199 fl_clear_choice(dialog_->choice_from);
1200 fl_addto_choice(dialog_->choice_from, choice.c_str());
1202 fl_clear_choice(dialog_->choice_to);
1203 fl_addto_choice(dialog_->choice_to, choice.c_str());
1207 FormPreferences::Formats::Formats(FormPreferences & p)
1212 FD_preferences_formats const * FormPreferences::Formats::dialog()
1214 return dialog_.get();
1218 void FormPreferences::Formats::apply() const
1220 parent_.controller().setFormats(local_formats);
1224 void FormPreferences::Formats::build()
1226 dialog_.reset(build_preferences_formats(&parent_));
1228 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1229 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1230 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1231 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1232 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1234 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1236 // set up the feedback mechanism
1237 setPrehandler(dialog_->browser_all);
1238 setPrehandler(dialog_->input_format);
1239 setPrehandler(dialog_->input_gui_name);
1240 setPrehandler(dialog_->button_delete);
1241 setPrehandler(dialog_->button_add);
1242 setPrehandler(dialog_->input_extension);
1243 setPrehandler(dialog_->input_viewer);
1244 setPrehandler(dialog_->input_shrtcut);
1249 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1251 if (ob == dialog_->browser_all)
1252 return _("All the currently defined formats known to LyX.");
1254 if (ob == dialog_->input_format)
1255 return _("The format identifier.");
1257 if (ob == dialog_->input_gui_name)
1258 return _("The format name as it will appear in the menus.");
1260 if (ob == dialog_->input_shrtcut)
1261 return _("The keyboard accelerator. Use a letter in the GUI name. "
1264 if (ob == dialog_->input_extension)
1265 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1267 if (ob == dialog_->input_viewer)
1268 return _("The command used to launch the viewer application.");
1270 if (ob == dialog_->button_delete)
1271 return _("Remove the current format from the list of available "
1272 "formats. Note: you must then \"Apply\" the change.");
1274 if (ob == dialog_->button_add) {
1275 if (string(ob->label) == _("Add"))
1276 return _("Add the current format to the list of available "
1277 "formats. Note: you must then \"Apply\" the change.");
1279 return _("Modify the contents of the current format. Note: "
1280 "you must then \"Apply\" the change.");
1287 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1289 if (ob == dialog_->browser_all)
1292 if (ob == dialog_->input_format
1293 || ob == dialog_->input_gui_name
1294 || ob == dialog_->input_shrtcut
1295 || ob == dialog_->input_extension
1296 || ob == dialog_->input_viewer)
1299 if (ob == dialog_->button_add)
1302 if (ob == dialog_->button_delete)
1309 void FormPreferences::Formats::update()
1311 local_formats = formats;
1316 void FormPreferences::Formats::UpdateBrowser()
1318 local_formats.sort();
1320 fl_freeze_form(dialog_->form);
1321 fl_deselect_browser(dialog_->browser_all);
1322 fl_clear_browser(dialog_->browser_all);
1323 for (::Formats::const_iterator cit = local_formats.begin();
1324 cit != local_formats.end(); ++cit)
1325 fl_addto_browser(dialog_->browser_all,
1326 cit->prettyname().c_str());
1329 fl_unfreeze_form(dialog_->form);
1331 // Mustn't forget to update the Formats available to the converters_
1332 parent_.converters_.UpdateChoices();
1333 local_converters.update(local_formats);
1337 bool FormPreferences::Formats::Add()
1339 string const name = fl_get_input(dialog_->input_format);
1340 string const prettyname = fl_get_input(dialog_->input_gui_name);
1341 string const extension = fl_get_input(dialog_->input_extension);
1342 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1343 string const viewer = fl_get_input(dialog_->input_viewer);
1345 Format const * old = local_formats.getFormat(name);
1346 string const old_prettyname = old ? old->prettyname() : string();
1347 local_formats.add(name, extension, prettyname, shortcut);
1348 local_formats.setViewer(name, viewer);
1349 if (!old || prettyname != old_prettyname) {
1352 parent_.converters_.UpdateBrowser();
1354 setEnabled(dialog_->button_add, false);
1360 bool FormPreferences::Formats::Browser()
1362 int const i = fl_get_browser(dialog_->browser_all);
1366 fl_freeze_form(dialog_->form);
1368 Format const & f = local_formats.get(i - 1);
1370 fl_set_input(dialog_->input_format, f.name().c_str());
1371 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1372 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1373 fl_set_input(dialog_->input_extension, f.extension().c_str());
1374 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1376 fl_set_object_label(dialog_->button_add,
1377 idex(_("Modify|#M")).c_str());
1378 fl_set_button_shortcut(dialog_->button_add,
1379 scex(_("Modify|#M")).c_str(), 1);
1381 setEnabled(dialog_->button_add, false);
1382 setEnabled(dialog_->button_delete, true);
1384 fl_unfreeze_form(dialog_->form);
1389 bool FormPreferences::Formats::erase()
1391 string const name = fl_get_input(dialog_->input_format);
1393 if (local_converters.formatIsUsed(name)) {
1394 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1395 "Remove the converter first."));
1396 setEnabled(dialog_->button_delete, false);
1400 local_formats.erase(name);
1406 bool FormPreferences::Formats::Input()
1408 string const name = fl_get_input(dialog_->input_format);
1409 int const sel = local_formats.getNumber(name);
1410 fl_freeze_form(dialog_->form);
1413 fl_set_object_label(dialog_->button_add,
1414 idex(_("Add|#A")).c_str());
1415 fl_set_button_shortcut(dialog_->button_add,
1416 scex(_("Add|#A")).c_str(), 1);
1418 fl_deselect_browser(dialog_->browser_all);
1419 setEnabled(dialog_->button_delete, false);
1422 fl_set_object_label(dialog_->button_add,
1423 idex(_("Modify|#M")).c_str());
1424 fl_set_button_shortcut(dialog_->button_add,
1425 scex(_("Modify|#M")).c_str(), 1);
1427 int const top = max(sel-5, 0);
1428 fl_set_browser_topline(dialog_->browser_all, top);
1429 fl_select_browser_line(dialog_->browser_all, sel+1);
1431 setEnabled(dialog_->button_add, true);
1432 setEnabled(dialog_->button_delete, true);
1435 string const prettyname = fl_get_input(dialog_->input_gui_name);
1436 bool const enable = !(name.empty() || prettyname.empty());
1437 setEnabled(dialog_->button_add, enable);
1439 fl_unfreeze_form(dialog_->form);
1444 FormPreferences::Identity::Identity(FormPreferences & p)
1449 FD_preferences_identity const * FormPreferences::Identity::dialog()
1451 return dialog_.get();
1455 void FormPreferences::Identity::apply(LyXRC & rc) const
1457 rc.user_name = fl_get_input(dialog_->input_user_name);
1458 rc.user_email = fl_get_input(dialog_->input_user_email);
1462 void FormPreferences::Identity::build()
1464 dialog_.reset(build_preferences_identity(&parent_));
1465 fl_set_input_return(dialog_->input_user_name, FL_RETURN_CHANGED);
1466 fl_set_input_return(dialog_->input_user_email, FL_RETURN_CHANGED);
1470 void FormPreferences::Identity::update(LyXRC const & rc)
1472 fl_set_input(dialog_->input_user_name, rc.user_name.c_str());
1473 fl_set_input(dialog_->input_user_email, rc.user_email.c_str());
1477 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1482 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1484 return dialog_.get();
1488 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1490 rc.date_insert_format =
1491 fl_get_input(dialog_->input_date_format);
1495 void FormPreferences::InputsMisc::build()
1497 dialog_.reset(build_preferences_inputs_misc(&parent_));
1499 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1501 // set up the feedback mechanism
1502 setPrehandler(dialog_->input_date_format);
1507 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1509 if (ob == dialog_->input_date_format)
1510 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1515 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1517 fl_set_input(dialog_->input_date_format,
1518 rc.date_insert_format.c_str());
1522 FormPreferences::Interface::Interface(FormPreferences & p)
1527 FD_preferences_interface const * FormPreferences::Interface::dialog()
1529 return dialog_.get();
1533 void FormPreferences::Interface::apply(LyXRC & rc) const
1535 rc.popup_normal_font =
1536 fl_get_input(dialog_->input_popup_normal_font);
1537 rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1538 rc.popup_font_encoding =
1539 fl_get_input(dialog_->input_popup_font_encoding);
1540 rc.bind_file = fl_get_input(dialog_->input_bind_file);
1541 rc.ui_file = fl_get_input(dialog_->input_ui_file);
1545 void FormPreferences::Interface::build()
1547 dialog_.reset(build_preferences_interface(&parent_));
1549 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1550 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1551 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1552 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1553 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1555 // set up the feedback mechanism
1556 setPrehandler(dialog_->input_popup_normal_font);
1557 setPrehandler(dialog_->input_popup_bold_font);
1558 setPrehandler(dialog_->input_popup_font_encoding);
1559 setPrehandler(dialog_->input_bind_file);
1560 setPrehandler(dialog_->button_bind_file_browse);
1561 setPrehandler(dialog_->input_ui_file);
1562 setPrehandler(dialog_->button_ui_file_browse);
1567 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1569 if (ob == dialog_->input_popup_normal_font)
1570 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1571 if (ob == dialog_->input_popup_bold_font)
1572 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1573 if (ob == dialog_->input_popup_font_encoding)
1574 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1575 if (ob == dialog_->input_bind_file)
1576 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1577 if (ob == dialog_->input_ui_file)
1578 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1583 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1585 if (ob == dialog_->button_bind_file_browse) {
1586 string f = parent_.controller().browsebind(
1587 fl_get_input(dialog_->input_bind_file));
1589 fl_set_input(dialog_->input_bind_file, f.c_str());
1590 } else if (ob == dialog_->button_ui_file_browse) {
1591 string f = parent_.controller().browseUI(
1592 fl_get_input(dialog_->input_ui_file));
1594 fl_set_input(dialog_->input_ui_file, f.c_str());
1601 void FormPreferences::Interface::update(LyXRC const & rc)
1603 fl_set_input(dialog_->input_popup_normal_font,
1604 rc.popup_normal_font.c_str());
1605 fl_set_input(dialog_->input_popup_bold_font,
1606 rc.popup_bold_font.c_str());
1607 fl_set_input(dialog_->input_popup_font_encoding,
1608 rc.popup_font_encoding.c_str());
1609 fl_set_input(dialog_->input_bind_file,
1610 rc.bind_file.c_str());
1611 fl_set_input(dialog_->input_ui_file,
1612 rc.ui_file.c_str());
1616 FormPreferences::Language::Language(FormPreferences & p)
1621 FD_preferences_language const * FormPreferences::Language::dialog()
1623 return dialog_.get();
1627 void FormPreferences::Language::apply(LyXRC & rc)
1629 int const pos = fl_get_combox(dialog_->combox_default_lang);
1630 rc.default_language = lang_[pos-1];
1632 int button = fl_get_button(dialog_->check_use_kbmap);
1633 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1634 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1636 button = !(name_1.empty() && name_2.empty());
1637 rc.use_kbmap = static_cast<bool>(button);
1640 rc.primary_kbmap = name_1;
1641 rc.secondary_kbmap = name_2;
1644 button = fl_get_button(dialog_->check_rtl_support);
1645 rc.rtl_support = static_cast<bool>(button);
1647 button = fl_get_button(dialog_->check_mark_foreign);
1648 rc.mark_foreign_language = static_cast<bool>(button);
1650 button = fl_get_button(dialog_->check_auto_begin);
1651 rc.language_auto_begin = static_cast<bool>(button);
1653 button = fl_get_button(dialog_->check_auto_end);
1654 rc.language_auto_end = static_cast<bool>(button);
1656 button = fl_get_button(dialog_->check_use_babel);
1657 rc.language_use_babel = static_cast<bool>(button);
1659 button = fl_get_button(dialog_->check_global_options);
1660 rc.language_global_options = static_cast<bool>(button);
1662 rc.language_package = fl_get_input(dialog_->input_package);
1663 rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1664 rc.language_command_end = fl_get_input(dialog_->input_command_end);
1666 // Ensure that all is self-consistent.
1671 void FormPreferences::Language::build()
1673 dialog_.reset(build_preferences_language(&parent_));
1675 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1676 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1677 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1679 // Store the lang identifiers for later
1680 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1681 lang_ = getSecond(langs);
1683 FL_OBJECT * obj = dialog_->combox_default_lang;
1684 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1685 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1686 for (; lit != lend; ++lit) {
1687 fl_addto_combox(obj, lit->first.c_str());
1689 fl_set_combox_browser_height(obj, 400);
1691 // set up the feedback mechanism
1692 setPrehandler(dialog_->input_package);
1693 setPrehandler(dialog_->check_use_kbmap);
1694 setPrehandler(dialog_->combox_default_lang);
1695 setPrehandler(dialog_->input_kbmap1);
1696 setPrehandler(dialog_->input_kbmap2);
1697 setPrehandler(dialog_->check_rtl_support);
1698 setPrehandler(dialog_->check_mark_foreign);
1699 setPrehandler(dialog_->check_auto_begin);
1700 setPrehandler(dialog_->check_auto_end);
1701 setPrehandler(dialog_->check_use_babel);
1702 setPrehandler(dialog_->check_global_options);
1703 setPrehandler(dialog_->input_command_begin);
1704 setPrehandler(dialog_->input_command_end);
1706 // Activate/Deactivate the input fields dependent on the state of the
1713 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1715 if (ob == dialog_->combox_default_lang)
1716 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1717 if (ob == dialog_->check_use_kbmap)
1718 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1719 if (ob == dialog_->input_kbmap1)
1720 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1721 if (ob == dialog_->input_kbmap2)
1722 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1723 if (ob == dialog_->check_rtl_support)
1724 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1725 if (ob == dialog_->check_mark_foreign)
1726 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1727 if (ob == dialog_->check_auto_begin)
1728 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1729 if (ob == dialog_->check_auto_end)
1730 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1731 if (ob == dialog_->check_use_babel)
1732 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1733 if (ob == dialog_->check_global_options)
1734 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1735 if (ob == dialog_->input_package)
1736 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1737 if (ob == dialog_->input_command_begin)
1738 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1739 if (ob == dialog_->input_command_end)
1740 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1745 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1747 bool activate = true;
1749 // !ob if function is called from Language::build() to de/activate
1751 // otherwise the function is called by an xforms CB via input().
1752 if (!ob || ob == dialog_->check_use_kbmap) {
1753 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1754 setEnabled(dialog_->button_kbmap1_browse, enable);
1755 setEnabled(dialog_->button_kbmap2_browse, enable);
1756 setEnabled(dialog_->input_kbmap1, enable);
1757 setEnabled(dialog_->input_kbmap2, enable);
1760 if (ob == dialog_->button_kbmap1_browse) {
1761 string f = parent_.controller().browsekbmap(
1762 fl_get_input(dialog_->input_kbmap1));
1764 fl_set_input(dialog_->input_kbmap1, f.c_str());
1765 } else if (ob == dialog_->button_kbmap2_browse) {
1766 string f = parent_.controller().browsekbmap(
1767 fl_get_input(dialog_->input_kbmap2));
1769 fl_set_input(dialog_->input_kbmap2, f.c_str());
1776 void FormPreferences::Language::update(LyXRC const & rc)
1778 fl_set_button(dialog_->check_use_kbmap,
1781 int const pos = int(findPos(lang_, rc.default_language));
1782 fl_set_combox(dialog_->combox_default_lang, pos + 1);
1785 fl_set_input(dialog_->input_kbmap1,
1786 rc.primary_kbmap.c_str());
1787 fl_set_input(dialog_->input_kbmap2,
1788 rc.secondary_kbmap.c_str());
1790 fl_set_input(dialog_->input_kbmap1, "");
1791 fl_set_input(dialog_->input_kbmap2, "");
1794 fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1795 fl_set_button(dialog_->check_mark_foreign,
1796 rc.mark_foreign_language);
1797 fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1798 fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1799 fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1800 fl_set_button(dialog_->check_global_options,
1801 rc.language_global_options);
1803 fl_set_input(dialog_->input_package,
1804 rc.language_package.c_str());
1805 fl_set_input(dialog_->input_command_begin,
1806 rc.language_command_begin.c_str());
1807 fl_set_input(dialog_->input_command_end,
1808 rc.language_command_end.c_str());
1810 // Activate/Deactivate the input fields dependent on the state of the
1816 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1821 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1823 return dialog_.get();
1827 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1829 rc.auto_region_delete =
1830 fl_get_button(dialog_->check_auto_region_delete);
1831 rc.cursor_follows_scrollbar =
1832 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1833 rc.dialogs_iconify_with_main =
1834 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1835 rc.preview = fl_get_button(dialog_->check_preview_latex);
1836 rc.autosave = static_cast<unsigned int>
1837 (fl_get_counter_value(dialog_->counter_autosave));
1838 rc.wheel_jump = static_cast<unsigned int>
1839 (fl_get_counter_value(dialog_->counter_wm_jump));
1842 // grfx::DisplayType old_value = rc.display_graphics;
1843 switch (fl_get_choice(dialog_->choice_display)) {
1845 rc.display_graphics = grfx::NoDisplay;
1848 rc.display_graphics = grfx::ColorDisplay;
1851 rc.display_graphics = grfx::GrayscaleDisplay;
1854 rc.display_graphics = grfx::MonochromeDisplay;
1857 rc.display_graphics = grfx::ColorDisplay;
1861 #ifdef WITH_WARNINGS
1862 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1865 if (old_value != rc.display_graphics) {
1866 grfx::GCache & gc = grfx::GCache::get();
1873 void FormPreferences::LnFmisc::build()
1875 dialog_.reset(build_preferences_lnf_misc(&parent_));
1877 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1878 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1880 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1881 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1883 // set up the feedback mechanism
1884 setPrehandler(dialog_->check_auto_region_delete);
1885 setPrehandler(dialog_->counter_autosave);
1886 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1887 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1888 setPrehandler(dialog_->check_preview_latex);
1889 setPrehandler(dialog_->counter_wm_jump);
1891 fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
1896 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1898 if (ob == dialog_->check_auto_region_delete)
1899 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
1900 if (ob == dialog_->check_cursor_follows_scrollbar)
1901 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1902 if (ob == dialog_->check_dialogs_iconify_with_main)
1903 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1904 if (ob == dialog_->check_preview_latex)
1905 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
1906 if (ob == dialog_->counter_autosave)
1907 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
1908 if (ob == dialog_->counter_wm_jump)
1909 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
1910 if (ob == dialog_->choice_display)
1911 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1916 void FormPreferences::LnFmisc::update(LyXRC const & rc)
1918 fl_set_button(dialog_->check_auto_region_delete,
1919 rc.auto_region_delete);
1920 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1921 rc.cursor_follows_scrollbar);
1922 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1923 rc.dialogs_iconify_with_main);
1924 fl_set_button(dialog_->check_preview_latex,
1926 fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
1927 fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
1929 switch (rc.display_graphics) {
1930 case grfx::NoDisplay:
1931 fl_set_choice(dialog_->choice_display, 4);
1933 case grfx::ColorDisplay:
1934 fl_set_choice(dialog_->choice_display, 3);
1936 case grfx::GrayscaleDisplay:
1937 fl_set_choice(dialog_->choice_display, 2);
1939 case grfx::MonochromeDisplay:
1940 fl_set_choice(dialog_->choice_display, 1);
1943 fl_set_choice(dialog_->choice_display, 3);
1949 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1954 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1956 return dialog_.get();
1960 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
1962 rc.ascii_linelen = static_cast<unsigned int>
1963 (fl_get_counter_value(dialog_->counter_line_len));
1964 rc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1967 fl_get_choice(dialog_->choice_default_papersize) - 1;
1968 rc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1970 rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1971 rc.chktex_command = fl_get_input(dialog_->input_checktex);
1972 rc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1973 rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1977 void FormPreferences::OutputsMisc::build()
1979 dialog_.reset(build_preferences_outputs_misc(&parent_));
1981 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1983 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1984 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1985 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1986 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1987 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1989 fl_addto_choice(dialog_->choice_default_papersize,
1990 _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1992 // set up the feedback mechanism
1993 setPrehandler(dialog_->counter_line_len);
1994 setPrehandler(dialog_->input_tex_encoding);
1995 setPrehandler(dialog_->choice_default_papersize);
1996 setPrehandler(dialog_->input_ascii_roff);
1997 setPrehandler(dialog_->input_checktex);
1998 setPrehandler(dialog_->input_paperoption);
1999 setPrehandler(dialog_->check_autoreset_classopt);
2004 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
2006 if (ob == dialog_->counter_line_len)
2007 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
2008 if (ob == dialog_->input_tex_encoding)
2009 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
2010 if (ob == dialog_->input_ascii_roff)
2011 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
2012 if (ob == dialog_->input_checktex)
2013 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
2014 if (ob == dialog_->choice_default_papersize)
2015 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2016 if (ob == dialog_->input_paperoption)
2017 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
2018 if (ob == dialog_->check_autoreset_classopt)
2019 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2024 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
2026 fl_set_counter_value(dialog_->counter_line_len,
2028 fl_set_input(dialog_->input_tex_encoding,
2029 rc.fontenc.c_str());
2030 fl_set_choice(dialog_->choice_default_papersize,
2031 rc.default_papersize + 1);
2032 fl_set_input(dialog_->input_ascii_roff,
2033 rc.ascii_roff_command.c_str());
2034 fl_set_input(dialog_->input_checktex,
2035 rc.chktex_command.c_str());
2036 fl_set_input(dialog_->input_paperoption,
2037 rc.view_dvi_paper_option.c_str());
2038 fl_set_button(dialog_->check_autoreset_classopt,
2039 rc.auto_reset_options);
2044 FormPreferences::Paths::Paths(FormPreferences & p)
2049 FD_preferences_paths const * FormPreferences::Paths::dialog()
2051 return dialog_.get();
2055 void FormPreferences::Paths::apply(LyXRC & rc)
2057 rc.document_path = fl_get_input(dialog_->input_default_path);
2058 rc.template_path = fl_get_input(dialog_->input_template_path);
2060 int button = fl_get_button(dialog_->check_use_temp_dir);
2061 string str = fl_get_input(dialog_->input_temp_dir);
2065 rc.use_tempdir = button;
2066 rc.tempdir_path = str;
2068 button = fl_get_button(dialog_->check_last_files);
2069 str = fl_get_input(dialog_->input_lastfiles);
2070 if (!button) str.erase();
2072 rc.check_lastfiles = button;
2074 rc.num_lastfiles = static_cast<unsigned int>
2075 (fl_get_counter_value(dialog_->counter_lastfiles));
2077 button = fl_get_button(dialog_->check_make_backups);
2078 str = fl_get_input(dialog_->input_backup_path);
2082 rc.make_backup = button;
2083 rc.backupdir_path = str;
2085 rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2092 void FormPreferences::Paths::build()
2094 dialog_.reset(build_preferences_paths(&parent_));
2096 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2097 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2098 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2099 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2100 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2101 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2102 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2104 // set up the feedback mechanism
2105 setPrehandler(dialog_->input_default_path);
2106 setPrehandler(dialog_->counter_lastfiles);
2107 setPrehandler(dialog_->input_template_path);
2108 setPrehandler(dialog_->check_last_files);
2109 setPrehandler(dialog_->input_lastfiles);
2110 setPrehandler(dialog_->check_make_backups);
2111 setPrehandler(dialog_->input_backup_path);
2112 setPrehandler(dialog_->input_serverpipe);
2113 setPrehandler(dialog_->input_temp_dir);
2114 setPrehandler(dialog_->check_use_temp_dir);
2119 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2121 if (ob == dialog_->input_default_path)
2122 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2123 if (ob == dialog_->input_template_path)
2124 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2125 if (ob == dialog_->check_use_temp_dir)
2126 return LyXRC::getDescription(LyXRC::RC_USETEMPDIR);
2127 if (ob == dialog_->input_temp_dir)
2128 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2129 if (ob == dialog_->check_last_files)
2130 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2131 if (ob == dialog_->input_lastfiles)
2132 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
2133 if (ob == dialog_->counter_lastfiles)
2134 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2135 if (ob == dialog_->check_make_backups)
2136 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2137 if (ob == dialog_->input_backup_path)
2138 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2139 if (ob == dialog_->input_serverpipe)
2140 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2145 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2147 bool activate = true;
2149 // !ob if function is called from Paths::update() to de/activate
2151 // otherwise the function is called by an xforms CB via input().
2152 if (!ob || ob == dialog_->check_use_temp_dir) {
2153 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2154 setEnabled(dialog_->input_temp_dir, enable);
2157 if (!ob || ob == dialog_->check_last_files) {
2158 bool const enable = fl_get_button(dialog_->check_last_files);
2159 setEnabled(dialog_->input_lastfiles, enable);
2162 if (!ob || ob == dialog_->check_make_backups) {
2163 bool const enable = fl_get_button(dialog_->check_make_backups);
2164 setEnabled(dialog_->input_backup_path, enable);
2167 if (!ob || ob == dialog_->input_default_path) {
2168 string const name = fl_get_input(dialog_->input_default_path);
2169 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2170 parent_.postWarning(RWInfo::ErrorMessage());
2175 if (!ob || ob == dialog_->input_template_path) {
2176 string const name = fl_get_input(dialog_->input_template_path);
2177 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2178 parent_.postWarning(RWInfo::ErrorMessage());
2183 if (!ob || ob == dialog_->input_temp_dir) {
2184 string const name = fl_get_input(dialog_->input_temp_dir);
2185 if (fl_get_button(dialog_->check_make_backups)
2187 && !RWInfo::WriteableDir(name)) {
2188 parent_.postWarning(RWInfo::ErrorMessage());
2193 if (!ob || ob == dialog_->input_backup_path) {
2194 string const name = fl_get_input(dialog_->input_backup_path);
2195 if (fl_get_button(dialog_->check_make_backups)
2197 && !RWInfo::WriteableDir(name)) {
2198 parent_.postWarning(RWInfo::ErrorMessage());
2203 if (!ob || ob == dialog_->input_lastfiles) {
2204 string const name = fl_get_input(dialog_->input_lastfiles);
2205 if (fl_get_button(dialog_->check_last_files)
2207 && !RWInfo::WriteableFile(name)) {
2208 parent_.postWarning(RWInfo::ErrorMessage());
2213 if (!ob || ob == dialog_->input_serverpipe) {
2214 string const name = fl_get_input(dialog_->input_serverpipe);
2215 if (!name.empty()) {
2216 // strip off the extension
2217 string const str = ChangeExtension(name, "");
2218 if (!RWInfo::WriteableFile(str + ".in")) {
2219 parent_.postWarning(RWInfo::ErrorMessage());
2222 if (!RWInfo::WriteableFile(str + ".out")) {
2223 parent_.postWarning(RWInfo::ErrorMessage());
2229 if (ob == dialog_->button_default_path_browse) {
2230 string f = parent_.controller().browsedir(
2231 fl_get_input(dialog_->input_default_path), _("Default path"));
2233 fl_set_input(dialog_->input_default_path, f.c_str());
2234 } else if (ob == dialog_->button_template_path_browse) {
2235 string f = parent_.controller().browsedir(
2236 fl_get_input(dialog_->input_template_path), _("Template path"));
2238 fl_set_input(dialog_->input_template_path, f.c_str());
2239 } else if (ob == dialog_->button_temp_dir_browse) {
2240 string f = parent_.controller().browsedir(
2241 fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2243 fl_set_input(dialog_->input_temp_dir, f.c_str());
2244 } else if (ob == dialog_->button_lastfiles_browse) {
2245 string f = parent_.controller().browse(
2246 fl_get_input(dialog_->input_lastfiles), _("Last files"));
2248 fl_set_input(dialog_->input_lastfiles, f.c_str());
2249 } else if (ob == dialog_->button_backup_path_browse) {
2250 string f = parent_.controller().browsedir(
2251 fl_get_input(dialog_->input_backup_path), _("Backup path"));
2253 fl_set_input(dialog_->input_backup_path, f.c_str());
2254 } else if (ob == dialog_->button_serverpipe_browse) {
2255 string f = parent_.controller().browse(
2256 fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2258 fl_set_input(dialog_->input_serverpipe, f.c_str());
2265 void FormPreferences::Paths::update(LyXRC const & rc)
2267 fl_set_input(dialog_->input_default_path,
2268 rc.document_path.c_str());
2269 fl_set_input(dialog_->input_template_path,
2270 rc.template_path.c_str());
2274 str = rc.backupdir_path;
2276 fl_set_button(dialog_->check_make_backups,
2278 fl_set_input(dialog_->input_backup_path, str.c_str());
2282 str = rc.tempdir_path;
2284 fl_set_button(dialog_->check_use_temp_dir,
2286 fl_set_input(dialog_->input_temp_dir, str.c_str());
2289 if (rc.check_lastfiles)
2292 fl_set_button(dialog_->check_last_files,
2293 rc.check_lastfiles);
2294 fl_set_input(dialog_->input_lastfiles, str.c_str());
2295 fl_set_counter_value(dialog_->counter_lastfiles,
2298 fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2300 // Activate/Deactivate the input fields dependent on the state of the
2306 FormPreferences::Printer::Printer(FormPreferences & p)
2311 FD_preferences_printer const * FormPreferences::Printer::dialog()
2313 return dialog_.get();
2317 void FormPreferences::Printer::apply(LyXRC & rc) const
2319 rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2320 rc.print_command = fl_get_input(dialog_->input_command);
2321 rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2322 rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2323 rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2324 rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2325 rc.print_file_extension =
2326 fl_get_input(dialog_->input_file_extension);
2327 rc.print_spool_command =
2328 fl_get_input(dialog_->input_spool_command);
2329 rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2330 rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2331 rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2332 rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2333 rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2334 rc.print_to_file = fl_get_input(dialog_->input_to_file);
2335 rc.print_extra_options =
2336 fl_get_input(dialog_->input_extra_options);
2337 rc.print_spool_printerprefix =
2338 fl_get_input(dialog_->input_spool_prefix);
2339 rc.print_paper_dimension_flag =
2340 fl_get_input(dialog_->input_paper_size);
2341 rc.printer = fl_get_input(dialog_->input_name);
2346 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2348 if (ob == dialog_->input_command)
2349 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2350 if (ob == dialog_->check_adapt_output)
2351 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2352 if (ob == dialog_->input_to_printer)
2353 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2354 if (ob == dialog_->input_to_file)
2355 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2356 if (ob == dialog_->input_file_extension)
2357 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2358 if (ob == dialog_->input_extra_options)
2359 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2360 if (ob == dialog_->input_spool_command)
2361 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2362 if (ob == dialog_->input_spool_prefix)
2363 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2364 if (ob == dialog_->input_name)
2365 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2366 if (ob == dialog_->input_even_pages)
2367 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2368 if (ob == dialog_->input_odd_pages)
2369 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2370 if (ob == dialog_->input_page_range)
2371 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2372 if (ob == dialog_->input_reverse)
2373 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2374 if (ob == dialog_->input_landscape)
2375 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2376 if (ob == dialog_->input_copies)
2377 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2378 if (ob == dialog_->input_collated)
2379 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2380 if (ob == dialog_->input_paper_type)
2381 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2382 if (ob == dialog_->input_paper_size)
2383 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2388 void FormPreferences::Printer::build()
2390 dialog_.reset(build_preferences_printer(&parent_));
2392 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2393 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2394 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2395 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2396 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2397 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2398 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2399 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2400 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2401 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2402 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2403 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2404 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2405 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2406 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2407 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2408 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2410 // set up the feedback mechanism
2411 setPrehandler(dialog_->input_command);
2412 setPrehandler(dialog_->input_page_range);
2413 setPrehandler(dialog_->input_copies);
2414 setPrehandler(dialog_->input_reverse);
2415 setPrehandler(dialog_->input_to_printer);
2416 setPrehandler(dialog_->input_file_extension);
2417 setPrehandler(dialog_->input_spool_command);
2418 setPrehandler(dialog_->input_paper_type);
2419 setPrehandler(dialog_->input_even_pages);
2420 setPrehandler(dialog_->input_odd_pages);
2421 setPrehandler(dialog_->input_collated);
2422 setPrehandler(dialog_->input_landscape);
2423 setPrehandler(dialog_->input_to_file);
2424 setPrehandler(dialog_->input_extra_options);
2425 setPrehandler(dialog_->input_spool_prefix);
2426 setPrehandler(dialog_->input_paper_size);
2427 setPrehandler(dialog_->input_name);
2428 setPrehandler(dialog_->check_adapt_output);
2432 void FormPreferences::Printer::update(LyXRC const & rc)
2434 fl_set_button(dialog_->check_adapt_output,
2435 rc.print_adapt_output);
2436 fl_set_input(dialog_->input_command,
2437 rc.print_command.c_str());
2438 fl_set_input(dialog_->input_page_range,
2439 rc.print_pagerange_flag.c_str());
2440 fl_set_input(dialog_->input_copies,
2441 rc.print_copies_flag.c_str());
2442 fl_set_input(dialog_->input_reverse,
2443 rc.print_reverse_flag.c_str());
2444 fl_set_input(dialog_->input_to_printer,
2445 rc.print_to_printer.c_str());
2446 fl_set_input(dialog_->input_file_extension,
2447 rc.print_file_extension.c_str());
2448 fl_set_input(dialog_->input_spool_command,
2449 rc.print_spool_command.c_str());
2450 fl_set_input(dialog_->input_paper_type,
2451 rc.print_paper_flag.c_str());
2452 fl_set_input(dialog_->input_even_pages,
2453 rc.print_evenpage_flag.c_str());
2454 fl_set_input(dialog_->input_odd_pages,
2455 rc.print_oddpage_flag.c_str());
2456 fl_set_input(dialog_->input_collated,
2457 rc.print_collcopies_flag.c_str());
2458 fl_set_input(dialog_->input_landscape,
2459 rc.print_landscape_flag.c_str());
2460 fl_set_input(dialog_->input_to_file,
2461 rc.print_to_file.c_str());
2462 fl_set_input(dialog_->input_extra_options,
2463 rc.print_extra_options.c_str());
2464 fl_set_input(dialog_->input_spool_prefix,
2465 rc.print_spool_printerprefix.c_str());
2466 fl_set_input(dialog_->input_paper_size,
2467 rc.print_paper_dimension_flag.c_str());
2468 fl_set_input(dialog_->input_name,
2469 rc.printer.c_str());
2473 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2478 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2480 return dialog_.get();
2484 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2486 bool changed = false;
2488 pair<string, string> tmp =
2489 parseFontName(fl_get_input(dialog_->input_roman));
2490 if (rc.roman_font_name != tmp.first ||
2491 rc.roman_font_foundry != tmp.second) {
2493 rc.roman_font_name = tmp.first;
2494 rc.roman_font_foundry = tmp.second;
2497 tmp = parseFontName(fl_get_input(dialog_->input_sans));
2498 if (rc.sans_font_name != tmp.first ||
2499 rc.sans_font_foundry != tmp.second) {
2501 rc.sans_font_name = tmp.first;
2502 rc.sans_font_foundry = tmp.second;
2505 tmp = parseFontName(fl_get_input(dialog_->input_typewriter));
2506 if (rc.typewriter_font_name != tmp.first ||
2507 rc.typewriter_font_foundry != tmp.second) {
2509 rc.typewriter_font_name = tmp.first;
2510 rc.typewriter_font_foundry = tmp.second;
2513 string str = fl_get_input(dialog_->input_screen_encoding);
2514 if (rc.font_norm != str) {
2517 rc.set_font_norm_type();
2520 bool button = fl_get_button(dialog_->check_scalable);
2521 if (rc.use_scalable_fonts != button) {
2523 rc.use_scalable_fonts = button;
2526 unsigned int ivalue = static_cast<unsigned int>
2527 (fl_get_counter_value(dialog_->counter_zoom));
2528 if (rc.zoom != ivalue) {
2533 ivalue = static_cast<unsigned int>
2534 (fl_get_counter_value(dialog_->counter_dpi));
2535 if (rc.dpi != ivalue) {
2540 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2541 if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2543 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2546 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2547 if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2549 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2552 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2553 if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2555 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2558 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2559 if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2561 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2564 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2565 if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2567 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2570 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2571 if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2573 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2576 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2577 if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2579 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2582 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2583 if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2585 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2588 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2589 if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2591 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2594 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2595 if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2597 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2601 // Now update the buffers
2602 // Can anything below here affect the redraw process?
2603 parent_.controller().updateScreenFonts();
2608 void FormPreferences::ScreenFonts::build()
2610 dialog_.reset(build_preferences_screen_fonts(&parent_));
2612 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2613 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2615 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2616 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2617 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2618 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2619 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2620 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2621 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2622 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2623 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2624 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2625 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2626 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2627 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2628 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2629 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2630 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2632 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2633 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2634 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2635 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2636 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2637 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2638 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2639 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2640 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2641 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2643 // set up the feedback mechanism
2644 setPrehandler(dialog_->input_roman);
2645 setPrehandler(dialog_->input_sans);
2646 setPrehandler(dialog_->input_typewriter);
2647 setPrehandler(dialog_->counter_zoom);
2648 setPrehandler(dialog_->counter_dpi);
2649 setPrehandler(dialog_->check_scalable);
2650 setPrehandler(dialog_->input_screen_encoding);
2651 setPrehandler(dialog_->input_tiny);
2652 setPrehandler(dialog_->input_script);
2653 setPrehandler(dialog_->input_footnote);
2654 setPrehandler(dialog_->input_small);
2655 setPrehandler(dialog_->input_large);
2656 setPrehandler(dialog_->input_larger);
2657 setPrehandler(dialog_->input_largest);
2658 setPrehandler(dialog_->input_normal);
2659 setPrehandler(dialog_->input_huge);
2660 setPrehandler(dialog_->input_huger);
2665 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2667 if (ob == dialog_->input_roman)
2668 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2669 if (ob == dialog_->input_sans)
2670 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2671 if (ob == dialog_->input_typewriter)
2672 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2673 if (ob == dialog_->check_scalable)
2674 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2675 if (ob == dialog_->input_screen_encoding)
2676 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2677 if (ob == dialog_->counter_zoom)
2678 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2679 if (ob == dialog_->counter_dpi)
2680 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2681 if (ob == dialog_->input_tiny
2682 || ob == dialog_->input_script
2683 || ob == dialog_->input_footnote
2684 || ob == dialog_->input_small
2685 || ob == dialog_->input_large
2686 || ob == dialog_->input_larger
2687 || ob == dialog_->input_larger
2688 || ob == dialog_->input_largest
2689 || ob == dialog_->input_normal
2690 || ob == dialog_->input_huge
2691 || ob == dialog_->input_huger)
2692 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2697 bool FormPreferences::ScreenFonts::input()
2699 bool activate = true;
2702 // Make sure that all fonts all have positive entries
2703 // Also note that an empty entry is returned as 0.0 by strToDbl
2704 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2705 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2706 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2707 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2708 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2709 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2710 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2711 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2712 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2713 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2715 str = _("Fonts must be positive!");
2717 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2718 // Fontsizes -- tiny < script < footnote etc.
2719 strToDbl(fl_get_input(dialog_->input_script)) ||
2720 strToDbl(fl_get_input(dialog_->input_script)) >
2721 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2722 strToDbl(fl_get_input(dialog_->input_footnote)) >
2723 strToDbl(fl_get_input(dialog_->input_small)) ||
2724 strToDbl(fl_get_input(dialog_->input_small)) >
2725 strToDbl(fl_get_input(dialog_->input_normal)) ||
2726 strToDbl(fl_get_input(dialog_->input_normal)) >
2727 strToDbl(fl_get_input(dialog_->input_large)) ||
2728 strToDbl(fl_get_input(dialog_->input_large)) >
2729 strToDbl(fl_get_input(dialog_->input_larger)) ||
2730 strToDbl(fl_get_input(dialog_->input_larger)) >
2731 strToDbl(fl_get_input(dialog_->input_largest)) ||
2732 strToDbl(fl_get_input(dialog_->input_largest)) >
2733 strToDbl(fl_get_input(dialog_->input_huge)) ||
2734 strToDbl(fl_get_input(dialog_->input_huge)) >
2735 strToDbl(fl_get_input(dialog_->input_huger))) {
2738 str = _("Fonts must be input in the order Tiny > Smallest > Smaller > Small > Normal > Large > Larger > Largest > Huge > Huger.");
2742 parent_.postWarning(str);
2748 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2750 fl_set_input(dialog_->input_roman,
2751 makeFontName(rc.roman_font_name,
2752 rc.roman_font_foundry).c_str());
2753 fl_set_input(dialog_->input_sans,
2754 makeFontName(rc.sans_font_name,
2755 rc.sans_font_foundry).c_str());
2756 fl_set_input(dialog_->input_typewriter,
2757 makeFontName(rc.typewriter_font_name,
2758 rc.typewriter_font_foundry).c_str());
2759 fl_set_input(dialog_->input_screen_encoding,
2760 rc.font_norm.c_str());
2761 fl_set_button(dialog_->check_scalable,
2762 rc.use_scalable_fonts);
2763 fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2764 fl_set_counter_value(dialog_->counter_dpi, rc.dpi);
2765 fl_set_input(dialog_->input_tiny,
2766 tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2767 fl_set_input(dialog_->input_script,
2768 tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2769 fl_set_input(dialog_->input_footnote,
2770 tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2771 fl_set_input(dialog_->input_small,
2772 tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2773 fl_set_input(dialog_->input_normal,
2774 tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2775 fl_set_input(dialog_->input_large,
2776 tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2777 fl_set_input(dialog_->input_larger,
2778 tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2779 fl_set_input(dialog_->input_largest,
2780 tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2781 fl_set_input(dialog_->input_huge,
2782 tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2783 fl_set_input(dialog_->input_huger,
2784 tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2789 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2794 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2796 return dialog_.get();
2800 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2802 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2803 choice = trim(choice);
2805 rc.isp_command = choice;
2808 // If spell checker == "none", all other input set to off.
2809 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2810 rc.isp_use_alt_lang = false;
2811 rc.isp_alt_lang.erase();
2813 rc.isp_use_esc_chars = false;
2814 rc.isp_esc_chars.erase();
2816 rc.isp_use_pers_dict = false;
2817 rc.isp_pers_dict.erase();
2819 rc.isp_accept_compound = false;
2820 rc.isp_use_input_encoding = false;
2823 int button = fl_get_button(dialog_->check_alt_lang);
2824 choice = fl_get_input(dialog_->input_alt_lang);
2825 if (button && choice.empty()) button = 0;
2826 if (!button) choice.erase();
2828 rc.isp_use_alt_lang = static_cast<bool>(button);
2829 rc.isp_alt_lang = choice;
2831 button = fl_get_button(dialog_->check_escape_chars);
2832 choice = fl_get_input(dialog_->input_escape_chars);
2833 if (button && choice.empty()) button = 0;
2834 if (!button) choice.erase();
2836 rc.isp_use_esc_chars = static_cast<bool>(button);
2837 rc.isp_esc_chars = choice;
2839 button = fl_get_button(dialog_->check_personal_dict);
2840 choice = fl_get_input(dialog_->input_personal_dict);
2841 if (button && choice.empty()) button = 0;
2842 if (!button) choice.erase();
2844 rc.isp_use_pers_dict = static_cast<bool>(button);
2845 rc.isp_pers_dict = choice;
2847 button = fl_get_button(dialog_->check_compound_words);
2848 rc.isp_accept_compound = static_cast<bool>(button);
2850 button = fl_get_button(dialog_->check_input_enc);
2851 rc.isp_use_input_encoding = static_cast<bool>(button);
2862 void FormPreferences::SpellOptions::build()
2864 dialog_.reset(build_preferences_spelloptions(&parent_));
2866 fl_addto_choice(dialog_->choice_spell_command,
2867 _(" ispell | aspell "));
2868 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2869 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2870 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2872 // set up the feedback mechanism
2873 setPrehandler(dialog_->choice_spell_command);
2874 setPrehandler(dialog_->check_alt_lang);
2875 setPrehandler(dialog_->input_alt_lang);
2876 setPrehandler(dialog_->check_escape_chars);
2877 setPrehandler(dialog_->input_escape_chars);
2878 setPrehandler(dialog_->check_personal_dict);
2879 setPrehandler(dialog_->input_personal_dict);
2880 setPrehandler(dialog_->button_personal_dict);
2881 setPrehandler(dialog_->check_compound_words);
2882 setPrehandler(dialog_->check_input_enc);
2887 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2889 if (ob == dialog_->choice_spell_command)
2890 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2891 if (ob == dialog_->check_alt_lang)
2892 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2893 if (ob == dialog_->input_alt_lang)
2894 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2895 if (ob == dialog_->check_escape_chars)
2896 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2897 if (ob == dialog_->input_escape_chars)
2898 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2899 if (ob == dialog_->check_personal_dict)
2900 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2901 if (ob == dialog_->input_personal_dict)
2902 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2903 if (ob == dialog_->check_compound_words)
2904 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2905 if (ob == dialog_->check_input_enc)
2906 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
2911 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2913 // !ob if function is called from updateSpellOptions() to de/activate
2915 // otherwise the function is called by an xforms CB via input().
2918 // If spell checker == "none", disable all input.
2919 if (!ob || ob == dialog_->choice_spell_command) {
2920 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2921 fl_deactivate_object(dialog_->check_alt_lang);
2922 fl_deactivate_object(dialog_->input_alt_lang);
2923 fl_deactivate_object(dialog_->check_escape_chars);
2924 fl_deactivate_object(dialog_->input_escape_chars);
2925 fl_deactivate_object(dialog_->check_personal_dict);
2926 fl_deactivate_object(dialog_->input_personal_dict);
2927 fl_deactivate_object(dialog_->check_compound_words);
2928 fl_deactivate_object(dialog_->check_input_enc);
2931 fl_activate_object(dialog_->check_alt_lang);
2932 fl_activate_object(dialog_->check_escape_chars);
2933 fl_activate_object(dialog_->check_personal_dict);
2934 fl_activate_object(dialog_->check_compound_words);
2935 fl_activate_object(dialog_->check_input_enc);
2940 if (!ob || ob == dialog_->check_alt_lang) {
2941 bool const enable = fl_get_button(dialog_->check_alt_lang);
2942 setEnabled(dialog_->input_alt_lang, enable);
2945 if (!ob || ob == dialog_->check_escape_chars) {
2946 bool const enable = fl_get_button(dialog_->check_escape_chars);
2947 setEnabled(dialog_->input_escape_chars, enable);
2950 if (!ob || ob == dialog_->check_personal_dict) {
2951 bool const enable = fl_get_button(dialog_->check_personal_dict);
2952 setEnabled(dialog_->input_personal_dict, enable);
2955 if (ob == dialog_->button_personal_dict) {
2956 string f = parent_.controller().browsedict(
2957 fl_get_input(dialog_->input_personal_dict));
2958 fl_set_input(dialog_->input_personal_dict, f.c_str());
2961 return true; // All input is valid!
2965 void FormPreferences::SpellOptions::update(LyXRC const & rc)
2969 if (rc.isp_command == "none")
2971 else if (rc.isp_command == "ispell")
2973 else if (rc.isp_command == "aspell")
2976 if (rc.isp_command == "ispell")
2978 else if (rc.isp_command == "aspell")
2981 fl_set_choice(dialog_->choice_spell_command, choice);
2984 if (rc.isp_use_alt_lang)
2985 str = rc.isp_alt_lang;
2987 fl_set_button(dialog_->check_alt_lang,
2988 rc.isp_use_alt_lang);
2989 fl_set_input(dialog_->input_alt_lang, str.c_str());
2992 if (rc.isp_use_esc_chars)
2993 str = rc.isp_esc_chars;
2995 fl_set_button(dialog_->check_escape_chars,
2996 rc.isp_use_esc_chars);
2997 fl_set_input(dialog_->input_escape_chars, str.c_str());
3000 if (rc.isp_use_pers_dict)
3001 str = rc.isp_pers_dict;
3003 fl_set_button(dialog_->check_personal_dict,
3004 rc.isp_use_pers_dict);
3005 fl_set_input(dialog_->input_personal_dict, str.c_str());
3007 fl_set_button(dialog_->check_compound_words,
3008 rc.isp_accept_compound);
3009 fl_set_button(dialog_->check_input_enc,
3010 rc.isp_use_input_encoding);
3012 // Activate/Deactivate the input fields dependent on the state of the