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());
107 typedef FormCB<ControlPrefs, FormDB<FD_preferences> > base_class;
109 FormPreferences::FormPreferences()
110 : base_class(_("Preferences"), false),
111 colors_(*this), converters_(*this), inputs_misc_(*this),
112 formats_(*this), interface_(*this), language_(*this),
113 lnf_misc_(*this), identity_(*this), outputs_misc_(*this),
114 paths_(*this), printer_(*this), screen_fonts_(*this),
120 void FormPreferences::redraw()
122 if (!(form() && form()->visible))
124 fl_redraw_form(form());
126 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
127 if (!(form2 && form2->visible))
129 fl_redraw_form(form2);
132 if (form2 == converters_tab_->form)
133 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
135 else if (form2 == look_n_feel_tab_->form)
136 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
138 else if (form2 == inputs_tab_->form)
139 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
141 else if (form2 == outputs_tab_->form)
142 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
144 else if (form2 == lang_opts_tab_->form)
145 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
147 if (form3 && form3->visible)
148 fl_redraw_form(form3);
152 void FormPreferences::hide()
154 // We need to hide the active tabfolder otherwise we get a
155 // BadDrawable error from X window and LyX crashes without saving.
156 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
157 if (inner_form && inner_form->visible)
158 fl_hide_form(inner_form);
163 void FormPreferences::build()
165 dialog_.reset(build_preferences(this));
167 // Manage the restore, save, apply and cancel/close buttons
168 bcview().setOK(dialog_->button_ok);
169 bcview().setApply(dialog_->button_apply);
170 bcview().setCancel(dialog_->button_close);
171 bcview().setRestore(dialog_->button_restore);
173 // Allow the base class to control messages
174 setMessageWidget(dialog_->text_warning);
176 // build the tab folders
177 converters_tab_.reset(build_preferences_inner_tab(this));
178 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
179 inputs_tab_.reset(build_preferences_inner_tab(this));
180 outputs_tab_.reset(build_preferences_inner_tab(this));
181 lang_opts_tab_.reset(build_preferences_inner_tab(this));
183 // build actual tabfolder contents
184 // these will become nested tabfolders
188 inputs_misc_.build();
193 outputs_misc_.build();
196 screen_fonts_.build();
197 spelloptions_.build();
199 // Now add them to the tabfolder
200 fl_addto_tabfolder(dialog_->tabfolder_prefs,
202 look_n_feel_tab_->form);
203 fl_addto_tabfolder(dialog_->tabfolder_prefs,
205 lang_opts_tab_->form);
206 fl_addto_tabfolder(dialog_->tabfolder_prefs,
208 converters_tab_->form);
209 fl_addto_tabfolder(dialog_->tabfolder_prefs,
212 fl_addto_tabfolder(dialog_->tabfolder_prefs,
216 // now build the nested tabfolders
217 // Starting with look and feel
218 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
220 screen_fonts_.dialog()->form);
221 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
223 interface_.dialog()->form);
224 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
226 colors_.dialog()->form);
227 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
229 lnf_misc_.dialog()->form);
230 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
232 identity_.dialog()->form);
234 // then build converters
235 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
237 formats_.dialog()->form);
238 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
240 converters_.dialog()->form);
243 // Paths should probably go in a few inner_tab called Files
244 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
246 paths_.dialog()->form);
247 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
249 inputs_misc_.dialog()->form);
251 // then building outputs
252 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
254 printer_.dialog()->form);
255 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
257 outputs_misc_.dialog()->form);
259 // then building usage
260 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
262 spelloptions_.dialog()->form);
263 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
265 language_.dialog()->form);
267 // work-around xforms bug re update of folder->x, folder->y coords.
268 setPrehandler(look_n_feel_tab_->tabfolder_inner);
269 setPrehandler(converters_tab_->tabfolder_inner);
270 setPrehandler(inputs_tab_->tabfolder_inner);
271 setPrehandler(outputs_tab_->tabfolder_inner);
272 setPrehandler(lang_opts_tab_->tabfolder_inner);
276 void FormPreferences::apply()
278 // set the new lyxrc entries
279 // many of these need to trigger other functions when the assignment
280 // is made. For example, screen zoom and font types. These could be
281 // handled either by signals/slots in lyxrc or just directly call the
282 // associated functions here.
283 // There are other problems with this scheme. We really should check
284 // what we copy to make sure that it really is necessary to do things
285 // like update the screen fonts because that flushes the textcache
286 // and other stuff which may cost us a lot on slower/high-load
289 LyXRC & rc(controller().rc());
292 formats_.apply(); // Must be before converters_.apply()
294 inputs_misc_.apply(rc);
295 interface_.apply(rc);
299 outputs_misc_.apply(rc);
302 screen_fonts_.apply(rc);
303 spelloptions_.apply(rc);
305 // The "Save" button has been pressed.
306 if (controller().isClosing() && colors_.modifiedXformsPrefs) {
307 string const filename =
308 AddName(user_lyxdir, "preferences.xform");
309 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
314 string const FormPreferences::getFeedback(FL_OBJECT * ob)
318 if (ob->form->fdui == colors_.dialog())
319 return colors_.feedback(ob);
320 if (ob->form->fdui == converters_.dialog())
321 return converters_.feedback(ob);
322 if (ob->form->fdui == formats_.dialog())
323 return formats_.feedback(ob);
324 if (ob->form->fdui == inputs_misc_.dialog())
325 return inputs_misc_.feedback(ob);
326 if (ob->form->fdui == interface_.dialog())
327 return interface_.feedback(ob);
328 if (ob->form->fdui == language_.dialog())
329 return language_.feedback(ob);
330 if (ob->form->fdui == lnf_misc_.dialog())
331 return lnf_misc_.feedback(ob);
332 if (ob->form->fdui == outputs_misc_.dialog())
333 return outputs_misc_.feedback(ob);
334 if (ob->form->fdui == paths_.dialog())
335 return paths_.feedback(ob);
336 if (ob->form->fdui == printer_.dialog())
337 return printer_.feedback(ob);
338 if (ob->form->fdui == screen_fonts_.dialog())
339 return screen_fonts_.feedback(ob);
340 if (ob->form->fdui == spelloptions_.dialog())
341 return spelloptions_.feedback(ob);
347 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
353 // whatever checks you need to ensure the user hasn't entered
354 // some totally ridiculous value somewhere. Change activate to suit.
355 // comments before each test describe what is _valid_
357 if (ob->form->fdui == colors_.dialog()) {
359 } else if (ob->form->fdui == converters_.dialog()) {
360 valid = converters_.input(ob);
361 } else if (ob->form->fdui == formats_.dialog()) {
362 valid = formats_.input(ob);
363 } else if (ob->form->fdui == interface_.dialog()) {
364 valid = interface_.input(ob);
365 } else if (ob->form->fdui == language_.dialog()) {
366 valid = language_.input(ob);
367 } else if (ob->form->fdui == paths_.dialog()) {
368 valid = paths_.input(ob);
369 } else if (ob->form->fdui == screen_fonts_.dialog()) {
370 valid = screen_fonts_.input();
371 } else if (ob->form->fdui == spelloptions_.dialog()) {
372 valid = spelloptions_.input(ob);
375 return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
379 void FormPreferences::update()
381 if (!dialog_.get()) return;
383 LyXRC const & rc(controller().rc());
385 // read lyxrc entries
387 formats_.update(); // Must be before converters_.update()
388 converters_.update();
389 inputs_misc_.update(rc);
390 interface_.update(rc);
391 language_.update(rc);
392 lnf_misc_.update(rc);
393 identity_.update(rc);
394 outputs_misc_.update(rc);
397 screen_fonts_.update(rc);
398 spelloptions_.update(rc);
402 FormPreferences::Colors::Colors(FormPreferences & p)
403 : modifiedXformsPrefs(false), parent_(p)
407 FD_preferences_colors const * FormPreferences::Colors::dialog()
409 return dialog_.get();
413 void FormPreferences::Colors::apply()
415 bool modifiedText = false;
416 bool modifiedBackground = false;
418 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
419 cit != xformsColorDB.end(); ++cit) {
421 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
422 if (col != cit->color()) {
423 modifiedXformsPrefs = true;
424 if (cit->colorID == FL_BLACK)
426 if (cit->colorID == FL_COL1)
427 modifiedBackground = true;
431 if (modifiedXformsPrefs) {
432 for (vector<XformsColor>::const_iterator cit =
433 xformsColorDB.begin();
434 cit != xformsColorDB.end(); ++cit) {
435 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
437 if (modifiedText && cit->colorID == FL_BLACK) {
438 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
441 if (modifiedBackground && cit->colorID == FL_COL1) {
442 AdjustVal(FL_MCOL, FL_COL1, 0.1);
443 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
444 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
446 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
447 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
450 if (cit->colorID == GUI_COLOR_CURSOR) {
451 fl_mapcolor(GUI_COLOR_CURSOR,
452 cit->r, cit->g, cit->b);
453 setCursorColor(GUI_COLOR_CURSOR);
456 parent_.controller().redrawGUI();
459 // Now do the same for the LyX LColors...
460 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
461 cit != lyxColorDB.end(); ++cit) {
462 LColor::color lc = lcolor.getFromGUIName(cit->getname());
463 if (lc == LColor::inherit) continue;
465 // Create a valid X11 name of the form "#rrggbb"
466 string const hexname = X11hexname(cit->color());
468 if (lcolor.getX11Name(lc) != hexname) {
470 << "FormPreferences::Colors::apply: "
471 << "resetting LColor " << lcolor.getGUIName(lc)
472 << " from \"" << lcolor.getX11Name(lc)
473 << "\" to \"" << hexname << "\"."
476 parent_.controller().setColor(lc, hexname);
482 void FormPreferences::Colors::build()
484 dialog_.reset(build_preferences_colors(&parent_));
486 fl_set_object_color(dialog_->button_color,
487 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
489 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
490 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
491 fl_set_dial_step(dialog_->dial_hue, 1.0);
492 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
494 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
495 fl_set_slider_step(dialog_->slider_saturation, 0.01);
496 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
498 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
499 fl_set_slider_step(dialog_->slider_value, 0.01);
500 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
502 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
503 fl_set_slider_step(dialog_->slider_red, 1.0);
504 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
506 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
507 fl_set_slider_step(dialog_->slider_green, 1.0);
508 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
510 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
511 fl_set_slider_step(dialog_->slider_blue, 1.0);
512 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
514 // set up the feedback mechanism
515 setPrehandler(dialog_->browser_lyx_objs);
516 setPrehandler(dialog_->button_color);
517 setPrehandler(dialog_->button_modify);
518 setPrehandler(dialog_->dial_hue);
519 setPrehandler(dialog_->slider_saturation);
520 setPrehandler(dialog_->slider_value);
521 setPrehandler(dialog_->slider_red);
522 setPrehandler(dialog_->slider_green);
523 setPrehandler(dialog_->slider_blue);
524 setPrehandler(dialog_->radio_rgb);
525 setPrehandler(dialog_->radio_hsv);
530 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
532 if (ob == dialog_->browser_lyx_objs)
533 return _("LyX objects that can be assigned a color.");
535 if (ob == dialog_->button_modify)
536 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
538 if (ob == dialog_->dial_hue ||
539 ob == dialog_->slider_saturation ||
540 ob == dialog_->slider_value ||
541 ob == dialog_->slider_red ||
542 ob == dialog_->slider_green ||
543 ob == dialog_->slider_blue)
544 return _("Find a new color.");
546 if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
547 return _("Toggle between RGB and HSV color spaces.");
553 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
555 if (ob == dialog_->browser_lyx_objs) {
558 } else if (ob == dialog_->dial_hue ||
559 ob == dialog_->slider_saturation ||
560 ob == dialog_->slider_value) {
563 } else if (ob == dialog_->slider_red ||
564 ob == dialog_->slider_green ||
565 ob == dialog_->slider_blue) {
568 } else if (ob == dialog_->radio_rgb ||
569 ob == dialog_->radio_hsv) {
572 } else if (ob == dialog_->button_modify) {
578 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
582 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
586 hsv.v = min(1.0, max(0.0, hsv.v));
589 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
593 void FormPreferences::Colors::InputBrowserLyX() const
595 vector<NamedColor>::size_type const selLyX =
596 fl_get_browser(dialog_->browser_lyx_objs);
597 if (selLyX < 1) return;
599 // Is the choice an Xforms color...
602 if (selLyX - 1 < xformsColorDB.size()) {
603 vector<XformsColor>::size_type const i = selLyX - 1;
604 col = xformsColorDB[i].color();
606 // or a LyX Logical color?
608 vector<NamedColor>::size_type const i = selLyX - 1 -
609 xformsColorDB.size();
610 col = lyxColorDB[i].color();
613 fl_freeze_form(dialog_->form);
615 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
616 fl_redraw_object(dialog_->button_color);
618 // Display either RGB or HSV but not both!
621 // Deactivate the modify button to begin with...
622 setEnabled(dialog_->button_modify, false);
624 fl_unfreeze_form(dialog_->form);
628 void FormPreferences::Colors::InputHSV()
630 double const hue = fl_get_dial_value(dialog_->dial_hue);
631 double const sat = fl_get_slider_value(dialog_->slider_saturation);
632 double const val = fl_get_slider_value(dialog_->slider_value);
634 int const h = int(hue);
635 int const s = int(100.0 * sat);
636 int const v = int(100.0 * val);
638 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
640 fl_set_object_label(dialog_->text_color_values, label.c_str());
642 RGBColor col = HSVColor(hue, sat, val);
644 fl_freeze_form(dialog_->form);
646 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
647 fl_redraw_object(dialog_->button_color);
649 col = HSVColor(hue, 1.0, 1.0);
650 col.r = max(col.r, 0u);
651 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
652 fl_redraw_object(dialog_->dial_hue);
654 // Ascertain whether to activate the Modify button.
655 vector<NamedColor>::size_type const selLyX =
656 fl_get_browser(dialog_->browser_lyx_objs);
658 fl_unfreeze_form(dialog_->form);
659 if (selLyX < 1) return;
661 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
664 // Is the choice an Xforms color...
665 if (selLyX - 1 < xformsColorDB.size()) {
666 vector<XformsColor>::size_type const i = selLyX - 1;
667 modify = (xformsColorDB[i].color() != col);
669 // or a LyX Logical color?
671 vector<NamedColor>::size_type const i = selLyX - 1 -
672 xformsColorDB.size();
673 modify = (lyxColorDB[i].color() != col);
676 setEnabled(dialog_->button_modify, modify);
680 void FormPreferences::Colors::InputRGB()
682 int const red = int(fl_get_slider_value(dialog_->slider_red));
683 int const green = int(fl_get_slider_value(dialog_->slider_green));
684 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
686 string const label = tostr(red) + string(", ") + tostr(green) +
687 string(", ") + tostr(blue);
688 fl_set_object_label(dialog_->text_color_values, label.c_str());
690 fl_freeze_form(dialog_->form);
692 RGBColor col = RGBColor(red, green, blue);
693 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
694 fl_redraw_object(dialog_->button_color);
696 // Ascertain whether to activate the Modify button.
697 vector<NamedColor>::size_type const selLyX =
698 fl_get_browser(dialog_->browser_lyx_objs);
700 fl_unfreeze_form(dialog_->form);
701 if (selLyX < 1) return;
705 // Is the choice an Xforms color...
706 if (selLyX - 1 < xformsColorDB.size()) {
707 vector<XformsColor>::size_type const i = selLyX - 1;
708 modify = (xformsColorDB[i].color() != col);
710 // or a LyX Logical color?
712 vector<NamedColor>::size_type const i = selLyX - 1 -
713 xformsColorDB.size();
714 modify = (lyxColorDB[i].color() != col);
717 setEnabled(dialog_->button_modify, modify);
721 void FormPreferences::Colors::LoadBrowserLyX()
723 if (!dialog_->browser_lyx_objs->visible)
726 // First, define the modifiable xforms colors
727 xformsColorDB.clear();
730 xcol.name = _("GUI background");
731 xcol.colorID = FL_COL1;
732 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
734 xformsColorDB.push_back(xcol);
736 xcol.name = _("GUI text");
737 xcol.colorID = FL_BLACK;
738 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
740 xformsColorDB.push_back(xcol);
742 xcol.name = _("GUI selection");
743 xcol.colorID = FL_YELLOW;
744 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
746 xformsColorDB.push_back(xcol);
748 xcol.name = _("GUI pointer");
749 xcol.colorID = GUI_COLOR_CURSOR;
750 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
752 xformsColorDB.push_back(xcol);
754 // Now create the the LyX LColors database
756 for (int i=0; i<LColor::ignore; ++i) {
757 LColor::color lc = static_cast<LColor::color>(i);
758 if (lc == LColor::none
759 || lc == LColor::black
760 || lc == LColor::white
762 || lc == LColor::green
763 || lc == LColor::blue
764 || lc == LColor::cyan
765 || lc == LColor::magenta
766 || lc == LColor::yellow
767 || lc == LColor::inherit
768 || lc == LColor::ignore) continue;
771 bool const success = getRGBColor(lc, col.r, col.g, col.b);
773 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
774 << "LColor " << lcolor.getLyXName(lc)
775 << ": X can't find color \""
776 << lcolor.getX11Name(lc)
777 << "\". Set to \"black\"!" << endl;
779 string const arg = lcolor.getLyXName(lc) + " black";
780 parent_.controller().setColor(lc, "black");
784 // Create a valid X11 name of the form "#rrggbb" and change the
785 // LColor X11name to this. Don't want to trigger a redraw,
786 // as we're just changing the name not the RGB values.
787 // Also reset the system_lcolor names, so that we don't output
788 // unnecessary changes.
789 string const hexname = X11hexname(col);
791 if (lcolor.getX11Name(lc) != hexname) {
792 lcolor.setColor(lc, hexname);
793 system_lcolor.setColor(lc, hexname);
796 // Finally, push the color onto the database
797 NamedColor ncol(lcolor.getGUIName(lc), col);
798 lyxColorDB.push_back(ncol);
801 // Now construct the browser
802 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
803 fl_freeze_form(dialog_->form);
804 fl_clear_browser(colbr);
805 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
806 cit != xformsColorDB.end(); ++cit) {
807 fl_addto_browser(colbr, cit->getname().c_str());
809 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
810 cit != lyxColorDB.end(); ++cit) {
811 fl_addto_browser(colbr, cit->getname().c_str());
814 // just to be safe...
815 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
816 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
817 fl_unfreeze_form(dialog_->form);
823 void FormPreferences::Colors::Modify()
825 vector<NamedColor>::size_type const selLyX =
826 fl_get_browser(dialog_->browser_lyx_objs);
831 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
833 // Is the choice an Xforms color...
834 if (selLyX - 1 < xformsColorDB.size()) {
835 vector<XformsColor>::size_type const i = selLyX - 1;
836 xformsColorDB[i].r = col.r;
837 xformsColorDB[i].g = col.g;
838 xformsColorDB[i].b = col.b;
840 // or a LyX Logical color?
842 vector<NamedColor>::size_type const i = selLyX - 1 -
843 xformsColorDB.size();
844 lyxColorDB[i].r = col.r;
845 lyxColorDB[i].g = col.g;
846 lyxColorDB[i].b = col.b;
849 fl_freeze_form(dialog_->form);
850 setEnabled(dialog_->button_modify, false);
851 fl_unfreeze_form(dialog_->form);
855 void FormPreferences::Colors::SwitchColorSpace() const
857 bool const hsv = fl_get_button(dialog_->radio_hsv);
860 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
862 fl_freeze_form(dialog_->form);
865 fl_hide_object(dialog_->slider_red);
866 fl_hide_object(dialog_->slider_blue);
867 fl_hide_object(dialog_->slider_green);
868 fl_show_object(dialog_->dial_hue);
869 fl_show_object(dialog_->slider_saturation);
870 fl_show_object(dialog_->slider_value);
872 HSVColor hsv = HSVColor(col);
873 hsv.h = max(hsv.h, 0.0);
875 fl_set_dial_value(dialog_->dial_hue, hsv.h);
876 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
877 fl_set_slider_value(dialog_->slider_value, hsv.v);
879 col = HSVColor(hsv.h, 1.0, 1.0);
880 col.r = max(col.r, 0u);
881 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
882 fl_redraw_object(dialog_->dial_hue);
884 // Adjust the label a bit, but not the actual values.
885 // Means that toggling from one space to the other has no
886 // effect on the final color.
887 int const h = int(hsv.h);
888 int const s = int(100 * hsv.s);
889 int const v = int(100 * hsv.v);
890 string const label = tostr(h) + ", " + tostr(s) +
892 fl_set_object_label(dialog_->text_color_values, label.c_str());
895 fl_show_object(dialog_->slider_red);
896 fl_show_object(dialog_->slider_blue);
897 fl_show_object(dialog_->slider_green);
898 fl_hide_object(dialog_->dial_hue);
899 fl_hide_object(dialog_->slider_saturation);
900 fl_hide_object(dialog_->slider_value);
902 fl_set_slider_value(dialog_->slider_red, col.r);
903 fl_set_slider_value(dialog_->slider_green, col.g);
904 fl_set_slider_value(dialog_->slider_blue, col.b);
906 // Adjust the label a bit. Same reasoning as above.
907 int const r = int(col.r);
908 int const g = int(col.g);
909 int const b = int(col.b);
910 string const label = tostr(r) + ", " + tostr(g) +
912 fl_set_object_label(dialog_->text_color_values, label.c_str());
915 fl_unfreeze_form(dialog_->form);
919 FormPreferences::Converters::Converters(FormPreferences & p)
924 FD_preferences_converters const * FormPreferences::Converters::dialog()
926 return dialog_.get();
930 void FormPreferences::Converters::apply() const
932 parent_.controller().setConverters(local_converters);
936 void FormPreferences::Converters::build()
938 dialog_.reset(build_preferences_converters(&parent_));
940 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
941 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
943 // set up the feedback mechanism
944 setPrehandler(dialog_->browser_all);
945 setPrehandler(dialog_->button_delete);
946 setPrehandler(dialog_->button_add);
947 setPrehandler(dialog_->input_converter);
948 setPrehandler(dialog_->choice_from);
949 setPrehandler(dialog_->choice_to);
950 setPrehandler(dialog_->input_flags);
955 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
957 if (ob == dialog_->browser_all)
958 return _("All the currently defined converters known to LyX.");
960 if (ob == dialog_->choice_from)
961 return _("Convert \"from\" this format");
963 if (ob == dialog_->choice_to)
964 return _("Convert \"to\" this format");
966 if (ob == dialog_->input_converter)
967 return _("The conversion command. $$i is the input file name, "
968 "$$b is the file name without its extension and $$o is "
969 "the name of the output file. $$s can be used as path to "
970 "LyX's own collection of conversion scripts.");
972 if (ob == dialog_->input_flags)
973 return _("Extra information for the Converter class, whether and "
974 "how to parse the result, and various other things.");
976 if (ob == dialog_->button_delete)
977 return _("Remove the current converter from the list of available "
978 "converters. Note: you must then \"Apply\" the change.");
980 if (ob == dialog_->button_add) {
981 if (string(ob->label) == _("Add"))
982 return _("Add the current converter to the list of available "
983 "converters. Note: you must then \"Apply\" the change.");
985 return _("Modify the contents of the current converter. "
986 "Note: you must then \"Apply\" the change.");
993 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
995 if (ob == dialog_->browser_all)
998 if (ob == dialog_->choice_from
999 || ob == dialog_->choice_to
1000 || ob == dialog_->input_converter
1001 || ob == dialog_->input_flags)
1004 if (ob == dialog_->button_add)
1007 if (ob == dialog_->button_delete)
1014 void FormPreferences::Converters::update()
1016 local_converters = converters;
1017 local_converters.update(local_formats);
1022 void FormPreferences::Converters::UpdateBrowser()
1024 local_converters.sort();
1026 fl_freeze_form(dialog_->form);
1027 fl_clear_browser(dialog_->browser_all);
1028 for (::Converters::const_iterator cit = local_converters.begin();
1029 cit != local_converters.end(); ++cit) {
1030 string const name = cit->From->prettyname() + " -> "
1031 + cit->To->prettyname();
1032 fl_addto_browser(dialog_->browser_all, name.c_str());
1035 fl_unfreeze_form(dialog_->form);
1039 bool FormPreferences::Converters::Add()
1041 string const from = GetFrom();
1042 string const to = GetTo();
1043 string const command = fl_get_input(dialog_->input_converter);
1044 string const flags = fl_get_input(dialog_->input_flags);
1046 Converter const * old = local_converters.getConverter(from, to);
1047 local_converters.add(from, to, command, flags);
1049 local_converters.updateLast(local_formats);
1052 setEnabled(dialog_->button_add, false);
1058 bool FormPreferences::Converters::Browser()
1060 int const i = fl_get_browser(dialog_->browser_all);
1061 if (i <= 0) return false;
1063 fl_freeze_form(dialog_->form);
1065 Converter const & c = local_converters.get(i - 1);
1066 int j = local_formats.getNumber(c.from);
1068 fl_set_choice(dialog_->choice_from, j + 1);
1070 j = local_formats.getNumber(c.to);
1072 fl_set_choice(dialog_->choice_to, j + 1);
1074 fl_set_input(dialog_->input_converter, c.command.c_str());
1075 fl_set_input(dialog_->input_flags, c.flags.c_str());
1077 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
1078 fl_set_button_shortcut(dialog_->button_add,
1079 scex(_("Modify|#M")).c_str(), 1);
1081 setEnabled(dialog_->button_add, false);
1082 setEnabled(dialog_->button_delete, true);
1084 fl_unfreeze_form(dialog_->form);
1089 bool FormPreferences::Converters::erase()
1091 string const from = GetFrom();
1092 string const to = GetTo();
1094 local_converters.erase(from, to);
1100 bool FormPreferences::Converters::Input()
1102 string const from = GetFrom();
1103 string const to = GetTo();
1104 int const sel = local_converters.getNumber(from, to);
1106 fl_freeze_form(dialog_->form);
1109 fl_set_object_label(dialog_->button_add,
1110 idex(_("Add|#A")).c_str());
1111 fl_set_button_shortcut(dialog_->button_add,
1112 scex(_("Add|#A")).c_str(), 1);
1114 fl_deselect_browser(dialog_->browser_all);
1115 setEnabled(dialog_->button_delete, false);
1118 fl_set_object_label(dialog_->button_add,
1119 idex(_("Modify|#M")).c_str());
1120 fl_set_button_shortcut(dialog_->button_add,
1121 scex(_("Modify|#M")).c_str(), 1);
1123 int top = max(sel-5, 0);
1124 fl_set_browser_topline(dialog_->browser_all, top);
1125 fl_select_browser_line(dialog_->browser_all, sel+1);
1126 setEnabled(dialog_->button_delete, true);
1129 string const command = rtrim(fl_get_input(dialog_->input_converter));
1130 bool const enable = !(command.empty() || from == to);
1131 setEnabled(dialog_->button_add, enable);
1133 fl_unfreeze_form(dialog_->form);
1138 string const FormPreferences::Converters::GetFrom() const
1140 ::Formats::FormatList::size_type const i =
1141 fl_get_choice(dialog_->choice_from);
1143 if (i > 0 && i <= local_formats.size())
1144 return local_formats.get(i - 1).name();
1146 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1151 string const FormPreferences::Converters::GetTo() const
1153 ::Formats::FormatList::size_type const i =
1154 fl_get_choice(dialog_->choice_to);
1156 if (i > 0 && i <= local_formats.size())
1157 return local_formats.get(i - 1).name();
1159 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1164 void FormPreferences::Converters::UpdateChoices() const
1167 for (::Formats::const_iterator cit = local_formats.begin();
1168 cit != local_formats.end(); ++cit) {
1169 if (!choice.empty())
1173 choice += cit->prettyname();
1177 fl_clear_choice(dialog_->choice_from);
1178 fl_addto_choice(dialog_->choice_from, choice.c_str());
1180 fl_clear_choice(dialog_->choice_to);
1181 fl_addto_choice(dialog_->choice_to, choice.c_str());
1185 FormPreferences::Formats::Formats(FormPreferences & p)
1190 FD_preferences_formats const * FormPreferences::Formats::dialog()
1192 return dialog_.get();
1196 void FormPreferences::Formats::apply() const
1198 parent_.controller().setFormats(local_formats);
1202 void FormPreferences::Formats::build()
1204 dialog_.reset(build_preferences_formats(&parent_));
1206 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1207 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1208 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1209 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1210 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1212 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1214 // set up the feedback mechanism
1215 setPrehandler(dialog_->browser_all);
1216 setPrehandler(dialog_->input_format);
1217 setPrehandler(dialog_->input_gui_name);
1218 setPrehandler(dialog_->button_delete);
1219 setPrehandler(dialog_->button_add);
1220 setPrehandler(dialog_->input_extension);
1221 setPrehandler(dialog_->input_viewer);
1222 setPrehandler(dialog_->input_shrtcut);
1227 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1229 if (ob == dialog_->browser_all)
1230 return _("All the currently defined formats known to LyX.");
1232 if (ob == dialog_->input_format)
1233 return _("The format identifier.");
1235 if (ob == dialog_->input_gui_name)
1236 return _("The format name as it will appear in the menus.");
1238 if (ob == dialog_->input_shrtcut)
1239 return _("The keyboard accelerator. Use a letter in the GUI name. "
1242 if (ob == dialog_->input_extension)
1243 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1245 if (ob == dialog_->input_viewer)
1246 return _("The command used to launch the viewer application.");
1248 if (ob == dialog_->button_delete)
1249 return _("Remove the current format from the list of available "
1250 "formats. Note: you must then \"Apply\" the change.");
1252 if (ob == dialog_->button_add) {
1253 if (string(ob->label) == _("Add"))
1254 return _("Add the current format to the list of available "
1255 "formats. Note: you must then \"Apply\" the change.");
1257 return _("Modify the contents of the current format. Note: "
1258 "you must then \"Apply\" the change.");
1265 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1267 if (ob == dialog_->browser_all)
1270 if (ob == dialog_->input_format
1271 || ob == dialog_->input_gui_name
1272 || ob == dialog_->input_shrtcut
1273 || ob == dialog_->input_extension
1274 || ob == dialog_->input_viewer)
1277 if (ob == dialog_->button_add)
1280 if (ob == dialog_->button_delete)
1287 void FormPreferences::Formats::update()
1289 local_formats = formats;
1294 void FormPreferences::Formats::UpdateBrowser()
1296 local_formats.sort();
1298 fl_freeze_form(dialog_->form);
1299 fl_deselect_browser(dialog_->browser_all);
1300 fl_clear_browser(dialog_->browser_all);
1301 for (::Formats::const_iterator cit = local_formats.begin();
1302 cit != local_formats.end(); ++cit)
1303 fl_addto_browser(dialog_->browser_all,
1304 cit->prettyname().c_str());
1307 fl_unfreeze_form(dialog_->form);
1309 // Mustn't forget to update the Formats available to the converters_
1310 parent_.converters_.UpdateChoices();
1311 local_converters.update(local_formats);
1315 bool FormPreferences::Formats::Add()
1317 string const name = fl_get_input(dialog_->input_format);
1318 string const prettyname = fl_get_input(dialog_->input_gui_name);
1319 string const extension = fl_get_input(dialog_->input_extension);
1320 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1321 string const viewer = fl_get_input(dialog_->input_viewer);
1323 Format const * old = local_formats.getFormat(name);
1324 string const old_prettyname = old ? old->prettyname() : string();
1325 local_formats.add(name, extension, prettyname, shortcut);
1326 local_formats.setViewer(name, viewer);
1327 if (!old || prettyname != old_prettyname) {
1330 parent_.converters_.UpdateBrowser();
1332 setEnabled(dialog_->button_add, false);
1338 bool FormPreferences::Formats::Browser()
1340 int const i = fl_get_browser(dialog_->browser_all);
1344 fl_freeze_form(dialog_->form);
1346 Format const & f = local_formats.get(i - 1);
1348 fl_set_input(dialog_->input_format, f.name().c_str());
1349 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1350 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1351 fl_set_input(dialog_->input_extension, f.extension().c_str());
1352 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1354 fl_set_object_label(dialog_->button_add,
1355 idex(_("Modify|#M")).c_str());
1356 fl_set_button_shortcut(dialog_->button_add,
1357 scex(_("Modify|#M")).c_str(), 1);
1359 setEnabled(dialog_->button_add, false);
1360 setEnabled(dialog_->button_delete, true);
1362 fl_unfreeze_form(dialog_->form);
1367 bool FormPreferences::Formats::erase()
1369 string const name = fl_get_input(dialog_->input_format);
1371 if (local_converters.formatIsUsed(name)) {
1372 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1373 "Remove the converter first."));
1374 setEnabled(dialog_->button_delete, false);
1378 local_formats.erase(name);
1384 bool FormPreferences::Formats::Input()
1386 string const name = fl_get_input(dialog_->input_format);
1387 int const sel = local_formats.getNumber(name);
1388 fl_freeze_form(dialog_->form);
1391 fl_set_object_label(dialog_->button_add,
1392 idex(_("Add|#A")).c_str());
1393 fl_set_button_shortcut(dialog_->button_add,
1394 scex(_("Add|#A")).c_str(), 1);
1396 fl_deselect_browser(dialog_->browser_all);
1397 setEnabled(dialog_->button_delete, false);
1400 fl_set_object_label(dialog_->button_add,
1401 idex(_("Modify|#M")).c_str());
1402 fl_set_button_shortcut(dialog_->button_add,
1403 scex(_("Modify|#M")).c_str(), 1);
1405 int const top = max(sel-5, 0);
1406 fl_set_browser_topline(dialog_->browser_all, top);
1407 fl_select_browser_line(dialog_->browser_all, sel+1);
1409 setEnabled(dialog_->button_add, true);
1410 setEnabled(dialog_->button_delete, true);
1413 string const prettyname = fl_get_input(dialog_->input_gui_name);
1414 bool const enable = !(name.empty() || prettyname.empty());
1415 setEnabled(dialog_->button_add, enable);
1417 fl_unfreeze_form(dialog_->form);
1422 FormPreferences::Identity::Identity(FormPreferences & p)
1427 FD_preferences_identity const * FormPreferences::Identity::dialog()
1429 return dialog_.get();
1433 void FormPreferences::Identity::apply(LyXRC & rc) const
1435 rc.user_name = fl_get_input(dialog_->input_user_name);
1436 rc.user_email = fl_get_input(dialog_->input_user_email);
1440 void FormPreferences::Identity::build()
1442 dialog_.reset(build_preferences_identity(&parent_));
1443 fl_set_input_return(dialog_->input_user_name, FL_RETURN_CHANGED);
1444 fl_set_input_return(dialog_->input_user_email, FL_RETURN_CHANGED);
1448 void FormPreferences::Identity::update(LyXRC const & rc)
1450 fl_set_input(dialog_->input_user_name, rc.user_name.c_str());
1451 fl_set_input(dialog_->input_user_email, rc.user_email.c_str());
1455 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1460 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1462 return dialog_.get();
1466 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1468 rc.date_insert_format =
1469 fl_get_input(dialog_->input_date_format);
1473 void FormPreferences::InputsMisc::build()
1475 dialog_.reset(build_preferences_inputs_misc(&parent_));
1477 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1479 // set up the feedback mechanism
1480 setPrehandler(dialog_->input_date_format);
1485 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1487 if (ob == dialog_->input_date_format)
1488 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1493 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1495 fl_set_input(dialog_->input_date_format,
1496 rc.date_insert_format.c_str());
1500 FormPreferences::Interface::Interface(FormPreferences & p)
1505 FD_preferences_interface const * FormPreferences::Interface::dialog()
1507 return dialog_.get();
1511 void FormPreferences::Interface::apply(LyXRC & rc) const
1513 rc.popup_normal_font =
1514 fl_get_input(dialog_->input_popup_normal_font);
1515 rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1516 rc.popup_font_encoding =
1517 fl_get_input(dialog_->input_popup_font_encoding);
1518 rc.bind_file = fl_get_input(dialog_->input_bind_file);
1519 rc.ui_file = fl_get_input(dialog_->input_ui_file);
1523 void FormPreferences::Interface::build()
1525 dialog_.reset(build_preferences_interface(&parent_));
1527 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1528 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1529 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1530 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1531 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1533 // set up the feedback mechanism
1534 setPrehandler(dialog_->input_popup_normal_font);
1535 setPrehandler(dialog_->input_popup_bold_font);
1536 setPrehandler(dialog_->input_popup_font_encoding);
1537 setPrehandler(dialog_->input_bind_file);
1538 setPrehandler(dialog_->button_bind_file_browse);
1539 setPrehandler(dialog_->input_ui_file);
1540 setPrehandler(dialog_->button_ui_file_browse);
1545 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1547 if (ob == dialog_->input_popup_normal_font)
1548 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1549 if (ob == dialog_->input_popup_bold_font)
1550 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1551 if (ob == dialog_->input_popup_font_encoding)
1552 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1553 if (ob == dialog_->input_bind_file)
1554 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1555 if (ob == dialog_->input_ui_file)
1556 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1561 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1563 if (ob == dialog_->button_bind_file_browse) {
1564 string f = parent_.controller().browsebind(
1565 fl_get_input(dialog_->input_bind_file));
1567 fl_set_input(dialog_->input_bind_file, f.c_str());
1568 } else if (ob == dialog_->button_ui_file_browse) {
1569 string f = parent_.controller().browseUI(
1570 fl_get_input(dialog_->input_ui_file));
1572 fl_set_input(dialog_->input_ui_file, f.c_str());
1579 void FormPreferences::Interface::update(LyXRC const & rc)
1581 fl_set_input(dialog_->input_popup_normal_font,
1582 rc.popup_normal_font.c_str());
1583 fl_set_input(dialog_->input_popup_bold_font,
1584 rc.popup_bold_font.c_str());
1585 fl_set_input(dialog_->input_popup_font_encoding,
1586 rc.popup_font_encoding.c_str());
1587 fl_set_input(dialog_->input_bind_file,
1588 rc.bind_file.c_str());
1589 fl_set_input(dialog_->input_ui_file,
1590 rc.ui_file.c_str());
1594 FormPreferences::Language::Language(FormPreferences & p)
1599 FD_preferences_language const * FormPreferences::Language::dialog()
1601 return dialog_.get();
1605 void FormPreferences::Language::apply(LyXRC & rc)
1607 int const pos = fl_get_combox(dialog_->combox_default_lang);
1608 rc.default_language = lang_[pos-1];
1610 int button = fl_get_button(dialog_->check_use_kbmap);
1611 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1612 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1614 button = !(name_1.empty() && name_2.empty());
1615 rc.use_kbmap = static_cast<bool>(button);
1618 rc.primary_kbmap = name_1;
1619 rc.secondary_kbmap = name_2;
1622 button = fl_get_button(dialog_->check_rtl_support);
1623 rc.rtl_support = static_cast<bool>(button);
1625 button = fl_get_button(dialog_->check_mark_foreign);
1626 rc.mark_foreign_language = static_cast<bool>(button);
1628 button = fl_get_button(dialog_->check_auto_begin);
1629 rc.language_auto_begin = static_cast<bool>(button);
1631 button = fl_get_button(dialog_->check_auto_end);
1632 rc.language_auto_end = static_cast<bool>(button);
1634 button = fl_get_button(dialog_->check_use_babel);
1635 rc.language_use_babel = static_cast<bool>(button);
1637 button = fl_get_button(dialog_->check_global_options);
1638 rc.language_global_options = static_cast<bool>(button);
1640 rc.language_package = fl_get_input(dialog_->input_package);
1641 rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1642 rc.language_command_end = fl_get_input(dialog_->input_command_end);
1644 // Ensure that all is self-consistent.
1649 void FormPreferences::Language::build()
1651 dialog_.reset(build_preferences_language(&parent_));
1653 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1654 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1655 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1657 // Store the lang identifiers for later
1658 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1659 lang_ = getSecond(langs);
1661 FL_OBJECT * obj = dialog_->combox_default_lang;
1662 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1663 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1664 for (; lit != lend; ++lit) {
1665 fl_addto_combox(obj, lit->first.c_str());
1667 fl_set_combox_browser_height(obj, 400);
1669 // set up the feedback mechanism
1670 setPrehandler(dialog_->input_package);
1671 setPrehandler(dialog_->check_use_kbmap);
1672 setPrehandler(dialog_->combox_default_lang);
1673 setPrehandler(dialog_->input_kbmap1);
1674 setPrehandler(dialog_->input_kbmap2);
1675 setPrehandler(dialog_->check_rtl_support);
1676 setPrehandler(dialog_->check_mark_foreign);
1677 setPrehandler(dialog_->check_auto_begin);
1678 setPrehandler(dialog_->check_auto_end);
1679 setPrehandler(dialog_->check_use_babel);
1680 setPrehandler(dialog_->check_global_options);
1681 setPrehandler(dialog_->input_command_begin);
1682 setPrehandler(dialog_->input_command_end);
1684 // Activate/Deactivate the input fields dependent on the state of the
1691 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1693 if (ob == dialog_->combox_default_lang)
1694 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1695 if (ob == dialog_->check_use_kbmap)
1696 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1697 if (ob == dialog_->input_kbmap1)
1698 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1699 if (ob == dialog_->input_kbmap2)
1700 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1701 if (ob == dialog_->check_rtl_support)
1702 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1703 if (ob == dialog_->check_mark_foreign)
1704 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1705 if (ob == dialog_->check_auto_begin)
1706 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1707 if (ob == dialog_->check_auto_end)
1708 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1709 if (ob == dialog_->check_use_babel)
1710 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1711 if (ob == dialog_->check_global_options)
1712 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1713 if (ob == dialog_->input_package)
1714 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1715 if (ob == dialog_->input_command_begin)
1716 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1717 if (ob == dialog_->input_command_end)
1718 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1723 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1725 bool activate = true;
1727 // !ob if function is called from Language::build() to de/activate
1729 // otherwise the function is called by an xforms CB via input().
1730 if (!ob || ob == dialog_->check_use_kbmap) {
1731 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1732 setEnabled(dialog_->button_kbmap1_browse, enable);
1733 setEnabled(dialog_->button_kbmap2_browse, enable);
1734 setEnabled(dialog_->input_kbmap1, enable);
1735 setEnabled(dialog_->input_kbmap2, enable);
1738 if (ob == dialog_->button_kbmap1_browse) {
1739 string f = parent_.controller().browsekbmap(
1740 fl_get_input(dialog_->input_kbmap1));
1742 fl_set_input(dialog_->input_kbmap1, f.c_str());
1743 } else if (ob == dialog_->button_kbmap2_browse) {
1744 string f = parent_.controller().browsekbmap(
1745 fl_get_input(dialog_->input_kbmap2));
1747 fl_set_input(dialog_->input_kbmap2, f.c_str());
1754 void FormPreferences::Language::update(LyXRC const & rc)
1756 fl_set_button(dialog_->check_use_kbmap,
1759 int const pos = int(findPos(lang_, rc.default_language));
1760 fl_set_combox(dialog_->combox_default_lang, pos + 1);
1763 fl_set_input(dialog_->input_kbmap1,
1764 rc.primary_kbmap.c_str());
1765 fl_set_input(dialog_->input_kbmap2,
1766 rc.secondary_kbmap.c_str());
1768 fl_set_input(dialog_->input_kbmap1, "");
1769 fl_set_input(dialog_->input_kbmap2, "");
1772 fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1773 fl_set_button(dialog_->check_mark_foreign,
1774 rc.mark_foreign_language);
1775 fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1776 fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1777 fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1778 fl_set_button(dialog_->check_global_options,
1779 rc.language_global_options);
1781 fl_set_input(dialog_->input_package,
1782 rc.language_package.c_str());
1783 fl_set_input(dialog_->input_command_begin,
1784 rc.language_command_begin.c_str());
1785 fl_set_input(dialog_->input_command_end,
1786 rc.language_command_end.c_str());
1788 // Activate/Deactivate the input fields dependent on the state of the
1794 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1799 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1801 return dialog_.get();
1805 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1807 rc.auto_region_delete =
1808 fl_get_button(dialog_->check_auto_region_delete);
1809 rc.cursor_follows_scrollbar =
1810 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1811 rc.dialogs_iconify_with_main =
1812 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1813 rc.preview = fl_get_button(dialog_->check_preview_latex);
1814 rc.autosave = static_cast<unsigned int>
1815 (fl_get_counter_value(dialog_->counter_autosave));
1816 rc.wheel_jump = static_cast<unsigned int>
1817 (fl_get_counter_value(dialog_->counter_wm_jump));
1820 // grfx::DisplayType old_value = rc.display_graphics;
1821 switch (fl_get_choice(dialog_->choice_display)) {
1823 rc.display_graphics = grfx::NoDisplay;
1826 rc.display_graphics = grfx::ColorDisplay;
1829 rc.display_graphics = grfx::GrayscaleDisplay;
1832 rc.display_graphics = grfx::MonochromeDisplay;
1835 rc.display_graphics = grfx::ColorDisplay;
1839 #ifdef WITH_WARNINGS
1840 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1843 if (old_value != rc.display_graphics) {
1844 grfx::GCache & gc = grfx::GCache::get();
1851 void FormPreferences::LnFmisc::build()
1853 dialog_.reset(build_preferences_lnf_misc(&parent_));
1855 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1856 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1858 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1859 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1861 // set up the feedback mechanism
1862 setPrehandler(dialog_->check_auto_region_delete);
1863 setPrehandler(dialog_->counter_autosave);
1864 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1865 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1866 setPrehandler(dialog_->check_preview_latex);
1867 setPrehandler(dialog_->counter_wm_jump);
1869 fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
1874 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1876 if (ob == dialog_->check_auto_region_delete)
1877 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
1878 if (ob == dialog_->check_cursor_follows_scrollbar)
1879 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1880 if (ob == dialog_->check_dialogs_iconify_with_main)
1881 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1882 if (ob == dialog_->check_preview_latex)
1883 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
1884 if (ob == dialog_->counter_autosave)
1885 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
1886 if (ob == dialog_->counter_wm_jump)
1887 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
1888 if (ob == dialog_->choice_display)
1889 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1894 void FormPreferences::LnFmisc::update(LyXRC const & rc)
1896 fl_set_button(dialog_->check_auto_region_delete,
1897 rc.auto_region_delete);
1898 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1899 rc.cursor_follows_scrollbar);
1900 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1901 rc.dialogs_iconify_with_main);
1902 fl_set_button(dialog_->check_preview_latex,
1904 fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
1905 fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
1907 switch (rc.display_graphics) {
1908 case grfx::NoDisplay:
1909 fl_set_choice(dialog_->choice_display, 4);
1911 case grfx::ColorDisplay:
1912 fl_set_choice(dialog_->choice_display, 3);
1914 case grfx::GrayscaleDisplay:
1915 fl_set_choice(dialog_->choice_display, 2);
1917 case grfx::MonochromeDisplay:
1918 fl_set_choice(dialog_->choice_display, 1);
1921 fl_set_choice(dialog_->choice_display, 3);
1927 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1932 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1934 return dialog_.get();
1938 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
1940 rc.ascii_linelen = static_cast<unsigned int>
1941 (fl_get_counter_value(dialog_->counter_line_len));
1942 rc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1945 fl_get_choice(dialog_->choice_default_papersize) - 1;
1946 rc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1948 rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1949 rc.chktex_command = fl_get_input(dialog_->input_checktex);
1950 rc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1951 rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1955 void FormPreferences::OutputsMisc::build()
1957 dialog_.reset(build_preferences_outputs_misc(&parent_));
1959 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1961 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1962 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1963 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1964 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1965 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1967 fl_addto_choice(dialog_->choice_default_papersize,
1968 _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1970 // set up the feedback mechanism
1971 setPrehandler(dialog_->counter_line_len);
1972 setPrehandler(dialog_->input_tex_encoding);
1973 setPrehandler(dialog_->choice_default_papersize);
1974 setPrehandler(dialog_->input_ascii_roff);
1975 setPrehandler(dialog_->input_checktex);
1976 setPrehandler(dialog_->input_paperoption);
1977 setPrehandler(dialog_->check_autoreset_classopt);
1982 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1984 if (ob == dialog_->counter_line_len)
1985 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
1986 if (ob == dialog_->input_tex_encoding)
1987 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
1988 if (ob == dialog_->input_ascii_roff)
1989 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1990 if (ob == dialog_->input_checktex)
1991 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
1992 if (ob == dialog_->choice_default_papersize)
1993 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1994 if (ob == dialog_->input_paperoption)
1995 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
1996 if (ob == dialog_->check_autoreset_classopt)
1997 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2002 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
2004 fl_set_counter_value(dialog_->counter_line_len,
2006 fl_set_input(dialog_->input_tex_encoding,
2007 rc.fontenc.c_str());
2008 fl_set_choice(dialog_->choice_default_papersize,
2009 rc.default_papersize + 1);
2010 fl_set_input(dialog_->input_ascii_roff,
2011 rc.ascii_roff_command.c_str());
2012 fl_set_input(dialog_->input_checktex,
2013 rc.chktex_command.c_str());
2014 fl_set_input(dialog_->input_paperoption,
2015 rc.view_dvi_paper_option.c_str());
2016 fl_set_button(dialog_->check_autoreset_classopt,
2017 rc.auto_reset_options);
2022 FormPreferences::Paths::Paths(FormPreferences & p)
2027 FD_preferences_paths const * FormPreferences::Paths::dialog()
2029 return dialog_.get();
2033 void FormPreferences::Paths::apply(LyXRC & rc)
2035 rc.document_path = fl_get_input(dialog_->input_default_path);
2036 rc.template_path = fl_get_input(dialog_->input_template_path);
2038 int button = fl_get_button(dialog_->check_use_temp_dir);
2039 string str = fl_get_input(dialog_->input_temp_dir);
2043 rc.use_tempdir = button;
2044 rc.tempdir_path = str;
2046 button = fl_get_button(dialog_->check_last_files);
2047 str = fl_get_input(dialog_->input_lastfiles);
2048 if (!button) str.erase();
2050 rc.check_lastfiles = button;
2052 rc.num_lastfiles = static_cast<unsigned int>
2053 (fl_get_counter_value(dialog_->counter_lastfiles));
2055 button = fl_get_button(dialog_->check_make_backups);
2056 str = fl_get_input(dialog_->input_backup_path);
2060 rc.make_backup = button;
2061 rc.backupdir_path = str;
2063 rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2070 void FormPreferences::Paths::build()
2072 dialog_.reset(build_preferences_paths(&parent_));
2074 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2075 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2076 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2077 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2078 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2079 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2080 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2082 // set up the feedback mechanism
2083 setPrehandler(dialog_->input_default_path);
2084 setPrehandler(dialog_->counter_lastfiles);
2085 setPrehandler(dialog_->input_template_path);
2086 setPrehandler(dialog_->check_last_files);
2087 setPrehandler(dialog_->input_lastfiles);
2088 setPrehandler(dialog_->check_make_backups);
2089 setPrehandler(dialog_->input_backup_path);
2090 setPrehandler(dialog_->input_serverpipe);
2091 setPrehandler(dialog_->input_temp_dir);
2092 setPrehandler(dialog_->check_use_temp_dir);
2097 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2099 if (ob == dialog_->input_default_path)
2100 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2101 if (ob == dialog_->input_template_path)
2102 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2103 if (ob == dialog_->check_use_temp_dir)
2104 return LyXRC::getDescription(LyXRC::RC_USETEMPDIR);
2105 if (ob == dialog_->input_temp_dir)
2106 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2107 if (ob == dialog_->check_last_files)
2108 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2109 if (ob == dialog_->input_lastfiles)
2110 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
2111 if (ob == dialog_->counter_lastfiles)
2112 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2113 if (ob == dialog_->check_make_backups)
2114 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2115 if (ob == dialog_->input_backup_path)
2116 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2117 if (ob == dialog_->input_serverpipe)
2118 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2123 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2125 bool activate = true;
2127 // !ob if function is called from Paths::update() to de/activate
2129 // otherwise the function is called by an xforms CB via input().
2130 if (!ob || ob == dialog_->check_use_temp_dir) {
2131 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2132 setEnabled(dialog_->input_temp_dir, enable);
2135 if (!ob || ob == dialog_->check_last_files) {
2136 bool const enable = fl_get_button(dialog_->check_last_files);
2137 setEnabled(dialog_->input_lastfiles, enable);
2140 if (!ob || ob == dialog_->check_make_backups) {
2141 bool const enable = fl_get_button(dialog_->check_make_backups);
2142 setEnabled(dialog_->input_backup_path, enable);
2145 if (!ob || ob == dialog_->input_default_path) {
2146 string const name = fl_get_input(dialog_->input_default_path);
2147 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2148 parent_.postWarning(RWInfo::ErrorMessage());
2153 if (!ob || ob == dialog_->input_template_path) {
2154 string const name = fl_get_input(dialog_->input_template_path);
2155 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2156 parent_.postWarning(RWInfo::ErrorMessage());
2161 if (!ob || ob == dialog_->input_temp_dir) {
2162 string const name = fl_get_input(dialog_->input_temp_dir);
2163 if (fl_get_button(dialog_->check_make_backups)
2165 && !RWInfo::WriteableDir(name)) {
2166 parent_.postWarning(RWInfo::ErrorMessage());
2171 if (!ob || ob == dialog_->input_backup_path) {
2172 string const name = fl_get_input(dialog_->input_backup_path);
2173 if (fl_get_button(dialog_->check_make_backups)
2175 && !RWInfo::WriteableDir(name)) {
2176 parent_.postWarning(RWInfo::ErrorMessage());
2181 if (!ob || ob == dialog_->input_lastfiles) {
2182 string const name = fl_get_input(dialog_->input_lastfiles);
2183 if (fl_get_button(dialog_->check_last_files)
2185 && !RWInfo::WriteableFile(name)) {
2186 parent_.postWarning(RWInfo::ErrorMessage());
2191 if (!ob || ob == dialog_->input_serverpipe) {
2192 string const name = fl_get_input(dialog_->input_serverpipe);
2193 if (!name.empty()) {
2194 // strip off the extension
2195 string const str = ChangeExtension(name, "");
2196 if (!RWInfo::WriteableFile(str + ".in")) {
2197 parent_.postWarning(RWInfo::ErrorMessage());
2200 if (!RWInfo::WriteableFile(str + ".out")) {
2201 parent_.postWarning(RWInfo::ErrorMessage());
2207 if (ob == dialog_->button_default_path_browse) {
2208 string f = parent_.controller().browsedir(
2209 fl_get_input(dialog_->input_default_path), _("Default path"));
2211 fl_set_input(dialog_->input_default_path, f.c_str());
2212 } else if (ob == dialog_->button_template_path_browse) {
2213 string f = parent_.controller().browsedir(
2214 fl_get_input(dialog_->input_template_path), _("Template path"));
2216 fl_set_input(dialog_->input_template_path, f.c_str());
2217 } else if (ob == dialog_->button_temp_dir_browse) {
2218 string f = parent_.controller().browsedir(
2219 fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2221 fl_set_input(dialog_->input_temp_dir, f.c_str());
2222 } else if (ob == dialog_->button_lastfiles_browse) {
2223 string f = parent_.controller().browse(
2224 fl_get_input(dialog_->input_lastfiles), _("Last files"));
2226 fl_set_input(dialog_->input_lastfiles, f.c_str());
2227 } else if (ob == dialog_->button_backup_path_browse) {
2228 string f = parent_.controller().browsedir(
2229 fl_get_input(dialog_->input_backup_path), _("Backup path"));
2231 fl_set_input(dialog_->input_backup_path, f.c_str());
2232 } else if (ob == dialog_->button_serverpipe_browse) {
2233 string f = parent_.controller().browse(
2234 fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2236 fl_set_input(dialog_->input_serverpipe, f.c_str());
2243 void FormPreferences::Paths::update(LyXRC const & rc)
2245 fl_set_input(dialog_->input_default_path,
2246 rc.document_path.c_str());
2247 fl_set_input(dialog_->input_template_path,
2248 rc.template_path.c_str());
2252 str = rc.backupdir_path;
2254 fl_set_button(dialog_->check_make_backups,
2256 fl_set_input(dialog_->input_backup_path, str.c_str());
2260 str = rc.tempdir_path;
2262 fl_set_button(dialog_->check_use_temp_dir,
2264 fl_set_input(dialog_->input_temp_dir, str.c_str());
2267 if (rc.check_lastfiles)
2270 fl_set_button(dialog_->check_last_files,
2271 rc.check_lastfiles);
2272 fl_set_input(dialog_->input_lastfiles, str.c_str());
2273 fl_set_counter_value(dialog_->counter_lastfiles,
2276 fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2278 // Activate/Deactivate the input fields dependent on the state of the
2284 FormPreferences::Printer::Printer(FormPreferences & p)
2289 FD_preferences_printer const * FormPreferences::Printer::dialog()
2291 return dialog_.get();
2295 void FormPreferences::Printer::apply(LyXRC & rc) const
2297 rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2298 rc.print_command = fl_get_input(dialog_->input_command);
2299 rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2300 rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2301 rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2302 rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2303 rc.print_file_extension =
2304 fl_get_input(dialog_->input_file_extension);
2305 rc.print_spool_command =
2306 fl_get_input(dialog_->input_spool_command);
2307 rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2308 rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2309 rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2310 rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2311 rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2312 rc.print_to_file = fl_get_input(dialog_->input_to_file);
2313 rc.print_extra_options =
2314 fl_get_input(dialog_->input_extra_options);
2315 rc.print_spool_printerprefix =
2316 fl_get_input(dialog_->input_spool_prefix);
2317 rc.print_paper_dimension_flag =
2318 fl_get_input(dialog_->input_paper_size);
2319 rc.printer = fl_get_input(dialog_->input_name);
2324 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2326 if (ob == dialog_->input_command)
2327 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2328 if (ob == dialog_->check_adapt_output)
2329 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2330 if (ob == dialog_->input_to_printer)
2331 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2332 if (ob == dialog_->input_to_file)
2333 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2334 if (ob == dialog_->input_file_extension)
2335 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2336 if (ob == dialog_->input_extra_options)
2337 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2338 if (ob == dialog_->input_spool_command)
2339 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2340 if (ob == dialog_->input_spool_prefix)
2341 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2342 if (ob == dialog_->input_name)
2343 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2344 if (ob == dialog_->input_even_pages)
2345 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2346 if (ob == dialog_->input_odd_pages)
2347 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2348 if (ob == dialog_->input_page_range)
2349 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2350 if (ob == dialog_->input_reverse)
2351 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2352 if (ob == dialog_->input_landscape)
2353 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2354 if (ob == dialog_->input_copies)
2355 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2356 if (ob == dialog_->input_collated)
2357 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2358 if (ob == dialog_->input_paper_type)
2359 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2360 if (ob == dialog_->input_paper_size)
2361 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2366 void FormPreferences::Printer::build()
2368 dialog_.reset(build_preferences_printer(&parent_));
2370 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2371 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2372 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2373 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2374 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2375 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2376 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2377 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2378 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2379 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2380 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2381 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2382 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2383 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2384 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2385 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2386 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2388 // set up the feedback mechanism
2389 setPrehandler(dialog_->input_command);
2390 setPrehandler(dialog_->input_page_range);
2391 setPrehandler(dialog_->input_copies);
2392 setPrehandler(dialog_->input_reverse);
2393 setPrehandler(dialog_->input_to_printer);
2394 setPrehandler(dialog_->input_file_extension);
2395 setPrehandler(dialog_->input_spool_command);
2396 setPrehandler(dialog_->input_paper_type);
2397 setPrehandler(dialog_->input_even_pages);
2398 setPrehandler(dialog_->input_odd_pages);
2399 setPrehandler(dialog_->input_collated);
2400 setPrehandler(dialog_->input_landscape);
2401 setPrehandler(dialog_->input_to_file);
2402 setPrehandler(dialog_->input_extra_options);
2403 setPrehandler(dialog_->input_spool_prefix);
2404 setPrehandler(dialog_->input_paper_size);
2405 setPrehandler(dialog_->input_name);
2406 setPrehandler(dialog_->check_adapt_output);
2410 void FormPreferences::Printer::update(LyXRC const & rc)
2412 fl_set_button(dialog_->check_adapt_output,
2413 rc.print_adapt_output);
2414 fl_set_input(dialog_->input_command,
2415 rc.print_command.c_str());
2416 fl_set_input(dialog_->input_page_range,
2417 rc.print_pagerange_flag.c_str());
2418 fl_set_input(dialog_->input_copies,
2419 rc.print_copies_flag.c_str());
2420 fl_set_input(dialog_->input_reverse,
2421 rc.print_reverse_flag.c_str());
2422 fl_set_input(dialog_->input_to_printer,
2423 rc.print_to_printer.c_str());
2424 fl_set_input(dialog_->input_file_extension,
2425 rc.print_file_extension.c_str());
2426 fl_set_input(dialog_->input_spool_command,
2427 rc.print_spool_command.c_str());
2428 fl_set_input(dialog_->input_paper_type,
2429 rc.print_paper_flag.c_str());
2430 fl_set_input(dialog_->input_even_pages,
2431 rc.print_evenpage_flag.c_str());
2432 fl_set_input(dialog_->input_odd_pages,
2433 rc.print_oddpage_flag.c_str());
2434 fl_set_input(dialog_->input_collated,
2435 rc.print_collcopies_flag.c_str());
2436 fl_set_input(dialog_->input_landscape,
2437 rc.print_landscape_flag.c_str());
2438 fl_set_input(dialog_->input_to_file,
2439 rc.print_to_file.c_str());
2440 fl_set_input(dialog_->input_extra_options,
2441 rc.print_extra_options.c_str());
2442 fl_set_input(dialog_->input_spool_prefix,
2443 rc.print_spool_printerprefix.c_str());
2444 fl_set_input(dialog_->input_paper_size,
2445 rc.print_paper_dimension_flag.c_str());
2446 fl_set_input(dialog_->input_name,
2447 rc.printer.c_str());
2451 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2456 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2458 return dialog_.get();
2462 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2464 bool changed = false;
2466 pair<string, string> tmp =
2467 parseFontName(fl_get_input(dialog_->input_roman));
2468 if (rc.roman_font_name != tmp.first ||
2469 rc.roman_font_foundry != tmp.second) {
2471 rc.roman_font_name = tmp.first;
2472 rc.roman_font_foundry = tmp.second;
2475 tmp = parseFontName(fl_get_input(dialog_->input_sans));
2476 if (rc.sans_font_name != tmp.first ||
2477 rc.sans_font_foundry != tmp.second) {
2479 rc.sans_font_name = tmp.first;
2480 rc.sans_font_foundry = tmp.second;
2483 tmp = parseFontName(fl_get_input(dialog_->input_typewriter));
2484 if (rc.typewriter_font_name != tmp.first ||
2485 rc.typewriter_font_foundry != tmp.second) {
2487 rc.typewriter_font_name = tmp.first;
2488 rc.typewriter_font_foundry = tmp.second;
2491 string str = fl_get_input(dialog_->input_screen_encoding);
2492 if (rc.font_norm != str) {
2495 rc.set_font_norm_type();
2498 bool button = fl_get_button(dialog_->check_scalable);
2499 if (rc.use_scalable_fonts != button) {
2501 rc.use_scalable_fonts = button;
2504 unsigned int ivalue = static_cast<unsigned int>
2505 (fl_get_counter_value(dialog_->counter_zoom));
2506 if (rc.zoom != ivalue) {
2511 ivalue = static_cast<unsigned int>
2512 (fl_get_counter_value(dialog_->counter_dpi));
2513 if (rc.dpi != ivalue) {
2518 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2519 if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2521 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2524 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2525 if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2527 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2530 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2531 if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2533 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2536 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2537 if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2539 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2542 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2543 if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2545 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2548 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2549 if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2551 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2554 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2555 if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2557 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2560 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2561 if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2563 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2566 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2567 if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2569 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2572 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2573 if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2575 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2579 // Now update the buffers
2580 // Can anything below here affect the redraw process?
2581 parent_.controller().updateScreenFonts();
2586 void FormPreferences::ScreenFonts::build()
2588 dialog_.reset(build_preferences_screen_fonts(&parent_));
2590 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2591 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2593 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2594 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2595 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2596 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2597 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2598 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2599 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2600 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2601 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2602 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2603 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2604 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2605 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2606 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2607 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2608 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2610 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2611 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2612 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2613 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2614 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2615 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2616 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2617 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2618 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2619 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2621 // set up the feedback mechanism
2622 setPrehandler(dialog_->input_roman);
2623 setPrehandler(dialog_->input_sans);
2624 setPrehandler(dialog_->input_typewriter);
2625 setPrehandler(dialog_->counter_zoom);
2626 setPrehandler(dialog_->counter_dpi);
2627 setPrehandler(dialog_->check_scalable);
2628 setPrehandler(dialog_->input_screen_encoding);
2629 setPrehandler(dialog_->input_tiny);
2630 setPrehandler(dialog_->input_script);
2631 setPrehandler(dialog_->input_footnote);
2632 setPrehandler(dialog_->input_small);
2633 setPrehandler(dialog_->input_large);
2634 setPrehandler(dialog_->input_larger);
2635 setPrehandler(dialog_->input_largest);
2636 setPrehandler(dialog_->input_normal);
2637 setPrehandler(dialog_->input_huge);
2638 setPrehandler(dialog_->input_huger);
2643 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2645 if (ob == dialog_->input_roman)
2646 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2647 if (ob == dialog_->input_sans)
2648 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2649 if (ob == dialog_->input_typewriter)
2650 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2651 if (ob == dialog_->check_scalable)
2652 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2653 if (ob == dialog_->input_screen_encoding)
2654 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2655 if (ob == dialog_->counter_zoom)
2656 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2657 if (ob == dialog_->counter_dpi)
2658 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2659 if (ob == dialog_->input_tiny
2660 || ob == dialog_->input_script
2661 || ob == dialog_->input_footnote
2662 || ob == dialog_->input_small
2663 || ob == dialog_->input_large
2664 || ob == dialog_->input_larger
2665 || ob == dialog_->input_larger
2666 || ob == dialog_->input_largest
2667 || ob == dialog_->input_normal
2668 || ob == dialog_->input_huge
2669 || ob == dialog_->input_huger)
2670 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2675 bool FormPreferences::ScreenFonts::input()
2677 bool activate = true;
2680 // Make sure that all fonts all have positive entries
2681 // Also note that an empty entry is returned as 0.0 by strToDbl
2682 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2683 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2684 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2685 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2686 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2687 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2688 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2689 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2690 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2691 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2693 str = _("Fonts must be positive!");
2695 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2696 // Fontsizes -- tiny < script < footnote etc.
2697 strToDbl(fl_get_input(dialog_->input_script)) ||
2698 strToDbl(fl_get_input(dialog_->input_script)) >
2699 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2700 strToDbl(fl_get_input(dialog_->input_footnote)) >
2701 strToDbl(fl_get_input(dialog_->input_small)) ||
2702 strToDbl(fl_get_input(dialog_->input_small)) >
2703 strToDbl(fl_get_input(dialog_->input_normal)) ||
2704 strToDbl(fl_get_input(dialog_->input_normal)) >
2705 strToDbl(fl_get_input(dialog_->input_large)) ||
2706 strToDbl(fl_get_input(dialog_->input_large)) >
2707 strToDbl(fl_get_input(dialog_->input_larger)) ||
2708 strToDbl(fl_get_input(dialog_->input_larger)) >
2709 strToDbl(fl_get_input(dialog_->input_largest)) ||
2710 strToDbl(fl_get_input(dialog_->input_largest)) >
2711 strToDbl(fl_get_input(dialog_->input_huge)) ||
2712 strToDbl(fl_get_input(dialog_->input_huge)) >
2713 strToDbl(fl_get_input(dialog_->input_huger))) {
2716 str = _("Fonts must be input in the order Tiny > Smallest > Smaller > Small > Normal > Large > Larger > Largest > Huge > Huger.");
2720 parent_.postWarning(str);
2726 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2728 fl_set_input(dialog_->input_roman,
2729 makeFontName(rc.roman_font_name,
2730 rc.roman_font_foundry).c_str());
2731 fl_set_input(dialog_->input_sans,
2732 makeFontName(rc.sans_font_name,
2733 rc.sans_font_foundry).c_str());
2734 fl_set_input(dialog_->input_typewriter,
2735 makeFontName(rc.typewriter_font_name,
2736 rc.typewriter_font_foundry).c_str());
2737 fl_set_input(dialog_->input_screen_encoding,
2738 rc.font_norm.c_str());
2739 fl_set_button(dialog_->check_scalable,
2740 rc.use_scalable_fonts);
2741 fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2742 fl_set_counter_value(dialog_->counter_dpi, rc.dpi);
2743 fl_set_input(dialog_->input_tiny,
2744 tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2745 fl_set_input(dialog_->input_script,
2746 tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2747 fl_set_input(dialog_->input_footnote,
2748 tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2749 fl_set_input(dialog_->input_small,
2750 tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2751 fl_set_input(dialog_->input_normal,
2752 tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2753 fl_set_input(dialog_->input_large,
2754 tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2755 fl_set_input(dialog_->input_larger,
2756 tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2757 fl_set_input(dialog_->input_largest,
2758 tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2759 fl_set_input(dialog_->input_huge,
2760 tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2761 fl_set_input(dialog_->input_huger,
2762 tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2767 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2772 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2774 return dialog_.get();
2778 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2780 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2781 choice = trim(choice);
2783 rc.isp_command = choice;
2786 // If spell checker == "none", all other input set to off.
2787 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2788 rc.isp_use_alt_lang = false;
2789 rc.isp_alt_lang.erase();
2791 rc.isp_use_esc_chars = false;
2792 rc.isp_esc_chars.erase();
2794 rc.isp_use_pers_dict = false;
2795 rc.isp_pers_dict.erase();
2797 rc.isp_accept_compound = false;
2798 rc.isp_use_input_encoding = false;
2801 int button = fl_get_button(dialog_->check_alt_lang);
2802 choice = fl_get_input(dialog_->input_alt_lang);
2803 if (button && choice.empty()) button = 0;
2804 if (!button) choice.erase();
2806 rc.isp_use_alt_lang = static_cast<bool>(button);
2807 rc.isp_alt_lang = choice;
2809 button = fl_get_button(dialog_->check_escape_chars);
2810 choice = fl_get_input(dialog_->input_escape_chars);
2811 if (button && choice.empty()) button = 0;
2812 if (!button) choice.erase();
2814 rc.isp_use_esc_chars = static_cast<bool>(button);
2815 rc.isp_esc_chars = choice;
2817 button = fl_get_button(dialog_->check_personal_dict);
2818 choice = fl_get_input(dialog_->input_personal_dict);
2819 if (button && choice.empty()) button = 0;
2820 if (!button) choice.erase();
2822 rc.isp_use_pers_dict = static_cast<bool>(button);
2823 rc.isp_pers_dict = choice;
2825 button = fl_get_button(dialog_->check_compound_words);
2826 rc.isp_accept_compound = static_cast<bool>(button);
2828 button = fl_get_button(dialog_->check_input_enc);
2829 rc.isp_use_input_encoding = static_cast<bool>(button);
2840 void FormPreferences::SpellOptions::build()
2842 dialog_.reset(build_preferences_spelloptions(&parent_));
2844 fl_addto_choice(dialog_->choice_spell_command,
2845 _(" ispell | aspell "));
2846 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2847 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2848 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2850 // set up the feedback mechanism
2851 setPrehandler(dialog_->choice_spell_command);
2852 setPrehandler(dialog_->check_alt_lang);
2853 setPrehandler(dialog_->input_alt_lang);
2854 setPrehandler(dialog_->check_escape_chars);
2855 setPrehandler(dialog_->input_escape_chars);
2856 setPrehandler(dialog_->check_personal_dict);
2857 setPrehandler(dialog_->input_personal_dict);
2858 setPrehandler(dialog_->button_personal_dict);
2859 setPrehandler(dialog_->check_compound_words);
2860 setPrehandler(dialog_->check_input_enc);
2865 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2867 if (ob == dialog_->choice_spell_command)
2868 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2869 if (ob == dialog_->check_alt_lang)
2870 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2871 if (ob == dialog_->input_alt_lang)
2872 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2873 if (ob == dialog_->check_escape_chars)
2874 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2875 if (ob == dialog_->input_escape_chars)
2876 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2877 if (ob == dialog_->check_personal_dict)
2878 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2879 if (ob == dialog_->input_personal_dict)
2880 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2881 if (ob == dialog_->check_compound_words)
2882 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2883 if (ob == dialog_->check_input_enc)
2884 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
2889 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2891 // !ob if function is called from updateSpellOptions() to de/activate
2893 // otherwise the function is called by an xforms CB via input().
2896 // If spell checker == "none", disable all input.
2897 if (!ob || ob == dialog_->choice_spell_command) {
2898 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2899 fl_deactivate_object(dialog_->check_alt_lang);
2900 fl_deactivate_object(dialog_->input_alt_lang);
2901 fl_deactivate_object(dialog_->check_escape_chars);
2902 fl_deactivate_object(dialog_->input_escape_chars);
2903 fl_deactivate_object(dialog_->check_personal_dict);
2904 fl_deactivate_object(dialog_->input_personal_dict);
2905 fl_deactivate_object(dialog_->check_compound_words);
2906 fl_deactivate_object(dialog_->check_input_enc);
2909 fl_activate_object(dialog_->check_alt_lang);
2910 fl_activate_object(dialog_->check_escape_chars);
2911 fl_activate_object(dialog_->check_personal_dict);
2912 fl_activate_object(dialog_->check_compound_words);
2913 fl_activate_object(dialog_->check_input_enc);
2918 if (!ob || ob == dialog_->check_alt_lang) {
2919 bool const enable = fl_get_button(dialog_->check_alt_lang);
2920 setEnabled(dialog_->input_alt_lang, enable);
2923 if (!ob || ob == dialog_->check_escape_chars) {
2924 bool const enable = fl_get_button(dialog_->check_escape_chars);
2925 setEnabled(dialog_->input_escape_chars, enable);
2928 if (!ob || ob == dialog_->check_personal_dict) {
2929 bool const enable = fl_get_button(dialog_->check_personal_dict);
2930 setEnabled(dialog_->input_personal_dict, enable);
2933 if (ob == dialog_->button_personal_dict) {
2934 string f = parent_.controller().browsedict(
2935 fl_get_input(dialog_->input_personal_dict));
2936 fl_set_input(dialog_->input_personal_dict, f.c_str());
2939 return true; // All input is valid!
2943 void FormPreferences::SpellOptions::update(LyXRC const & rc)
2947 if (rc.isp_command == "none")
2949 else if (rc.isp_command == "ispell")
2951 else if (rc.isp_command == "aspell")
2954 if (rc.isp_command == "ispell")
2956 else if (rc.isp_command == "aspell")
2959 fl_set_choice(dialog_->choice_spell_command, choice);
2962 if (rc.isp_use_alt_lang)
2963 str = rc.isp_alt_lang;
2965 fl_set_button(dialog_->check_alt_lang,
2966 rc.isp_use_alt_lang);
2967 fl_set_input(dialog_->input_alt_lang, str.c_str());
2970 if (rc.isp_use_esc_chars)
2971 str = rc.isp_esc_chars;
2973 fl_set_button(dialog_->check_escape_chars,
2974 rc.isp_use_esc_chars);
2975 fl_set_input(dialog_->input_escape_chars, str.c_str());
2978 if (rc.isp_use_pers_dict)
2979 str = rc.isp_pers_dict;
2981 fl_set_button(dialog_->check_personal_dict,
2982 rc.isp_use_pers_dict);
2983 fl_set_input(dialog_->input_personal_dict, str.c_str());
2985 fl_set_button(dialog_->check_compound_words,
2986 rc.isp_accept_compound);
2987 fl_set_button(dialog_->check_input_enc,
2988 rc.isp_use_input_encoding);
2990 // Activate/Deactivate the input fields dependent on the state of the