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
13 #include "ControlPrefs.h"
14 #include "FormPreferences.h"
15 #include "forms/form_preferences.h"
17 #include "ButtonController.h"
20 #include "input_validators.h"
21 #include "forms_gettext.h"
22 #include "xforms_helpers.h"
23 #include "helper_funcs.h" // getSecond
26 #include "converter.h"
30 #include "frnt_lang.h"
35 #include "funcrequest.h"
38 #include "support/lyxfunctional.h"
39 #include "support/lyxmanip.h"
40 #include "support/tostr.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 "lyx_forms.h"
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,
230 _("Look & Feel").c_str(),
231 look_n_feel_tab_->form);
232 fl_addto_tabfolder(dialog_->tabfolder_prefs,
233 _("Lang Opts").c_str(),
234 lang_opts_tab_->form);
235 fl_addto_tabfolder(dialog_->tabfolder_prefs,
236 _("Conversion").c_str(),
237 converters_tab_->form);
238 fl_addto_tabfolder(dialog_->tabfolder_prefs,
241 fl_addto_tabfolder(dialog_->tabfolder_prefs,
242 _("Outputs").c_str(),
245 // now build the nested tabfolders
246 // Starting with look and feel
247 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
248 _("Screen Fonts").c_str(),
249 screen_fonts_.dialog()->form);
250 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
251 _("Interface").c_str(),
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,
260 _("Identity").c_str(),
261 identity_.dialog()->form);
263 // then build converters
264 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
265 _("Formats").c_str(),
266 formats_.dialog()->form);
267 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
268 _("Converters").c_str(),
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,
282 _("Printer").c_str(),
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,
290 _("Spell checker").c_str(),
291 spelloptions_.dialog()->form);
292 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
293 _("Language").c_str(),
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) + ", " + tostr(s) + ", " + tostr(v);
661 fl_set_object_label(dialog_->text_color_values, label.c_str());
663 RGBColor col = HSVColor(hue, sat, val);
665 fl_freeze_form(dialog_->form);
667 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
668 fl_redraw_object(dialog_->button_color);
670 col = HSVColor(hue, 1.0, 1.0);
671 col.r = max(col.r, 0u);
672 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
673 fl_redraw_object(dialog_->dial_hue);
675 // Ascertain whether to activate the Modify button.
676 vector<NamedColor>::size_type const selLyX =
677 fl_get_browser(dialog_->browser_lyx_objs);
679 fl_unfreeze_form(dialog_->form);
680 if (selLyX < 1) return;
682 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
685 // Is the choice an Xforms color...
686 if (selLyX - 1 < xformsColorDB.size()) {
687 vector<XformsColor>::size_type const i = selLyX - 1;
688 modify = (xformsColorDB[i].color() != col);
690 // or a LyX Logical color?
692 vector<NamedColor>::size_type const i = selLyX - 1 -
693 xformsColorDB.size();
694 modify = (lyxColorDB[i].color() != col);
697 setEnabled(dialog_->button_modify, modify);
701 void FormPreferences::Colors::InputRGB()
703 int const red = int(fl_get_slider_value(dialog_->slider_red));
704 int const green = int(fl_get_slider_value(dialog_->slider_green));
705 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
707 string const label = tostr(red) + string(", ") + tostr(green) +
708 string(", ") + tostr(blue);
709 fl_set_object_label(dialog_->text_color_values, label.c_str());
711 fl_freeze_form(dialog_->form);
713 RGBColor col = RGBColor(red, green, blue);
714 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
715 fl_redraw_object(dialog_->button_color);
717 // Ascertain whether to activate the Modify button.
718 vector<NamedColor>::size_type const selLyX =
719 fl_get_browser(dialog_->browser_lyx_objs);
721 fl_unfreeze_form(dialog_->form);
722 if (selLyX < 1) return;
726 // Is the choice an Xforms color...
727 if (selLyX - 1 < xformsColorDB.size()) {
728 vector<XformsColor>::size_type const i = selLyX - 1;
729 modify = (xformsColorDB[i].color() != col);
731 // or a LyX Logical color?
733 vector<NamedColor>::size_type const i = selLyX - 1 -
734 xformsColorDB.size();
735 modify = (lyxColorDB[i].color() != col);
738 setEnabled(dialog_->button_modify, modify);
742 void FormPreferences::Colors::LoadBrowserLyX()
744 if (!dialog_->browser_lyx_objs->visible)
747 // First, define the modifiable xforms colors
748 xformsColorDB.clear();
751 xcol.name = _("GUI background");
752 xcol.colorID = FL_COL1;
753 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
755 xformsColorDB.push_back(xcol);
757 xcol.name = _("GUI text");
758 xcol.colorID = FL_BLACK;
759 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
761 xformsColorDB.push_back(xcol);
763 xcol.name = _("GUI selection");
764 xcol.colorID = FL_YELLOW;
765 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
767 xformsColorDB.push_back(xcol);
769 xcol.name = _("GUI pointer");
770 xcol.colorID = GUI_COLOR_CURSOR;
771 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
773 xformsColorDB.push_back(xcol);
775 // Now create the the LyX LColors database
777 for (int i=0; i<LColor::ignore; ++i) {
778 LColor::color lc = static_cast<LColor::color>(i);
779 if (lc == LColor::none
780 || lc == LColor::black
781 || lc == LColor::white
783 || lc == LColor::green
784 || lc == LColor::blue
785 || lc == LColor::cyan
786 || lc == LColor::magenta
787 || lc == LColor::yellow
788 || lc == LColor::inherit
789 || lc == LColor::ignore) continue;
792 bool const success = getRGBColor(lc, col.r, col.g, col.b);
794 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
795 << "LColor " << lcolor.getLyXName(lc)
796 << ": X can't find color \""
797 << lcolor.getX11Name(lc)
798 << "\". Set to \"black\"!" << endl;
800 string const arg = lcolor.getLyXName(lc) + " black";
801 parent_.controller().setColor(lc, "black");
805 // Create a valid X11 name of the form "#rrggbb" and change the
806 // LColor X11name to this. Don't want to trigger a redraw,
807 // as we're just changing the name not the RGB values.
808 // Also reset the system_lcolor names, so that we don't output
809 // unnecessary changes.
810 string const hexname = X11hexname(col);
812 if (lcolor.getX11Name(lc) != hexname) {
813 lcolor.setColor(lc, hexname);
814 system_lcolor.setColor(lc, hexname);
817 // Finally, push the color onto the database
818 NamedColor ncol(lcolor.getGUIName(lc), col);
819 lyxColorDB.push_back(ncol);
822 // Now construct the browser
823 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
824 fl_freeze_form(dialog_->form);
825 fl_clear_browser(colbr);
826 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
827 cit != xformsColorDB.end(); ++cit) {
828 fl_addto_browser(colbr, cit->getname().c_str());
830 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
831 cit != lyxColorDB.end(); ++cit) {
832 fl_addto_browser(colbr, cit->getname().c_str());
835 // just to be safe...
836 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
837 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
838 fl_unfreeze_form(dialog_->form);
844 void FormPreferences::Colors::Modify()
846 vector<NamedColor>::size_type const selLyX =
847 fl_get_browser(dialog_->browser_lyx_objs);
852 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
854 // Is the choice an Xforms color...
855 if (selLyX - 1 < xformsColorDB.size()) {
856 vector<XformsColor>::size_type const i = selLyX - 1;
857 xformsColorDB[i].r = col.r;
858 xformsColorDB[i].g = col.g;
859 xformsColorDB[i].b = col.b;
861 // or a LyX Logical color?
863 vector<NamedColor>::size_type const i = selLyX - 1 -
864 xformsColorDB.size();
865 lyxColorDB[i].r = col.r;
866 lyxColorDB[i].g = col.g;
867 lyxColorDB[i].b = col.b;
870 fl_freeze_form(dialog_->form);
871 setEnabled(dialog_->button_modify, false);
872 fl_unfreeze_form(dialog_->form);
876 void FormPreferences::Colors::SwitchColorSpace() const
878 bool const hsv = fl_get_button(dialog_->radio_hsv);
881 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
883 fl_freeze_form(dialog_->form);
886 fl_hide_object(dialog_->slider_red);
887 fl_hide_object(dialog_->slider_blue);
888 fl_hide_object(dialog_->slider_green);
889 fl_show_object(dialog_->dial_hue);
890 fl_show_object(dialog_->slider_saturation);
891 fl_show_object(dialog_->slider_value);
893 HSVColor hsv = HSVColor(col);
894 hsv.h = max(hsv.h, 0.0);
896 fl_set_dial_value(dialog_->dial_hue, hsv.h);
897 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
898 fl_set_slider_value(dialog_->slider_value, hsv.v);
900 col = HSVColor(hsv.h, 1.0, 1.0);
901 col.r = max(col.r, 0u);
902 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
903 fl_redraw_object(dialog_->dial_hue);
905 // Adjust the label a bit, but not the actual values.
906 // Means that toggling from one space to the other has no
907 // effect on the final color.
908 int const h = int(hsv.h);
909 int const s = int(100 * hsv.s);
910 int const v = int(100 * hsv.v);
911 string const label = tostr(h) + ", " + tostr(s) +
913 fl_set_object_label(dialog_->text_color_values, label.c_str());
916 fl_show_object(dialog_->slider_red);
917 fl_show_object(dialog_->slider_blue);
918 fl_show_object(dialog_->slider_green);
919 fl_hide_object(dialog_->dial_hue);
920 fl_hide_object(dialog_->slider_saturation);
921 fl_hide_object(dialog_->slider_value);
923 fl_set_slider_value(dialog_->slider_red, col.r);
924 fl_set_slider_value(dialog_->slider_green, col.g);
925 fl_set_slider_value(dialog_->slider_blue, col.b);
927 // Adjust the label a bit. Same reasoning as above.
928 int const r = int(col.r);
929 int const g = int(col.g);
930 int const b = int(col.b);
931 string const label = tostr(r) + ", " + tostr(g) +
933 fl_set_object_label(dialog_->text_color_values, label.c_str());
936 fl_unfreeze_form(dialog_->form);
940 FormPreferences::Converters::Converters(FormPreferences & p)
945 FD_preferences_converters const * FormPreferences::Converters::dialog()
947 return dialog_.get();
951 void FormPreferences::Converters::apply() const
953 parent_.controller().setConverters(local_converters);
957 void FormPreferences::Converters::build()
959 dialog_.reset(build_preferences_converters(&parent_));
961 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
962 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
964 // set up the feedback mechanism
965 setPrehandler(dialog_->browser_all);
966 setPrehandler(dialog_->button_delete);
967 setPrehandler(dialog_->button_add);
968 setPrehandler(dialog_->input_converter);
969 setPrehandler(dialog_->choice_from);
970 setPrehandler(dialog_->choice_to);
971 setPrehandler(dialog_->input_flags);
976 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
978 if (ob == dialog_->browser_all)
979 return _("All explicitly defined converters for LyX");
981 if (ob == dialog_->choice_from)
982 return _("Convert \"from\" this format");
984 if (ob == dialog_->choice_to)
985 return _("Convert \"to\" this format");
987 if (ob == dialog_->input_converter)
988 return _("The conversion command. $$i is the input file name, "
989 "$$b is the file name without its extension and $$o is "
990 "the name of the output file. $$s can be used as path to "
991 "LyX's own collection of conversion scripts.");
993 if (ob == dialog_->input_flags)
994 return _("Extra information for the Converter class, whether and "
995 "how to parse the result, and various other things.");
997 if (ob == dialog_->button_delete)
998 return _("Remove the current converter from the list of available "
999 "converters. Note: you must then \"Apply\" the change.");
1001 if (ob == dialog_->button_add) {
1002 if (string(ob->label) == _("Add"))
1003 return _("Add the current converter to the list of available "
1004 "converters. Note: you must then \"Apply\" the change.");
1006 return _("Modify the contents of the current converter. "
1007 "Note: you must then \"Apply\" the change.");
1014 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
1016 if (ob == dialog_->browser_all)
1019 if (ob == dialog_->choice_from
1020 || ob == dialog_->choice_to
1021 || ob == dialog_->input_converter
1022 || ob == dialog_->input_flags)
1025 if (ob == dialog_->button_add)
1028 if (ob == dialog_->button_delete)
1035 void FormPreferences::Converters::update()
1037 local_converters = converters;
1038 local_converters.update(local_formats);
1043 void FormPreferences::Converters::UpdateBrowser()
1045 local_converters.sort();
1047 fl_freeze_form(dialog_->form);
1048 fl_clear_browser(dialog_->browser_all);
1049 for (::Converters::const_iterator cit = local_converters.begin();
1050 cit != local_converters.end(); ++cit) {
1051 string const name = cit->From->prettyname() + " -> "
1052 + cit->To->prettyname();
1053 fl_addto_browser(dialog_->browser_all, name.c_str());
1056 fl_unfreeze_form(dialog_->form);
1060 bool FormPreferences::Converters::Add()
1062 string const from = GetFrom();
1063 string const to = GetTo();
1064 string const command = fl_get_input(dialog_->input_converter);
1065 string const flags = fl_get_input(dialog_->input_flags);
1067 Converter const * old = local_converters.getConverter(from, to);
1068 local_converters.add(from, to, command, flags);
1070 local_converters.updateLast(local_formats);
1073 setEnabled(dialog_->button_add, false);
1079 bool FormPreferences::Converters::Browser()
1081 int const i = fl_get_browser(dialog_->browser_all);
1082 if (i <= 0) return false;
1084 fl_freeze_form(dialog_->form);
1086 Converter const & c = local_converters.get(i - 1);
1087 int j = local_formats.getNumber(c.from);
1089 fl_set_choice(dialog_->choice_from, j + 1);
1091 j = local_formats.getNumber(c.to);
1093 fl_set_choice(dialog_->choice_to, j + 1);
1095 fl_set_input(dialog_->input_converter, c.command.c_str());
1096 fl_set_input(dialog_->input_flags, c.flags.c_str());
1098 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
1099 fl_set_button_shortcut(dialog_->button_add,
1100 scex(_("Modify|#M")).c_str(), 1);
1102 setEnabled(dialog_->button_add, false);
1103 setEnabled(dialog_->button_delete, true);
1105 fl_unfreeze_form(dialog_->form);
1110 bool FormPreferences::Converters::erase()
1112 string const from = GetFrom();
1113 string const to = GetTo();
1115 local_converters.erase(from, to);
1121 bool FormPreferences::Converters::Input()
1123 string const from = GetFrom();
1124 string const to = GetTo();
1125 int const sel = local_converters.getNumber(from, to);
1127 fl_freeze_form(dialog_->form);
1130 fl_set_object_label(dialog_->button_add,
1131 idex(_("Add|#A")).c_str());
1132 fl_set_button_shortcut(dialog_->button_add,
1133 scex(_("Add|#A")).c_str(), 1);
1135 fl_deselect_browser(dialog_->browser_all);
1136 setEnabled(dialog_->button_delete, false);
1139 fl_set_object_label(dialog_->button_add,
1140 idex(_("Modify|#M")).c_str());
1141 fl_set_button_shortcut(dialog_->button_add,
1142 scex(_("Modify|#M")).c_str(), 1);
1144 int top = max(sel-5, 0);
1145 fl_set_browser_topline(dialog_->browser_all, top);
1146 fl_select_browser_line(dialog_->browser_all, sel+1);
1147 setEnabled(dialog_->button_delete, true);
1150 string const command = rtrim(fl_get_input(dialog_->input_converter));
1151 bool const enable = !(command.empty() || from == to);
1152 setEnabled(dialog_->button_add, enable);
1154 fl_unfreeze_form(dialog_->form);
1159 string const FormPreferences::Converters::GetFrom() const
1161 ::Formats::FormatList::size_type const i =
1162 fl_get_choice(dialog_->choice_from);
1164 if (i > 0 && i <= local_formats.size())
1165 return local_formats.get(i - 1).name();
1167 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1172 string const FormPreferences::Converters::GetTo() const
1174 ::Formats::FormatList::size_type const i =
1175 fl_get_choice(dialog_->choice_to);
1177 if (i > 0 && i <= local_formats.size())
1178 return local_formats.get(i - 1).name();
1180 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1185 void FormPreferences::Converters::UpdateChoices() const
1188 for (::Formats::const_iterator cit = local_formats.begin();
1189 cit != local_formats.end(); ++cit) {
1190 if (!choice.empty())
1194 choice += cit->prettyname();
1198 fl_clear_choice(dialog_->choice_from);
1199 fl_addto_choice(dialog_->choice_from, choice.c_str());
1201 fl_clear_choice(dialog_->choice_to);
1202 fl_addto_choice(dialog_->choice_to, choice.c_str());
1206 FormPreferences::Formats::Formats(FormPreferences & p)
1211 FD_preferences_formats const * FormPreferences::Formats::dialog()
1213 return dialog_.get();
1217 void FormPreferences::Formats::apply() const
1219 parent_.controller().setFormats(local_formats);
1223 void FormPreferences::Formats::build()
1225 dialog_.reset(build_preferences_formats(&parent_));
1227 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1228 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1229 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1230 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1231 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1233 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1235 // set up the feedback mechanism
1236 setPrehandler(dialog_->browser_all);
1237 setPrehandler(dialog_->input_format);
1238 setPrehandler(dialog_->input_gui_name);
1239 setPrehandler(dialog_->button_delete);
1240 setPrehandler(dialog_->button_add);
1241 setPrehandler(dialog_->input_extension);
1242 setPrehandler(dialog_->input_viewer);
1243 setPrehandler(dialog_->input_shrtcut);
1248 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1250 if (ob == dialog_->browser_all)
1251 return _("All the currently defined formats known to LyX.");
1253 if (ob == dialog_->input_format)
1254 return _("The format identifier.");
1256 if (ob == dialog_->input_gui_name)
1257 return _("The format name as it will appear in the menus.");
1259 if (ob == dialog_->input_shrtcut)
1260 return _("The keyboard accelerator. Use a letter in the GUI name. "
1263 if (ob == dialog_->input_extension)
1264 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1266 if (ob == dialog_->input_viewer)
1267 return _("The command used to launch the viewer application.");
1269 if (ob == dialog_->button_delete)
1270 return _("Remove the current format from the list of available "
1271 "formats. Note: you must then \"Apply\" the change.");
1273 if (ob == dialog_->button_add) {
1274 if (string(ob->label) == _("Add"))
1275 return _("Add the current format to the list of available "
1276 "formats. Note: you must then \"Apply\" the change.");
1278 return _("Modify the contents of the current format. Note: "
1279 "you must then \"Apply\" the change.");
1286 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1288 if (ob == dialog_->browser_all)
1291 if (ob == dialog_->input_format
1292 || ob == dialog_->input_gui_name
1293 || ob == dialog_->input_shrtcut
1294 || ob == dialog_->input_extension
1295 || ob == dialog_->input_viewer)
1298 if (ob == dialog_->button_add)
1301 if (ob == dialog_->button_delete)
1308 void FormPreferences::Formats::update()
1310 local_formats = formats;
1315 void FormPreferences::Formats::UpdateBrowser()
1317 local_formats.sort();
1319 fl_freeze_form(dialog_->form);
1320 fl_deselect_browser(dialog_->browser_all);
1321 fl_clear_browser(dialog_->browser_all);
1322 for (::Formats::const_iterator cit = local_formats.begin();
1323 cit != local_formats.end(); ++cit)
1324 fl_addto_browser(dialog_->browser_all,
1325 cit->prettyname().c_str());
1328 fl_unfreeze_form(dialog_->form);
1330 // Mustn't forget to update the Formats available to the converters_
1331 parent_.converters_.UpdateChoices();
1332 local_converters.update(local_formats);
1336 bool FormPreferences::Formats::Add()
1338 string const name = fl_get_input(dialog_->input_format);
1339 string const prettyname = fl_get_input(dialog_->input_gui_name);
1340 string const extension = fl_get_input(dialog_->input_extension);
1341 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1342 string const viewer = fl_get_input(dialog_->input_viewer);
1344 Format const * old = local_formats.getFormat(name);
1345 string const old_prettyname = old ? old->prettyname() : string();
1346 local_formats.add(name, extension, prettyname, shortcut);
1347 local_formats.setViewer(name, viewer);
1348 if (!old || prettyname != old_prettyname) {
1351 parent_.converters_.UpdateBrowser();
1353 setEnabled(dialog_->button_add, false);
1359 bool FormPreferences::Formats::Browser()
1361 int const i = fl_get_browser(dialog_->browser_all);
1365 fl_freeze_form(dialog_->form);
1367 Format const & f = local_formats.get(i - 1);
1369 fl_set_input(dialog_->input_format, f.name().c_str());
1370 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1371 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1372 fl_set_input(dialog_->input_extension, f.extension().c_str());
1373 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1375 fl_set_object_label(dialog_->button_add,
1376 idex(_("Modify|#M")).c_str());
1377 fl_set_button_shortcut(dialog_->button_add,
1378 scex(_("Modify|#M")).c_str(), 1);
1380 setEnabled(dialog_->button_add, false);
1381 setEnabled(dialog_->button_delete, true);
1383 fl_unfreeze_form(dialog_->form);
1388 bool FormPreferences::Formats::erase()
1390 string const name = fl_get_input(dialog_->input_format);
1392 if (local_converters.formatIsUsed(name)) {
1393 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1394 "Remove the converter first."));
1395 setEnabled(dialog_->button_delete, false);
1399 local_formats.erase(name);
1405 bool FormPreferences::Formats::Input()
1407 string const name = fl_get_input(dialog_->input_format);
1408 int const sel = local_formats.getNumber(name);
1409 fl_freeze_form(dialog_->form);
1412 fl_set_object_label(dialog_->button_add,
1413 idex(_("Add|#A")).c_str());
1414 fl_set_button_shortcut(dialog_->button_add,
1415 scex(_("Add|#A")).c_str(), 1);
1417 fl_deselect_browser(dialog_->browser_all);
1418 setEnabled(dialog_->button_delete, false);
1421 fl_set_object_label(dialog_->button_add,
1422 idex(_("Modify|#M")).c_str());
1423 fl_set_button_shortcut(dialog_->button_add,
1424 scex(_("Modify|#M")).c_str(), 1);
1426 int const top = max(sel-5, 0);
1427 fl_set_browser_topline(dialog_->browser_all, top);
1428 fl_select_browser_line(dialog_->browser_all, sel+1);
1430 setEnabled(dialog_->button_add, true);
1431 setEnabled(dialog_->button_delete, true);
1434 string const prettyname = fl_get_input(dialog_->input_gui_name);
1435 bool const enable = !(name.empty() || prettyname.empty());
1436 setEnabled(dialog_->button_add, enable);
1438 fl_unfreeze_form(dialog_->form);
1443 FormPreferences::Identity::Identity(FormPreferences & p)
1448 FD_preferences_identity const * FormPreferences::Identity::dialog()
1450 return dialog_.get();
1454 void FormPreferences::Identity::apply(LyXRC & rc) const
1456 rc.user_name = fl_get_input(dialog_->input_user_name);
1457 rc.user_email = fl_get_input(dialog_->input_user_email);
1461 void FormPreferences::Identity::build()
1463 dialog_.reset(build_preferences_identity(&parent_));
1464 fl_set_input_return(dialog_->input_user_name, FL_RETURN_CHANGED);
1465 fl_set_input_return(dialog_->input_user_email, FL_RETURN_CHANGED);
1469 void FormPreferences::Identity::update(LyXRC const & rc)
1471 fl_set_input(dialog_->input_user_name, rc.user_name.c_str());
1472 fl_set_input(dialog_->input_user_email, rc.user_email.c_str());
1476 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1481 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1483 return dialog_.get();
1487 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1489 rc.date_insert_format =
1490 fl_get_input(dialog_->input_date_format);
1494 void FormPreferences::InputsMisc::build()
1496 dialog_.reset(build_preferences_inputs_misc(&parent_));
1498 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1500 // set up the feedback mechanism
1501 setPrehandler(dialog_->input_date_format);
1506 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1508 if (ob == dialog_->input_date_format)
1509 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1514 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1516 fl_set_input(dialog_->input_date_format,
1517 rc.date_insert_format.c_str());
1521 FormPreferences::Interface::Interface(FormPreferences & p)
1526 FD_preferences_interface const * FormPreferences::Interface::dialog()
1528 return dialog_.get();
1532 void FormPreferences::Interface::apply(LyXRC & rc) const
1534 rc.popup_normal_font =
1535 fl_get_input(dialog_->input_popup_normal_font);
1536 rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1537 rc.popup_font_encoding =
1538 fl_get_input(dialog_->input_popup_font_encoding);
1539 rc.bind_file = fl_get_input(dialog_->input_bind_file);
1540 rc.ui_file = fl_get_input(dialog_->input_ui_file);
1544 void FormPreferences::Interface::build()
1546 dialog_.reset(build_preferences_interface(&parent_));
1548 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1549 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1550 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1551 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1552 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1554 // set up the feedback mechanism
1555 setPrehandler(dialog_->input_popup_normal_font);
1556 setPrehandler(dialog_->input_popup_bold_font);
1557 setPrehandler(dialog_->input_popup_font_encoding);
1558 setPrehandler(dialog_->input_bind_file);
1559 setPrehandler(dialog_->button_bind_file_browse);
1560 setPrehandler(dialog_->input_ui_file);
1561 setPrehandler(dialog_->button_ui_file_browse);
1566 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1568 if (ob == dialog_->input_popup_normal_font)
1569 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1570 if (ob == dialog_->input_popup_bold_font)
1571 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1572 if (ob == dialog_->input_popup_font_encoding)
1573 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1574 if (ob == dialog_->input_bind_file)
1575 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1576 if (ob == dialog_->input_ui_file)
1577 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1582 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1584 if (ob == dialog_->button_bind_file_browse) {
1585 string f = parent_.controller().browsebind(
1586 fl_get_input(dialog_->input_bind_file));
1588 fl_set_input(dialog_->input_bind_file, f.c_str());
1589 } else if (ob == dialog_->button_ui_file_browse) {
1590 string f = parent_.controller().browseUI(
1591 fl_get_input(dialog_->input_ui_file));
1593 fl_set_input(dialog_->input_ui_file, f.c_str());
1600 void FormPreferences::Interface::update(LyXRC const & rc)
1602 fl_set_input(dialog_->input_popup_normal_font,
1603 rc.popup_normal_font.c_str());
1604 fl_set_input(dialog_->input_popup_bold_font,
1605 rc.popup_bold_font.c_str());
1606 fl_set_input(dialog_->input_popup_font_encoding,
1607 rc.popup_font_encoding.c_str());
1608 fl_set_input(dialog_->input_bind_file,
1609 rc.bind_file.c_str());
1610 fl_set_input(dialog_->input_ui_file,
1611 rc.ui_file.c_str());
1615 FormPreferences::Language::Language(FormPreferences & p)
1620 FD_preferences_language const * FormPreferences::Language::dialog()
1622 return dialog_.get();
1626 void FormPreferences::Language::apply(LyXRC & rc)
1628 int const pos = fl_get_combox(dialog_->combox_default_lang);
1629 rc.default_language = lang_[pos-1];
1631 int button = fl_get_button(dialog_->check_use_kbmap);
1632 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1633 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1635 button = !(name_1.empty() && name_2.empty());
1636 rc.use_kbmap = static_cast<bool>(button);
1639 rc.primary_kbmap = name_1;
1640 rc.secondary_kbmap = name_2;
1643 button = fl_get_button(dialog_->check_rtl_support);
1644 rc.rtl_support = static_cast<bool>(button);
1646 button = fl_get_button(dialog_->check_mark_foreign);
1647 rc.mark_foreign_language = static_cast<bool>(button);
1649 button = fl_get_button(dialog_->check_auto_begin);
1650 rc.language_auto_begin = static_cast<bool>(button);
1652 button = fl_get_button(dialog_->check_auto_end);
1653 rc.language_auto_end = static_cast<bool>(button);
1655 button = fl_get_button(dialog_->check_use_babel);
1656 rc.language_use_babel = static_cast<bool>(button);
1658 button = fl_get_button(dialog_->check_global_options);
1659 rc.language_global_options = static_cast<bool>(button);
1661 rc.language_package = fl_get_input(dialog_->input_package);
1662 rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1663 rc.language_command_end = fl_get_input(dialog_->input_command_end);
1665 // Ensure that all is self-consistent.
1670 void FormPreferences::Language::build()
1672 dialog_.reset(build_preferences_language(&parent_));
1674 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1675 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1676 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1678 // Store the lang identifiers for later
1679 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1680 lang_ = getSecond(langs);
1682 FL_OBJECT * obj = dialog_->combox_default_lang;
1683 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1684 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1685 for (; lit != lend; ++lit) {
1686 fl_addto_combox(obj, lit->first.c_str());
1688 fl_set_combox_browser_height(obj, 400);
1690 // set up the feedback mechanism
1691 setPrehandler(dialog_->input_package);
1692 setPrehandler(dialog_->check_use_kbmap);
1693 setPrehandler(dialog_->combox_default_lang);
1694 setPrehandler(dialog_->input_kbmap1);
1695 setPrehandler(dialog_->input_kbmap2);
1696 setPrehandler(dialog_->check_rtl_support);
1697 setPrehandler(dialog_->check_mark_foreign);
1698 setPrehandler(dialog_->check_auto_begin);
1699 setPrehandler(dialog_->check_auto_end);
1700 setPrehandler(dialog_->check_use_babel);
1701 setPrehandler(dialog_->check_global_options);
1702 setPrehandler(dialog_->input_command_begin);
1703 setPrehandler(dialog_->input_command_end);
1705 // Activate/Deactivate the input fields dependent on the state of the
1712 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1714 if (ob == dialog_->combox_default_lang)
1715 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1716 if (ob == dialog_->check_use_kbmap)
1717 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1718 if (ob == dialog_->input_kbmap1)
1719 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1720 if (ob == dialog_->input_kbmap2)
1721 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1722 if (ob == dialog_->check_rtl_support)
1723 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1724 if (ob == dialog_->check_mark_foreign)
1725 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1726 if (ob == dialog_->check_auto_begin)
1727 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1728 if (ob == dialog_->check_auto_end)
1729 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1730 if (ob == dialog_->check_use_babel)
1731 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1732 if (ob == dialog_->check_global_options)
1733 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1734 if (ob == dialog_->input_package)
1735 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1736 if (ob == dialog_->input_command_begin)
1737 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1738 if (ob == dialog_->input_command_end)
1739 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1744 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1746 bool activate = true;
1748 // !ob if function is called from Language::build() to de/activate
1750 // otherwise the function is called by an xforms CB via input().
1751 if (!ob || ob == dialog_->check_use_kbmap) {
1752 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1753 setEnabled(dialog_->button_kbmap1_browse, enable);
1754 setEnabled(dialog_->button_kbmap2_browse, enable);
1755 setEnabled(dialog_->input_kbmap1, enable);
1756 setEnabled(dialog_->input_kbmap2, enable);
1759 if (ob == dialog_->button_kbmap1_browse) {
1760 string f = parent_.controller().browsekbmap(
1761 fl_get_input(dialog_->input_kbmap1));
1763 fl_set_input(dialog_->input_kbmap1, f.c_str());
1764 } else if (ob == dialog_->button_kbmap2_browse) {
1765 string f = parent_.controller().browsekbmap(
1766 fl_get_input(dialog_->input_kbmap2));
1768 fl_set_input(dialog_->input_kbmap2, f.c_str());
1775 void FormPreferences::Language::update(LyXRC const & rc)
1777 fl_set_button(dialog_->check_use_kbmap,
1780 int const pos = int(findPos(lang_, rc.default_language));
1781 fl_set_combox(dialog_->combox_default_lang, pos + 1);
1784 fl_set_input(dialog_->input_kbmap1,
1785 rc.primary_kbmap.c_str());
1786 fl_set_input(dialog_->input_kbmap2,
1787 rc.secondary_kbmap.c_str());
1789 fl_set_input(dialog_->input_kbmap1, "");
1790 fl_set_input(dialog_->input_kbmap2, "");
1793 fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1794 fl_set_button(dialog_->check_mark_foreign,
1795 rc.mark_foreign_language);
1796 fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1797 fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1798 fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1799 fl_set_button(dialog_->check_global_options,
1800 rc.language_global_options);
1802 fl_set_input(dialog_->input_package,
1803 rc.language_package.c_str());
1804 fl_set_input(dialog_->input_command_begin,
1805 rc.language_command_begin.c_str());
1806 fl_set_input(dialog_->input_command_end,
1807 rc.language_command_end.c_str());
1809 // Activate/Deactivate the input fields dependent on the state of the
1815 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1820 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1822 return dialog_.get();
1826 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1828 rc.auto_region_delete =
1829 fl_get_button(dialog_->check_auto_region_delete);
1830 rc.cursor_follows_scrollbar =
1831 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1832 rc.dialogs_iconify_with_main =
1833 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1834 rc.preview = fl_get_button(dialog_->check_preview_latex);
1835 rc.autosave = static_cast<unsigned int>
1836 (fl_get_counter_value(dialog_->counter_autosave));
1837 rc.wheel_jump = static_cast<unsigned int>
1838 (fl_get_counter_value(dialog_->counter_wm_jump));
1841 // grfx::DisplayType old_value = rc.display_graphics;
1842 switch (fl_get_choice(dialog_->choice_display)) {
1844 rc.display_graphics = grfx::NoDisplay;
1847 rc.display_graphics = grfx::ColorDisplay;
1850 rc.display_graphics = grfx::GrayscaleDisplay;
1853 rc.display_graphics = grfx::MonochromeDisplay;
1856 rc.display_graphics = grfx::ColorDisplay;
1860 #ifdef WITH_WARNINGS
1861 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1864 if (old_value != rc.display_graphics) {
1865 grfx::GCache & gc = grfx::GCache::get();
1872 void FormPreferences::LnFmisc::build()
1874 dialog_.reset(build_preferences_lnf_misc(&parent_));
1876 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1877 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1879 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1880 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1882 // set up the feedback mechanism
1883 setPrehandler(dialog_->check_auto_region_delete);
1884 setPrehandler(dialog_->counter_autosave);
1885 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1886 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1887 setPrehandler(dialog_->check_preview_latex);
1888 setPrehandler(dialog_->counter_wm_jump);
1890 fl_addto_choice(dialog_->choice_display,
1891 _("Monochrome|Grayscale|Color|Do not display").c_str());
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 "
1991 "| US executive | A3 | A4 | A5 | B5 ").c_str());
1993 // set up the feedback mechanism
1994 setPrehandler(dialog_->counter_line_len);
1995 setPrehandler(dialog_->input_tex_encoding);
1996 setPrehandler(dialog_->choice_default_papersize);
1997 setPrehandler(dialog_->input_ascii_roff);
1998 setPrehandler(dialog_->input_checktex);
1999 setPrehandler(dialog_->input_paperoption);
2000 setPrehandler(dialog_->check_autoreset_classopt);
2005 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
2007 if (ob == dialog_->counter_line_len)
2008 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
2009 if (ob == dialog_->input_tex_encoding)
2010 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
2011 if (ob == dialog_->input_ascii_roff)
2012 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
2013 if (ob == dialog_->input_checktex)
2014 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
2015 if (ob == dialog_->choice_default_papersize)
2016 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2017 if (ob == dialog_->input_paperoption)
2018 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
2019 if (ob == dialog_->check_autoreset_classopt)
2020 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2025 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
2027 fl_set_counter_value(dialog_->counter_line_len,
2029 fl_set_input(dialog_->input_tex_encoding,
2030 rc.fontenc.c_str());
2031 fl_set_choice(dialog_->choice_default_papersize,
2032 rc.default_papersize + 1);
2033 fl_set_input(dialog_->input_ascii_roff,
2034 rc.ascii_roff_command.c_str());
2035 fl_set_input(dialog_->input_checktex,
2036 rc.chktex_command.c_str());
2037 fl_set_input(dialog_->input_paperoption,
2038 rc.view_dvi_paper_option.c_str());
2039 fl_set_button(dialog_->check_autoreset_classopt,
2040 rc.auto_reset_options);
2045 FormPreferences::Paths::Paths(FormPreferences & p)
2050 FD_preferences_paths const * FormPreferences::Paths::dialog()
2052 return dialog_.get();
2056 void FormPreferences::Paths::apply(LyXRC & rc)
2058 rc.document_path = fl_get_input(dialog_->input_default_path);
2059 rc.template_path = fl_get_input(dialog_->input_template_path);
2061 int button = fl_get_button(dialog_->check_use_temp_dir);
2062 string str = fl_get_input(dialog_->input_temp_dir);
2066 rc.use_tempdir = button;
2067 rc.tempdir_path = str;
2069 button = fl_get_button(dialog_->check_last_files);
2070 str = fl_get_input(dialog_->input_lastfiles);
2071 if (!button) str.erase();
2073 rc.check_lastfiles = button;
2075 rc.num_lastfiles = static_cast<unsigned int>
2076 (fl_get_counter_value(dialog_->counter_lastfiles));
2078 button = fl_get_button(dialog_->check_make_backups);
2079 str = fl_get_input(dialog_->input_backup_path);
2083 rc.make_backup = button;
2084 rc.backupdir_path = str;
2086 rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2093 void FormPreferences::Paths::build()
2095 dialog_.reset(build_preferences_paths(&parent_));
2097 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2098 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2099 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2100 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2101 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2102 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2103 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2105 // set up the feedback mechanism
2106 setPrehandler(dialog_->input_default_path);
2107 setPrehandler(dialog_->counter_lastfiles);
2108 setPrehandler(dialog_->input_template_path);
2109 setPrehandler(dialog_->check_last_files);
2110 setPrehandler(dialog_->input_lastfiles);
2111 setPrehandler(dialog_->check_make_backups);
2112 setPrehandler(dialog_->input_backup_path);
2113 setPrehandler(dialog_->input_serverpipe);
2114 setPrehandler(dialog_->input_temp_dir);
2115 setPrehandler(dialog_->check_use_temp_dir);
2120 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2122 if (ob == dialog_->input_default_path)
2123 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2124 if (ob == dialog_->input_template_path)
2125 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2126 if (ob == dialog_->check_use_temp_dir)
2127 return LyXRC::getDescription(LyXRC::RC_USETEMPDIR);
2128 if (ob == dialog_->input_temp_dir)
2129 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2130 if (ob == dialog_->check_last_files)
2131 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2132 if (ob == dialog_->input_lastfiles)
2133 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
2134 if (ob == dialog_->counter_lastfiles)
2135 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2136 if (ob == dialog_->check_make_backups)
2137 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2138 if (ob == dialog_->input_backup_path)
2139 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2140 if (ob == dialog_->input_serverpipe)
2141 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2146 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2148 bool activate = true;
2150 // !ob if function is called from Paths::update() to de/activate
2152 // otherwise the function is called by an xforms CB via input().
2153 if (!ob || ob == dialog_->check_use_temp_dir) {
2154 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2155 setEnabled(dialog_->input_temp_dir, enable);
2158 if (!ob || ob == dialog_->check_last_files) {
2159 bool const enable = fl_get_button(dialog_->check_last_files);
2160 setEnabled(dialog_->input_lastfiles, enable);
2163 if (!ob || ob == dialog_->check_make_backups) {
2164 bool const enable = fl_get_button(dialog_->check_make_backups);
2165 setEnabled(dialog_->input_backup_path, enable);
2168 if (!ob || ob == dialog_->input_default_path) {
2169 string const name = fl_get_input(dialog_->input_default_path);
2170 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2171 parent_.postWarning(RWInfo::ErrorMessage());
2176 if (!ob || ob == dialog_->input_template_path) {
2177 string const name = fl_get_input(dialog_->input_template_path);
2178 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2179 parent_.postWarning(RWInfo::ErrorMessage());
2184 if (!ob || ob == dialog_->input_temp_dir) {
2185 string const name = fl_get_input(dialog_->input_temp_dir);
2186 if (fl_get_button(dialog_->check_make_backups)
2188 && !RWInfo::WriteableDir(name)) {
2189 parent_.postWarning(RWInfo::ErrorMessage());
2194 if (!ob || ob == dialog_->input_backup_path) {
2195 string const name = fl_get_input(dialog_->input_backup_path);
2196 if (fl_get_button(dialog_->check_make_backups)
2198 && !RWInfo::WriteableDir(name)) {
2199 parent_.postWarning(RWInfo::ErrorMessage());
2204 if (!ob || ob == dialog_->input_lastfiles) {
2205 string const name = fl_get_input(dialog_->input_lastfiles);
2206 if (fl_get_button(dialog_->check_last_files)
2208 && !RWInfo::WriteableFile(name)) {
2209 parent_.postWarning(RWInfo::ErrorMessage());
2214 if (!ob || ob == dialog_->input_serverpipe) {
2215 string const name = fl_get_input(dialog_->input_serverpipe);
2216 if (!name.empty()) {
2217 // strip off the extension
2218 string const str = ChangeExtension(name, "");
2219 if (!RWInfo::WriteableFile(str + ".in")) {
2220 parent_.postWarning(RWInfo::ErrorMessage());
2223 if (!RWInfo::WriteableFile(str + ".out")) {
2224 parent_.postWarning(RWInfo::ErrorMessage());
2230 if (ob == dialog_->button_default_path_browse) {
2231 string f = parent_.controller().browsedir(
2232 fl_get_input(dialog_->input_default_path), _("Default path"));
2234 fl_set_input(dialog_->input_default_path, f.c_str());
2235 } else if (ob == dialog_->button_template_path_browse) {
2236 string f = parent_.controller().browsedir(
2237 fl_get_input(dialog_->input_template_path), _("Template path"));
2239 fl_set_input(dialog_->input_template_path, f.c_str());
2240 } else if (ob == dialog_->button_temp_dir_browse) {
2241 string f = parent_.controller().browsedir(
2242 fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2244 fl_set_input(dialog_->input_temp_dir, f.c_str());
2245 } else if (ob == dialog_->button_lastfiles_browse) {
2246 string f = parent_.controller().browse(
2247 fl_get_input(dialog_->input_lastfiles), _("Last files"));
2249 fl_set_input(dialog_->input_lastfiles, f.c_str());
2250 } else if (ob == dialog_->button_backup_path_browse) {
2251 string f = parent_.controller().browsedir(
2252 fl_get_input(dialog_->input_backup_path), _("Backup path"));
2254 fl_set_input(dialog_->input_backup_path, f.c_str());
2255 } else if (ob == dialog_->button_serverpipe_browse) {
2256 string f = parent_.controller().browse(
2257 fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2259 fl_set_input(dialog_->input_serverpipe, f.c_str());
2266 void FormPreferences::Paths::update(LyXRC const & rc)
2268 fl_set_input(dialog_->input_default_path,
2269 rc.document_path.c_str());
2270 fl_set_input(dialog_->input_template_path,
2271 rc.template_path.c_str());
2275 str = rc.backupdir_path;
2277 fl_set_button(dialog_->check_make_backups,
2279 fl_set_input(dialog_->input_backup_path, str.c_str());
2283 str = rc.tempdir_path;
2285 fl_set_button(dialog_->check_use_temp_dir,
2287 fl_set_input(dialog_->input_temp_dir, str.c_str());
2290 if (rc.check_lastfiles)
2293 fl_set_button(dialog_->check_last_files,
2294 rc.check_lastfiles);
2295 fl_set_input(dialog_->input_lastfiles, str.c_str());
2296 fl_set_counter_value(dialog_->counter_lastfiles,
2299 fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2301 // Activate/Deactivate the input fields dependent on the state of the
2307 FormPreferences::Printer::Printer(FormPreferences & p)
2312 FD_preferences_printer const * FormPreferences::Printer::dialog()
2314 return dialog_.get();
2318 void FormPreferences::Printer::apply(LyXRC & rc) const
2320 rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2321 rc.print_command = fl_get_input(dialog_->input_command);
2322 rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2323 rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2324 rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2325 rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2326 rc.print_file_extension =
2327 fl_get_input(dialog_->input_file_extension);
2328 rc.print_spool_command =
2329 fl_get_input(dialog_->input_spool_command);
2330 rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2331 rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2332 rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2333 rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2334 rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2335 rc.print_to_file = fl_get_input(dialog_->input_to_file);
2336 rc.print_extra_options =
2337 fl_get_input(dialog_->input_extra_options);
2338 rc.print_spool_printerprefix =
2339 fl_get_input(dialog_->input_spool_prefix);
2340 rc.print_paper_dimension_flag =
2341 fl_get_input(dialog_->input_paper_size);
2342 rc.printer = fl_get_input(dialog_->input_name);
2347 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2349 if (ob == dialog_->input_command)
2350 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2351 if (ob == dialog_->check_adapt_output)
2352 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2353 if (ob == dialog_->input_to_printer)
2354 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2355 if (ob == dialog_->input_to_file)
2356 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2357 if (ob == dialog_->input_file_extension)
2358 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2359 if (ob == dialog_->input_extra_options)
2360 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2361 if (ob == dialog_->input_spool_command)
2362 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2363 if (ob == dialog_->input_spool_prefix)
2364 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2365 if (ob == dialog_->input_name)
2366 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2367 if (ob == dialog_->input_even_pages)
2368 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2369 if (ob == dialog_->input_odd_pages)
2370 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2371 if (ob == dialog_->input_page_range)
2372 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2373 if (ob == dialog_->input_reverse)
2374 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2375 if (ob == dialog_->input_landscape)
2376 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2377 if (ob == dialog_->input_copies)
2378 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2379 if (ob == dialog_->input_collated)
2380 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2381 if (ob == dialog_->input_paper_type)
2382 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2383 if (ob == dialog_->input_paper_size)
2384 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2389 void FormPreferences::Printer::build()
2391 dialog_.reset(build_preferences_printer(&parent_));
2393 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2394 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2395 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2396 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2397 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2398 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2399 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2400 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2401 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2402 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2403 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2404 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2405 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2406 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2407 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2408 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2409 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2411 // set up the feedback mechanism
2412 setPrehandler(dialog_->input_command);
2413 setPrehandler(dialog_->input_page_range);
2414 setPrehandler(dialog_->input_copies);
2415 setPrehandler(dialog_->input_reverse);
2416 setPrehandler(dialog_->input_to_printer);
2417 setPrehandler(dialog_->input_file_extension);
2418 setPrehandler(dialog_->input_spool_command);
2419 setPrehandler(dialog_->input_paper_type);
2420 setPrehandler(dialog_->input_even_pages);
2421 setPrehandler(dialog_->input_odd_pages);
2422 setPrehandler(dialog_->input_collated);
2423 setPrehandler(dialog_->input_landscape);
2424 setPrehandler(dialog_->input_to_file);
2425 setPrehandler(dialog_->input_extra_options);
2426 setPrehandler(dialog_->input_spool_prefix);
2427 setPrehandler(dialog_->input_paper_size);
2428 setPrehandler(dialog_->input_name);
2429 setPrehandler(dialog_->check_adapt_output);
2433 void FormPreferences::Printer::update(LyXRC const & rc)
2435 fl_set_button(dialog_->check_adapt_output,
2436 rc.print_adapt_output);
2437 fl_set_input(dialog_->input_command,
2438 rc.print_command.c_str());
2439 fl_set_input(dialog_->input_page_range,
2440 rc.print_pagerange_flag.c_str());
2441 fl_set_input(dialog_->input_copies,
2442 rc.print_copies_flag.c_str());
2443 fl_set_input(dialog_->input_reverse,
2444 rc.print_reverse_flag.c_str());
2445 fl_set_input(dialog_->input_to_printer,
2446 rc.print_to_printer.c_str());
2447 fl_set_input(dialog_->input_file_extension,
2448 rc.print_file_extension.c_str());
2449 fl_set_input(dialog_->input_spool_command,
2450 rc.print_spool_command.c_str());
2451 fl_set_input(dialog_->input_paper_type,
2452 rc.print_paper_flag.c_str());
2453 fl_set_input(dialog_->input_even_pages,
2454 rc.print_evenpage_flag.c_str());
2455 fl_set_input(dialog_->input_odd_pages,
2456 rc.print_oddpage_flag.c_str());
2457 fl_set_input(dialog_->input_collated,
2458 rc.print_collcopies_flag.c_str());
2459 fl_set_input(dialog_->input_landscape,
2460 rc.print_landscape_flag.c_str());
2461 fl_set_input(dialog_->input_to_file,
2462 rc.print_to_file.c_str());
2463 fl_set_input(dialog_->input_extra_options,
2464 rc.print_extra_options.c_str());
2465 fl_set_input(dialog_->input_spool_prefix,
2466 rc.print_spool_printerprefix.c_str());
2467 fl_set_input(dialog_->input_paper_size,
2468 rc.print_paper_dimension_flag.c_str());
2469 fl_set_input(dialog_->input_name,
2470 rc.printer.c_str());
2474 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2479 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2481 return dialog_.get();
2485 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2487 bool changed = false;
2489 pair<string, string> tmp =
2490 parseFontName(fl_get_input(dialog_->input_roman));
2491 if (rc.roman_font_name != tmp.first ||
2492 rc.roman_font_foundry != tmp.second) {
2494 rc.roman_font_name = tmp.first;
2495 rc.roman_font_foundry = tmp.second;
2498 tmp = parseFontName(fl_get_input(dialog_->input_sans));
2499 if (rc.sans_font_name != tmp.first ||
2500 rc.sans_font_foundry != tmp.second) {
2502 rc.sans_font_name = tmp.first;
2503 rc.sans_font_foundry = tmp.second;
2506 tmp = parseFontName(fl_get_input(dialog_->input_typewriter));
2507 if (rc.typewriter_font_name != tmp.first ||
2508 rc.typewriter_font_foundry != tmp.second) {
2510 rc.typewriter_font_name = tmp.first;
2511 rc.typewriter_font_foundry = tmp.second;
2514 string str = fl_get_input(dialog_->input_screen_encoding);
2515 if (rc.font_norm != str) {
2518 rc.set_font_norm_type();
2521 bool button = fl_get_button(dialog_->check_scalable);
2522 if (rc.use_scalable_fonts != button) {
2524 rc.use_scalable_fonts = button;
2527 unsigned int ivalue = static_cast<unsigned int>
2528 (fl_get_counter_value(dialog_->counter_zoom));
2529 if (rc.zoom != ivalue) {
2534 ivalue = static_cast<unsigned int>
2535 (fl_get_counter_value(dialog_->counter_dpi));
2536 if (rc.dpi != ivalue) {
2541 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2542 if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2544 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2547 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2548 if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2550 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2553 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2554 if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2556 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2559 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2560 if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2562 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2565 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2566 if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2568 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2571 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2572 if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2574 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2577 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2578 if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2580 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2583 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2584 if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2586 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2589 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2590 if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2592 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2595 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2596 if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2598 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2602 // Now update the buffers
2603 // Can anything below here affect the redraw process?
2604 parent_.controller().updateScreenFonts();
2609 void FormPreferences::ScreenFonts::build()
2611 dialog_.reset(build_preferences_screen_fonts(&parent_));
2613 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2614 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2616 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2617 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2618 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2619 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2620 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2621 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2622 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2623 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2624 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2625 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2626 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2627 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2628 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2629 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2630 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2631 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2633 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2634 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2635 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2636 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2637 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2638 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2639 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2640 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2641 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2642 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2644 // set up the feedback mechanism
2645 setPrehandler(dialog_->input_roman);
2646 setPrehandler(dialog_->input_sans);
2647 setPrehandler(dialog_->input_typewriter);
2648 setPrehandler(dialog_->counter_zoom);
2649 setPrehandler(dialog_->counter_dpi);
2650 setPrehandler(dialog_->check_scalable);
2651 setPrehandler(dialog_->input_screen_encoding);
2652 setPrehandler(dialog_->input_tiny);
2653 setPrehandler(dialog_->input_script);
2654 setPrehandler(dialog_->input_footnote);
2655 setPrehandler(dialog_->input_small);
2656 setPrehandler(dialog_->input_large);
2657 setPrehandler(dialog_->input_larger);
2658 setPrehandler(dialog_->input_largest);
2659 setPrehandler(dialog_->input_normal);
2660 setPrehandler(dialog_->input_huge);
2661 setPrehandler(dialog_->input_huger);
2666 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2668 if (ob == dialog_->input_roman)
2669 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2670 if (ob == dialog_->input_sans)
2671 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2672 if (ob == dialog_->input_typewriter)
2673 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2674 if (ob == dialog_->check_scalable)
2675 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2676 if (ob == dialog_->input_screen_encoding)
2677 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2678 if (ob == dialog_->counter_zoom)
2679 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2680 if (ob == dialog_->counter_dpi)
2681 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2682 if (ob == dialog_->input_tiny
2683 || ob == dialog_->input_script
2684 || ob == dialog_->input_footnote
2685 || ob == dialog_->input_small
2686 || ob == dialog_->input_large
2687 || ob == dialog_->input_larger
2688 || ob == dialog_->input_larger
2689 || ob == dialog_->input_largest
2690 || ob == dialog_->input_normal
2691 || ob == dialog_->input_huge
2692 || ob == dialog_->input_huger)
2693 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2698 bool FormPreferences::ScreenFonts::input()
2700 bool activate = true;
2703 // Make sure that all fonts all have positive entries
2704 // Also note that an empty entry is returned as 0.0 by strToDbl
2705 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2706 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2707 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2708 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2709 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2710 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2711 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2712 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2713 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2714 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2716 str = _("Fonts must be positive!");
2718 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2719 // Fontsizes -- tiny < script < footnote etc.
2720 strToDbl(fl_get_input(dialog_->input_script)) ||
2721 strToDbl(fl_get_input(dialog_->input_script)) >
2722 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2723 strToDbl(fl_get_input(dialog_->input_footnote)) >
2724 strToDbl(fl_get_input(dialog_->input_small)) ||
2725 strToDbl(fl_get_input(dialog_->input_small)) >
2726 strToDbl(fl_get_input(dialog_->input_normal)) ||
2727 strToDbl(fl_get_input(dialog_->input_normal)) >
2728 strToDbl(fl_get_input(dialog_->input_large)) ||
2729 strToDbl(fl_get_input(dialog_->input_large)) >
2730 strToDbl(fl_get_input(dialog_->input_larger)) ||
2731 strToDbl(fl_get_input(dialog_->input_larger)) >
2732 strToDbl(fl_get_input(dialog_->input_largest)) ||
2733 strToDbl(fl_get_input(dialog_->input_largest)) >
2734 strToDbl(fl_get_input(dialog_->input_huge)) ||
2735 strToDbl(fl_get_input(dialog_->input_huge)) >
2736 strToDbl(fl_get_input(dialog_->input_huger))) {
2739 str = _("Fonts must be input in the order Tiny > Smallest > Smaller > Small > Normal > Large > Larger > Largest > Huge > Huger.");
2743 parent_.postWarning(str);
2749 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2751 fl_set_input(dialog_->input_roman,
2752 makeFontName(rc.roman_font_name,
2753 rc.roman_font_foundry).c_str());
2754 fl_set_input(dialog_->input_sans,
2755 makeFontName(rc.sans_font_name,
2756 rc.sans_font_foundry).c_str());
2757 fl_set_input(dialog_->input_typewriter,
2758 makeFontName(rc.typewriter_font_name,
2759 rc.typewriter_font_foundry).c_str());
2760 fl_set_input(dialog_->input_screen_encoding,
2761 rc.font_norm.c_str());
2762 fl_set_button(dialog_->check_scalable,
2763 rc.use_scalable_fonts);
2764 fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2765 fl_set_counter_value(dialog_->counter_dpi, rc.dpi);
2766 fl_set_input(dialog_->input_tiny,
2767 tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2768 fl_set_input(dialog_->input_script,
2769 tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2770 fl_set_input(dialog_->input_footnote,
2771 tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2772 fl_set_input(dialog_->input_small,
2773 tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2774 fl_set_input(dialog_->input_normal,
2775 tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2776 fl_set_input(dialog_->input_large,
2777 tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2778 fl_set_input(dialog_->input_larger,
2779 tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2780 fl_set_input(dialog_->input_largest,
2781 tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2782 fl_set_input(dialog_->input_huge,
2783 tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2784 fl_set_input(dialog_->input_huger,
2785 tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2790 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2795 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2797 return dialog_.get();
2801 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2803 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2804 choice = trim(choice);
2806 rc.isp_command = choice;
2809 // If spell checker == "none", all other input set to off.
2810 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2811 rc.isp_use_alt_lang = false;
2812 rc.isp_alt_lang.erase();
2814 rc.isp_use_esc_chars = false;
2815 rc.isp_esc_chars.erase();
2817 rc.isp_use_pers_dict = false;
2818 rc.isp_pers_dict.erase();
2820 rc.isp_accept_compound = false;
2821 rc.isp_use_input_encoding = false;
2824 int button = fl_get_button(dialog_->check_alt_lang);
2825 choice = fl_get_input(dialog_->input_alt_lang);
2826 if (button && choice.empty()) button = 0;
2827 if (!button) choice.erase();
2829 rc.isp_use_alt_lang = static_cast<bool>(button);
2830 rc.isp_alt_lang = choice;
2832 button = fl_get_button(dialog_->check_escape_chars);
2833 choice = fl_get_input(dialog_->input_escape_chars);
2834 if (button && choice.empty()) button = 0;
2835 if (!button) choice.erase();
2837 rc.isp_use_esc_chars = static_cast<bool>(button);
2838 rc.isp_esc_chars = choice;
2840 button = fl_get_button(dialog_->check_personal_dict);
2841 choice = fl_get_input(dialog_->input_personal_dict);
2842 if (button && choice.empty()) button = 0;
2843 if (!button) choice.erase();
2845 rc.isp_use_pers_dict = static_cast<bool>(button);
2846 rc.isp_pers_dict = choice;
2848 button = fl_get_button(dialog_->check_compound_words);
2849 rc.isp_accept_compound = static_cast<bool>(button);
2851 button = fl_get_button(dialog_->check_input_enc);
2852 rc.isp_use_input_encoding = static_cast<bool>(button);
2863 void FormPreferences::SpellOptions::build()
2865 dialog_.reset(build_preferences_spelloptions(&parent_));
2867 fl_addto_choice(dialog_->choice_spell_command,
2868 _(" ispell | aspell ").c_str());
2869 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2870 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2871 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2873 // set up the feedback mechanism
2874 setPrehandler(dialog_->choice_spell_command);
2875 setPrehandler(dialog_->check_alt_lang);
2876 setPrehandler(dialog_->input_alt_lang);
2877 setPrehandler(dialog_->check_escape_chars);
2878 setPrehandler(dialog_->input_escape_chars);
2879 setPrehandler(dialog_->check_personal_dict);
2880 setPrehandler(dialog_->input_personal_dict);
2881 setPrehandler(dialog_->button_personal_dict);
2882 setPrehandler(dialog_->check_compound_words);
2883 setPrehandler(dialog_->check_input_enc);
2888 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2890 if (ob == dialog_->choice_spell_command)
2891 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2892 if (ob == dialog_->check_alt_lang)
2893 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2894 if (ob == dialog_->input_alt_lang)
2895 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2896 if (ob == dialog_->check_escape_chars)
2897 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2898 if (ob == dialog_->input_escape_chars)
2899 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2900 if (ob == dialog_->check_personal_dict)
2901 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2902 if (ob == dialog_->input_personal_dict)
2903 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2904 if (ob == dialog_->check_compound_words)
2905 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2906 if (ob == dialog_->check_input_enc)
2907 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
2912 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2914 // !ob if function is called from updateSpellOptions() to de/activate
2916 // otherwise the function is called by an xforms CB via input().
2919 // If spell checker == "none", disable all input.
2920 if (!ob || ob == dialog_->choice_spell_command) {
2921 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2922 fl_deactivate_object(dialog_->check_alt_lang);
2923 fl_deactivate_object(dialog_->input_alt_lang);
2924 fl_deactivate_object(dialog_->check_escape_chars);
2925 fl_deactivate_object(dialog_->input_escape_chars);
2926 fl_deactivate_object(dialog_->check_personal_dict);
2927 fl_deactivate_object(dialog_->input_personal_dict);
2928 fl_deactivate_object(dialog_->check_compound_words);
2929 fl_deactivate_object(dialog_->check_input_enc);
2932 fl_activate_object(dialog_->check_alt_lang);
2933 fl_activate_object(dialog_->check_escape_chars);
2934 fl_activate_object(dialog_->check_personal_dict);
2935 fl_activate_object(dialog_->check_compound_words);
2936 fl_activate_object(dialog_->check_input_enc);
2941 if (!ob || ob == dialog_->check_alt_lang) {
2942 bool const enable = fl_get_button(dialog_->check_alt_lang);
2943 setEnabled(dialog_->input_alt_lang, enable);
2946 if (!ob || ob == dialog_->check_escape_chars) {
2947 bool const enable = fl_get_button(dialog_->check_escape_chars);
2948 setEnabled(dialog_->input_escape_chars, enable);
2951 if (!ob || ob == dialog_->check_personal_dict) {
2952 bool const enable = fl_get_button(dialog_->check_personal_dict);
2953 setEnabled(dialog_->input_personal_dict, enable);
2956 if (ob == dialog_->button_personal_dict) {
2957 string f = parent_.controller().browsedict(
2958 fl_get_input(dialog_->input_personal_dict));
2959 fl_set_input(dialog_->input_personal_dict, f.c_str());
2962 return true; // All input is valid!
2966 void FormPreferences::SpellOptions::update(LyXRC const & rc)
2970 if (rc.isp_command == "none")
2972 else if (rc.isp_command == "ispell")
2974 else if (rc.isp_command == "aspell")
2977 if (rc.isp_command == "ispell")
2979 else if (rc.isp_command == "aspell")
2982 fl_set_choice(dialog_->choice_spell_command, choice);
2985 if (rc.isp_use_alt_lang)
2986 str = rc.isp_alt_lang;
2988 fl_set_button(dialog_->check_alt_lang,
2989 rc.isp_use_alt_lang);
2990 fl_set_input(dialog_->input_alt_lang, str.c_str());
2993 if (rc.isp_use_esc_chars)
2994 str = rc.isp_esc_chars;
2996 fl_set_button(dialog_->check_escape_chars,
2997 rc.isp_use_esc_chars);
2998 fl_set_input(dialog_->input_escape_chars, str.c_str());
3001 if (rc.isp_use_pers_dict)
3002 str = rc.isp_pers_dict;
3004 fl_set_button(dialog_->check_personal_dict,
3005 rc.isp_use_pers_dict);
3006 fl_set_input(dialog_->input_personal_dict, str.c_str());
3008 fl_set_button(dialog_->check_compound_words,
3009 rc.isp_accept_compound);
3010 fl_set_button(dialog_->check_input_enc,
3011 rc.isp_use_input_encoding);
3013 // Activate/Deactivate the input fields dependent on the state of the