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 #pragma implementation
17 #include "ControlPrefs.h"
18 #include "FormPreferences.h"
19 #include "forms/form_preferences.h"
24 #include "input_validators.h"
25 #include "forms_gettext.h"
26 #include "xforms_helpers.h"
27 #include "helper_funcs.h" // getSecond
30 #include "converter.h"
33 #include "frnt_lang.h"
38 #include "funcrequest.h"
40 #include "support/lyxfunctional.h"
41 #include "support/lyxmanip.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 FORMS_H_LOCATION
64 extern string system_lyxdir;
65 extern string user_lyxdir;
69 // These should probably go inside the class definition...
70 Formats local_formats;
71 Converters local_converters;
76 typedef FormCB<ControlPrefs, FormDB<FD_preferences> > base_class;
78 FormPreferences::FormPreferences()
79 : base_class(_("Preferences"), false),
80 colors_(*this), converters_(*this), inputs_misc_(*this),
81 formats_(*this), interface_(*this), language_(*this),
82 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
83 printer_(*this), screen_fonts_(*this), spelloptions_(*this)
88 void FormPreferences::redraw()
90 if (!(form() && form()->visible))
92 fl_redraw_form(form());
94 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
95 if (!(form2 && form2->visible))
97 fl_redraw_form(form2);
100 if (form2 == converters_tab_->form)
101 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
103 else if (form2 == look_n_feel_tab_->form)
104 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
106 else if (form2 == inputs_tab_->form)
107 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
109 else if (form2 == outputs_tab_->form)
110 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
112 else if (form2 == lang_opts_tab_->form)
113 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
115 if (form3 && form3->visible)
116 fl_redraw_form(form3);
121 void FormPreferences::ok()
123 FormBaseDeprecated::ok();
126 if (colors_.modifiedXformsPrefs) {
127 string const filename =
128 AddName(user_lyxdir, "preferences.xform");
129 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
132 lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
138 void FormPreferences::hide()
140 // We need to hide the active tabfolder otherwise we get a
141 // BadDrawable error from X window and LyX crashes without saving.
142 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
143 if (inner_form && inner_form->visible)
144 fl_hide_form(inner_form);
149 void FormPreferences::build()
151 dialog_.reset(build_preferences(this));
153 // Manage the restore, save, apply and cancel/close buttons
154 bc().setOK(dialog_->button_ok);
155 bc().setApply(dialog_->button_apply);
156 bc().setCancel(dialog_->button_close);
157 bc().setRestore(dialog_->button_restore);
159 // Allow the base class to control messages
160 setMessageWidget(dialog_->text_warning);
162 // build the tab folders
163 converters_tab_.reset(build_preferences_inner_tab(this));
164 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
165 inputs_tab_.reset(build_preferences_inner_tab(this));
166 outputs_tab_.reset(build_preferences_inner_tab(this));
167 lang_opts_tab_.reset(build_preferences_inner_tab(this));
169 // build actual tabfolder contents
170 // these will become nested tabfolders
174 inputs_misc_.build();
178 outputs_misc_.build();
181 screen_fonts_.build();
182 spelloptions_.build();
184 // Now add them to the tabfolder
185 fl_addto_tabfolder(dialog_->tabfolder_prefs,
187 look_n_feel_tab_->form);
188 fl_addto_tabfolder(dialog_->tabfolder_prefs,
190 lang_opts_tab_->form);
191 fl_addto_tabfolder(dialog_->tabfolder_prefs,
193 converters_tab_->form);
194 fl_addto_tabfolder(dialog_->tabfolder_prefs,
197 fl_addto_tabfolder(dialog_->tabfolder_prefs,
201 // now build the nested tabfolders
202 // Starting with look and feel
203 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
205 screen_fonts_.dialog()->form);
206 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
208 interface_.dialog()->form);
209 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
211 colors_.dialog()->form);
212 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
214 lnf_misc_.dialog()->form);
216 // then build converters
217 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
219 formats_.dialog()->form);
220 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
222 converters_.dialog()->form);
225 // Paths should probably go in a few inner_tab called Files
226 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
228 paths_.dialog()->form);
229 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
231 inputs_misc_.dialog()->form);
233 // then building outputs
234 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
236 printer_.dialog()->form);
237 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
239 outputs_misc_.dialog()->form);
241 // then building usage
242 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
244 spelloptions_.dialog()->form);
245 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
247 language_.dialog()->form);
249 // work-around xforms bug re update of folder->x, folder->y coords.
250 setPrehandler(look_n_feel_tab_->tabfolder_inner);
251 setPrehandler(converters_tab_->tabfolder_inner);
252 setPrehandler(inputs_tab_->tabfolder_inner);
253 setPrehandler(outputs_tab_->tabfolder_inner);
254 setPrehandler(lang_opts_tab_->tabfolder_inner);
258 void FormPreferences::apply()
260 // set the new lyxrc entries
261 // many of these need to trigger other functions when the assignment
262 // is made. For example, screen zoom and font types. These could be
263 // handled either by signals/slots in lyxrc or just directly call the
264 // associated functions here.
265 // There are other problems with this scheme. We really should check
266 // what we copy to make sure that it really is necessary to do things
267 // like update the screen fonts because that flushes the textcache
268 // and other stuff which may cost us a lot on slower/high-load
271 lyxerr << "apply in form !" << endl;
273 LyXRC & rc(controller().rc());
276 formats_.apply(); // Must be before converters_.apply()
278 inputs_misc_.apply(rc);
279 interface_.apply(rc);
282 outputs_misc_.apply(rc);
285 screen_fonts_.apply(rc);
286 spelloptions_.apply(rc);
290 string const FormPreferences::getFeedback(FL_OBJECT * ob)
294 if (ob->form->fdui == colors_.dialog())
295 return colors_.feedback(ob);
296 if (ob->form->fdui == converters_.dialog())
297 return converters_.feedback(ob);
298 if (ob->form->fdui == formats_.dialog())
299 return formats_.feedback(ob);
300 if (ob->form->fdui == inputs_misc_.dialog())
301 return inputs_misc_.feedback(ob);
302 if (ob->form->fdui == interface_.dialog())
303 return interface_.feedback(ob);
304 if (ob->form->fdui == language_.dialog())
305 return language_.feedback(ob);
306 if (ob->form->fdui == lnf_misc_.dialog())
307 return lnf_misc_.feedback(ob);
308 if (ob->form->fdui == outputs_misc_.dialog())
309 return outputs_misc_.feedback(ob);
310 if (ob->form->fdui == paths_.dialog())
311 return paths_.feedback(ob);
312 if (ob->form->fdui == printer_.dialog())
313 return printer_.feedback(ob);
314 if (ob->form->fdui == screen_fonts_.dialog())
315 return screen_fonts_.feedback(ob);
316 if (ob->form->fdui == spelloptions_.dialog())
317 return spelloptions_.feedback(ob);
323 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
329 // whatever checks you need to ensure the user hasn't entered
330 // some totally ridiculous value somewhere. Change activate to suit.
331 // comments before each test describe what is _valid_
333 if (ob->form->fdui == colors_.dialog()) {
335 } else if (ob->form->fdui == converters_.dialog()) {
336 valid = converters_.input(ob);
337 } else if (ob->form->fdui == formats_.dialog()) {
338 valid = formats_.input(ob);
339 } else if (ob->form->fdui == interface_.dialog()) {
340 valid = interface_.input(ob);
341 } else if (ob->form->fdui == language_.dialog()) {
342 valid = language_.input(ob);
343 } else if (ob->form->fdui == paths_.dialog()) {
344 valid = paths_.input(ob);
345 } else if (ob->form->fdui == screen_fonts_.dialog()) {
346 valid = screen_fonts_.input();
347 } else if (ob->form->fdui == spelloptions_.dialog()) {
348 valid = spelloptions_.input(ob);
351 return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
355 void FormPreferences::update()
357 if (!dialog_.get()) return;
359 LyXRC const & rc(controller().rc());
361 // read lyxrc entries
363 formats_.update(); // Must be before converters_.update()
364 converters_.update();
365 inputs_misc_.update(rc);
366 interface_.update(rc);
367 language_.update(rc);
368 lnf_misc_.update(rc);
369 outputs_misc_.update(rc);
372 screen_fonts_.update(rc);
373 spelloptions_.update(rc);
377 FormPreferences::Colors::Colors(FormPreferences & p)
378 : modifiedXformsPrefs(false), parent_(p)
382 FD_preferences_colors const * FormPreferences::Colors::dialog()
384 return dialog_.get();
388 void FormPreferences::Colors::apply()
390 bool modifiedText = false;
391 bool modifiedBackground = false;
393 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
394 cit != xformsColorDB.end(); ++cit) {
396 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
397 if (col != cit->color()) {
398 modifiedXformsPrefs = true;
399 if (cit->colorID == FL_BLACK)
401 if (cit->colorID == FL_COL1)
402 modifiedBackground = true;
406 if (modifiedXformsPrefs) {
407 for (vector<XformsColor>::const_iterator cit =
408 xformsColorDB.begin();
409 cit != xformsColorDB.end(); ++cit) {
410 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
412 if (modifiedText && cit->colorID == FL_BLACK) {
413 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
416 if (modifiedBackground && cit->colorID == FL_COL1) {
417 AdjustVal(FL_MCOL, FL_COL1, 0.1);
418 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
419 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
421 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
422 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
425 if (cit->colorID == GUI_COLOR_CURSOR) {
426 fl_mapcolor(GUI_COLOR_CURSOR,
427 cit->r, cit->g, cit->b);
428 setCursorColor(GUI_COLOR_CURSOR);
431 parent_.controller().redrawGUI();
434 // Now do the same for the LyX LColors...
435 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
436 cit != lyxColorDB.end(); ++cit) {
437 LColor::color lc = lcolor.getFromGUIName(cit->getname());
438 if (lc == LColor::inherit) continue;
440 // Create a valid X11 name of the form "#rrggbb"
441 string const hexname = X11hexname(cit->color());
443 if (lcolor.getX11Name(lc) != hexname) {
445 << "FormPreferences::Colors::apply: "
446 << "resetting LColor " << lcolor.getGUIName(lc)
447 << " from \"" << lcolor.getX11Name(lc)
448 << "\" to \"" << hexname << "\"."
451 parent_.controller().setColor(lc, hexname);
457 void FormPreferences::Colors::build()
459 dialog_.reset(build_preferences_colors(&parent_));
461 fl_set_object_color(dialog_->button_color,
462 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
464 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
465 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
466 fl_set_dial_step(dialog_->dial_hue, 1.0);
467 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
469 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
470 fl_set_slider_step(dialog_->slider_saturation, 0.01);
471 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
473 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
474 fl_set_slider_step(dialog_->slider_value, 0.01);
475 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
477 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
478 fl_set_slider_step(dialog_->slider_red, 1.0);
479 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
481 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
482 fl_set_slider_step(dialog_->slider_green, 1.0);
483 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
485 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
486 fl_set_slider_step(dialog_->slider_blue, 1.0);
487 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
489 // set up the feedback mechanism
490 setPrehandler(dialog_->browser_lyx_objs);
491 setPrehandler(dialog_->button_color);
492 setPrehandler(dialog_->button_modify);
493 setPrehandler(dialog_->dial_hue);
494 setPrehandler(dialog_->slider_saturation);
495 setPrehandler(dialog_->slider_value);
496 setPrehandler(dialog_->slider_red);
497 setPrehandler(dialog_->slider_green);
498 setPrehandler(dialog_->slider_blue);
499 setPrehandler(dialog_->radio_rgb);
500 setPrehandler(dialog_->radio_hsv);
505 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
507 if (ob == dialog_->browser_lyx_objs)
508 return _("LyX objects that can be assigned a color.");
510 if (ob == dialog_->button_modify)
511 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
513 if (ob == dialog_->dial_hue ||
514 ob == dialog_->slider_saturation ||
515 ob == dialog_->slider_value ||
516 ob == dialog_->slider_red ||
517 ob == dialog_->slider_green ||
518 ob == dialog_->slider_blue)
519 return _("Find a new color.");
521 if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
522 return _("Toggle between RGB and HSV color spaces.");
528 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
530 if (ob == dialog_->browser_lyx_objs) {
533 } else if (ob == dialog_->dial_hue ||
534 ob == dialog_->slider_saturation ||
535 ob == dialog_->slider_value) {
538 } else if (ob == dialog_->slider_red ||
539 ob == dialog_->slider_green ||
540 ob == dialog_->slider_blue) {
543 } else if (ob == dialog_->radio_rgb ||
544 ob == dialog_->radio_hsv) {
547 } else if (ob == dialog_->button_modify) {
553 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
557 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
561 hsv.v = min(1.0, max(0.0, hsv.v));
564 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
568 void FormPreferences::Colors::InputBrowserLyX() const
570 vector<NamedColor>::size_type const selLyX =
571 fl_get_browser(dialog_->browser_lyx_objs);
572 if (selLyX < 1) return;
574 // Is the choice an Xforms color...
577 if (selLyX - 1 < xformsColorDB.size()) {
578 vector<XformsColor>::size_type const i = selLyX - 1;
579 col = xformsColorDB[i].color();
581 // or a LyX Logical color?
583 vector<NamedColor>::size_type const i = selLyX - 1 -
584 xformsColorDB.size();
585 col = lyxColorDB[i].color();
588 fl_freeze_form(dialog_->form);
590 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
591 fl_redraw_object(dialog_->button_color);
593 // Display either RGB or HSV but not both!
596 // Deactivate the modify button to begin with...
597 setEnabled(dialog_->button_modify, false);
599 fl_unfreeze_form(dialog_->form);
603 void FormPreferences::Colors::InputHSV()
605 double const hue = fl_get_dial_value(dialog_->dial_hue);
606 double const sat = fl_get_slider_value(dialog_->slider_saturation);
607 double const val = fl_get_slider_value(dialog_->slider_value);
609 int const h = int(hue);
610 int const s = int(100.0 * sat);
611 int const v = int(100.0 * val);
613 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
615 fl_set_object_label(dialog_->text_color_values, label.c_str());
617 RGBColor col = HSVColor(hue, sat, val);
619 fl_freeze_form(dialog_->form);
621 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
622 fl_redraw_object(dialog_->button_color);
624 col = HSVColor(hue, 1.0, 1.0);
625 col.r = max(col.r, 0);
626 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
627 fl_redraw_object(dialog_->dial_hue);
629 // Ascertain whether to activate the Modify button.
630 vector<NamedColor>::size_type const selLyX =
631 fl_get_browser(dialog_->browser_lyx_objs);
633 fl_unfreeze_form(dialog_->form);
634 if (selLyX < 1) return;
636 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
639 // Is the choice an Xforms color...
640 if (selLyX - 1 < xformsColorDB.size()) {
641 vector<XformsColor>::size_type const i = selLyX - 1;
642 modify = (xformsColorDB[i].color() != col);
644 // or a LyX Logical color?
646 vector<NamedColor>::size_type const i = selLyX - 1 -
647 xformsColorDB.size();
648 modify = (lyxColorDB[i].color() != col);
651 setEnabled(dialog_->button_modify, modify);
655 void FormPreferences::Colors::InputRGB()
657 int const red = int(fl_get_slider_value(dialog_->slider_red));
658 int const green = int(fl_get_slider_value(dialog_->slider_green));
659 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
661 string const label = tostr(red) + string(", ") + tostr(green) +
662 string(", ") + tostr(blue);
663 fl_set_object_label(dialog_->text_color_values, label.c_str());
665 fl_freeze_form(dialog_->form);
667 RGBColor col = RGBColor(red, green, blue);
668 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
669 fl_redraw_object(dialog_->button_color);
671 // Ascertain whether to activate the Modify button.
672 vector<NamedColor>::size_type const selLyX =
673 fl_get_browser(dialog_->browser_lyx_objs);
675 fl_unfreeze_form(dialog_->form);
676 if (selLyX < 1) return;
680 // Is the choice an Xforms color...
681 if (selLyX - 1 < xformsColorDB.size()) {
682 vector<XformsColor>::size_type const i = selLyX - 1;
683 modify = (xformsColorDB[i].color() != col);
685 // or a LyX Logical color?
687 vector<NamedColor>::size_type const i = selLyX - 1 -
688 xformsColorDB.size();
689 modify = (lyxColorDB[i].color() != col);
692 setEnabled(dialog_->button_modify, modify);
696 void FormPreferences::Colors::LoadBrowserLyX()
698 if (!dialog_->browser_lyx_objs->visible)
701 // First, define the modifiable xforms colors
702 xformsColorDB.clear();
705 xcol.name = _("GUI background");
706 xcol.colorID = FL_COL1;
707 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
709 xformsColorDB.push_back(xcol);
711 xcol.name = _("GUI text");
712 xcol.colorID = FL_BLACK;
713 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
715 xformsColorDB.push_back(xcol);
717 xcol.name = _("GUI selection");
718 xcol.colorID = FL_YELLOW;
719 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
721 xformsColorDB.push_back(xcol);
723 xcol.name = _("GUI pointer");
724 xcol.colorID = GUI_COLOR_CURSOR;
725 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
727 xformsColorDB.push_back(xcol);
729 // Now create the the LyX LColors database
731 for (int i=0; i<LColor::ignore; ++i) {
732 LColor::color lc = static_cast<LColor::color>(i);
733 if (lc == LColor::none
734 || lc == LColor::black
735 || lc == LColor::white
737 || lc == LColor::green
738 || lc == LColor::blue
739 || lc == LColor::cyan
740 || lc == LColor::magenta
741 || lc == LColor::yellow
742 || lc == LColor::inherit
743 || lc == LColor::ignore) continue;
745 string const name = lcolor.getX11Name(lc);
746 Display * display = fl_get_display();;
747 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
750 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
752 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
753 << "LColor " << lcolor.getLyXName(lc)
754 << ": X can't find color \"" << name
755 << "\". Set to \"black\"!" << endl;
757 string const arg = lcolor.getLyXName(lc) + " black";
758 parent_.controller().setColor(lc, "black");
762 // X has found the color. Now find the "appropriate" X11 name
765 // Note that X stores the RGB values in the range 0 - 65535
766 // whilst we require them in the range 0 - 255.
768 col.r = xcol.red / 256;
769 col.g = xcol.green / 256;
770 col.b = xcol.blue / 256;
772 // Create a valid X11 name of the form "#rrggbb" and change the
773 // LColor X11name to this. Don't want to trigger a redraw,
774 // as we're just changing the name not the RGB values.
775 // Also reset the system_lcolor names, so that we don't output
776 // unnecessary changes.
777 string const hexname = X11hexname(col);
779 if (lcolor.getX11Name(lc) != hexname) {
780 lcolor.setColor(lc, hexname);
781 system_lcolor.setColor(lc, hexname);
784 // Finally, push the color onto the database
785 NamedColor ncol(lcolor.getGUIName(lc), col);
786 lyxColorDB.push_back(ncol);
789 // Now construct the browser
790 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
791 fl_freeze_form(dialog_->form);
792 fl_clear_browser(colbr);
793 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
794 cit != xformsColorDB.end(); ++cit) {
795 fl_addto_browser(colbr, cit->getname().c_str());
797 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
798 cit != lyxColorDB.end(); ++cit) {
799 fl_addto_browser(colbr, cit->getname().c_str());
802 // just to be safe...
803 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
804 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
805 fl_unfreeze_form(dialog_->form);
811 void FormPreferences::Colors::Modify()
813 vector<NamedColor>::size_type const selLyX =
814 fl_get_browser(dialog_->browser_lyx_objs);
819 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
821 // Is the choice an Xforms color...
822 if (selLyX - 1 < xformsColorDB.size()) {
823 vector<XformsColor>::size_type const i = selLyX - 1;
824 xformsColorDB[i].r = col.r;
825 xformsColorDB[i].g = col.g;
826 xformsColorDB[i].b = col.b;
828 // or a LyX Logical color?
830 vector<NamedColor>::size_type const i = selLyX - 1 -
831 xformsColorDB.size();
832 lyxColorDB[i].r = col.r;
833 lyxColorDB[i].g = col.g;
834 lyxColorDB[i].b = col.b;
837 fl_freeze_form(dialog_->form);
838 setEnabled(dialog_->button_modify, false);
839 fl_unfreeze_form(dialog_->form);
843 void FormPreferences::Colors::SwitchColorSpace() const
845 bool const hsv = fl_get_button(dialog_->radio_hsv);
848 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
850 fl_freeze_form(dialog_->form);
853 fl_hide_object(dialog_->slider_red);
854 fl_hide_object(dialog_->slider_blue);
855 fl_hide_object(dialog_->slider_green);
856 fl_show_object(dialog_->dial_hue);
857 fl_show_object(dialog_->slider_saturation);
858 fl_show_object(dialog_->slider_value);
860 HSVColor hsv = HSVColor(col);
861 hsv.h = max(hsv.h, 0.0);
863 fl_set_dial_value(dialog_->dial_hue, hsv.h);
864 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
865 fl_set_slider_value(dialog_->slider_value, hsv.v);
867 col = HSVColor(hsv.h, 1.0, 1.0);
868 col.r = max(col.r, 0);
869 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
870 fl_redraw_object(dialog_->dial_hue);
872 // Adjust the label a bit, but not the actual values.
873 // Means that toggling from one space to the other has no
874 // effect on the final color.
875 int const h = int(hsv.h);
876 int const s = int(100 * hsv.s);
877 int const v = int(100 * hsv.v);
878 string const label = tostr(h) + ", " + tostr(s) +
880 fl_set_object_label(dialog_->text_color_values, label.c_str());
883 fl_show_object(dialog_->slider_red);
884 fl_show_object(dialog_->slider_blue);
885 fl_show_object(dialog_->slider_green);
886 fl_hide_object(dialog_->dial_hue);
887 fl_hide_object(dialog_->slider_saturation);
888 fl_hide_object(dialog_->slider_value);
890 fl_set_slider_value(dialog_->slider_red, col.r);
891 fl_set_slider_value(dialog_->slider_green, col.g);
892 fl_set_slider_value(dialog_->slider_blue, col.b);
894 // Adjust the label a bit. Same reasoning as above.
895 int const r = int(col.r);
896 int const g = int(col.g);
897 int const b = int(col.b);
898 string const label = tostr(r) + ", " + tostr(g) +
900 fl_set_object_label(dialog_->text_color_values, label.c_str());
903 fl_unfreeze_form(dialog_->form);
906 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
910 ostr << "#" << std::setbase(16) << setfill('0')
915 return STRCONV(ostr.str());
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")));
1078 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1080 setEnabled(dialog_->button_add, false);
1081 setEnabled(dialog_->button_delete, true);
1083 fl_unfreeze_form(dialog_->form);
1088 bool FormPreferences::Converters::erase()
1090 string const from = GetFrom();
1091 string const to = GetTo();
1093 local_converters.erase(from, to);
1099 bool FormPreferences::Converters::Input()
1101 string const from = GetFrom();
1102 string const to = GetTo();
1103 int const sel = local_converters.getNumber(from, to);
1105 fl_freeze_form(dialog_->form);
1108 fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
1109 fl_set_button_shortcut(dialog_->button_add,
1110 scex(_("Add|#A")), 1);
1112 fl_deselect_browser(dialog_->browser_all);
1113 setEnabled(dialog_->button_delete, false);
1116 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1117 fl_set_button_shortcut(dialog_->button_add,
1118 scex(_("Modify|#M")), 1);
1120 int top = max(sel-5, 0);
1121 fl_set_browser_topline(dialog_->browser_all, top);
1122 fl_select_browser_line(dialog_->browser_all, sel+1);
1123 setEnabled(dialog_->button_delete, true);
1126 string const command = rtrim(fl_get_input(dialog_->input_converter));
1127 bool const enable = !(command.empty() || from == to);
1128 setEnabled(dialog_->button_add, enable);
1130 fl_unfreeze_form(dialog_->form);
1135 string const FormPreferences::Converters::GetFrom() const
1137 ::Formats::FormatList::size_type const i =
1138 fl_get_choice(dialog_->choice_from);
1140 if (i > 0 && i <= local_formats.size())
1141 return local_formats.get(i - 1).name();
1143 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1148 string const FormPreferences::Converters::GetTo() const
1150 ::Formats::FormatList::size_type const i =
1151 fl_get_choice(dialog_->choice_to);
1153 if (i > 0 && i <= local_formats.size())
1154 return local_formats.get(i - 1).name();
1156 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1161 void FormPreferences::Converters::UpdateChoices() const
1164 for (::Formats::const_iterator cit = local_formats.begin();
1165 cit != local_formats.end(); ++cit) {
1166 if (!choice.empty())
1170 choice += cit->prettyname();
1174 fl_clear_choice(dialog_->choice_from);
1175 fl_addto_choice(dialog_->choice_from, choice.c_str());
1177 fl_clear_choice(dialog_->choice_to);
1178 fl_addto_choice(dialog_->choice_to, choice.c_str());
1182 FormPreferences::Formats::Formats(FormPreferences & p)
1187 FD_preferences_formats const * FormPreferences::Formats::dialog()
1189 return dialog_.get();
1193 void FormPreferences::Formats::apply() const
1195 parent_.controller().setFormats(local_formats);
1199 void FormPreferences::Formats::build()
1201 dialog_.reset(build_preferences_formats(&parent_));
1203 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1204 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1205 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1206 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1207 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1209 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1211 // set up the feedback mechanism
1212 setPrehandler(dialog_->browser_all);
1213 setPrehandler(dialog_->input_format);
1214 setPrehandler(dialog_->input_gui_name);
1215 setPrehandler(dialog_->button_delete);
1216 setPrehandler(dialog_->button_add);
1217 setPrehandler(dialog_->input_extension);
1218 setPrehandler(dialog_->input_viewer);
1219 setPrehandler(dialog_->input_shrtcut);
1224 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1226 if (ob == dialog_->browser_all)
1227 return _("All the currently defined formats known to LyX.");
1229 if (ob == dialog_->input_format)
1230 return _("The format identifier.");
1232 if (ob == dialog_->input_gui_name)
1233 return _("The format name as it will appear in the menus.");
1235 if (ob == dialog_->input_shrtcut)
1236 return _("The keyboard accelerator. Use a letter in the GUI name. "
1239 if (ob == dialog_->input_extension)
1240 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1242 if (ob == dialog_->input_viewer)
1243 return _("The command used to launch the viewer application.");
1245 if (ob == dialog_->button_delete)
1246 return _("Remove the current format from the list of available "
1247 "formats. Note: you must then \"Apply\" the change.");
1249 if (ob == dialog_->button_add) {
1250 if (string(ob->label) == _("Add"))
1251 return _("Add the current format to the list of available "
1252 "formats. Note: you must then \"Apply\" the change.");
1254 return _("Modify the contents of the current format. Note: "
1255 "you must then \"Apply\" the change.");
1262 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1264 if (ob == dialog_->browser_all)
1267 if (ob == dialog_->input_format
1268 || ob == dialog_->input_gui_name
1269 || ob == dialog_->input_shrtcut
1270 || ob == dialog_->input_extension
1271 || ob == dialog_->input_viewer)
1274 if (ob == dialog_->button_add)
1277 if (ob == dialog_->button_delete)
1284 void FormPreferences::Formats::update()
1286 local_formats = formats;
1291 void FormPreferences::Formats::UpdateBrowser()
1293 local_formats.sort();
1295 fl_freeze_form(dialog_->form);
1296 fl_deselect_browser(dialog_->browser_all);
1297 fl_clear_browser(dialog_->browser_all);
1298 for (::Formats::const_iterator cit = local_formats.begin();
1299 cit != local_formats.end(); ++cit)
1300 fl_addto_browser(dialog_->browser_all,
1301 cit->prettyname().c_str());
1304 fl_unfreeze_form(dialog_->form);
1306 // Mustn't forget to update the Formats available to the converters_
1307 parent_.converters_.UpdateChoices();
1308 local_converters.update(local_formats);
1312 bool FormPreferences::Formats::Add()
1314 string const name = fl_get_input(dialog_->input_format);
1315 string const prettyname = fl_get_input(dialog_->input_gui_name);
1316 string const extension = fl_get_input(dialog_->input_extension);
1317 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1318 string const viewer = fl_get_input(dialog_->input_viewer);
1320 Format const * old = local_formats.getFormat(name);
1321 string const old_prettyname = old ? old->prettyname() : string();
1322 local_formats.add(name, extension, prettyname, shortcut);
1323 local_formats.setViewer(name, viewer);
1324 if (!old || prettyname != old_prettyname) {
1327 parent_.converters_.UpdateBrowser();
1329 setEnabled(dialog_->button_add, false);
1335 bool FormPreferences::Formats::Browser()
1337 int const i = fl_get_browser(dialog_->browser_all);
1341 fl_freeze_form(dialog_->form);
1343 Format const & f = local_formats.get(i - 1);
1345 fl_set_input(dialog_->input_format, f.name().c_str());
1346 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1347 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1348 fl_set_input(dialog_->input_extension, f.extension().c_str());
1349 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1351 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1352 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1354 setEnabled(dialog_->button_add, false);
1355 setEnabled(dialog_->button_delete, true);
1357 fl_unfreeze_form(dialog_->form);
1362 bool FormPreferences::Formats::erase()
1364 string const name = fl_get_input(dialog_->input_format);
1366 if (local_converters.formatIsUsed(name)) {
1367 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1368 "Remove the converter first."));
1369 setEnabled(dialog_->button_delete, false);
1373 local_formats.erase(name);
1379 bool FormPreferences::Formats::Input()
1381 string const name = fl_get_input(dialog_->input_format);
1382 int const sel = local_formats.getNumber(name);
1383 fl_freeze_form(dialog_->form);
1386 fl_set_object_label(dialog_->button_add,
1388 fl_set_button_shortcut(dialog_->button_add,
1389 scex(_("Add|#A")), 1);
1391 fl_deselect_browser(dialog_->browser_all);
1392 setEnabled(dialog_->button_delete, false);
1395 fl_set_object_label(dialog_->button_add,
1396 idex(_("Modify|#M")));
1397 fl_set_button_shortcut(dialog_->button_add,
1398 scex(_("Modify|#M")), 1);
1400 int const top = max(sel-5, 0);
1401 fl_set_browser_topline(dialog_->browser_all, top);
1402 fl_select_browser_line(dialog_->browser_all, sel+1);
1404 setEnabled(dialog_->button_add, true);
1405 setEnabled(dialog_->button_delete, true);
1408 string const prettyname = fl_get_input(dialog_->input_gui_name);
1409 bool const enable = !(name.empty() || prettyname.empty());
1410 setEnabled(dialog_->button_add, enable);
1412 fl_unfreeze_form(dialog_->form);
1417 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1422 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1424 return dialog_.get();
1428 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1430 rc.date_insert_format =
1431 fl_get_input(dialog_->input_date_format);
1435 void FormPreferences::InputsMisc::build()
1437 dialog_.reset(build_preferences_inputs_misc(&parent_));
1439 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1441 // set up the feedback mechanism
1442 setPrehandler(dialog_->input_date_format);
1447 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1449 if (ob == dialog_->input_date_format)
1450 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1455 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1457 fl_set_input(dialog_->input_date_format,
1458 rc.date_insert_format.c_str());
1462 FormPreferences::Interface::Interface(FormPreferences & p)
1467 FD_preferences_interface const * FormPreferences::Interface::dialog()
1469 return dialog_.get();
1473 void FormPreferences::Interface::apply(LyXRC & rc) const
1475 rc.popup_normal_font =
1476 fl_get_input(dialog_->input_popup_normal_font);
1477 rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1478 rc.popup_font_encoding =
1479 fl_get_input(dialog_->input_popup_font_encoding);
1480 rc.bind_file = fl_get_input(dialog_->input_bind_file);
1481 rc.ui_file = fl_get_input(dialog_->input_ui_file);
1482 rc.override_x_deadkeys =
1483 fl_get_button(dialog_->check_override_x_dead_keys);
1487 void FormPreferences::Interface::build()
1489 dialog_.reset(build_preferences_interface(&parent_));
1491 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1492 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1493 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1494 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1495 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1497 // set up the feedback mechanism
1498 setPrehandler(dialog_->input_popup_normal_font);
1499 setPrehandler(dialog_->input_popup_bold_font);
1500 setPrehandler(dialog_->input_popup_font_encoding);
1501 setPrehandler(dialog_->input_bind_file);
1502 setPrehandler(dialog_->button_bind_file_browse);
1503 setPrehandler(dialog_->input_ui_file);
1504 setPrehandler(dialog_->button_ui_file_browse);
1505 setPrehandler(dialog_->check_override_x_dead_keys);
1510 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1512 if (ob == dialog_->input_popup_normal_font)
1513 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1514 if (ob == dialog_->input_popup_bold_font)
1515 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1516 if (ob == dialog_->input_popup_font_encoding)
1517 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1518 if (ob == dialog_->input_bind_file)
1519 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1520 if (ob == dialog_->input_ui_file)
1521 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1522 if (ob == dialog_->check_override_x_dead_keys)
1523 return LyXRC::getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1528 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1530 if (ob == dialog_->button_bind_file_browse) {
1531 string f = parent_.controller().browsebind(
1532 fl_get_input(dialog_->input_bind_file));
1534 fl_set_input(dialog_->input_bind_file, f.c_str());
1535 } else if (ob == dialog_->button_ui_file_browse) {
1536 string f = parent_.controller().browseUI(
1537 fl_get_input(dialog_->input_ui_file));
1539 fl_set_input(dialog_->input_ui_file, f.c_str());
1546 void FormPreferences::Interface::update(LyXRC const & rc)
1548 fl_set_input(dialog_->input_popup_normal_font,
1549 rc.popup_normal_font.c_str());
1550 fl_set_input(dialog_->input_popup_bold_font,
1551 rc.popup_bold_font.c_str());
1552 fl_set_input(dialog_->input_popup_font_encoding,
1553 rc.popup_font_encoding.c_str());
1554 fl_set_input(dialog_->input_bind_file,
1555 rc.bind_file.c_str());
1556 fl_set_input(dialog_->input_ui_file,
1557 rc.ui_file.c_str());
1558 fl_set_button(dialog_->check_override_x_dead_keys,
1559 rc.override_x_deadkeys);
1563 FormPreferences::Language::Language(FormPreferences & p)
1568 FD_preferences_language const * FormPreferences::Language::dialog()
1570 return dialog_.get();
1574 void FormPreferences::Language::apply(LyXRC & rc)
1576 int const pos = combo_default_lang->get();
1577 rc.default_language = lang_[pos-1];
1579 int button = fl_get_button(dialog_->check_use_kbmap);
1580 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1581 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1583 button = !(name_1.empty() && name_2.empty());
1584 rc.use_kbmap = static_cast<bool>(button);
1587 rc.primary_kbmap = name_1;
1588 rc.secondary_kbmap = name_2;
1591 button = fl_get_button(dialog_->check_rtl_support);
1592 rc.rtl_support = static_cast<bool>(button);
1594 button = fl_get_button(dialog_->check_mark_foreign);
1595 rc.mark_foreign_language = static_cast<bool>(button);
1597 button = fl_get_button(dialog_->check_auto_begin);
1598 rc.language_auto_begin = static_cast<bool>(button);
1600 button = fl_get_button(dialog_->check_auto_end);
1601 rc.language_auto_end = static_cast<bool>(button);
1603 button = fl_get_button(dialog_->check_use_babel);
1604 rc.language_use_babel = static_cast<bool>(button);
1606 button = fl_get_button(dialog_->check_global_options);
1607 rc.language_global_options = static_cast<bool>(button);
1609 rc.language_package = fl_get_input(dialog_->input_package);
1610 rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1611 rc.language_command_end = fl_get_input(dialog_->input_command_end);
1613 // Ensure that all is self-consistent.
1618 void FormPreferences::Language::build()
1620 dialog_.reset(build_preferences_language(&parent_));
1622 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1623 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1624 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1626 // Store the lang identifiers for later
1627 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1628 lang_ = getSecond(langs);
1630 // The default_language is a combo-box and has to be inserted manually
1631 fl_freeze_form(dialog_->form);
1632 fl_addto_form(dialog_->form);
1634 FL_OBJECT * obj = dialog_->choice_default_lang;
1635 fl_deactivate_object(dialog_->choice_default_lang);
1636 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1637 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
1638 combo_default_lang->shortcut("#L",1);
1639 combo_default_lang->setcallback(ComboCB, &parent_);
1641 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1642 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1643 for (; lit != lend; ++lit) {
1644 combo_default_lang->addto(lit->first);
1646 combo_default_lang->select(1);
1649 fl_unfreeze_form(dialog_->form);
1651 // set up the feedback mechanism
1652 setPrehandler(dialog_->input_package);
1653 setPrehandler(dialog_->check_use_kbmap);
1655 // This is safe, as nothing is done to the pointer, other than
1656 // to use its address in a block-if statement.
1657 // No it's not! Leads to crash.
1659 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1660 // C_FormPreferencesFeedbackCB);
1662 setPrehandler(dialog_->input_kbmap1);
1663 setPrehandler(dialog_->input_kbmap2);
1664 setPrehandler(dialog_->check_rtl_support);
1665 setPrehandler(dialog_->check_mark_foreign);
1666 setPrehandler(dialog_->check_auto_begin);
1667 setPrehandler(dialog_->check_auto_end);
1668 setPrehandler(dialog_->check_use_babel);
1669 setPrehandler(dialog_->check_global_options);
1670 setPrehandler(dialog_->input_command_begin);
1671 setPrehandler(dialog_->input_command_end);
1673 // Activate/Deactivate the input fields dependent on the state of the
1680 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1682 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1683 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1684 if (ob == dialog_->check_use_kbmap)
1685 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1686 if (ob == dialog_->input_kbmap1)
1687 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1688 if (ob == dialog_->input_kbmap2)
1689 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1690 if (ob == dialog_->check_rtl_support)
1691 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1692 if (ob == dialog_->check_mark_foreign)
1693 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1694 if (ob == dialog_->check_auto_begin)
1695 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1696 if (ob == dialog_->check_auto_end)
1697 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1698 if (ob == dialog_->check_use_babel)
1699 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1700 if (ob == dialog_->check_global_options)
1701 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1702 if (ob == dialog_->input_package)
1703 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1704 if (ob == dialog_->input_command_begin)
1705 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1706 if (ob == dialog_->input_command_end)
1707 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1712 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1714 bool activate = true;
1716 // !ob if function is called from Language::build() to de/activate
1718 // otherwise the function is called by an xforms CB via input().
1719 if (!ob || ob == dialog_->check_use_kbmap) {
1720 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1721 setEnabled(dialog_->button_kbmap1_browse, enable);
1722 setEnabled(dialog_->button_kbmap2_browse, enable);
1723 setEnabled(dialog_->input_kbmap1, enable);
1724 setEnabled(dialog_->input_kbmap2, enable);
1727 if (ob == dialog_->button_kbmap1_browse) {
1728 string f = parent_.controller().browsekbmap(
1729 fl_get_input(dialog_->input_kbmap1));
1731 fl_set_input(dialog_->input_kbmap1, f.c_str());
1732 } else if (ob == dialog_->button_kbmap2_browse) {
1733 string f = parent_.controller().browsekbmap(
1734 fl_get_input(dialog_->input_kbmap2));
1736 fl_set_input(dialog_->input_kbmap2, f.c_str());
1743 void FormPreferences::Language::update(LyXRC const & rc)
1745 fl_set_button(dialog_->check_use_kbmap,
1748 int const pos = int(findPos(lang_, rc.default_language));
1749 combo_default_lang->select(pos + 1);
1752 fl_set_input(dialog_->input_kbmap1,
1753 rc.primary_kbmap.c_str());
1754 fl_set_input(dialog_->input_kbmap2,
1755 rc.secondary_kbmap.c_str());
1757 fl_set_input(dialog_->input_kbmap1, "");
1758 fl_set_input(dialog_->input_kbmap2, "");
1761 fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1762 fl_set_button(dialog_->check_mark_foreign,
1763 rc.mark_foreign_language);
1764 fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1765 fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1766 fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1767 fl_set_button(dialog_->check_global_options,
1768 rc.language_global_options);
1770 fl_set_input(dialog_->input_package,
1771 rc.language_package.c_str());
1772 fl_set_input(dialog_->input_command_begin,
1773 rc.language_command_begin.c_str());
1774 fl_set_input(dialog_->input_command_end,
1775 rc.language_command_end.c_str());
1777 // Activate/Deactivate the input fields dependent on the state of the
1783 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1785 FormPreferences * pre = static_cast<FormPreferences*>(v);
1786 // This is safe, as nothing is done to the pointer, other than
1787 // to use its address in a block-if statement.
1788 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1792 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1797 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1799 return dialog_.get();
1803 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1805 rc.auto_region_delete =
1806 fl_get_button(dialog_->check_auto_region_delete);
1807 rc.cursor_follows_scrollbar =
1808 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1809 rc.dialogs_iconify_with_main =
1810 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1811 rc.preview = fl_get_button(dialog_->check_preview_latex);
1812 rc.autosave = static_cast<unsigned int>
1813 (fl_get_counter_value(dialog_->counter_autosave));
1814 rc.wheel_jump = static_cast<unsigned int>
1815 (fl_get_counter_value(dialog_->counter_wm_jump));
1818 // grfx::DisplayType old_value = rc.display_graphics;
1819 switch (fl_get_choice(dialog_->choice_display)) {
1820 case 4: rc.display_graphics = grfx::NoDisplay; break;
1821 case 3: rc.display_graphics = grfx::ColorDisplay; break;
1822 case 2: rc.display_graphics = grfx::GrayscaleDisplay; break;
1823 case 1: rc.display_graphics = grfx::MonochromeDisplay; break;
1824 default: rc.display_graphics = grfx::ColorDisplay; break;
1827 #ifdef WITH_WARNINGS
1828 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1831 if (old_value != rc.display_graphics) {
1832 grfx::GCache & gc = grfx::GCache::get();
1839 void FormPreferences::LnFmisc::build()
1841 dialog_.reset(build_preferences_lnf_misc(&parent_));
1843 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1844 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1846 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1847 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1849 // set up the feedback mechanism
1850 setPrehandler(dialog_->check_auto_region_delete);
1851 setPrehandler(dialog_->counter_autosave);
1852 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1853 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1854 setPrehandler(dialog_->check_preview_latex);
1855 setPrehandler(dialog_->counter_wm_jump);
1857 fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
1862 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1864 if (ob == dialog_->check_auto_region_delete)
1865 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
1866 if (ob == dialog_->check_cursor_follows_scrollbar)
1867 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1868 if (ob == dialog_->check_dialogs_iconify_with_main)
1869 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1870 if (ob == dialog_->check_preview_latex)
1871 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
1872 if (ob == dialog_->counter_autosave)
1873 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
1874 if (ob == dialog_->counter_wm_jump)
1875 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
1876 if (ob == dialog_->choice_display)
1877 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1882 void FormPreferences::LnFmisc::update(LyXRC const & rc)
1884 fl_set_button(dialog_->check_auto_region_delete,
1885 rc.auto_region_delete);
1886 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1887 rc.cursor_follows_scrollbar);
1888 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1889 rc.dialogs_iconify_with_main);
1890 fl_set_button(dialog_->check_preview_latex,
1892 fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
1893 fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
1895 switch (rc.display_graphics) {
1896 case grfx::NoDisplay: fl_set_choice(dialog_->choice_display, 4); break;
1897 case grfx::ColorDisplay: fl_set_choice(dialog_->choice_display, 3); break;
1898 case grfx::GrayscaleDisplay: fl_set_choice(dialog_->choice_display, 2); break;
1899 case grfx::MonochromeDisplay: fl_set_choice(dialog_->choice_display, 1); break;
1900 default: fl_set_choice(dialog_->choice_display, 3); break;
1905 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1910 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1912 return dialog_.get();
1916 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
1918 rc.ascii_linelen = static_cast<unsigned int>
1919 (fl_get_counter_value(dialog_->counter_line_len));
1920 rc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1923 fl_get_choice(dialog_->choice_default_papersize) - 1;
1924 rc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1926 rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1927 rc.chktex_command = fl_get_input(dialog_->input_checktex);
1928 rc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1929 rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1933 void FormPreferences::OutputsMisc::build()
1935 dialog_.reset(build_preferences_outputs_misc(&parent_));
1937 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1939 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1940 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1941 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1942 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1943 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1945 fl_addto_choice(dialog_->choice_default_papersize,
1946 _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1948 // set up the feedback mechanism
1949 setPrehandler(dialog_->counter_line_len);
1950 setPrehandler(dialog_->input_tex_encoding);
1951 setPrehandler(dialog_->choice_default_papersize);
1952 setPrehandler(dialog_->input_ascii_roff);
1953 setPrehandler(dialog_->input_checktex);
1954 setPrehandler(dialog_->input_paperoption);
1955 setPrehandler(dialog_->check_autoreset_classopt);
1960 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1962 if (ob == dialog_->counter_line_len)
1963 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
1964 if (ob == dialog_->input_tex_encoding)
1965 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
1966 if (ob == dialog_->input_ascii_roff)
1967 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1968 if (ob == dialog_->input_checktex)
1969 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
1970 if (ob == dialog_->choice_default_papersize)
1971 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1972 if (ob == dialog_->input_paperoption)
1973 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
1974 if (ob == dialog_->check_autoreset_classopt)
1975 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
1980 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
1982 fl_set_counter_value(dialog_->counter_line_len,
1984 fl_set_input(dialog_->input_tex_encoding,
1985 rc.fontenc.c_str());
1986 fl_set_choice(dialog_->choice_default_papersize,
1987 rc.default_papersize + 1);
1988 fl_set_input(dialog_->input_ascii_roff,
1989 rc.ascii_roff_command.c_str());
1990 fl_set_input(dialog_->input_checktex,
1991 rc.chktex_command.c_str());
1992 fl_set_input(dialog_->input_paperoption,
1993 rc.view_dvi_paper_option.c_str());
1994 fl_set_button(dialog_->check_autoreset_classopt,
1995 rc.auto_reset_options);
2000 FormPreferences::Paths::Paths(FormPreferences & p)
2005 FD_preferences_paths const * FormPreferences::Paths::dialog()
2007 return dialog_.get();
2011 void FormPreferences::Paths::apply(LyXRC & rc)
2013 rc.document_path = fl_get_input(dialog_->input_default_path);
2014 rc.template_path = fl_get_input(dialog_->input_template_path);
2016 int button = fl_get_button(dialog_->check_use_temp_dir);
2017 string str = fl_get_input(dialog_->input_temp_dir);
2021 rc.use_tempdir = button;
2022 rc.tempdir_path = str;
2024 button = fl_get_button(dialog_->check_last_files);
2025 str = fl_get_input(dialog_->input_lastfiles);
2026 if (!button) str.erase();
2028 rc.check_lastfiles = button;
2030 rc.num_lastfiles = static_cast<unsigned int>
2031 (fl_get_counter_value(dialog_->counter_lastfiles));
2033 button = fl_get_button(dialog_->check_make_backups);
2034 str = fl_get_input(dialog_->input_backup_path);
2038 rc.make_backup = button;
2039 rc.backupdir_path = str;
2041 rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2048 void FormPreferences::Paths::build()
2050 dialog_.reset(build_preferences_paths(&parent_));
2052 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2053 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2054 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2055 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2056 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2057 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2058 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2060 // set up the feedback mechanism
2061 setPrehandler(dialog_->input_default_path);
2062 setPrehandler(dialog_->counter_lastfiles);
2063 setPrehandler(dialog_->input_template_path);
2064 setPrehandler(dialog_->check_last_files);
2065 setPrehandler(dialog_->input_lastfiles);
2066 setPrehandler(dialog_->check_make_backups);
2067 setPrehandler(dialog_->input_backup_path);
2068 setPrehandler(dialog_->input_serverpipe);
2069 setPrehandler(dialog_->input_temp_dir);
2070 setPrehandler(dialog_->check_use_temp_dir);
2075 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2077 if (ob == dialog_->input_default_path)
2078 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2079 if (ob == dialog_->input_template_path)
2080 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2081 if (ob == dialog_->check_use_temp_dir)
2082 return LyXRC::getDescription(LyXRC::RC_USETEMPDIR);
2083 if (ob == dialog_->input_temp_dir)
2084 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2085 if (ob == dialog_->check_last_files)
2086 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2087 if (ob == dialog_->input_lastfiles)
2088 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
2089 if (ob == dialog_->counter_lastfiles)
2090 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2091 if (ob == dialog_->check_make_backups)
2092 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2093 if (ob == dialog_->input_backup_path)
2094 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2095 if (ob == dialog_->input_serverpipe)
2096 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2101 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2103 bool activate = true;
2105 // !ob if function is called from Paths::update() to de/activate
2107 // otherwise the function is called by an xforms CB via input().
2108 if (!ob || ob == dialog_->check_use_temp_dir) {
2109 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2110 setEnabled(dialog_->input_temp_dir, enable);
2113 if (!ob || ob == dialog_->check_last_files) {
2114 bool const enable = fl_get_button(dialog_->check_last_files);
2115 setEnabled(dialog_->input_lastfiles, enable);
2118 if (!ob || ob == dialog_->check_make_backups) {
2119 bool const enable = fl_get_button(dialog_->check_make_backups);
2120 setEnabled(dialog_->input_backup_path, enable);
2123 if (!ob || ob == dialog_->input_default_path) {
2124 string const name = fl_get_input(dialog_->input_default_path);
2125 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2126 parent_.postWarning(RWInfo::ErrorMessage());
2131 if (!ob || ob == dialog_->input_template_path) {
2132 string const name = fl_get_input(dialog_->input_template_path);
2133 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2134 parent_.postWarning(RWInfo::ErrorMessage());
2139 if (!ob || ob == dialog_->input_temp_dir) {
2140 string const name = fl_get_input(dialog_->input_temp_dir);
2141 if (fl_get_button(dialog_->check_make_backups)
2143 && !RWInfo::WriteableDir(name)) {
2144 parent_.postWarning(RWInfo::ErrorMessage());
2149 if (!ob || ob == dialog_->input_backup_path) {
2150 string const name = fl_get_input(dialog_->input_backup_path);
2151 if (fl_get_button(dialog_->check_make_backups)
2153 && !RWInfo::WriteableDir(name)) {
2154 parent_.postWarning(RWInfo::ErrorMessage());
2159 if (!ob || ob == dialog_->input_lastfiles) {
2160 string const name = fl_get_input(dialog_->input_lastfiles);
2161 if (fl_get_button(dialog_->check_last_files)
2163 && !RWInfo::WriteableFile(name)) {
2164 parent_.postWarning(RWInfo::ErrorMessage());
2169 if (!ob || ob == dialog_->input_serverpipe) {
2170 string const name = fl_get_input(dialog_->input_serverpipe);
2171 if (!name.empty()) {
2172 // strip off the extension
2173 string const str = ChangeExtension(name, "");
2174 if (!RWInfo::WriteableFile(str + ".in")) {
2175 parent_.postWarning(RWInfo::ErrorMessage());
2178 if (!RWInfo::WriteableFile(str + ".out")) {
2179 parent_.postWarning(RWInfo::ErrorMessage());
2185 if (ob == dialog_->button_default_path_browse) {
2186 string f = parent_.controller().browse(
2187 fl_get_input(dialog_->input_default_path), _("Default path"));
2188 fl_set_input(dialog_->input_default_path, f.c_str());
2189 } else if (ob == dialog_->button_template_path_browse) {
2190 string f = parent_.controller().browse(
2191 fl_get_input(dialog_->input_template_path), _("Template path"));
2192 fl_set_input(dialog_->input_template_path, f.c_str());
2193 } else if (ob == dialog_->button_temp_dir_browse) {
2194 string f = parent_.controller().browse(
2195 fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2196 fl_set_input(dialog_->input_temp_dir, f.c_str());
2197 } else if (ob == dialog_->button_lastfiles_browse) {
2198 string f = parent_.controller().browse(
2199 fl_get_input(dialog_->input_lastfiles), _("Last files"));
2200 fl_set_input(dialog_->input_lastfiles, f.c_str());
2201 } else if (ob == dialog_->button_backup_path_browse) {
2202 string f = parent_.controller().browse(
2203 fl_get_input(dialog_->input_backup_path), _("Backup path"));
2204 fl_set_input(dialog_->input_backup_path, f.c_str());
2205 } else if (ob == dialog_->button_serverpipe_browse) {
2206 string f = parent_.controller().browse(
2207 fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2208 fl_set_input(dialog_->input_serverpipe, f.c_str());
2215 void FormPreferences::Paths::update(LyXRC const & rc)
2217 fl_set_input(dialog_->input_default_path,
2218 rc.document_path.c_str());
2219 fl_set_input(dialog_->input_template_path,
2220 rc.template_path.c_str());
2224 str = rc.backupdir_path;
2226 fl_set_button(dialog_->check_make_backups,
2228 fl_set_input(dialog_->input_backup_path, str.c_str());
2232 str = rc.tempdir_path;
2234 fl_set_button(dialog_->check_use_temp_dir,
2236 fl_set_input(dialog_->input_temp_dir, str.c_str());
2239 if (rc.check_lastfiles)
2242 fl_set_button(dialog_->check_last_files,
2243 rc.check_lastfiles);
2244 fl_set_input(dialog_->input_lastfiles, str.c_str());
2245 fl_set_counter_value(dialog_->counter_lastfiles,
2248 fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2250 // Activate/Deactivate the input fields dependent on the state of the
2256 FormPreferences::Printer::Printer(FormPreferences & p)
2261 FD_preferences_printer const * FormPreferences::Printer::dialog()
2263 return dialog_.get();
2267 void FormPreferences::Printer::apply(LyXRC & rc) const
2269 rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2270 rc.print_command = fl_get_input(dialog_->input_command);
2271 rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2272 rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2273 rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2274 rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2275 rc.print_file_extension =
2276 fl_get_input(dialog_->input_file_extension);
2277 rc.print_spool_command =
2278 fl_get_input(dialog_->input_spool_command);
2279 rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2280 rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2281 rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2282 rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2283 rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2284 rc.print_to_file = fl_get_input(dialog_->input_to_file);
2285 rc.print_extra_options =
2286 fl_get_input(dialog_->input_extra_options);
2287 rc.print_spool_printerprefix =
2288 fl_get_input(dialog_->input_spool_prefix);
2289 rc.print_paper_dimension_flag =
2290 fl_get_input(dialog_->input_paper_size);
2291 rc.printer = fl_get_input(dialog_->input_name);
2296 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2298 if (ob == dialog_->input_command)
2299 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2300 if (ob == dialog_->check_adapt_output)
2301 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2302 if (ob == dialog_->input_to_printer)
2303 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2304 if (ob == dialog_->input_to_file)
2305 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2306 if (ob == dialog_->input_file_extension)
2307 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2308 if (ob == dialog_->input_extra_options)
2309 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2310 if (ob == dialog_->input_spool_command)
2311 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2312 if (ob == dialog_->input_spool_prefix)
2313 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2314 if (ob == dialog_->input_name)
2315 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2316 if (ob == dialog_->input_even_pages)
2317 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2318 if (ob == dialog_->input_odd_pages)
2319 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2320 if (ob == dialog_->input_page_range)
2321 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2322 if (ob == dialog_->input_reverse)
2323 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2324 if (ob == dialog_->input_landscape)
2325 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2326 if (ob == dialog_->input_copies)
2327 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2328 if (ob == dialog_->input_collated)
2329 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2330 if (ob == dialog_->input_paper_type)
2331 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2332 if (ob == dialog_->input_paper_size)
2333 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2338 void FormPreferences::Printer::build()
2340 dialog_.reset(build_preferences_printer(&parent_));
2342 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2343 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2344 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2345 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2346 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2347 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2348 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2349 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2350 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2351 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2352 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2353 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2354 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2355 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2356 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2357 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2358 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2360 // set up the feedback mechanism
2361 setPrehandler(dialog_->input_command);
2362 setPrehandler(dialog_->input_page_range);
2363 setPrehandler(dialog_->input_copies);
2364 setPrehandler(dialog_->input_reverse);
2365 setPrehandler(dialog_->input_to_printer);
2366 setPrehandler(dialog_->input_file_extension);
2367 setPrehandler(dialog_->input_spool_command);
2368 setPrehandler(dialog_->input_paper_type);
2369 setPrehandler(dialog_->input_even_pages);
2370 setPrehandler(dialog_->input_odd_pages);
2371 setPrehandler(dialog_->input_collated);
2372 setPrehandler(dialog_->input_landscape);
2373 setPrehandler(dialog_->input_to_file);
2374 setPrehandler(dialog_->input_extra_options);
2375 setPrehandler(dialog_->input_spool_prefix);
2376 setPrehandler(dialog_->input_paper_size);
2377 setPrehandler(dialog_->input_name);
2378 setPrehandler(dialog_->check_adapt_output);
2382 void FormPreferences::Printer::update(LyXRC const & rc)
2384 fl_set_button(dialog_->check_adapt_output,
2385 rc.print_adapt_output);
2386 fl_set_input(dialog_->input_command,
2387 rc.print_command.c_str());
2388 fl_set_input(dialog_->input_page_range,
2389 rc.print_pagerange_flag.c_str());
2390 fl_set_input(dialog_->input_copies,
2391 rc.print_copies_flag.c_str());
2392 fl_set_input(dialog_->input_reverse,
2393 rc.print_reverse_flag.c_str());
2394 fl_set_input(dialog_->input_to_printer,
2395 rc.print_to_printer.c_str());
2396 fl_set_input(dialog_->input_file_extension,
2397 rc.print_file_extension.c_str());
2398 fl_set_input(dialog_->input_spool_command,
2399 rc.print_spool_command.c_str());
2400 fl_set_input(dialog_->input_paper_type,
2401 rc.print_paper_flag.c_str());
2402 fl_set_input(dialog_->input_even_pages,
2403 rc.print_evenpage_flag.c_str());
2404 fl_set_input(dialog_->input_odd_pages,
2405 rc.print_oddpage_flag.c_str());
2406 fl_set_input(dialog_->input_collated,
2407 rc.print_collcopies_flag.c_str());
2408 fl_set_input(dialog_->input_landscape,
2409 rc.print_landscape_flag.c_str());
2410 fl_set_input(dialog_->input_to_file,
2411 rc.print_to_file.c_str());
2412 fl_set_input(dialog_->input_extra_options,
2413 rc.print_extra_options.c_str());
2414 fl_set_input(dialog_->input_spool_prefix,
2415 rc.print_spool_printerprefix.c_str());
2416 fl_set_input(dialog_->input_paper_size,
2417 rc.print_paper_dimension_flag.c_str());
2418 fl_set_input(dialog_->input_name,
2419 rc.printer.c_str());
2423 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2428 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2430 return dialog_.get();
2434 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2436 bool changed = false;
2438 string str = fl_get_input(dialog_->input_roman);
2439 if (rc.roman_font_name != str) {
2441 rc.roman_font_name = str;
2444 str = fl_get_input(dialog_->input_sans);
2445 if (rc.sans_font_name != str) {
2447 rc.sans_font_name = str;
2450 str = fl_get_input(dialog_->input_typewriter);
2451 if (rc.typewriter_font_name != str) {
2453 rc.typewriter_font_name = str;
2456 str = fl_get_input(dialog_->input_screen_encoding);
2457 if (rc.font_norm != str) {
2462 bool button = fl_get_button(dialog_->check_scalable);
2463 if (rc.use_scalable_fonts != button) {
2465 rc.use_scalable_fonts = button;
2468 unsigned int ivalue = static_cast<unsigned int>
2469 (fl_get_counter_value(dialog_->counter_zoom));
2470 if (rc.zoom != ivalue) {
2475 ivalue = static_cast<unsigned int>
2476 (fl_get_counter_value(dialog_->counter_dpi));
2477 if (rc.dpi != ivalue) {
2482 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2483 if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2485 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2488 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2489 if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2491 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2494 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2495 if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2497 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2500 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2501 if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2503 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2506 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2507 if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2509 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2512 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2513 if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2515 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2518 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2519 if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2521 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2524 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2525 if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2527 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2530 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2531 if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2533 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2536 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2537 if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2539 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2543 // Now update the buffers
2544 // Can anything below here affect the redraw process?
2545 parent_.controller().updateScreenFonts();
2550 void FormPreferences::ScreenFonts::build()
2552 dialog_.reset(build_preferences_screen_fonts(&parent_));
2554 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2555 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2557 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2558 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2559 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2560 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2561 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2562 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2563 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2564 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2565 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2566 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2567 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2568 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2569 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2570 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2571 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2572 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2574 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2575 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2576 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2577 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2578 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2579 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2580 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2581 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2582 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2583 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2585 // set up the feedback mechanism
2586 setPrehandler(dialog_->input_roman);
2587 setPrehandler(dialog_->input_sans);
2588 setPrehandler(dialog_->input_typewriter);
2589 setPrehandler(dialog_->counter_zoom);
2590 setPrehandler(dialog_->counter_dpi);
2591 setPrehandler(dialog_->check_scalable);
2592 setPrehandler(dialog_->input_screen_encoding);
2593 setPrehandler(dialog_->input_tiny);
2594 setPrehandler(dialog_->input_script);
2595 setPrehandler(dialog_->input_footnote);
2596 setPrehandler(dialog_->input_small);
2597 setPrehandler(dialog_->input_large);
2598 setPrehandler(dialog_->input_larger);
2599 setPrehandler(dialog_->input_largest);
2600 setPrehandler(dialog_->input_normal);
2601 setPrehandler(dialog_->input_huge);
2602 setPrehandler(dialog_->input_huger);
2607 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2609 if (ob == dialog_->input_roman)
2610 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2611 if (ob == dialog_->input_sans)
2612 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2613 if (ob == dialog_->input_typewriter)
2614 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2615 if (ob == dialog_->check_scalable)
2616 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2617 if (ob == dialog_->input_screen_encoding)
2618 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2619 if (ob == dialog_->counter_zoom)
2620 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2621 if (ob == dialog_->counter_dpi)
2622 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2623 if (ob == dialog_->input_tiny
2624 || ob == dialog_->input_script
2625 || ob == dialog_->input_footnote
2626 || ob == dialog_->input_small
2627 || ob == dialog_->input_large
2628 || ob == dialog_->input_larger
2629 || ob == dialog_->input_larger
2630 || ob == dialog_->input_largest
2631 || ob == dialog_->input_normal
2632 || ob == dialog_->input_huge
2633 || ob == dialog_->input_huger)
2634 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2639 bool FormPreferences::ScreenFonts::input()
2641 bool activate = true;
2644 // Make sure that all fonts all have positive entries
2645 // Also note that an empty entry is returned as 0.0 by strToDbl
2646 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2647 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2648 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2649 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2650 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2651 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2652 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2653 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2654 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2655 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2657 str = _("Fonts must be positive!");
2659 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2660 // Fontsizes -- tiny < script < footnote etc.
2661 strToDbl(fl_get_input(dialog_->input_script)) ||
2662 strToDbl(fl_get_input(dialog_->input_script)) >
2663 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2664 strToDbl(fl_get_input(dialog_->input_footnote)) >
2665 strToDbl(fl_get_input(dialog_->input_small)) ||
2666 strToDbl(fl_get_input(dialog_->input_small)) >
2667 strToDbl(fl_get_input(dialog_->input_normal)) ||
2668 strToDbl(fl_get_input(dialog_->input_normal)) >
2669 strToDbl(fl_get_input(dialog_->input_large)) ||
2670 strToDbl(fl_get_input(dialog_->input_large)) >
2671 strToDbl(fl_get_input(dialog_->input_larger)) ||
2672 strToDbl(fl_get_input(dialog_->input_larger)) >
2673 strToDbl(fl_get_input(dialog_->input_largest)) ||
2674 strToDbl(fl_get_input(dialog_->input_largest)) >
2675 strToDbl(fl_get_input(dialog_->input_huge)) ||
2676 strToDbl(fl_get_input(dialog_->input_huge)) >
2677 strToDbl(fl_get_input(dialog_->input_huger))) {
2680 str = _("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2684 parent_.postWarning(str);
2690 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2692 fl_set_input(dialog_->input_roman,
2693 rc.roman_font_name.c_str());
2694 fl_set_input(dialog_->input_sans,
2695 rc.sans_font_name.c_str());
2696 fl_set_input(dialog_->input_typewriter,
2697 rc.typewriter_font_name.c_str());
2698 fl_set_input(dialog_->input_screen_encoding,
2699 rc.font_norm.c_str());
2700 fl_set_button(dialog_->check_scalable,
2701 rc.use_scalable_fonts);
2702 fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2703 fl_set_counter_value(dialog_->counter_dpi, rc.dpi);
2704 fl_set_input(dialog_->input_tiny,
2705 tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2706 fl_set_input(dialog_->input_script,
2707 tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2708 fl_set_input(dialog_->input_footnote,
2709 tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2710 fl_set_input(dialog_->input_small,
2711 tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2712 fl_set_input(dialog_->input_normal,
2713 tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2714 fl_set_input(dialog_->input_large,
2715 tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2716 fl_set_input(dialog_->input_larger,
2717 tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2718 fl_set_input(dialog_->input_largest,
2719 tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2720 fl_set_input(dialog_->input_huge,
2721 tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2722 fl_set_input(dialog_->input_huger,
2723 tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2728 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2733 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2735 return dialog_.get();
2739 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2741 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2742 choice = trim(choice);
2744 rc.isp_command = choice;
2747 // If spell checker == "none", all other input set to off.
2748 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2749 rc.isp_use_alt_lang = false;
2750 rc.isp_alt_lang.erase();
2752 rc.isp_use_esc_chars = false;
2753 rc.isp_esc_chars.erase();
2755 rc.isp_use_pers_dict = false;
2756 rc.isp_pers_dict.erase();
2758 rc.isp_accept_compound = false;
2759 rc.isp_use_input_encoding = false;
2762 int button = fl_get_button(dialog_->check_alt_lang);
2763 choice = fl_get_input(dialog_->input_alt_lang);
2764 if (button && choice.empty()) button = 0;
2765 if (!button) choice.erase();
2767 rc.isp_use_alt_lang = static_cast<bool>(button);
2768 rc.isp_alt_lang = choice;
2770 button = fl_get_button(dialog_->check_escape_chars);
2771 choice = fl_get_input(dialog_->input_escape_chars);
2772 if (button && choice.empty()) button = 0;
2773 if (!button) choice.erase();
2775 rc.isp_use_esc_chars = static_cast<bool>(button);
2776 rc.isp_esc_chars = choice;
2778 button = fl_get_button(dialog_->check_personal_dict);
2779 choice = fl_get_input(dialog_->input_personal_dict);
2780 if (button && choice.empty()) button = 0;
2781 if (!button) choice.erase();
2783 rc.isp_use_pers_dict = static_cast<bool>(button);
2784 rc.isp_pers_dict = choice;
2786 button = fl_get_button(dialog_->check_compound_words);
2787 rc.isp_accept_compound = static_cast<bool>(button);
2789 button = fl_get_button(dialog_->check_input_enc);
2790 rc.isp_use_input_encoding = static_cast<bool>(button);
2801 void FormPreferences::SpellOptions::build()
2803 dialog_.reset(build_preferences_spelloptions(&parent_));
2805 fl_addto_choice(dialog_->choice_spell_command,
2806 _(" ispell | aspell "));
2807 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2808 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2809 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2811 // set up the feedback mechanism
2812 setPrehandler(dialog_->choice_spell_command);
2813 setPrehandler(dialog_->check_alt_lang);
2814 setPrehandler(dialog_->input_alt_lang);
2815 setPrehandler(dialog_->check_escape_chars);
2816 setPrehandler(dialog_->input_escape_chars);
2817 setPrehandler(dialog_->check_personal_dict);
2818 setPrehandler(dialog_->input_personal_dict);
2819 setPrehandler(dialog_->button_personal_dict);
2820 setPrehandler(dialog_->check_compound_words);
2821 setPrehandler(dialog_->check_input_enc);
2826 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2828 if (ob == dialog_->choice_spell_command)
2829 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2830 if (ob == dialog_->check_alt_lang)
2831 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2832 if (ob == dialog_->input_alt_lang)
2833 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2834 if (ob == dialog_->check_escape_chars)
2835 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2836 if (ob == dialog_->input_escape_chars)
2837 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2838 if (ob == dialog_->check_personal_dict)
2839 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2840 if (ob == dialog_->input_personal_dict)
2841 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2842 if (ob == dialog_->check_compound_words)
2843 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2844 if (ob == dialog_->check_input_enc)
2845 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
2850 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2852 // !ob if function is called from updateSpellOptions() to de/activate
2854 // otherwise the function is called by an xforms CB via input().
2857 // If spell checker == "none", disable all input.
2858 if (!ob || ob == dialog_->choice_spell_command) {
2859 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2860 fl_deactivate_object(dialog_->check_alt_lang);
2861 fl_deactivate_object(dialog_->input_alt_lang);
2862 fl_deactivate_object(dialog_->check_escape_chars);
2863 fl_deactivate_object(dialog_->input_escape_chars);
2864 fl_deactivate_object(dialog_->check_personal_dict);
2865 fl_deactivate_object(dialog_->input_personal_dict);
2866 fl_deactivate_object(dialog_->check_compound_words);
2867 fl_deactivate_object(dialog_->check_input_enc);
2870 fl_activate_object(dialog_->check_alt_lang);
2871 fl_activate_object(dialog_->check_escape_chars);
2872 fl_activate_object(dialog_->check_personal_dict);
2873 fl_activate_object(dialog_->check_compound_words);
2874 fl_activate_object(dialog_->check_input_enc);
2879 if (!ob || ob == dialog_->check_alt_lang) {
2880 bool const enable = fl_get_button(dialog_->check_alt_lang);
2881 setEnabled(dialog_->input_alt_lang, enable);
2884 if (!ob || ob == dialog_->check_escape_chars) {
2885 bool const enable = fl_get_button(dialog_->check_escape_chars);
2886 setEnabled(dialog_->input_escape_chars, enable);
2889 if (!ob || ob == dialog_->check_personal_dict) {
2890 bool const enable = fl_get_button(dialog_->check_personal_dict);
2891 setEnabled(dialog_->input_personal_dict, enable);
2894 if (ob == dialog_->button_personal_dict) {
2895 string f = parent_.controller().browsedict(
2896 fl_get_input(dialog_->input_personal_dict));
2897 fl_set_input(dialog_->input_personal_dict, f.c_str());
2900 return true; // All input is valid!
2904 void FormPreferences::SpellOptions::update(LyXRC const & rc)
2908 if (rc.isp_command == "none")
2910 else if (rc.isp_command == "ispell")
2912 else if (rc.isp_command == "aspell")
2915 if (rc.isp_command == "ispell")
2917 else if (rc.isp_command == "aspell")
2920 fl_set_choice(dialog_->choice_spell_command, choice);
2923 if (rc.isp_use_alt_lang)
2924 str = rc.isp_alt_lang;
2926 fl_set_button(dialog_->check_alt_lang,
2927 rc.isp_use_alt_lang);
2928 fl_set_input(dialog_->input_alt_lang, str.c_str());
2931 if (rc.isp_use_esc_chars)
2932 str = rc.isp_esc_chars;
2934 fl_set_button(dialog_->check_escape_chars,
2935 rc.isp_use_esc_chars);
2936 fl_set_input(dialog_->input_escape_chars, str.c_str());
2939 if (rc.isp_use_pers_dict)
2940 str = rc.isp_pers_dict;
2942 fl_set_button(dialog_->check_personal_dict,
2943 rc.isp_use_pers_dict);
2944 fl_set_input(dialog_->input_personal_dict, str.c_str());
2946 fl_set_button(dialog_->check_compound_words,
2947 rc.isp_accept_compound);
2948 fl_set_button(dialog_->check_input_enc,
2949 rc.isp_use_input_encoding);
2951 // Activate/Deactivate the input fields dependent on the state of the