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/lstrings.h"
39 #include "support/lyxfunctional.h"
40 #include "support/lyxmanip.h"
41 #include "support/tostr.h"
42 #include "support/filetools.h"
43 #include "support/LAssert.h"
45 #include "graphics/GraphicsCache.h"
46 #include "graphics/GraphicsTypes.h"
48 #include <boost/bind.hpp>
50 #include "lyx_forms.h"
66 extern string system_lyxdir;
67 extern string user_lyxdir;
71 // These should probably go inside the class definition...
72 Formats local_formats;
73 Converters local_converters;
75 string makeFontName(string const & family, string const & foundry)
79 return family + ',' + foundry;
83 pair<string,string> parseFontName(string const & name)
85 string::size_type const idx = name.find(',');
86 if (idx == string::npos)
87 return make_pair(name, string());
88 return make_pair(name.substr(0, idx),
93 string const X11hexname(RGBColor const & col)
97 ostr << '#' << std::setbase(16) << setfill('0')
102 return STRCONV(ostr.str());
105 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
106 bool const scalableTabfolders = false;
108 bool const scalableTabfolders = true;
114 typedef FormCB<ControlPrefs, FormDB<FD_preferences> > base_class;
117 FormPreferences::FormPreferences()
118 : base_class(_("Preferences"), scalableTabfolders),
119 colors_(*this), converters_(*this), inputs_misc_(*this),
120 formats_(*this), interface_(*this), language_(*this),
121 lnf_misc_(*this), identity_(*this), outputs_misc_(*this),
122 paths_(*this), printer_(*this), screen_fonts_(*this),
128 void FormPreferences::redraw()
130 if (!(form() && form()->visible))
132 fl_redraw_form(form());
134 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
135 if (!(form2 && form2->visible))
137 fl_redraw_form(form2);
140 if (form2 == converters_tab_->form)
141 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
143 else if (form2 == look_n_feel_tab_->form)
144 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
146 else if (form2 == inputs_tab_->form)
147 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
149 else if (form2 == outputs_tab_->form)
150 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
152 else if (form2 == lang_opts_tab_->form)
153 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
155 if (form3 && form3->visible)
156 fl_redraw_form(form3);
160 void FormPreferences::hide()
162 // We need to hide the active tabfolder otherwise we get a
163 // BadDrawable error from X window and LyX crashes without saving.
164 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
165 if (inner_form && inner_form->visible)
166 fl_hide_form(inner_form);
171 void FormPreferences::build()
173 dialog_.reset(build_preferences(this));
175 // Manage the restore, save, apply and cancel/close buttons
176 bcview().setOK(dialog_->button_ok);
177 bcview().setApply(dialog_->button_apply);
178 bcview().setCancel(dialog_->button_close);
179 bcview().setRestore(dialog_->button_restore);
181 // Allow the base class to control messages
182 setMessageWidget(dialog_->text_warning);
184 // build the tab folders
185 converters_tab_.reset(build_preferences_inner_tab(this));
186 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
187 inputs_tab_.reset(build_preferences_inner_tab(this));
188 outputs_tab_.reset(build_preferences_inner_tab(this));
189 lang_opts_tab_.reset(build_preferences_inner_tab(this));
191 // build actual tabfolder contents
192 // these will become nested tabfolders
196 inputs_misc_.build();
201 outputs_misc_.build();
204 screen_fonts_.build();
205 spelloptions_.build();
207 // Enable the tabfolders to be rescaled correctly.
208 if (scalableTabfolders) {
209 FL_OBJECT * folder = dialog_->tabfolder_prefs;
210 fl_set_tabfolder_autofit(folder, FL_FIT);
212 folder = look_n_feel_tab_->tabfolder_inner;
213 fl_set_tabfolder_autofit(folder, FL_FIT);
215 folder = converters_tab_->tabfolder_inner;
216 fl_set_tabfolder_autofit(folder, FL_FIT);
218 folder = inputs_tab_->tabfolder_inner;
219 fl_set_tabfolder_autofit(folder, FL_FIT);
221 folder = outputs_tab_->tabfolder_inner;
222 fl_set_tabfolder_autofit(folder, FL_FIT);
224 folder = lang_opts_tab_->tabfolder_inner;
225 fl_set_tabfolder_autofit(folder, FL_FIT);
229 // Now add them to the tabfolder
230 fl_addto_tabfolder(dialog_->tabfolder_prefs,
231 _("Look & Feel").c_str(),
232 look_n_feel_tab_->form);
233 fl_addto_tabfolder(dialog_->tabfolder_prefs,
234 _("Lang Opts").c_str(),
235 lang_opts_tab_->form);
236 fl_addto_tabfolder(dialog_->tabfolder_prefs,
237 _("Conversion").c_str(),
238 converters_tab_->form);
239 fl_addto_tabfolder(dialog_->tabfolder_prefs,
242 fl_addto_tabfolder(dialog_->tabfolder_prefs,
243 _("Outputs").c_str(),
246 // now build the nested tabfolders
247 // Starting with look and feel
248 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
249 _("Screen Fonts").c_str(),
250 screen_fonts_.dialog()->form);
251 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
252 _("Interface").c_str(),
253 interface_.dialog()->form);
254 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
256 colors_.dialog()->form);
257 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
259 lnf_misc_.dialog()->form);
260 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
261 _("Identity").c_str(),
262 identity_.dialog()->form);
264 // then build converters
265 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
266 _("Formats").c_str(),
267 formats_.dialog()->form);
268 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
269 _("Converters").c_str(),
270 converters_.dialog()->form);
273 // Paths should probably go in a few inner_tab called Files
274 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
276 paths_.dialog()->form);
277 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
279 inputs_misc_.dialog()->form);
281 // then building outputs
282 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
283 _("Printer").c_str(),
284 printer_.dialog()->form);
285 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
287 outputs_misc_.dialog()->form);
289 // then building usage
290 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
291 _("Spell checker").c_str(),
292 spelloptions_.dialog()->form);
293 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
294 _("Language").c_str(),
295 language_.dialog()->form);
299 void FormPreferences::apply()
301 // set the new lyxrc entries
302 // many of these need to trigger other functions when the assignment
303 // is made. For example, screen zoom and font types. These could be
304 // handled either by signals/slots in lyxrc or just directly call the
305 // associated functions here.
306 // There are other problems with this scheme. We really should check
307 // what we copy to make sure that it really is necessary to do things
308 // like update the screen fonts because that flushes the textcache
309 // and other stuff which may cost us a lot on slower/high-load
312 LyXRC & rc(controller().rc());
315 formats_.apply(); // Must be before converters_.apply()
317 inputs_misc_.apply(rc);
318 interface_.apply(rc);
322 outputs_misc_.apply(rc);
325 screen_fonts_.apply(rc);
326 spelloptions_.apply(rc);
328 // The "Save" button has been pressed.
329 if (controller().isClosing() && colors_.modifiedXformsPrefs) {
330 string const filename =
331 AddName(user_lyxdir, "preferences.xform");
332 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
337 string const FormPreferences::getFeedback(FL_OBJECT * ob)
341 if (ob->form->fdui == colors_.dialog())
342 return colors_.feedback(ob);
343 if (ob->form->fdui == converters_.dialog())
344 return converters_.feedback(ob);
345 if (ob->form->fdui == formats_.dialog())
346 return formats_.feedback(ob);
347 if (ob->form->fdui == inputs_misc_.dialog())
348 return inputs_misc_.feedback(ob);
349 if (ob->form->fdui == interface_.dialog())
350 return interface_.feedback(ob);
351 if (ob->form->fdui == language_.dialog())
352 return language_.feedback(ob);
353 if (ob->form->fdui == lnf_misc_.dialog())
354 return lnf_misc_.feedback(ob);
355 if (ob->form->fdui == outputs_misc_.dialog())
356 return outputs_misc_.feedback(ob);
357 if (ob->form->fdui == paths_.dialog())
358 return paths_.feedback(ob);
359 if (ob->form->fdui == printer_.dialog())
360 return printer_.feedback(ob);
361 if (ob->form->fdui == screen_fonts_.dialog())
362 return screen_fonts_.feedback(ob);
363 if (ob->form->fdui == spelloptions_.dialog())
364 return spelloptions_.feedback(ob);
370 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
376 // whatever checks you need to ensure the user hasn't entered
377 // some totally ridiculous value somewhere. Change activate to suit.
378 // comments before each test describe what is _valid_
380 if (ob->form->fdui == colors_.dialog()) {
382 } else if (ob->form->fdui == converters_.dialog()) {
383 valid = converters_.input(ob);
384 } else if (ob->form->fdui == formats_.dialog()) {
385 valid = formats_.input(ob);
386 } else if (ob->form->fdui == interface_.dialog()) {
387 valid = interface_.input(ob);
388 } else if (ob->form->fdui == language_.dialog()) {
389 valid = language_.input(ob);
390 } else if (ob->form->fdui == paths_.dialog()) {
391 valid = paths_.input(ob);
392 } else if (ob->form->fdui == screen_fonts_.dialog()) {
393 valid = screen_fonts_.input();
394 } else if (ob->form->fdui == spelloptions_.dialog()) {
395 valid = spelloptions_.input(ob);
398 return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
402 void FormPreferences::update()
404 if (!dialog_.get()) return;
406 LyXRC const & rc(controller().rc());
408 // read lyxrc entries
410 formats_.update(); // Must be before converters_.update()
411 converters_.update();
412 inputs_misc_.update(rc);
413 interface_.update(rc);
414 language_.update(rc);
415 lnf_misc_.update(rc);
416 identity_.update(rc);
417 outputs_misc_.update(rc);
420 screen_fonts_.update(rc);
421 spelloptions_.update(rc);
425 FormPreferences::Colors::Colors(FormPreferences & p)
426 : modifiedXformsPrefs(false), parent_(p)
430 FD_preferences_colors const * FormPreferences::Colors::dialog()
432 return dialog_.get();
436 void FormPreferences::Colors::apply()
438 bool modifiedText = false;
439 bool modifiedBackground = false;
441 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
442 cit != xformsColorDB.end(); ++cit) {
444 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
445 if (col != cit->color()) {
446 modifiedXformsPrefs = true;
447 if (cit->colorID == FL_BLACK)
449 if (cit->colorID == FL_COL1)
450 modifiedBackground = true;
454 if (modifiedXformsPrefs) {
455 for (vector<XformsColor>::const_iterator cit =
456 xformsColorDB.begin();
457 cit != xformsColorDB.end(); ++cit) {
458 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
460 if (modifiedText && cit->colorID == FL_BLACK) {
461 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
464 if (modifiedBackground && cit->colorID == FL_COL1) {
465 AdjustVal(FL_MCOL, FL_COL1, 0.1);
466 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
467 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
469 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
470 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
473 if (cit->colorID == GUI_COLOR_CURSOR) {
474 fl_mapcolor(GUI_COLOR_CURSOR,
475 cit->r, cit->g, cit->b);
476 setCursorColor(GUI_COLOR_CURSOR);
479 parent_.controller().redrawGUI();
482 // Now do the same for the LyX LColors...
483 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
484 cit != lyxColorDB.end(); ++cit) {
485 LColor::color lc = lcolor.getFromGUIName(cit->getname());
486 if (lc == LColor::inherit) continue;
488 // Create a valid X11 name of the form "#rrggbb"
489 string const hexname = X11hexname(cit->color());
491 if (lcolor.getX11Name(lc) != hexname) {
493 << "FormPreferences::Colors::apply: "
494 << "resetting LColor " << lcolor.getGUIName(lc)
495 << " from \"" << lcolor.getX11Name(lc)
496 << "\" to \"" << hexname << "\"."
499 parent_.controller().setColor(lc, hexname);
505 void FormPreferences::Colors::build()
507 dialog_.reset(build_preferences_colors(&parent_));
509 fl_set_object_color(dialog_->button_color,
510 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
512 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
513 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
514 fl_set_dial_step(dialog_->dial_hue, 1.0);
515 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
517 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
518 fl_set_slider_step(dialog_->slider_saturation, 0.01);
519 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
521 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
522 fl_set_slider_step(dialog_->slider_value, 0.01);
523 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
525 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
526 fl_set_slider_step(dialog_->slider_red, 1.0);
527 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
529 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
530 fl_set_slider_step(dialog_->slider_green, 1.0);
531 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
533 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
534 fl_set_slider_step(dialog_->slider_blue, 1.0);
535 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
537 // set up the feedback mechanism
538 setPrehandler(dialog_->browser_lyx_objs);
539 setPrehandler(dialog_->button_color);
540 setPrehandler(dialog_->button_modify);
541 setPrehandler(dialog_->dial_hue);
542 setPrehandler(dialog_->slider_saturation);
543 setPrehandler(dialog_->slider_value);
544 setPrehandler(dialog_->slider_red);
545 setPrehandler(dialog_->slider_green);
546 setPrehandler(dialog_->slider_blue);
547 setPrehandler(dialog_->radio_rgb);
548 setPrehandler(dialog_->radio_hsv);
553 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
555 if (ob == dialog_->browser_lyx_objs)
556 return _("LyX objects that can be assigned a color.");
558 if (ob == dialog_->button_modify)
559 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
561 if (ob == dialog_->dial_hue ||
562 ob == dialog_->slider_saturation ||
563 ob == dialog_->slider_value ||
564 ob == dialog_->slider_red ||
565 ob == dialog_->slider_green ||
566 ob == dialog_->slider_blue)
567 return _("Find a new color.");
569 if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
570 return _("Toggle between RGB and HSV color spaces.");
576 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
578 if (ob == dialog_->browser_lyx_objs) {
581 } else if (ob == dialog_->dial_hue ||
582 ob == dialog_->slider_saturation ||
583 ob == dialog_->slider_value) {
586 } else if (ob == dialog_->slider_red ||
587 ob == dialog_->slider_green ||
588 ob == dialog_->slider_blue) {
591 } else if (ob == dialog_->radio_rgb ||
592 ob == dialog_->radio_hsv) {
595 } else if (ob == dialog_->button_modify) {
601 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
605 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
609 hsv.v = min(1.0, max(0.0, hsv.v));
612 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
616 void FormPreferences::Colors::InputBrowserLyX() const
618 vector<NamedColor>::size_type const selLyX =
619 fl_get_browser(dialog_->browser_lyx_objs);
620 if (selLyX < 1) return;
622 // Is the choice an Xforms color...
625 if (selLyX - 1 < xformsColorDB.size()) {
626 vector<XformsColor>::size_type const i = selLyX - 1;
627 col = xformsColorDB[i].color();
629 // or a LyX Logical color?
631 vector<NamedColor>::size_type const i = selLyX - 1 -
632 xformsColorDB.size();
633 col = lyxColorDB[i].color();
636 fl_freeze_form(dialog_->form);
638 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
639 fl_redraw_object(dialog_->button_color);
641 // Display either RGB or HSV but not both!
644 // Deactivate the modify button to begin with...
645 setEnabled(dialog_->button_modify, false);
647 fl_unfreeze_form(dialog_->form);
651 void FormPreferences::Colors::InputHSV()
653 double const hue = fl_get_dial_value(dialog_->dial_hue);
654 double const sat = fl_get_slider_value(dialog_->slider_saturation);
655 double const val = fl_get_slider_value(dialog_->slider_value);
657 int const h = int(hue);
658 int const s = int(100.0 * sat);
659 int const v = int(100.0 * val);
661 string const label = tostr(h) + ", " + tostr(s) + ", " + tostr(v);
662 fl_set_object_label(dialog_->text_color_values, label.c_str());
664 RGBColor col = HSVColor(hue, sat, val);
666 fl_freeze_form(dialog_->form);
668 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
669 fl_redraw_object(dialog_->button_color);
671 col = HSVColor(hue, 1.0, 1.0);
672 col.r = max(col.r, 0u);
673 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
674 fl_redraw_object(dialog_->dial_hue);
676 // Ascertain whether to activate the Modify button.
677 vector<NamedColor>::size_type const selLyX =
678 fl_get_browser(dialog_->browser_lyx_objs);
680 fl_unfreeze_form(dialog_->form);
681 if (selLyX < 1) return;
683 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
686 // Is the choice an Xforms color...
687 if (selLyX - 1 < xformsColorDB.size()) {
688 vector<XformsColor>::size_type const i = selLyX - 1;
689 modify = (xformsColorDB[i].color() != col);
691 // or a LyX Logical color?
693 vector<NamedColor>::size_type const i = selLyX - 1 -
694 xformsColorDB.size();
695 modify = (lyxColorDB[i].color() != col);
698 setEnabled(dialog_->button_modify, modify);
702 void FormPreferences::Colors::InputRGB()
704 int const red = int(fl_get_slider_value(dialog_->slider_red));
705 int const green = int(fl_get_slider_value(dialog_->slider_green));
706 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
708 string const label = tostr(red) + string(", ") + tostr(green) +
709 string(", ") + tostr(blue);
710 fl_set_object_label(dialog_->text_color_values, label.c_str());
712 fl_freeze_form(dialog_->form);
714 RGBColor col = RGBColor(red, green, blue);
715 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
716 fl_redraw_object(dialog_->button_color);
718 // Ascertain whether to activate the Modify button.
719 vector<NamedColor>::size_type const selLyX =
720 fl_get_browser(dialog_->browser_lyx_objs);
722 fl_unfreeze_form(dialog_->form);
723 if (selLyX < 1) return;
727 // Is the choice an Xforms color...
728 if (selLyX - 1 < xformsColorDB.size()) {
729 vector<XformsColor>::size_type const i = selLyX - 1;
730 modify = (xformsColorDB[i].color() != col);
732 // or a LyX Logical color?
734 vector<NamedColor>::size_type const i = selLyX - 1 -
735 xformsColorDB.size();
736 modify = (lyxColorDB[i].color() != col);
739 setEnabled(dialog_->button_modify, modify);
743 void FormPreferences::Colors::LoadBrowserLyX()
745 if (!dialog_->browser_lyx_objs->visible)
748 // First, define the modifiable xforms colors
749 xformsColorDB.clear();
752 xcol.name = _("GUI background");
753 xcol.colorID = FL_COL1;
754 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
756 xformsColorDB.push_back(xcol);
758 xcol.name = _("GUI text");
759 xcol.colorID = FL_BLACK;
760 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
762 xformsColorDB.push_back(xcol);
764 xcol.name = _("GUI selection");
765 xcol.colorID = FL_YELLOW;
766 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
768 xformsColorDB.push_back(xcol);
770 xcol.name = _("GUI pointer");
771 xcol.colorID = GUI_COLOR_CURSOR;
772 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
774 xformsColorDB.push_back(xcol);
776 // Now create the the LyX LColors database
778 for (int i=0; i<LColor::ignore; ++i) {
779 LColor::color lc = static_cast<LColor::color>(i);
780 if (lc == LColor::none
781 || lc == LColor::black
782 || lc == LColor::white
784 || lc == LColor::green
785 || lc == LColor::blue
786 || lc == LColor::cyan
787 || lc == LColor::magenta
788 || lc == LColor::yellow
789 || lc == LColor::inherit
790 || lc == LColor::ignore) continue;
793 bool const success = getRGBColor(lc, col.r, col.g, col.b);
795 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
796 << "LColor " << lcolor.getLyXName(lc)
797 << ": X can't find color \""
798 << lcolor.getX11Name(lc)
799 << "\". Set to \"black\"!" << endl;
801 string const arg = lcolor.getLyXName(lc) + " black";
802 parent_.controller().setColor(lc, "black");
806 // Create a valid X11 name of the form "#rrggbb" and change the
807 // LColor X11name to this. Don't want to trigger a redraw,
808 // as we're just changing the name not the RGB values.
809 // Also reset the system_lcolor names, so that we don't output
810 // unnecessary changes.
811 string const hexname = X11hexname(col);
813 if (lcolor.getX11Name(lc) != hexname) {
814 lcolor.setColor(lc, hexname);
815 system_lcolor.setColor(lc, hexname);
818 // Finally, push the color onto the database
819 NamedColor ncol(lcolor.getGUIName(lc), col);
820 lyxColorDB.push_back(ncol);
823 // Now construct the browser
824 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
825 fl_freeze_form(dialog_->form);
826 fl_clear_browser(colbr);
827 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
828 cit != xformsColorDB.end(); ++cit) {
829 fl_addto_browser(colbr, cit->getname().c_str());
831 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
832 cit != lyxColorDB.end(); ++cit) {
833 fl_addto_browser(colbr, cit->getname().c_str());
836 // just to be safe...
837 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
838 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
839 fl_unfreeze_form(dialog_->form);
845 void FormPreferences::Colors::Modify()
847 vector<NamedColor>::size_type const selLyX =
848 fl_get_browser(dialog_->browser_lyx_objs);
853 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
855 // Is the choice an Xforms color...
856 if (selLyX - 1 < xformsColorDB.size()) {
857 vector<XformsColor>::size_type const i = selLyX - 1;
858 xformsColorDB[i].r = col.r;
859 xformsColorDB[i].g = col.g;
860 xformsColorDB[i].b = col.b;
862 // or a LyX Logical color?
864 vector<NamedColor>::size_type const i = selLyX - 1 -
865 xformsColorDB.size();
866 lyxColorDB[i].r = col.r;
867 lyxColorDB[i].g = col.g;
868 lyxColorDB[i].b = col.b;
871 fl_freeze_form(dialog_->form);
872 setEnabled(dialog_->button_modify, false);
873 fl_unfreeze_form(dialog_->form);
877 void FormPreferences::Colors::SwitchColorSpace() const
879 bool const hsv = fl_get_button(dialog_->radio_hsv);
882 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
884 fl_freeze_form(dialog_->form);
887 fl_hide_object(dialog_->slider_red);
888 fl_hide_object(dialog_->slider_blue);
889 fl_hide_object(dialog_->slider_green);
890 fl_show_object(dialog_->dial_hue);
891 fl_show_object(dialog_->slider_saturation);
892 fl_show_object(dialog_->slider_value);
894 HSVColor hsv = HSVColor(col);
895 hsv.h = max(hsv.h, 0.0);
897 fl_set_dial_value(dialog_->dial_hue, hsv.h);
898 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
899 fl_set_slider_value(dialog_->slider_value, hsv.v);
901 col = HSVColor(hsv.h, 1.0, 1.0);
902 col.r = max(col.r, 0u);
903 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
904 fl_redraw_object(dialog_->dial_hue);
906 // Adjust the label a bit, but not the actual values.
907 // Means that toggling from one space to the other has no
908 // effect on the final color.
909 int const h = int(hsv.h);
910 int const s = int(100 * hsv.s);
911 int const v = int(100 * hsv.v);
912 string const label = tostr(h) + ", " + tostr(s) +
914 fl_set_object_label(dialog_->text_color_values, label.c_str());
917 fl_show_object(dialog_->slider_red);
918 fl_show_object(dialog_->slider_blue);
919 fl_show_object(dialog_->slider_green);
920 fl_hide_object(dialog_->dial_hue);
921 fl_hide_object(dialog_->slider_saturation);
922 fl_hide_object(dialog_->slider_value);
924 fl_set_slider_value(dialog_->slider_red, col.r);
925 fl_set_slider_value(dialog_->slider_green, col.g);
926 fl_set_slider_value(dialog_->slider_blue, col.b);
928 // Adjust the label a bit. Same reasoning as above.
929 int const r = int(col.r);
930 int const g = int(col.g);
931 int const b = int(col.b);
932 string const label = tostr(r) + ", " + tostr(g) +
934 fl_set_object_label(dialog_->text_color_values, label.c_str());
937 fl_unfreeze_form(dialog_->form);
941 FormPreferences::Converters::Converters(FormPreferences & p)
946 FD_preferences_converters const * FormPreferences::Converters::dialog()
948 return dialog_.get();
952 void FormPreferences::Converters::apply() const
954 parent_.controller().setConverters(local_converters);
958 void FormPreferences::Converters::build()
960 dialog_.reset(build_preferences_converters(&parent_));
962 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
963 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
965 // set up the feedback mechanism
966 setPrehandler(dialog_->browser_all);
967 setPrehandler(dialog_->button_delete);
968 setPrehandler(dialog_->button_add);
969 setPrehandler(dialog_->input_converter);
970 setPrehandler(dialog_->choice_from);
971 setPrehandler(dialog_->choice_to);
972 setPrehandler(dialog_->input_flags);
977 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
979 if (ob == dialog_->browser_all)
980 return _("All explicitly defined converters for LyX");
982 if (ob == dialog_->choice_from)
983 return _("Convert \"from\" this format");
985 if (ob == dialog_->choice_to)
986 return _("Convert \"to\" this format");
988 if (ob == dialog_->input_converter)
989 return _("The conversion command. $$i is the input file name, "
990 "$$b is the file name without its extension and $$o is "
991 "the name of the output file. $$s can be used as path to "
992 "LyX's own collection of conversion scripts.");
994 if (ob == dialog_->input_flags)
995 return _("Extra information for the Converter class, whether and "
996 "how to parse the result, and various other things.");
998 if (ob == dialog_->button_delete)
999 return _("Remove the current converter from the list of available "
1000 "converters. Note: you must then \"Apply\" the change.");
1002 if (ob == dialog_->button_add) {
1003 if (string(ob->label) == _("Add"))
1004 return _("Add the current converter to the list of available "
1005 "converters. Note: you must then \"Apply\" the change.");
1007 return _("Modify the contents of the current converter. "
1008 "Note: you must then \"Apply\" the change.");
1015 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
1017 if (ob == dialog_->browser_all)
1020 if (ob == dialog_->choice_from
1021 || ob == dialog_->choice_to
1022 || ob == dialog_->input_converter
1023 || ob == dialog_->input_flags)
1026 if (ob == dialog_->button_add)
1029 if (ob == dialog_->button_delete)
1036 void FormPreferences::Converters::update()
1038 local_converters = converters;
1039 local_converters.update(local_formats);
1044 void FormPreferences::Converters::UpdateBrowser()
1046 local_converters.sort();
1048 fl_freeze_form(dialog_->form);
1049 fl_clear_browser(dialog_->browser_all);
1050 for (::Converters::const_iterator cit = local_converters.begin();
1051 cit != local_converters.end(); ++cit) {
1052 string const name = cit->From->prettyname() + " -> "
1053 + cit->To->prettyname();
1054 fl_addto_browser(dialog_->browser_all, name.c_str());
1057 fl_unfreeze_form(dialog_->form);
1061 bool FormPreferences::Converters::Add()
1063 string const from = GetFrom();
1064 string const to = GetTo();
1065 string const command = fl_get_input(dialog_->input_converter);
1066 string const flags = fl_get_input(dialog_->input_flags);
1068 Converter const * old = local_converters.getConverter(from, to);
1069 local_converters.add(from, to, command, flags);
1071 local_converters.updateLast(local_formats);
1074 setEnabled(dialog_->button_add, false);
1080 bool FormPreferences::Converters::Browser()
1082 int const i = fl_get_browser(dialog_->browser_all);
1083 if (i <= 0) return false;
1085 fl_freeze_form(dialog_->form);
1087 Converter const & c = local_converters.get(i - 1);
1088 int j = local_formats.getNumber(c.from);
1090 fl_set_choice(dialog_->choice_from, j + 1);
1092 j = local_formats.getNumber(c.to);
1094 fl_set_choice(dialog_->choice_to, j + 1);
1096 fl_set_input(dialog_->input_converter, c.command.c_str());
1097 fl_set_input(dialog_->input_flags, c.flags.c_str());
1099 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
1100 fl_set_button_shortcut(dialog_->button_add,
1101 scex(_("Modify|#M")).c_str(), 1);
1103 setEnabled(dialog_->button_add, false);
1104 setEnabled(dialog_->button_delete, true);
1106 fl_unfreeze_form(dialog_->form);
1111 bool FormPreferences::Converters::erase()
1113 string const from = GetFrom();
1114 string const to = GetTo();
1116 local_converters.erase(from, to);
1122 bool FormPreferences::Converters::Input()
1124 string const from = GetFrom();
1125 string const to = GetTo();
1126 int const sel = local_converters.getNumber(from, to);
1128 fl_freeze_form(dialog_->form);
1131 fl_set_object_label(dialog_->button_add,
1132 idex(_("Add|#A")).c_str());
1133 fl_set_button_shortcut(dialog_->button_add,
1134 scex(_("Add|#A")).c_str(), 1);
1136 fl_deselect_browser(dialog_->browser_all);
1137 setEnabled(dialog_->button_delete, false);
1140 fl_set_object_label(dialog_->button_add,
1141 idex(_("Modify|#M")).c_str());
1142 fl_set_button_shortcut(dialog_->button_add,
1143 scex(_("Modify|#M")).c_str(), 1);
1145 int top = max(sel-5, 0);
1146 fl_set_browser_topline(dialog_->browser_all, top);
1147 fl_select_browser_line(dialog_->browser_all, sel+1);
1148 setEnabled(dialog_->button_delete, true);
1151 string const command = rtrim(fl_get_input(dialog_->input_converter));
1152 bool const enable = !(command.empty() || from == to);
1153 setEnabled(dialog_->button_add, enable);
1155 fl_unfreeze_form(dialog_->form);
1160 string const FormPreferences::Converters::GetFrom() const
1162 ::Formats::FormatList::size_type const i =
1163 fl_get_choice(dialog_->choice_from);
1165 if (i > 0 && i <= local_formats.size())
1166 return local_formats.get(i - 1).name();
1168 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1173 string const FormPreferences::Converters::GetTo() const
1175 ::Formats::FormatList::size_type const i =
1176 fl_get_choice(dialog_->choice_to);
1178 if (i > 0 && i <= local_formats.size())
1179 return local_formats.get(i - 1).name();
1181 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1186 void FormPreferences::Converters::UpdateChoices() const
1189 for (::Formats::const_iterator cit = local_formats.begin();
1190 cit != local_formats.end(); ++cit) {
1191 if (!choice.empty())
1195 choice += cit->prettyname();
1199 fl_clear_choice(dialog_->choice_from);
1200 fl_addto_choice(dialog_->choice_from, choice.c_str());
1202 fl_clear_choice(dialog_->choice_to);
1203 fl_addto_choice(dialog_->choice_to, choice.c_str());
1207 FormPreferences::Formats::Formats(FormPreferences & p)
1212 FD_preferences_formats const * FormPreferences::Formats::dialog()
1214 return dialog_.get();
1218 void FormPreferences::Formats::apply() const
1220 parent_.controller().setFormats(local_formats);
1224 void FormPreferences::Formats::build()
1226 dialog_.reset(build_preferences_formats(&parent_));
1228 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1229 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1230 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1231 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1232 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1234 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1236 // set up the feedback mechanism
1237 setPrehandler(dialog_->browser_all);
1238 setPrehandler(dialog_->input_format);
1239 setPrehandler(dialog_->input_gui_name);
1240 setPrehandler(dialog_->button_delete);
1241 setPrehandler(dialog_->button_add);
1242 setPrehandler(dialog_->input_extension);
1243 setPrehandler(dialog_->input_viewer);
1244 setPrehandler(dialog_->input_shrtcut);
1249 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1251 if (ob == dialog_->browser_all)
1252 return _("All the currently defined formats known to LyX.");
1254 if (ob == dialog_->input_format)
1255 return _("The format identifier.");
1257 if (ob == dialog_->input_gui_name)
1258 return _("The format name as it will appear in the menus.");
1260 if (ob == dialog_->input_shrtcut)
1261 return _("The keyboard accelerator. Use a letter in the GUI name. "
1264 if (ob == dialog_->input_extension)
1265 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1267 if (ob == dialog_->input_viewer)
1268 return _("The command used to launch the viewer application.");
1270 if (ob == dialog_->button_delete)
1271 return _("Remove the current format from the list of available "
1272 "formats. Note: you must then \"Apply\" the change.");
1274 if (ob == dialog_->button_add) {
1275 if (string(ob->label) == _("Add"))
1276 return _("Add the current format to the list of available "
1277 "formats. Note: you must then \"Apply\" the change.");
1279 return _("Modify the contents of the current format. Note: "
1280 "you must then \"Apply\" the change.");
1287 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1289 if (ob == dialog_->browser_all)
1292 if (ob == dialog_->input_format
1293 || ob == dialog_->input_gui_name
1294 || ob == dialog_->input_shrtcut
1295 || ob == dialog_->input_extension
1296 || ob == dialog_->input_viewer)
1299 if (ob == dialog_->button_add)
1302 if (ob == dialog_->button_delete)
1309 void FormPreferences::Formats::update()
1311 local_formats = formats;
1316 void FormPreferences::Formats::UpdateBrowser()
1318 local_formats.sort();
1320 fl_freeze_form(dialog_->form);
1321 fl_deselect_browser(dialog_->browser_all);
1322 fl_clear_browser(dialog_->browser_all);
1323 for (::Formats::const_iterator cit = local_formats.begin();
1324 cit != local_formats.end(); ++cit)
1325 fl_addto_browser(dialog_->browser_all,
1326 cit->prettyname().c_str());
1329 fl_unfreeze_form(dialog_->form);
1331 // Mustn't forget to update the Formats available to the converters_
1332 parent_.converters_.UpdateChoices();
1333 local_converters.update(local_formats);
1337 bool FormPreferences::Formats::Add()
1339 string const name = fl_get_input(dialog_->input_format);
1340 string const prettyname = fl_get_input(dialog_->input_gui_name);
1341 string const extension = fl_get_input(dialog_->input_extension);
1342 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1343 string const viewer = fl_get_input(dialog_->input_viewer);
1345 Format const * old = local_formats.getFormat(name);
1346 string const old_prettyname = old ? old->prettyname() : string();
1347 local_formats.add(name, extension, prettyname, shortcut);
1348 local_formats.setViewer(name, viewer);
1349 if (!old || prettyname != old_prettyname) {
1352 parent_.converters_.UpdateBrowser();
1354 setEnabled(dialog_->button_add, false);
1360 bool FormPreferences::Formats::Browser()
1362 int const i = fl_get_browser(dialog_->browser_all);
1366 fl_freeze_form(dialog_->form);
1368 Format const & f = local_formats.get(i - 1);
1370 fl_set_input(dialog_->input_format, f.name().c_str());
1371 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1372 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1373 fl_set_input(dialog_->input_extension, f.extension().c_str());
1374 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1376 fl_set_object_label(dialog_->button_add,
1377 idex(_("Modify|#M")).c_str());
1378 fl_set_button_shortcut(dialog_->button_add,
1379 scex(_("Modify|#M")).c_str(), 1);
1381 setEnabled(dialog_->button_add, false);
1382 setEnabled(dialog_->button_delete, true);
1384 fl_unfreeze_form(dialog_->form);
1389 bool FormPreferences::Formats::erase()
1391 string const name = fl_get_input(dialog_->input_format);
1393 if (local_converters.formatIsUsed(name)) {
1394 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1395 "Remove the converter first."));
1396 setEnabled(dialog_->button_delete, false);
1400 local_formats.erase(name);
1406 bool FormPreferences::Formats::Input()
1408 string const name = fl_get_input(dialog_->input_format);
1409 int const sel = local_formats.getNumber(name);
1410 fl_freeze_form(dialog_->form);
1413 fl_set_object_label(dialog_->button_add,
1414 idex(_("Add|#A")).c_str());
1415 fl_set_button_shortcut(dialog_->button_add,
1416 scex(_("Add|#A")).c_str(), 1);
1418 fl_deselect_browser(dialog_->browser_all);
1419 setEnabled(dialog_->button_delete, false);
1422 fl_set_object_label(dialog_->button_add,
1423 idex(_("Modify|#M")).c_str());
1424 fl_set_button_shortcut(dialog_->button_add,
1425 scex(_("Modify|#M")).c_str(), 1);
1427 int const top = max(sel-5, 0);
1428 fl_set_browser_topline(dialog_->browser_all, top);
1429 fl_select_browser_line(dialog_->browser_all, sel+1);
1431 setEnabled(dialog_->button_add, true);
1432 setEnabled(dialog_->button_delete, true);
1435 string const prettyname = fl_get_input(dialog_->input_gui_name);
1436 bool const enable = !(name.empty() || prettyname.empty());
1437 setEnabled(dialog_->button_add, enable);
1439 fl_unfreeze_form(dialog_->form);
1444 FormPreferences::Identity::Identity(FormPreferences & p)
1449 FD_preferences_identity const * FormPreferences::Identity::dialog()
1451 return dialog_.get();
1455 void FormPreferences::Identity::apply(LyXRC & rc) const
1457 rc.user_name = fl_get_input(dialog_->input_user_name);
1458 rc.user_email = fl_get_input(dialog_->input_user_email);
1462 void FormPreferences::Identity::build()
1464 dialog_.reset(build_preferences_identity(&parent_));
1465 fl_set_input_return(dialog_->input_user_name, FL_RETURN_CHANGED);
1466 fl_set_input_return(dialog_->input_user_email, FL_RETURN_CHANGED);
1470 void FormPreferences::Identity::update(LyXRC const & rc)
1472 fl_set_input(dialog_->input_user_name, rc.user_name.c_str());
1473 fl_set_input(dialog_->input_user_email, rc.user_email.c_str());
1477 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1482 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1484 return dialog_.get();
1488 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1490 rc.date_insert_format =
1491 fl_get_input(dialog_->input_date_format);
1495 void FormPreferences::InputsMisc::build()
1497 dialog_.reset(build_preferences_inputs_misc(&parent_));
1499 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1501 // set up the feedback mechanism
1502 setPrehandler(dialog_->input_date_format);
1507 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1509 if (ob == dialog_->input_date_format)
1510 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1515 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1517 fl_set_input(dialog_->input_date_format,
1518 rc.date_insert_format.c_str());
1522 FormPreferences::Interface::Interface(FormPreferences & p)
1527 FD_preferences_interface const * FormPreferences::Interface::dialog()
1529 return dialog_.get();
1533 void FormPreferences::Interface::apply(LyXRC & rc) const
1535 rc.popup_normal_font =
1536 fl_get_input(dialog_->input_popup_normal_font);
1537 rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1538 rc.popup_font_encoding =
1539 fl_get_input(dialog_->input_popup_font_encoding);
1540 rc.bind_file = fl_get_input(dialog_->input_bind_file);
1541 rc.ui_file = fl_get_input(dialog_->input_ui_file);
1545 void FormPreferences::Interface::build()
1547 dialog_.reset(build_preferences_interface(&parent_));
1549 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1550 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1551 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1552 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1553 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1555 // set up the feedback mechanism
1556 setPrehandler(dialog_->input_popup_normal_font);
1557 setPrehandler(dialog_->input_popup_bold_font);
1558 setPrehandler(dialog_->input_popup_font_encoding);
1559 setPrehandler(dialog_->input_bind_file);
1560 setPrehandler(dialog_->button_bind_file_browse);
1561 setPrehandler(dialog_->input_ui_file);
1562 setPrehandler(dialog_->button_ui_file_browse);
1567 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1569 if (ob == dialog_->input_popup_normal_font)
1570 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1571 if (ob == dialog_->input_popup_bold_font)
1572 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1573 if (ob == dialog_->input_popup_font_encoding)
1574 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1575 if (ob == dialog_->input_bind_file)
1576 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1577 if (ob == dialog_->input_ui_file)
1578 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1583 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1585 if (ob == dialog_->button_bind_file_browse) {
1586 string f = parent_.controller().browsebind(
1587 fl_get_input(dialog_->input_bind_file));
1589 fl_set_input(dialog_->input_bind_file, f.c_str());
1590 } else if (ob == dialog_->button_ui_file_browse) {
1591 string f = parent_.controller().browseUI(
1592 fl_get_input(dialog_->input_ui_file));
1594 fl_set_input(dialog_->input_ui_file, f.c_str());
1601 void FormPreferences::Interface::update(LyXRC const & rc)
1603 fl_set_input(dialog_->input_popup_normal_font,
1604 rc.popup_normal_font.c_str());
1605 fl_set_input(dialog_->input_popup_bold_font,
1606 rc.popup_bold_font.c_str());
1607 fl_set_input(dialog_->input_popup_font_encoding,
1608 rc.popup_font_encoding.c_str());
1609 fl_set_input(dialog_->input_bind_file,
1610 rc.bind_file.c_str());
1611 fl_set_input(dialog_->input_ui_file,
1612 rc.ui_file.c_str());
1616 FormPreferences::Language::Language(FormPreferences & p)
1621 FD_preferences_language const * FormPreferences::Language::dialog()
1623 return dialog_.get();
1627 void FormPreferences::Language::apply(LyXRC & rc)
1629 int const pos = fl_get_combox(dialog_->combox_default_lang);
1630 rc.default_language = lang_[pos-1];
1632 int button = fl_get_button(dialog_->check_use_kbmap);
1633 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1634 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1636 button = !(name_1.empty() && name_2.empty());
1637 rc.use_kbmap = static_cast<bool>(button);
1640 rc.primary_kbmap = name_1;
1641 rc.secondary_kbmap = name_2;
1644 button = fl_get_button(dialog_->check_rtl_support);
1645 rc.rtl_support = static_cast<bool>(button);
1647 button = fl_get_button(dialog_->check_mark_foreign);
1648 rc.mark_foreign_language = static_cast<bool>(button);
1650 button = fl_get_button(dialog_->check_auto_begin);
1651 rc.language_auto_begin = static_cast<bool>(button);
1653 button = fl_get_button(dialog_->check_auto_end);
1654 rc.language_auto_end = static_cast<bool>(button);
1656 button = fl_get_button(dialog_->check_use_babel);
1657 rc.language_use_babel = static_cast<bool>(button);
1659 button = fl_get_button(dialog_->check_global_options);
1660 rc.language_global_options = static_cast<bool>(button);
1662 rc.language_package = fl_get_input(dialog_->input_package);
1663 rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1664 rc.language_command_end = fl_get_input(dialog_->input_command_end);
1666 // Ensure that all is self-consistent.
1671 void FormPreferences::Language::build()
1673 dialog_.reset(build_preferences_language(&parent_));
1675 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1676 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1677 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1679 // Store the lang identifiers for later
1680 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1681 lang_ = getSecond(langs);
1683 FL_OBJECT * obj = dialog_->combox_default_lang;
1684 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1685 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1686 for (; lit != lend; ++lit) {
1687 fl_addto_combox(obj, lit->first.c_str());
1689 fl_set_combox_browser_height(obj, 400);
1691 // set up the feedback mechanism
1692 setPrehandler(dialog_->input_package);
1693 setPrehandler(dialog_->check_use_kbmap);
1694 setPrehandler(dialog_->combox_default_lang);
1695 setPrehandler(dialog_->input_kbmap1);
1696 setPrehandler(dialog_->input_kbmap2);
1697 setPrehandler(dialog_->check_rtl_support);
1698 setPrehandler(dialog_->check_mark_foreign);
1699 setPrehandler(dialog_->check_auto_begin);
1700 setPrehandler(dialog_->check_auto_end);
1701 setPrehandler(dialog_->check_use_babel);
1702 setPrehandler(dialog_->check_global_options);
1703 setPrehandler(dialog_->input_command_begin);
1704 setPrehandler(dialog_->input_command_end);
1706 // Activate/Deactivate the input fields dependent on the state of the
1713 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1715 if (ob == dialog_->combox_default_lang)
1716 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1717 if (ob == dialog_->check_use_kbmap)
1718 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1719 if (ob == dialog_->input_kbmap1)
1720 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1721 if (ob == dialog_->input_kbmap2)
1722 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1723 if (ob == dialog_->check_rtl_support)
1724 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1725 if (ob == dialog_->check_mark_foreign)
1726 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1727 if (ob == dialog_->check_auto_begin)
1728 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1729 if (ob == dialog_->check_auto_end)
1730 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1731 if (ob == dialog_->check_use_babel)
1732 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1733 if (ob == dialog_->check_global_options)
1734 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1735 if (ob == dialog_->input_package)
1736 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1737 if (ob == dialog_->input_command_begin)
1738 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1739 if (ob == dialog_->input_command_end)
1740 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1745 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1747 bool activate = true;
1749 // !ob if function is called from Language::build() to de/activate
1751 // otherwise the function is called by an xforms CB via input().
1752 if (!ob || ob == dialog_->check_use_kbmap) {
1753 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1754 setEnabled(dialog_->button_kbmap1_browse, enable);
1755 setEnabled(dialog_->button_kbmap2_browse, enable);
1756 setEnabled(dialog_->input_kbmap1, enable);
1757 setEnabled(dialog_->input_kbmap2, enable);
1760 if (ob == dialog_->button_kbmap1_browse) {
1761 string f = parent_.controller().browsekbmap(
1762 fl_get_input(dialog_->input_kbmap1));
1764 fl_set_input(dialog_->input_kbmap1, f.c_str());
1765 } else if (ob == dialog_->button_kbmap2_browse) {
1766 string f = parent_.controller().browsekbmap(
1767 fl_get_input(dialog_->input_kbmap2));
1769 fl_set_input(dialog_->input_kbmap2, f.c_str());
1776 void FormPreferences::Language::update(LyXRC const & rc)
1778 fl_set_button(dialog_->check_use_kbmap,
1781 int const pos = int(findPos(lang_, rc.default_language));
1782 fl_set_combox(dialog_->combox_default_lang, pos + 1);
1785 fl_set_input(dialog_->input_kbmap1,
1786 rc.primary_kbmap.c_str());
1787 fl_set_input(dialog_->input_kbmap2,
1788 rc.secondary_kbmap.c_str());
1790 fl_set_input(dialog_->input_kbmap1, "");
1791 fl_set_input(dialog_->input_kbmap2, "");
1794 fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1795 fl_set_button(dialog_->check_mark_foreign,
1796 rc.mark_foreign_language);
1797 fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1798 fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1799 fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1800 fl_set_button(dialog_->check_global_options,
1801 rc.language_global_options);
1803 fl_set_input(dialog_->input_package,
1804 rc.language_package.c_str());
1805 fl_set_input(dialog_->input_command_begin,
1806 rc.language_command_begin.c_str());
1807 fl_set_input(dialog_->input_command_end,
1808 rc.language_command_end.c_str());
1810 // Activate/Deactivate the input fields dependent on the state of the
1816 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1821 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1823 return dialog_.get();
1827 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1829 rc.auto_region_delete =
1830 fl_get_button(dialog_->check_auto_region_delete);
1831 rc.cursor_follows_scrollbar =
1832 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1833 rc.dialogs_iconify_with_main =
1834 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1835 rc.preview = fl_get_button(dialog_->check_preview_latex);
1836 rc.autosave = static_cast<unsigned int>
1837 (fl_get_counter_value(dialog_->counter_autosave));
1838 rc.wheel_jump = static_cast<unsigned int>
1839 (fl_get_counter_value(dialog_->counter_wm_jump));
1842 // grfx::DisplayType old_value = rc.display_graphics;
1843 switch (fl_get_choice(dialog_->choice_display)) {
1845 rc.display_graphics = grfx::NoDisplay;
1848 rc.display_graphics = grfx::ColorDisplay;
1851 rc.display_graphics = grfx::GrayscaleDisplay;
1854 rc.display_graphics = grfx::MonochromeDisplay;
1857 rc.display_graphics = grfx::ColorDisplay;
1861 #ifdef WITH_WARNINGS
1862 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1865 if (old_value != rc.display_graphics) {
1866 grfx::GCache & gc = grfx::GCache::get();
1873 void FormPreferences::LnFmisc::build()
1875 dialog_.reset(build_preferences_lnf_misc(&parent_));
1877 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1878 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1880 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1881 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1883 // set up the feedback mechanism
1884 setPrehandler(dialog_->check_auto_region_delete);
1885 setPrehandler(dialog_->counter_autosave);
1886 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1887 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1888 setPrehandler(dialog_->check_preview_latex);
1889 setPrehandler(dialog_->counter_wm_jump);
1891 fl_addto_choice(dialog_->choice_display,
1892 _("Monochrome|Grayscale|Color|Do not display").c_str());
1897 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1899 if (ob == dialog_->check_auto_region_delete)
1900 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
1901 if (ob == dialog_->check_cursor_follows_scrollbar)
1902 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1903 if (ob == dialog_->check_dialogs_iconify_with_main)
1904 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1905 if (ob == dialog_->check_preview_latex)
1906 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
1907 if (ob == dialog_->counter_autosave)
1908 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
1909 if (ob == dialog_->counter_wm_jump)
1910 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
1911 if (ob == dialog_->choice_display)
1912 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1917 void FormPreferences::LnFmisc::update(LyXRC const & rc)
1919 fl_set_button(dialog_->check_auto_region_delete,
1920 rc.auto_region_delete);
1921 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1922 rc.cursor_follows_scrollbar);
1923 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1924 rc.dialogs_iconify_with_main);
1925 fl_set_button(dialog_->check_preview_latex,
1927 fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
1928 fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
1930 switch (rc.display_graphics) {
1931 case grfx::NoDisplay:
1932 fl_set_choice(dialog_->choice_display, 4);
1934 case grfx::ColorDisplay:
1935 fl_set_choice(dialog_->choice_display, 3);
1937 case grfx::GrayscaleDisplay:
1938 fl_set_choice(dialog_->choice_display, 2);
1940 case grfx::MonochromeDisplay:
1941 fl_set_choice(dialog_->choice_display, 1);
1944 fl_set_choice(dialog_->choice_display, 3);
1950 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1955 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1957 return dialog_.get();
1961 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
1963 rc.ascii_linelen = static_cast<unsigned int>
1964 (fl_get_counter_value(dialog_->counter_line_len));
1965 rc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1968 fl_get_choice(dialog_->choice_default_papersize) - 1;
1969 rc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1971 rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1972 rc.chktex_command = fl_get_input(dialog_->input_checktex);
1973 rc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1974 rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1978 void FormPreferences::OutputsMisc::build()
1980 dialog_.reset(build_preferences_outputs_misc(&parent_));
1982 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1984 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1985 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1986 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1987 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1988 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1990 fl_addto_choice(dialog_->choice_default_papersize,
1991 _(" default | US letter | US legal "
1992 "| US executive | A3 | A4 | A5 | B5 ").c_str());
1994 // set up the feedback mechanism
1995 setPrehandler(dialog_->counter_line_len);
1996 setPrehandler(dialog_->input_tex_encoding);
1997 setPrehandler(dialog_->choice_default_papersize);
1998 setPrehandler(dialog_->input_ascii_roff);
1999 setPrehandler(dialog_->input_checktex);
2000 setPrehandler(dialog_->input_paperoption);
2001 setPrehandler(dialog_->check_autoreset_classopt);
2006 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
2008 if (ob == dialog_->counter_line_len)
2009 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
2010 if (ob == dialog_->input_tex_encoding)
2011 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
2012 if (ob == dialog_->input_ascii_roff)
2013 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
2014 if (ob == dialog_->input_checktex)
2015 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
2016 if (ob == dialog_->choice_default_papersize)
2017 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2018 if (ob == dialog_->input_paperoption)
2019 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
2020 if (ob == dialog_->check_autoreset_classopt)
2021 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2026 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
2028 fl_set_counter_value(dialog_->counter_line_len,
2030 fl_set_input(dialog_->input_tex_encoding,
2031 rc.fontenc.c_str());
2032 fl_set_choice(dialog_->choice_default_papersize,
2033 rc.default_papersize + 1);
2034 fl_set_input(dialog_->input_ascii_roff,
2035 rc.ascii_roff_command.c_str());
2036 fl_set_input(dialog_->input_checktex,
2037 rc.chktex_command.c_str());
2038 fl_set_input(dialog_->input_paperoption,
2039 rc.view_dvi_paper_option.c_str());
2040 fl_set_button(dialog_->check_autoreset_classopt,
2041 rc.auto_reset_options);
2046 FormPreferences::Paths::Paths(FormPreferences & p)
2051 FD_preferences_paths const * FormPreferences::Paths::dialog()
2053 return dialog_.get();
2057 void FormPreferences::Paths::apply(LyXRC & rc)
2059 rc.document_path = fl_get_input(dialog_->input_default_path);
2060 rc.template_path = fl_get_input(dialog_->input_template_path);
2062 int button = fl_get_button(dialog_->check_use_temp_dir);
2063 string str = fl_get_input(dialog_->input_temp_dir);
2067 rc.use_tempdir = button;
2068 rc.tempdir_path = str;
2070 button = fl_get_button(dialog_->check_last_files);
2071 str = fl_get_input(dialog_->input_lastfiles);
2072 if (!button) str.erase();
2074 rc.check_lastfiles = button;
2076 rc.num_lastfiles = static_cast<unsigned int>
2077 (fl_get_counter_value(dialog_->counter_lastfiles));
2079 button = fl_get_button(dialog_->check_make_backups);
2080 str = fl_get_input(dialog_->input_backup_path);
2084 rc.make_backup = button;
2085 rc.backupdir_path = str;
2087 rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2094 void FormPreferences::Paths::build()
2096 dialog_.reset(build_preferences_paths(&parent_));
2098 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2099 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2100 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2101 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2102 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2103 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2104 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2106 // set up the feedback mechanism
2107 setPrehandler(dialog_->input_default_path);
2108 setPrehandler(dialog_->counter_lastfiles);
2109 setPrehandler(dialog_->input_template_path);
2110 setPrehandler(dialog_->check_last_files);
2111 setPrehandler(dialog_->input_lastfiles);
2112 setPrehandler(dialog_->check_make_backups);
2113 setPrehandler(dialog_->input_backup_path);
2114 setPrehandler(dialog_->input_serverpipe);
2115 setPrehandler(dialog_->input_temp_dir);
2116 setPrehandler(dialog_->check_use_temp_dir);
2121 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2123 if (ob == dialog_->input_default_path)
2124 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2125 if (ob == dialog_->input_template_path)
2126 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2127 if (ob == dialog_->check_use_temp_dir)
2128 return LyXRC::getDescription(LyXRC::RC_USETEMPDIR);
2129 if (ob == dialog_->input_temp_dir)
2130 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2131 if (ob == dialog_->check_last_files)
2132 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2133 if (ob == dialog_->input_lastfiles)
2134 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
2135 if (ob == dialog_->counter_lastfiles)
2136 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2137 if (ob == dialog_->check_make_backups)
2138 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2139 if (ob == dialog_->input_backup_path)
2140 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2141 if (ob == dialog_->input_serverpipe)
2142 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2147 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2149 bool activate = true;
2151 // !ob if function is called from Paths::update() to de/activate
2153 // otherwise the function is called by an xforms CB via input().
2154 if (!ob || ob == dialog_->check_use_temp_dir) {
2155 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2156 setEnabled(dialog_->input_temp_dir, enable);
2159 if (!ob || ob == dialog_->check_last_files) {
2160 bool const enable = fl_get_button(dialog_->check_last_files);
2161 setEnabled(dialog_->input_lastfiles, enable);
2164 if (!ob || ob == dialog_->check_make_backups) {
2165 bool const enable = fl_get_button(dialog_->check_make_backups);
2166 setEnabled(dialog_->input_backup_path, enable);
2169 if (!ob || ob == dialog_->input_default_path) {
2170 string const name = fl_get_input(dialog_->input_default_path);
2171 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2172 parent_.postWarning(RWInfo::ErrorMessage());
2177 if (!ob || ob == dialog_->input_template_path) {
2178 string const name = fl_get_input(dialog_->input_template_path);
2179 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2180 parent_.postWarning(RWInfo::ErrorMessage());
2185 if (!ob || ob == dialog_->input_temp_dir) {
2186 string const name = fl_get_input(dialog_->input_temp_dir);
2187 if (fl_get_button(dialog_->check_make_backups)
2189 && !RWInfo::WriteableDir(name)) {
2190 parent_.postWarning(RWInfo::ErrorMessage());
2195 if (!ob || ob == dialog_->input_backup_path) {
2196 string const name = fl_get_input(dialog_->input_backup_path);
2197 if (fl_get_button(dialog_->check_make_backups)
2199 && !RWInfo::WriteableDir(name)) {
2200 parent_.postWarning(RWInfo::ErrorMessage());
2205 if (!ob || ob == dialog_->input_lastfiles) {
2206 string const name = fl_get_input(dialog_->input_lastfiles);
2207 if (fl_get_button(dialog_->check_last_files)
2209 && !RWInfo::WriteableFile(name)) {
2210 parent_.postWarning(RWInfo::ErrorMessage());
2215 if (!ob || ob == dialog_->input_serverpipe) {
2216 string const name = fl_get_input(dialog_->input_serverpipe);
2217 if (!name.empty()) {
2218 // strip off the extension
2219 string const str = ChangeExtension(name, "");
2220 if (!RWInfo::WriteableFile(str + ".in")) {
2221 parent_.postWarning(RWInfo::ErrorMessage());
2224 if (!RWInfo::WriteableFile(str + ".out")) {
2225 parent_.postWarning(RWInfo::ErrorMessage());
2231 if (ob == dialog_->button_default_path_browse) {
2232 string f = parent_.controller().browsedir(
2233 fl_get_input(dialog_->input_default_path), _("Default path"));
2235 fl_set_input(dialog_->input_default_path, f.c_str());
2236 } else if (ob == dialog_->button_template_path_browse) {
2237 string f = parent_.controller().browsedir(
2238 fl_get_input(dialog_->input_template_path), _("Template path"));
2240 fl_set_input(dialog_->input_template_path, f.c_str());
2241 } else if (ob == dialog_->button_temp_dir_browse) {
2242 string f = parent_.controller().browsedir(
2243 fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2245 fl_set_input(dialog_->input_temp_dir, f.c_str());
2246 } else if (ob == dialog_->button_lastfiles_browse) {
2247 string f = parent_.controller().browse(
2248 fl_get_input(dialog_->input_lastfiles), _("Last files"));
2250 fl_set_input(dialog_->input_lastfiles, f.c_str());
2251 } else if (ob == dialog_->button_backup_path_browse) {
2252 string f = parent_.controller().browsedir(
2253 fl_get_input(dialog_->input_backup_path), _("Backup path"));
2255 fl_set_input(dialog_->input_backup_path, f.c_str());
2256 } else if (ob == dialog_->button_serverpipe_browse) {
2257 string f = parent_.controller().browse(
2258 fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2260 fl_set_input(dialog_->input_serverpipe, f.c_str());
2267 void FormPreferences::Paths::update(LyXRC const & rc)
2269 fl_set_input(dialog_->input_default_path,
2270 rc.document_path.c_str());
2271 fl_set_input(dialog_->input_template_path,
2272 rc.template_path.c_str());
2276 str = rc.backupdir_path;
2278 fl_set_button(dialog_->check_make_backups,
2280 fl_set_input(dialog_->input_backup_path, str.c_str());
2284 str = rc.tempdir_path;
2286 fl_set_button(dialog_->check_use_temp_dir,
2288 fl_set_input(dialog_->input_temp_dir, str.c_str());
2291 if (rc.check_lastfiles)
2294 fl_set_button(dialog_->check_last_files,
2295 rc.check_lastfiles);
2296 fl_set_input(dialog_->input_lastfiles, str.c_str());
2297 fl_set_counter_value(dialog_->counter_lastfiles,
2300 fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2302 // Activate/Deactivate the input fields dependent on the state of the
2308 FormPreferences::Printer::Printer(FormPreferences & p)
2313 FD_preferences_printer const * FormPreferences::Printer::dialog()
2315 return dialog_.get();
2319 void FormPreferences::Printer::apply(LyXRC & rc) const
2321 rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2322 rc.print_command = fl_get_input(dialog_->input_command);
2323 rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2324 rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2325 rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2326 rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2327 rc.print_file_extension =
2328 fl_get_input(dialog_->input_file_extension);
2329 rc.print_spool_command =
2330 fl_get_input(dialog_->input_spool_command);
2331 rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2332 rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2333 rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2334 rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2335 rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2336 rc.print_to_file = fl_get_input(dialog_->input_to_file);
2337 rc.print_extra_options =
2338 fl_get_input(dialog_->input_extra_options);
2339 rc.print_spool_printerprefix =
2340 fl_get_input(dialog_->input_spool_prefix);
2341 rc.print_paper_dimension_flag =
2342 fl_get_input(dialog_->input_paper_size);
2343 rc.printer = fl_get_input(dialog_->input_name);
2348 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2350 if (ob == dialog_->input_command)
2351 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2352 if (ob == dialog_->check_adapt_output)
2353 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2354 if (ob == dialog_->input_to_printer)
2355 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2356 if (ob == dialog_->input_to_file)
2357 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2358 if (ob == dialog_->input_file_extension)
2359 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2360 if (ob == dialog_->input_extra_options)
2361 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2362 if (ob == dialog_->input_spool_command)
2363 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2364 if (ob == dialog_->input_spool_prefix)
2365 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2366 if (ob == dialog_->input_name)
2367 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2368 if (ob == dialog_->input_even_pages)
2369 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2370 if (ob == dialog_->input_odd_pages)
2371 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2372 if (ob == dialog_->input_page_range)
2373 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2374 if (ob == dialog_->input_reverse)
2375 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2376 if (ob == dialog_->input_landscape)
2377 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2378 if (ob == dialog_->input_copies)
2379 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2380 if (ob == dialog_->input_collated)
2381 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2382 if (ob == dialog_->input_paper_type)
2383 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2384 if (ob == dialog_->input_paper_size)
2385 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2390 void FormPreferences::Printer::build()
2392 dialog_.reset(build_preferences_printer(&parent_));
2394 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2395 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2396 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2397 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2398 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2399 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2400 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2401 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2402 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2403 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2404 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2405 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2406 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2407 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2408 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2409 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2410 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2412 // set up the feedback mechanism
2413 setPrehandler(dialog_->input_command);
2414 setPrehandler(dialog_->input_page_range);
2415 setPrehandler(dialog_->input_copies);
2416 setPrehandler(dialog_->input_reverse);
2417 setPrehandler(dialog_->input_to_printer);
2418 setPrehandler(dialog_->input_file_extension);
2419 setPrehandler(dialog_->input_spool_command);
2420 setPrehandler(dialog_->input_paper_type);
2421 setPrehandler(dialog_->input_even_pages);
2422 setPrehandler(dialog_->input_odd_pages);
2423 setPrehandler(dialog_->input_collated);
2424 setPrehandler(dialog_->input_landscape);
2425 setPrehandler(dialog_->input_to_file);
2426 setPrehandler(dialog_->input_extra_options);
2427 setPrehandler(dialog_->input_spool_prefix);
2428 setPrehandler(dialog_->input_paper_size);
2429 setPrehandler(dialog_->input_name);
2430 setPrehandler(dialog_->check_adapt_output);
2434 void FormPreferences::Printer::update(LyXRC const & rc)
2436 fl_set_button(dialog_->check_adapt_output,
2437 rc.print_adapt_output);
2438 fl_set_input(dialog_->input_command,
2439 rc.print_command.c_str());
2440 fl_set_input(dialog_->input_page_range,
2441 rc.print_pagerange_flag.c_str());
2442 fl_set_input(dialog_->input_copies,
2443 rc.print_copies_flag.c_str());
2444 fl_set_input(dialog_->input_reverse,
2445 rc.print_reverse_flag.c_str());
2446 fl_set_input(dialog_->input_to_printer,
2447 rc.print_to_printer.c_str());
2448 fl_set_input(dialog_->input_file_extension,
2449 rc.print_file_extension.c_str());
2450 fl_set_input(dialog_->input_spool_command,
2451 rc.print_spool_command.c_str());
2452 fl_set_input(dialog_->input_paper_type,
2453 rc.print_paper_flag.c_str());
2454 fl_set_input(dialog_->input_even_pages,
2455 rc.print_evenpage_flag.c_str());
2456 fl_set_input(dialog_->input_odd_pages,
2457 rc.print_oddpage_flag.c_str());
2458 fl_set_input(dialog_->input_collated,
2459 rc.print_collcopies_flag.c_str());
2460 fl_set_input(dialog_->input_landscape,
2461 rc.print_landscape_flag.c_str());
2462 fl_set_input(dialog_->input_to_file,
2463 rc.print_to_file.c_str());
2464 fl_set_input(dialog_->input_extra_options,
2465 rc.print_extra_options.c_str());
2466 fl_set_input(dialog_->input_spool_prefix,
2467 rc.print_spool_printerprefix.c_str());
2468 fl_set_input(dialog_->input_paper_size,
2469 rc.print_paper_dimension_flag.c_str());
2470 fl_set_input(dialog_->input_name,
2471 rc.printer.c_str());
2475 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2480 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2482 return dialog_.get();
2486 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2488 bool changed = false;
2490 pair<string, string> tmp =
2491 parseFontName(fl_get_input(dialog_->input_roman));
2492 if (rc.roman_font_name != tmp.first ||
2493 rc.roman_font_foundry != tmp.second) {
2495 rc.roman_font_name = tmp.first;
2496 rc.roman_font_foundry = tmp.second;
2499 tmp = parseFontName(fl_get_input(dialog_->input_sans));
2500 if (rc.sans_font_name != tmp.first ||
2501 rc.sans_font_foundry != tmp.second) {
2503 rc.sans_font_name = tmp.first;
2504 rc.sans_font_foundry = tmp.second;
2507 tmp = parseFontName(fl_get_input(dialog_->input_typewriter));
2508 if (rc.typewriter_font_name != tmp.first ||
2509 rc.typewriter_font_foundry != tmp.second) {
2511 rc.typewriter_font_name = tmp.first;
2512 rc.typewriter_font_foundry = tmp.second;
2515 string str = fl_get_input(dialog_->input_screen_encoding);
2516 if (rc.font_norm != str) {
2519 rc.set_font_norm_type();
2522 bool button = fl_get_button(dialog_->check_scalable);
2523 if (rc.use_scalable_fonts != button) {
2525 rc.use_scalable_fonts = button;
2528 unsigned int ivalue = static_cast<unsigned int>
2529 (fl_get_counter_value(dialog_->counter_zoom));
2530 if (rc.zoom != ivalue) {
2535 ivalue = static_cast<unsigned int>
2536 (fl_get_counter_value(dialog_->counter_dpi));
2537 if (rc.dpi != ivalue) {
2542 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2543 if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2545 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2548 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2549 if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2551 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2554 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2555 if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2557 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2560 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2561 if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2563 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2566 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2567 if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2569 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2572 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2573 if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2575 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2578 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2579 if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2581 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2584 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2585 if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2587 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2590 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2591 if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2593 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2596 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2597 if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2599 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2603 // Now update the buffers
2604 // Can anything below here affect the redraw process?
2605 parent_.controller().updateScreenFonts();
2610 void FormPreferences::ScreenFonts::build()
2612 dialog_.reset(build_preferences_screen_fonts(&parent_));
2614 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2615 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2617 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2618 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2619 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2620 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2621 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2622 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2623 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2624 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2625 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2626 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2627 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2628 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2629 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2630 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2631 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2632 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2634 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2635 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2636 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2637 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2638 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2639 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2640 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2641 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2642 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2643 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2645 // set up the feedback mechanism
2646 setPrehandler(dialog_->input_roman);
2647 setPrehandler(dialog_->input_sans);
2648 setPrehandler(dialog_->input_typewriter);
2649 setPrehandler(dialog_->counter_zoom);
2650 setPrehandler(dialog_->counter_dpi);
2651 setPrehandler(dialog_->check_scalable);
2652 setPrehandler(dialog_->input_screen_encoding);
2653 setPrehandler(dialog_->input_tiny);
2654 setPrehandler(dialog_->input_script);
2655 setPrehandler(dialog_->input_footnote);
2656 setPrehandler(dialog_->input_small);
2657 setPrehandler(dialog_->input_large);
2658 setPrehandler(dialog_->input_larger);
2659 setPrehandler(dialog_->input_largest);
2660 setPrehandler(dialog_->input_normal);
2661 setPrehandler(dialog_->input_huge);
2662 setPrehandler(dialog_->input_huger);
2667 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2669 if (ob == dialog_->input_roman)
2670 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2671 if (ob == dialog_->input_sans)
2672 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2673 if (ob == dialog_->input_typewriter)
2674 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2675 if (ob == dialog_->check_scalable)
2676 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2677 if (ob == dialog_->input_screen_encoding)
2678 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2679 if (ob == dialog_->counter_zoom)
2680 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2681 if (ob == dialog_->counter_dpi)
2682 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2683 if (ob == dialog_->input_tiny
2684 || ob == dialog_->input_script
2685 || ob == dialog_->input_footnote
2686 || ob == dialog_->input_small
2687 || ob == dialog_->input_large
2688 || ob == dialog_->input_larger
2689 || ob == dialog_->input_larger
2690 || ob == dialog_->input_largest
2691 || ob == dialog_->input_normal
2692 || ob == dialog_->input_huge
2693 || ob == dialog_->input_huger)
2694 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2699 bool FormPreferences::ScreenFonts::input()
2701 bool activate = true;
2704 // Make sure that all fonts all have positive entries
2705 // Also note that an empty entry is returned as 0.0 by strToDbl
2706 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2707 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2708 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2709 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2710 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2711 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2712 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2713 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2714 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2715 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2717 str = _("Fonts must be positive!");
2719 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2720 // Fontsizes -- tiny < script < footnote etc.
2721 strToDbl(fl_get_input(dialog_->input_script)) ||
2722 strToDbl(fl_get_input(dialog_->input_script)) >
2723 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2724 strToDbl(fl_get_input(dialog_->input_footnote)) >
2725 strToDbl(fl_get_input(dialog_->input_small)) ||
2726 strToDbl(fl_get_input(dialog_->input_small)) >
2727 strToDbl(fl_get_input(dialog_->input_normal)) ||
2728 strToDbl(fl_get_input(dialog_->input_normal)) >
2729 strToDbl(fl_get_input(dialog_->input_large)) ||
2730 strToDbl(fl_get_input(dialog_->input_large)) >
2731 strToDbl(fl_get_input(dialog_->input_larger)) ||
2732 strToDbl(fl_get_input(dialog_->input_larger)) >
2733 strToDbl(fl_get_input(dialog_->input_largest)) ||
2734 strToDbl(fl_get_input(dialog_->input_largest)) >
2735 strToDbl(fl_get_input(dialog_->input_huge)) ||
2736 strToDbl(fl_get_input(dialog_->input_huge)) >
2737 strToDbl(fl_get_input(dialog_->input_huger))) {
2740 str = _("Fonts must be input in the order Tiny > Smallest > Smaller > Small > Normal > Large > Larger > Largest > Huge > Huger.");
2744 parent_.postWarning(str);
2750 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2752 fl_set_input(dialog_->input_roman,
2753 makeFontName(rc.roman_font_name,
2754 rc.roman_font_foundry).c_str());
2755 fl_set_input(dialog_->input_sans,
2756 makeFontName(rc.sans_font_name,
2757 rc.sans_font_foundry).c_str());
2758 fl_set_input(dialog_->input_typewriter,
2759 makeFontName(rc.typewriter_font_name,
2760 rc.typewriter_font_foundry).c_str());
2761 fl_set_input(dialog_->input_screen_encoding,
2762 rc.font_norm.c_str());
2763 fl_set_button(dialog_->check_scalable,
2764 rc.use_scalable_fonts);
2765 fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2766 fl_set_counter_value(dialog_->counter_dpi, rc.dpi);
2767 fl_set_input(dialog_->input_tiny,
2768 tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2769 fl_set_input(dialog_->input_script,
2770 tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2771 fl_set_input(dialog_->input_footnote,
2772 tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2773 fl_set_input(dialog_->input_small,
2774 tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2775 fl_set_input(dialog_->input_normal,
2776 tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2777 fl_set_input(dialog_->input_large,
2778 tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2779 fl_set_input(dialog_->input_larger,
2780 tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2781 fl_set_input(dialog_->input_largest,
2782 tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2783 fl_set_input(dialog_->input_huge,
2784 tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2785 fl_set_input(dialog_->input_huger,
2786 tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2791 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2796 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2798 return dialog_.get();
2802 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2804 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2805 choice = trim(choice);
2807 rc.isp_command = choice;
2810 // If spell checker == "none", all other input set to off.
2811 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2812 rc.isp_use_alt_lang = false;
2813 rc.isp_alt_lang.erase();
2815 rc.isp_use_esc_chars = false;
2816 rc.isp_esc_chars.erase();
2818 rc.isp_use_pers_dict = false;
2819 rc.isp_pers_dict.erase();
2821 rc.isp_accept_compound = false;
2822 rc.isp_use_input_encoding = false;
2825 int button = fl_get_button(dialog_->check_alt_lang);
2826 choice = fl_get_input(dialog_->input_alt_lang);
2827 if (button && choice.empty()) button = 0;
2828 if (!button) choice.erase();
2830 rc.isp_use_alt_lang = static_cast<bool>(button);
2831 rc.isp_alt_lang = choice;
2833 button = fl_get_button(dialog_->check_escape_chars);
2834 choice = fl_get_input(dialog_->input_escape_chars);
2835 if (button && choice.empty()) button = 0;
2836 if (!button) choice.erase();
2838 rc.isp_use_esc_chars = static_cast<bool>(button);
2839 rc.isp_esc_chars = choice;
2841 button = fl_get_button(dialog_->check_personal_dict);
2842 choice = fl_get_input(dialog_->input_personal_dict);
2843 if (button && choice.empty()) button = 0;
2844 if (!button) choice.erase();
2846 rc.isp_use_pers_dict = static_cast<bool>(button);
2847 rc.isp_pers_dict = choice;
2849 button = fl_get_button(dialog_->check_compound_words);
2850 rc.isp_accept_compound = static_cast<bool>(button);
2852 button = fl_get_button(dialog_->check_input_enc);
2853 rc.isp_use_input_encoding = static_cast<bool>(button);
2864 void FormPreferences::SpellOptions::build()
2866 dialog_.reset(build_preferences_spelloptions(&parent_));
2868 fl_addto_choice(dialog_->choice_spell_command,
2869 _(" ispell | aspell ").c_str());
2870 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2871 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2872 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2874 // set up the feedback mechanism
2875 setPrehandler(dialog_->choice_spell_command);
2876 setPrehandler(dialog_->check_alt_lang);
2877 setPrehandler(dialog_->input_alt_lang);
2878 setPrehandler(dialog_->check_escape_chars);
2879 setPrehandler(dialog_->input_escape_chars);
2880 setPrehandler(dialog_->check_personal_dict);
2881 setPrehandler(dialog_->input_personal_dict);
2882 setPrehandler(dialog_->button_personal_dict);
2883 setPrehandler(dialog_->check_compound_words);
2884 setPrehandler(dialog_->check_input_enc);
2889 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2891 if (ob == dialog_->choice_spell_command)
2892 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2893 if (ob == dialog_->check_alt_lang)
2894 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2895 if (ob == dialog_->input_alt_lang)
2896 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2897 if (ob == dialog_->check_escape_chars)
2898 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2899 if (ob == dialog_->input_escape_chars)
2900 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2901 if (ob == dialog_->check_personal_dict)
2902 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2903 if (ob == dialog_->input_personal_dict)
2904 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2905 if (ob == dialog_->check_compound_words)
2906 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2907 if (ob == dialog_->check_input_enc)
2908 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
2913 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2915 // !ob if function is called from updateSpellOptions() to de/activate
2917 // otherwise the function is called by an xforms CB via input().
2920 // If spell checker == "none", disable all input.
2921 if (!ob || ob == dialog_->choice_spell_command) {
2922 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2923 fl_deactivate_object(dialog_->check_alt_lang);
2924 fl_deactivate_object(dialog_->input_alt_lang);
2925 fl_deactivate_object(dialog_->check_escape_chars);
2926 fl_deactivate_object(dialog_->input_escape_chars);
2927 fl_deactivate_object(dialog_->check_personal_dict);
2928 fl_deactivate_object(dialog_->input_personal_dict);
2929 fl_deactivate_object(dialog_->check_compound_words);
2930 fl_deactivate_object(dialog_->check_input_enc);
2933 fl_activate_object(dialog_->check_alt_lang);
2934 fl_activate_object(dialog_->check_escape_chars);
2935 fl_activate_object(dialog_->check_personal_dict);
2936 fl_activate_object(dialog_->check_compound_words);
2937 fl_activate_object(dialog_->check_input_enc);
2942 if (!ob || ob == dialog_->check_alt_lang) {
2943 bool const enable = fl_get_button(dialog_->check_alt_lang);
2944 setEnabled(dialog_->input_alt_lang, enable);
2947 if (!ob || ob == dialog_->check_escape_chars) {
2948 bool const enable = fl_get_button(dialog_->check_escape_chars);
2949 setEnabled(dialog_->input_escape_chars, enable);
2952 if (!ob || ob == dialog_->check_personal_dict) {
2953 bool const enable = fl_get_button(dialog_->check_personal_dict);
2954 setEnabled(dialog_->input_personal_dict, enable);
2957 if (ob == dialog_->button_personal_dict) {
2958 string f = parent_.controller().browsedict(
2959 fl_get_input(dialog_->input_personal_dict));
2960 fl_set_input(dialog_->input_personal_dict, f.c_str());
2963 return true; // All input is valid!
2967 void FormPreferences::SpellOptions::update(LyXRC const & rc)
2971 if (rc.isp_command == "none")
2973 else if (rc.isp_command == "ispell")
2975 else if (rc.isp_command == "aspell")
2978 if (rc.isp_command == "ispell")
2980 else if (rc.isp_command == "aspell")
2983 fl_set_choice(dialog_->choice_spell_command, choice);
2986 if (rc.isp_use_alt_lang)
2987 str = rc.isp_alt_lang;
2989 fl_set_button(dialog_->check_alt_lang,
2990 rc.isp_use_alt_lang);
2991 fl_set_input(dialog_->input_alt_lang, str.c_str());
2994 if (rc.isp_use_esc_chars)
2995 str = rc.isp_esc_chars;
2997 fl_set_button(dialog_->check_escape_chars,
2998 rc.isp_use_esc_chars);
2999 fl_set_input(dialog_->input_escape_chars, str.c_str());
3002 if (rc.isp_use_pers_dict)
3003 str = rc.isp_pers_dict;
3005 fl_set_button(dialog_->check_personal_dict,
3006 rc.isp_use_pers_dict);
3007 fl_set_input(dialog_->input_personal_dict, str.c_str());
3009 fl_set_button(dialog_->check_compound_words,
3010 rc.isp_accept_compound);
3011 fl_set_button(dialog_->check_input_enc,
3012 rc.isp_use_input_encoding);
3014 // Activate/Deactivate the input fields dependent on the state of the