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;
73 string makeFontName(string const & family, string const & foundry)
77 return family + ',' + foundry;
81 pair<string,string> parseFontName(string const & name)
83 string::size_type const idx = name.find(',');
84 if (idx == string::npos)
85 return make_pair(name, string());
86 return make_pair(name.substr(0, idx),
94 typedef FormCB<ControlPrefs, FormDB<FD_preferences> > base_class;
96 FormPreferences::FormPreferences()
97 : base_class(_("Preferences"), false),
98 colors_(*this), converters_(*this), inputs_misc_(*this),
99 formats_(*this), interface_(*this), language_(*this),
100 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
101 printer_(*this), screen_fonts_(*this), spelloptions_(*this)
106 void FormPreferences::redraw()
108 if (!(form() && form()->visible))
110 fl_redraw_form(form());
112 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
113 if (!(form2 && form2->visible))
115 fl_redraw_form(form2);
118 if (form2 == converters_tab_->form)
119 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
121 else if (form2 == look_n_feel_tab_->form)
122 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
124 else if (form2 == inputs_tab_->form)
125 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
127 else if (form2 == outputs_tab_->form)
128 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
130 else if (form2 == lang_opts_tab_->form)
131 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
133 if (form3 && form3->visible)
134 fl_redraw_form(form3);
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 LyXRC & rc(controller().rc());
274 formats_.apply(); // Must be before converters_.apply()
276 inputs_misc_.apply(rc);
277 interface_.apply(rc);
280 outputs_misc_.apply(rc);
283 screen_fonts_.apply(rc);
284 spelloptions_.apply(rc);
286 // The "Save" button has been pressed.
287 if (controller().isClosing() && colors_.modifiedXformsPrefs) {
288 string const filename =
289 AddName(user_lyxdir, "preferences.xform");
290 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
295 string const FormPreferences::getFeedback(FL_OBJECT * ob)
299 if (ob->form->fdui == colors_.dialog())
300 return colors_.feedback(ob);
301 if (ob->form->fdui == converters_.dialog())
302 return converters_.feedback(ob);
303 if (ob->form->fdui == formats_.dialog())
304 return formats_.feedback(ob);
305 if (ob->form->fdui == inputs_misc_.dialog())
306 return inputs_misc_.feedback(ob);
307 if (ob->form->fdui == interface_.dialog())
308 return interface_.feedback(ob);
309 if (ob->form->fdui == language_.dialog())
310 return language_.feedback(ob);
311 if (ob->form->fdui == lnf_misc_.dialog())
312 return lnf_misc_.feedback(ob);
313 if (ob->form->fdui == outputs_misc_.dialog())
314 return outputs_misc_.feedback(ob);
315 if (ob->form->fdui == paths_.dialog())
316 return paths_.feedback(ob);
317 if (ob->form->fdui == printer_.dialog())
318 return printer_.feedback(ob);
319 if (ob->form->fdui == screen_fonts_.dialog())
320 return screen_fonts_.feedback(ob);
321 if (ob->form->fdui == spelloptions_.dialog())
322 return spelloptions_.feedback(ob);
328 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
334 // whatever checks you need to ensure the user hasn't entered
335 // some totally ridiculous value somewhere. Change activate to suit.
336 // comments before each test describe what is _valid_
338 if (ob->form->fdui == colors_.dialog()) {
340 } else if (ob->form->fdui == converters_.dialog()) {
341 valid = converters_.input(ob);
342 } else if (ob->form->fdui == formats_.dialog()) {
343 valid = formats_.input(ob);
344 } else if (ob->form->fdui == interface_.dialog()) {
345 valid = interface_.input(ob);
346 } else if (ob->form->fdui == language_.dialog()) {
347 valid = language_.input(ob);
348 } else if (ob->form->fdui == paths_.dialog()) {
349 valid = paths_.input(ob);
350 } else if (ob->form->fdui == screen_fonts_.dialog()) {
351 valid = screen_fonts_.input();
352 } else if (ob->form->fdui == spelloptions_.dialog()) {
353 valid = spelloptions_.input(ob);
356 return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
360 void FormPreferences::update()
362 if (!dialog_.get()) return;
364 LyXRC const & rc(controller().rc());
366 // read lyxrc entries
368 formats_.update(); // Must be before converters_.update()
369 converters_.update();
370 inputs_misc_.update(rc);
371 interface_.update(rc);
372 language_.update(rc);
373 lnf_misc_.update(rc);
374 outputs_misc_.update(rc);
377 screen_fonts_.update(rc);
378 spelloptions_.update(rc);
382 FormPreferences::Colors::Colors(FormPreferences & p)
383 : modifiedXformsPrefs(false), parent_(p)
387 FD_preferences_colors const * FormPreferences::Colors::dialog()
389 return dialog_.get();
393 void FormPreferences::Colors::apply()
395 bool modifiedText = false;
396 bool modifiedBackground = false;
398 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
399 cit != xformsColorDB.end(); ++cit) {
401 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
402 if (col != cit->color()) {
403 modifiedXformsPrefs = true;
404 if (cit->colorID == FL_BLACK)
406 if (cit->colorID == FL_COL1)
407 modifiedBackground = true;
411 if (modifiedXformsPrefs) {
412 for (vector<XformsColor>::const_iterator cit =
413 xformsColorDB.begin();
414 cit != xformsColorDB.end(); ++cit) {
415 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
417 if (modifiedText && cit->colorID == FL_BLACK) {
418 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
421 if (modifiedBackground && cit->colorID == FL_COL1) {
422 AdjustVal(FL_MCOL, FL_COL1, 0.1);
423 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
424 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
426 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
427 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
430 if (cit->colorID == GUI_COLOR_CURSOR) {
431 fl_mapcolor(GUI_COLOR_CURSOR,
432 cit->r, cit->g, cit->b);
433 setCursorColor(GUI_COLOR_CURSOR);
436 parent_.controller().redrawGUI();
439 // Now do the same for the LyX LColors...
440 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
441 cit != lyxColorDB.end(); ++cit) {
442 LColor::color lc = lcolor.getFromGUIName(cit->getname());
443 if (lc == LColor::inherit) continue;
445 // Create a valid X11 name of the form "#rrggbb"
446 string const hexname = X11hexname(cit->color());
448 if (lcolor.getX11Name(lc) != hexname) {
450 << "FormPreferences::Colors::apply: "
451 << "resetting LColor " << lcolor.getGUIName(lc)
452 << " from \"" << lcolor.getX11Name(lc)
453 << "\" to \"" << hexname << "\"."
456 parent_.controller().setColor(lc, hexname);
462 void FormPreferences::Colors::build()
464 dialog_.reset(build_preferences_colors(&parent_));
466 fl_set_object_color(dialog_->button_color,
467 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
469 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
470 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
471 fl_set_dial_step(dialog_->dial_hue, 1.0);
472 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
474 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
475 fl_set_slider_step(dialog_->slider_saturation, 0.01);
476 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
478 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
479 fl_set_slider_step(dialog_->slider_value, 0.01);
480 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
482 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
483 fl_set_slider_step(dialog_->slider_red, 1.0);
484 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
486 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
487 fl_set_slider_step(dialog_->slider_green, 1.0);
488 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
490 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
491 fl_set_slider_step(dialog_->slider_blue, 1.0);
492 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
494 // set up the feedback mechanism
495 setPrehandler(dialog_->browser_lyx_objs);
496 setPrehandler(dialog_->button_color);
497 setPrehandler(dialog_->button_modify);
498 setPrehandler(dialog_->dial_hue);
499 setPrehandler(dialog_->slider_saturation);
500 setPrehandler(dialog_->slider_value);
501 setPrehandler(dialog_->slider_red);
502 setPrehandler(dialog_->slider_green);
503 setPrehandler(dialog_->slider_blue);
504 setPrehandler(dialog_->radio_rgb);
505 setPrehandler(dialog_->radio_hsv);
510 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
512 if (ob == dialog_->browser_lyx_objs)
513 return _("LyX objects that can be assigned a color.");
515 if (ob == dialog_->button_modify)
516 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
518 if (ob == dialog_->dial_hue ||
519 ob == dialog_->slider_saturation ||
520 ob == dialog_->slider_value ||
521 ob == dialog_->slider_red ||
522 ob == dialog_->slider_green ||
523 ob == dialog_->slider_blue)
524 return _("Find a new color.");
526 if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
527 return _("Toggle between RGB and HSV color spaces.");
533 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
535 if (ob == dialog_->browser_lyx_objs) {
538 } else if (ob == dialog_->dial_hue ||
539 ob == dialog_->slider_saturation ||
540 ob == dialog_->slider_value) {
543 } else if (ob == dialog_->slider_red ||
544 ob == dialog_->slider_green ||
545 ob == dialog_->slider_blue) {
548 } else if (ob == dialog_->radio_rgb ||
549 ob == dialog_->radio_hsv) {
552 } else if (ob == dialog_->button_modify) {
558 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
562 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
566 hsv.v = min(1.0, max(0.0, hsv.v));
569 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
573 void FormPreferences::Colors::InputBrowserLyX() const
575 vector<NamedColor>::size_type const selLyX =
576 fl_get_browser(dialog_->browser_lyx_objs);
577 if (selLyX < 1) return;
579 // Is the choice an Xforms color...
582 if (selLyX - 1 < xformsColorDB.size()) {
583 vector<XformsColor>::size_type const i = selLyX - 1;
584 col = xformsColorDB[i].color();
586 // or a LyX Logical color?
588 vector<NamedColor>::size_type const i = selLyX - 1 -
589 xformsColorDB.size();
590 col = lyxColorDB[i].color();
593 fl_freeze_form(dialog_->form);
595 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
596 fl_redraw_object(dialog_->button_color);
598 // Display either RGB or HSV but not both!
601 // Deactivate the modify button to begin with...
602 setEnabled(dialog_->button_modify, false);
604 fl_unfreeze_form(dialog_->form);
608 void FormPreferences::Colors::InputHSV()
610 double const hue = fl_get_dial_value(dialog_->dial_hue);
611 double const sat = fl_get_slider_value(dialog_->slider_saturation);
612 double const val = fl_get_slider_value(dialog_->slider_value);
614 int const h = int(hue);
615 int const s = int(100.0 * sat);
616 int const v = int(100.0 * val);
618 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
620 fl_set_object_label(dialog_->text_color_values, label.c_str());
622 RGBColor col = HSVColor(hue, sat, val);
624 fl_freeze_form(dialog_->form);
626 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
627 fl_redraw_object(dialog_->button_color);
629 col = HSVColor(hue, 1.0, 1.0);
630 col.r = max(col.r, 0);
631 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
632 fl_redraw_object(dialog_->dial_hue);
634 // Ascertain whether to activate the Modify button.
635 vector<NamedColor>::size_type const selLyX =
636 fl_get_browser(dialog_->browser_lyx_objs);
638 fl_unfreeze_form(dialog_->form);
639 if (selLyX < 1) return;
641 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
644 // Is the choice an Xforms color...
645 if (selLyX - 1 < xformsColorDB.size()) {
646 vector<XformsColor>::size_type const i = selLyX - 1;
647 modify = (xformsColorDB[i].color() != col);
649 // or a LyX Logical color?
651 vector<NamedColor>::size_type const i = selLyX - 1 -
652 xformsColorDB.size();
653 modify = (lyxColorDB[i].color() != col);
656 setEnabled(dialog_->button_modify, modify);
660 void FormPreferences::Colors::InputRGB()
662 int const red = int(fl_get_slider_value(dialog_->slider_red));
663 int const green = int(fl_get_slider_value(dialog_->slider_green));
664 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
666 string const label = tostr(red) + string(", ") + tostr(green) +
667 string(", ") + tostr(blue);
668 fl_set_object_label(dialog_->text_color_values, label.c_str());
670 fl_freeze_form(dialog_->form);
672 RGBColor col = RGBColor(red, green, blue);
673 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
674 fl_redraw_object(dialog_->button_color);
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;
685 // Is the choice an Xforms color...
686 if (selLyX - 1 < xformsColorDB.size()) {
687 vector<XformsColor>::size_type const i = selLyX - 1;
688 modify = (xformsColorDB[i].color() != col);
690 // or a LyX Logical color?
692 vector<NamedColor>::size_type const i = selLyX - 1 -
693 xformsColorDB.size();
694 modify = (lyxColorDB[i].color() != col);
697 setEnabled(dialog_->button_modify, modify);
701 void FormPreferences::Colors::LoadBrowserLyX()
703 if (!dialog_->browser_lyx_objs->visible)
706 // First, define the modifiable xforms colors
707 xformsColorDB.clear();
710 xcol.name = _("GUI background");
711 xcol.colorID = FL_COL1;
712 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
714 xformsColorDB.push_back(xcol);
716 xcol.name = _("GUI text");
717 xcol.colorID = FL_BLACK;
718 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
720 xformsColorDB.push_back(xcol);
722 xcol.name = _("GUI selection");
723 xcol.colorID = FL_YELLOW;
724 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
726 xformsColorDB.push_back(xcol);
728 xcol.name = _("GUI pointer");
729 xcol.colorID = GUI_COLOR_CURSOR;
730 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
732 xformsColorDB.push_back(xcol);
734 // Now create the the LyX LColors database
736 for (int i=0; i<LColor::ignore; ++i) {
737 LColor::color lc = static_cast<LColor::color>(i);
738 if (lc == LColor::none
739 || lc == LColor::black
740 || lc == LColor::white
742 || lc == LColor::green
743 || lc == LColor::blue
744 || lc == LColor::cyan
745 || lc == LColor::magenta
746 || lc == LColor::yellow
747 || lc == LColor::inherit
748 || lc == LColor::ignore) continue;
750 string const name = lcolor.getX11Name(lc);
751 Display * display = fl_get_display();;
752 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
755 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
757 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
758 << "LColor " << lcolor.getLyXName(lc)
759 << ": X can't find color \"" << name
760 << "\". Set to \"black\"!" << endl;
762 string const arg = lcolor.getLyXName(lc) + " black";
763 parent_.controller().setColor(lc, "black");
767 // X has found the color. Now find the "appropriate" X11 name
770 // Note that X stores the RGB values in the range 0 - 65535
771 // whilst we require them in the range 0 - 255.
773 col.r = xcol.red / 256;
774 col.g = xcol.green / 256;
775 col.b = xcol.blue / 256;
777 // Create a valid X11 name of the form "#rrggbb" and change the
778 // LColor X11name to this. Don't want to trigger a redraw,
779 // as we're just changing the name not the RGB values.
780 // Also reset the system_lcolor names, so that we don't output
781 // unnecessary changes.
782 string const hexname = X11hexname(col);
784 if (lcolor.getX11Name(lc) != hexname) {
785 lcolor.setColor(lc, hexname);
786 system_lcolor.setColor(lc, hexname);
789 // Finally, push the color onto the database
790 NamedColor ncol(lcolor.getGUIName(lc), col);
791 lyxColorDB.push_back(ncol);
794 // Now construct the browser
795 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
796 fl_freeze_form(dialog_->form);
797 fl_clear_browser(colbr);
798 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
799 cit != xformsColorDB.end(); ++cit) {
800 fl_addto_browser(colbr, cit->getname().c_str());
802 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
803 cit != lyxColorDB.end(); ++cit) {
804 fl_addto_browser(colbr, cit->getname().c_str());
807 // just to be safe...
808 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
809 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
810 fl_unfreeze_form(dialog_->form);
816 void FormPreferences::Colors::Modify()
818 vector<NamedColor>::size_type const selLyX =
819 fl_get_browser(dialog_->browser_lyx_objs);
824 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
826 // Is the choice an Xforms color...
827 if (selLyX - 1 < xformsColorDB.size()) {
828 vector<XformsColor>::size_type const i = selLyX - 1;
829 xformsColorDB[i].r = col.r;
830 xformsColorDB[i].g = col.g;
831 xformsColorDB[i].b = col.b;
833 // or a LyX Logical color?
835 vector<NamedColor>::size_type const i = selLyX - 1 -
836 xformsColorDB.size();
837 lyxColorDB[i].r = col.r;
838 lyxColorDB[i].g = col.g;
839 lyxColorDB[i].b = col.b;
842 fl_freeze_form(dialog_->form);
843 setEnabled(dialog_->button_modify, false);
844 fl_unfreeze_form(dialog_->form);
848 void FormPreferences::Colors::SwitchColorSpace() const
850 bool const hsv = fl_get_button(dialog_->radio_hsv);
853 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
855 fl_freeze_form(dialog_->form);
858 fl_hide_object(dialog_->slider_red);
859 fl_hide_object(dialog_->slider_blue);
860 fl_hide_object(dialog_->slider_green);
861 fl_show_object(dialog_->dial_hue);
862 fl_show_object(dialog_->slider_saturation);
863 fl_show_object(dialog_->slider_value);
865 HSVColor hsv = HSVColor(col);
866 hsv.h = max(hsv.h, 0.0);
868 fl_set_dial_value(dialog_->dial_hue, hsv.h);
869 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
870 fl_set_slider_value(dialog_->slider_value, hsv.v);
872 col = HSVColor(hsv.h, 1.0, 1.0);
873 col.r = max(col.r, 0);
874 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
875 fl_redraw_object(dialog_->dial_hue);
877 // Adjust the label a bit, but not the actual values.
878 // Means that toggling from one space to the other has no
879 // effect on the final color.
880 int const h = int(hsv.h);
881 int const s = int(100 * hsv.s);
882 int const v = int(100 * hsv.v);
883 string const label = tostr(h) + ", " + tostr(s) +
885 fl_set_object_label(dialog_->text_color_values, label.c_str());
888 fl_show_object(dialog_->slider_red);
889 fl_show_object(dialog_->slider_blue);
890 fl_show_object(dialog_->slider_green);
891 fl_hide_object(dialog_->dial_hue);
892 fl_hide_object(dialog_->slider_saturation);
893 fl_hide_object(dialog_->slider_value);
895 fl_set_slider_value(dialog_->slider_red, col.r);
896 fl_set_slider_value(dialog_->slider_green, col.g);
897 fl_set_slider_value(dialog_->slider_blue, col.b);
899 // Adjust the label a bit. Same reasoning as above.
900 int const r = int(col.r);
901 int const g = int(col.g);
902 int const b = int(col.b);
903 string const label = tostr(r) + ", " + tostr(g) +
905 fl_set_object_label(dialog_->text_color_values, label.c_str());
908 fl_unfreeze_form(dialog_->form);
911 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
915 ostr << '#' << std::setbase(16) << setfill('0')
920 return STRCONV(ostr.str());
924 FormPreferences::Converters::Converters(FormPreferences & p)
929 FD_preferences_converters const * FormPreferences::Converters::dialog()
931 return dialog_.get();
935 void FormPreferences::Converters::apply() const
937 parent_.controller().setConverters(local_converters);
941 void FormPreferences::Converters::build()
943 dialog_.reset(build_preferences_converters(&parent_));
945 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
946 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
948 // set up the feedback mechanism
949 setPrehandler(dialog_->browser_all);
950 setPrehandler(dialog_->button_delete);
951 setPrehandler(dialog_->button_add);
952 setPrehandler(dialog_->input_converter);
953 setPrehandler(dialog_->choice_from);
954 setPrehandler(dialog_->choice_to);
955 setPrehandler(dialog_->input_flags);
960 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
962 if (ob == dialog_->browser_all)
963 return _("All the currently defined converters known to LyX.");
965 if (ob == dialog_->choice_from)
966 return _("Convert \"from\" this format");
968 if (ob == dialog_->choice_to)
969 return _("Convert \"to\" this format");
971 if (ob == dialog_->input_converter)
972 return _("The conversion command. $$i is the input file name, "
973 "$$b is the file name without its extension and $$o is "
974 "the name of the output file. $$s can be used as path to "
975 "LyX's own collection of conversion scripts.");
977 if (ob == dialog_->input_flags)
978 return _("Extra information for the Converter class, whether and "
979 "how to parse the result, and various other things.");
981 if (ob == dialog_->button_delete)
982 return _("Remove the current converter from the list of available "
983 "converters. Note: you must then \"Apply\" the change.");
985 if (ob == dialog_->button_add) {
986 if (string(ob->label) == _("Add"))
987 return _("Add the current converter to the list of available "
988 "converters. Note: you must then \"Apply\" the change.");
990 return _("Modify the contents of the current converter. "
991 "Note: you must then \"Apply\" the change.");
998 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
1000 if (ob == dialog_->browser_all)
1003 if (ob == dialog_->choice_from
1004 || ob == dialog_->choice_to
1005 || ob == dialog_->input_converter
1006 || ob == dialog_->input_flags)
1009 if (ob == dialog_->button_add)
1012 if (ob == dialog_->button_delete)
1019 void FormPreferences::Converters::update()
1021 local_converters = converters;
1022 local_converters.update(local_formats);
1027 void FormPreferences::Converters::UpdateBrowser()
1029 local_converters.sort();
1031 fl_freeze_form(dialog_->form);
1032 fl_clear_browser(dialog_->browser_all);
1033 for (::Converters::const_iterator cit = local_converters.begin();
1034 cit != local_converters.end(); ++cit) {
1035 string const name = cit->From->prettyname() + " -> "
1036 + cit->To->prettyname();
1037 fl_addto_browser(dialog_->browser_all, name.c_str());
1040 fl_unfreeze_form(dialog_->form);
1044 bool FormPreferences::Converters::Add()
1046 string const from = GetFrom();
1047 string const to = GetTo();
1048 string const command = fl_get_input(dialog_->input_converter);
1049 string const flags = fl_get_input(dialog_->input_flags);
1051 Converter const * old = local_converters.getConverter(from, to);
1052 local_converters.add(from, to, command, flags);
1054 local_converters.updateLast(local_formats);
1057 setEnabled(dialog_->button_add, false);
1063 bool FormPreferences::Converters::Browser()
1065 int const i = fl_get_browser(dialog_->browser_all);
1066 if (i <= 0) return false;
1068 fl_freeze_form(dialog_->form);
1070 Converter const & c = local_converters.get(i - 1);
1071 int j = local_formats.getNumber(c.from);
1073 fl_set_choice(dialog_->choice_from, j + 1);
1075 j = local_formats.getNumber(c.to);
1077 fl_set_choice(dialog_->choice_to, j + 1);
1079 fl_set_input(dialog_->input_converter, c.command.c_str());
1080 fl_set_input(dialog_->input_flags, c.flags.c_str());
1082 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
1083 fl_set_button_shortcut(dialog_->button_add,
1084 scex(_("Modify|#M")).c_str(), 1);
1086 setEnabled(dialog_->button_add, false);
1087 setEnabled(dialog_->button_delete, true);
1089 fl_unfreeze_form(dialog_->form);
1094 bool FormPreferences::Converters::erase()
1096 string const from = GetFrom();
1097 string const to = GetTo();
1099 local_converters.erase(from, to);
1105 bool FormPreferences::Converters::Input()
1107 string const from = GetFrom();
1108 string const to = GetTo();
1109 int const sel = local_converters.getNumber(from, to);
1111 fl_freeze_form(dialog_->form);
1114 fl_set_object_label(dialog_->button_add,
1115 idex(_("Add|#A")).c_str());
1116 fl_set_button_shortcut(dialog_->button_add,
1117 scex(_("Add|#A")).c_str(), 1);
1119 fl_deselect_browser(dialog_->browser_all);
1120 setEnabled(dialog_->button_delete, false);
1123 fl_set_object_label(dialog_->button_add,
1124 idex(_("Modify|#M")).c_str());
1125 fl_set_button_shortcut(dialog_->button_add,
1126 scex(_("Modify|#M")).c_str(), 1);
1128 int top = max(sel-5, 0);
1129 fl_set_browser_topline(dialog_->browser_all, top);
1130 fl_select_browser_line(dialog_->browser_all, sel+1);
1131 setEnabled(dialog_->button_delete, true);
1134 string const command = rtrim(fl_get_input(dialog_->input_converter));
1135 bool const enable = !(command.empty() || from == to);
1136 setEnabled(dialog_->button_add, enable);
1138 fl_unfreeze_form(dialog_->form);
1143 string const FormPreferences::Converters::GetFrom() const
1145 ::Formats::FormatList::size_type const i =
1146 fl_get_choice(dialog_->choice_from);
1148 if (i > 0 && i <= local_formats.size())
1149 return local_formats.get(i - 1).name();
1151 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1156 string const FormPreferences::Converters::GetTo() const
1158 ::Formats::FormatList::size_type const i =
1159 fl_get_choice(dialog_->choice_to);
1161 if (i > 0 && i <= local_formats.size())
1162 return local_formats.get(i - 1).name();
1164 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1169 void FormPreferences::Converters::UpdateChoices() const
1172 for (::Formats::const_iterator cit = local_formats.begin();
1173 cit != local_formats.end(); ++cit) {
1174 if (!choice.empty())
1178 choice += cit->prettyname();
1182 fl_clear_choice(dialog_->choice_from);
1183 fl_addto_choice(dialog_->choice_from, choice.c_str());
1185 fl_clear_choice(dialog_->choice_to);
1186 fl_addto_choice(dialog_->choice_to, choice.c_str());
1190 FormPreferences::Formats::Formats(FormPreferences & p)
1195 FD_preferences_formats const * FormPreferences::Formats::dialog()
1197 return dialog_.get();
1201 void FormPreferences::Formats::apply() const
1203 parent_.controller().setFormats(local_formats);
1207 void FormPreferences::Formats::build()
1209 dialog_.reset(build_preferences_formats(&parent_));
1211 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1212 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1213 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1214 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1215 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1217 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1219 // set up the feedback mechanism
1220 setPrehandler(dialog_->browser_all);
1221 setPrehandler(dialog_->input_format);
1222 setPrehandler(dialog_->input_gui_name);
1223 setPrehandler(dialog_->button_delete);
1224 setPrehandler(dialog_->button_add);
1225 setPrehandler(dialog_->input_extension);
1226 setPrehandler(dialog_->input_viewer);
1227 setPrehandler(dialog_->input_shrtcut);
1232 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1234 if (ob == dialog_->browser_all)
1235 return _("All the currently defined formats known to LyX.");
1237 if (ob == dialog_->input_format)
1238 return _("The format identifier.");
1240 if (ob == dialog_->input_gui_name)
1241 return _("The format name as it will appear in the menus.");
1243 if (ob == dialog_->input_shrtcut)
1244 return _("The keyboard accelerator. Use a letter in the GUI name. "
1247 if (ob == dialog_->input_extension)
1248 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1250 if (ob == dialog_->input_viewer)
1251 return _("The command used to launch the viewer application.");
1253 if (ob == dialog_->button_delete)
1254 return _("Remove the current format from the list of available "
1255 "formats. Note: you must then \"Apply\" the change.");
1257 if (ob == dialog_->button_add) {
1258 if (string(ob->label) == _("Add"))
1259 return _("Add the current format to the list of available "
1260 "formats. Note: you must then \"Apply\" the change.");
1262 return _("Modify the contents of the current format. Note: "
1263 "you must then \"Apply\" the change.");
1270 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1272 if (ob == dialog_->browser_all)
1275 if (ob == dialog_->input_format
1276 || ob == dialog_->input_gui_name
1277 || ob == dialog_->input_shrtcut
1278 || ob == dialog_->input_extension
1279 || ob == dialog_->input_viewer)
1282 if (ob == dialog_->button_add)
1285 if (ob == dialog_->button_delete)
1292 void FormPreferences::Formats::update()
1294 local_formats = formats;
1299 void FormPreferences::Formats::UpdateBrowser()
1301 local_formats.sort();
1303 fl_freeze_form(dialog_->form);
1304 fl_deselect_browser(dialog_->browser_all);
1305 fl_clear_browser(dialog_->browser_all);
1306 for (::Formats::const_iterator cit = local_formats.begin();
1307 cit != local_formats.end(); ++cit)
1308 fl_addto_browser(dialog_->browser_all,
1309 cit->prettyname().c_str());
1312 fl_unfreeze_form(dialog_->form);
1314 // Mustn't forget to update the Formats available to the converters_
1315 parent_.converters_.UpdateChoices();
1316 local_converters.update(local_formats);
1320 bool FormPreferences::Formats::Add()
1322 string const name = fl_get_input(dialog_->input_format);
1323 string const prettyname = fl_get_input(dialog_->input_gui_name);
1324 string const extension = fl_get_input(dialog_->input_extension);
1325 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1326 string const viewer = fl_get_input(dialog_->input_viewer);
1328 Format const * old = local_formats.getFormat(name);
1329 string const old_prettyname = old ? old->prettyname() : string();
1330 local_formats.add(name, extension, prettyname, shortcut);
1331 local_formats.setViewer(name, viewer);
1332 if (!old || prettyname != old_prettyname) {
1335 parent_.converters_.UpdateBrowser();
1337 setEnabled(dialog_->button_add, false);
1343 bool FormPreferences::Formats::Browser()
1345 int const i = fl_get_browser(dialog_->browser_all);
1349 fl_freeze_form(dialog_->form);
1351 Format const & f = local_formats.get(i - 1);
1353 fl_set_input(dialog_->input_format, f.name().c_str());
1354 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1355 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1356 fl_set_input(dialog_->input_extension, f.extension().c_str());
1357 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1359 fl_set_object_label(dialog_->button_add,
1360 idex(_("Modify|#M")).c_str());
1361 fl_set_button_shortcut(dialog_->button_add,
1362 scex(_("Modify|#M")).c_str(), 1);
1364 setEnabled(dialog_->button_add, false);
1365 setEnabled(dialog_->button_delete, true);
1367 fl_unfreeze_form(dialog_->form);
1372 bool FormPreferences::Formats::erase()
1374 string const name = fl_get_input(dialog_->input_format);
1376 if (local_converters.formatIsUsed(name)) {
1377 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1378 "Remove the converter first."));
1379 setEnabled(dialog_->button_delete, false);
1383 local_formats.erase(name);
1389 bool FormPreferences::Formats::Input()
1391 string const name = fl_get_input(dialog_->input_format);
1392 int const sel = local_formats.getNumber(name);
1393 fl_freeze_form(dialog_->form);
1396 fl_set_object_label(dialog_->button_add,
1397 idex(_("Add|#A")).c_str());
1398 fl_set_button_shortcut(dialog_->button_add,
1399 scex(_("Add|#A")).c_str(), 1);
1401 fl_deselect_browser(dialog_->browser_all);
1402 setEnabled(dialog_->button_delete, false);
1405 fl_set_object_label(dialog_->button_add,
1406 idex(_("Modify|#M")).c_str());
1407 fl_set_button_shortcut(dialog_->button_add,
1408 scex(_("Modify|#M")).c_str(), 1);
1410 int const top = max(sel-5, 0);
1411 fl_set_browser_topline(dialog_->browser_all, top);
1412 fl_select_browser_line(dialog_->browser_all, sel+1);
1414 setEnabled(dialog_->button_add, true);
1415 setEnabled(dialog_->button_delete, true);
1418 string const prettyname = fl_get_input(dialog_->input_gui_name);
1419 bool const enable = !(name.empty() || prettyname.empty());
1420 setEnabled(dialog_->button_add, enable);
1422 fl_unfreeze_form(dialog_->form);
1427 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1432 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1434 return dialog_.get();
1438 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1440 rc.date_insert_format =
1441 fl_get_input(dialog_->input_date_format);
1445 void FormPreferences::InputsMisc::build()
1447 dialog_.reset(build_preferences_inputs_misc(&parent_));
1449 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1451 // set up the feedback mechanism
1452 setPrehandler(dialog_->input_date_format);
1457 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1459 if (ob == dialog_->input_date_format)
1460 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1465 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1467 fl_set_input(dialog_->input_date_format,
1468 rc.date_insert_format.c_str());
1472 FormPreferences::Interface::Interface(FormPreferences & p)
1477 FD_preferences_interface const * FormPreferences::Interface::dialog()
1479 return dialog_.get();
1483 void FormPreferences::Interface::apply(LyXRC & rc) const
1485 rc.popup_normal_font =
1486 fl_get_input(dialog_->input_popup_normal_font);
1487 rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1488 rc.popup_font_encoding =
1489 fl_get_input(dialog_->input_popup_font_encoding);
1490 rc.bind_file = fl_get_input(dialog_->input_bind_file);
1491 rc.ui_file = fl_get_input(dialog_->input_ui_file);
1495 void FormPreferences::Interface::build()
1497 dialog_.reset(build_preferences_interface(&parent_));
1499 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1500 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1501 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1502 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1503 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1505 // set up the feedback mechanism
1506 setPrehandler(dialog_->input_popup_normal_font);
1507 setPrehandler(dialog_->input_popup_bold_font);
1508 setPrehandler(dialog_->input_popup_font_encoding);
1509 setPrehandler(dialog_->input_bind_file);
1510 setPrehandler(dialog_->button_bind_file_browse);
1511 setPrehandler(dialog_->input_ui_file);
1512 setPrehandler(dialog_->button_ui_file_browse);
1517 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1519 if (ob == dialog_->input_popup_normal_font)
1520 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1521 if (ob == dialog_->input_popup_bold_font)
1522 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1523 if (ob == dialog_->input_popup_font_encoding)
1524 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1525 if (ob == dialog_->input_bind_file)
1526 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1527 if (ob == dialog_->input_ui_file)
1528 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1533 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1535 if (ob == dialog_->button_bind_file_browse) {
1536 string f = parent_.controller().browsebind(
1537 fl_get_input(dialog_->input_bind_file));
1539 fl_set_input(dialog_->input_bind_file, f.c_str());
1540 } else if (ob == dialog_->button_ui_file_browse) {
1541 string f = parent_.controller().browseUI(
1542 fl_get_input(dialog_->input_ui_file));
1544 fl_set_input(dialog_->input_ui_file, f.c_str());
1551 void FormPreferences::Interface::update(LyXRC const & rc)
1553 fl_set_input(dialog_->input_popup_normal_font,
1554 rc.popup_normal_font.c_str());
1555 fl_set_input(dialog_->input_popup_bold_font,
1556 rc.popup_bold_font.c_str());
1557 fl_set_input(dialog_->input_popup_font_encoding,
1558 rc.popup_font_encoding.c_str());
1559 fl_set_input(dialog_->input_bind_file,
1560 rc.bind_file.c_str());
1561 fl_set_input(dialog_->input_ui_file,
1562 rc.ui_file.c_str());
1566 FormPreferences::Language::Language(FormPreferences & p)
1571 FD_preferences_language const * FormPreferences::Language::dialog()
1573 return dialog_.get();
1577 void FormPreferences::Language::apply(LyXRC & rc)
1579 int const pos = combo_default_lang->get();
1580 rc.default_language = lang_[pos-1];
1582 int button = fl_get_button(dialog_->check_use_kbmap);
1583 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1584 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1586 button = !(name_1.empty() && name_2.empty());
1587 rc.use_kbmap = static_cast<bool>(button);
1590 rc.primary_kbmap = name_1;
1591 rc.secondary_kbmap = name_2;
1594 button = fl_get_button(dialog_->check_rtl_support);
1595 rc.rtl_support = static_cast<bool>(button);
1597 button = fl_get_button(dialog_->check_mark_foreign);
1598 rc.mark_foreign_language = static_cast<bool>(button);
1600 button = fl_get_button(dialog_->check_auto_begin);
1601 rc.language_auto_begin = static_cast<bool>(button);
1603 button = fl_get_button(dialog_->check_auto_end);
1604 rc.language_auto_end = static_cast<bool>(button);
1606 button = fl_get_button(dialog_->check_use_babel);
1607 rc.language_use_babel = static_cast<bool>(button);
1609 button = fl_get_button(dialog_->check_global_options);
1610 rc.language_global_options = static_cast<bool>(button);
1612 rc.language_package = fl_get_input(dialog_->input_package);
1613 rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1614 rc.language_command_end = fl_get_input(dialog_->input_command_end);
1616 // Ensure that all is self-consistent.
1621 void FormPreferences::Language::build()
1623 dialog_.reset(build_preferences_language(&parent_));
1625 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1626 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1627 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1629 // Store the lang identifiers for later
1630 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1631 lang_ = getSecond(langs);
1633 // The default_language is a combo-box and has to be inserted manually
1634 fl_freeze_form(dialog_->form);
1635 fl_addto_form(dialog_->form);
1637 FL_OBJECT * obj = dialog_->choice_default_lang;
1638 fl_deactivate_object(dialog_->choice_default_lang);
1639 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1640 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
1641 combo_default_lang->shortcut("#L",1);
1642 combo_default_lang->setcallback(ComboCB, &parent_);
1644 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1645 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1646 for (; lit != lend; ++lit) {
1647 combo_default_lang->addto(lit->first);
1649 combo_default_lang->select(1);
1652 fl_unfreeze_form(dialog_->form);
1654 // set up the feedback mechanism
1655 setPrehandler(dialog_->input_package);
1656 setPrehandler(dialog_->check_use_kbmap);
1658 // This is safe, as nothing is done to the pointer, other than
1659 // to use its address in a block-if statement.
1660 // No it's not! Leads to crash.
1662 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1663 // C_FormPreferencesFeedbackCB);
1665 setPrehandler(dialog_->input_kbmap1);
1666 setPrehandler(dialog_->input_kbmap2);
1667 setPrehandler(dialog_->check_rtl_support);
1668 setPrehandler(dialog_->check_mark_foreign);
1669 setPrehandler(dialog_->check_auto_begin);
1670 setPrehandler(dialog_->check_auto_end);
1671 setPrehandler(dialog_->check_use_babel);
1672 setPrehandler(dialog_->check_global_options);
1673 setPrehandler(dialog_->input_command_begin);
1674 setPrehandler(dialog_->input_command_end);
1676 // Activate/Deactivate the input fields dependent on the state of the
1683 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1685 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1686 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1687 if (ob == dialog_->check_use_kbmap)
1688 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1689 if (ob == dialog_->input_kbmap1)
1690 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1691 if (ob == dialog_->input_kbmap2)
1692 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1693 if (ob == dialog_->check_rtl_support)
1694 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1695 if (ob == dialog_->check_mark_foreign)
1696 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1697 if (ob == dialog_->check_auto_begin)
1698 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1699 if (ob == dialog_->check_auto_end)
1700 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1701 if (ob == dialog_->check_use_babel)
1702 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1703 if (ob == dialog_->check_global_options)
1704 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1705 if (ob == dialog_->input_package)
1706 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1707 if (ob == dialog_->input_command_begin)
1708 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1709 if (ob == dialog_->input_command_end)
1710 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1715 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1717 bool activate = true;
1719 // !ob if function is called from Language::build() to de/activate
1721 // otherwise the function is called by an xforms CB via input().
1722 if (!ob || ob == dialog_->check_use_kbmap) {
1723 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1724 setEnabled(dialog_->button_kbmap1_browse, enable);
1725 setEnabled(dialog_->button_kbmap2_browse, enable);
1726 setEnabled(dialog_->input_kbmap1, enable);
1727 setEnabled(dialog_->input_kbmap2, enable);
1730 if (ob == dialog_->button_kbmap1_browse) {
1731 string f = parent_.controller().browsekbmap(
1732 fl_get_input(dialog_->input_kbmap1));
1734 fl_set_input(dialog_->input_kbmap1, f.c_str());
1735 } else if (ob == dialog_->button_kbmap2_browse) {
1736 string f = parent_.controller().browsekbmap(
1737 fl_get_input(dialog_->input_kbmap2));
1739 fl_set_input(dialog_->input_kbmap2, f.c_str());
1746 void FormPreferences::Language::update(LyXRC const & rc)
1748 fl_set_button(dialog_->check_use_kbmap,
1751 int const pos = int(findPos(lang_, rc.default_language));
1752 combo_default_lang->select(pos + 1);
1755 fl_set_input(dialog_->input_kbmap1,
1756 rc.primary_kbmap.c_str());
1757 fl_set_input(dialog_->input_kbmap2,
1758 rc.secondary_kbmap.c_str());
1760 fl_set_input(dialog_->input_kbmap1, "");
1761 fl_set_input(dialog_->input_kbmap2, "");
1764 fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1765 fl_set_button(dialog_->check_mark_foreign,
1766 rc.mark_foreign_language);
1767 fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1768 fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1769 fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1770 fl_set_button(dialog_->check_global_options,
1771 rc.language_global_options);
1773 fl_set_input(dialog_->input_package,
1774 rc.language_package.c_str());
1775 fl_set_input(dialog_->input_command_begin,
1776 rc.language_command_begin.c_str());
1777 fl_set_input(dialog_->input_command_end,
1778 rc.language_command_end.c_str());
1780 // Activate/Deactivate the input fields dependent on the state of the
1786 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1788 FormPreferences * pre = static_cast<FormPreferences*>(v);
1789 // This is safe, as nothing is done to the pointer, other than
1790 // to use its address in a block-if statement.
1791 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1795 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1800 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1802 return dialog_.get();
1806 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1808 rc.auto_region_delete =
1809 fl_get_button(dialog_->check_auto_region_delete);
1810 rc.cursor_follows_scrollbar =
1811 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1812 rc.dialogs_iconify_with_main =
1813 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1814 rc.preview = fl_get_button(dialog_->check_preview_latex);
1815 rc.autosave = static_cast<unsigned int>
1816 (fl_get_counter_value(dialog_->counter_autosave));
1817 rc.wheel_jump = static_cast<unsigned int>
1818 (fl_get_counter_value(dialog_->counter_wm_jump));
1821 // grfx::DisplayType old_value = rc.display_graphics;
1822 switch (fl_get_choice(dialog_->choice_display)) {
1823 case 4: rc.display_graphics = grfx::NoDisplay; break;
1824 case 3: rc.display_graphics = grfx::ColorDisplay; break;
1825 case 2: rc.display_graphics = grfx::GrayscaleDisplay; break;
1826 case 1: rc.display_graphics = grfx::MonochromeDisplay; break;
1827 default: rc.display_graphics = grfx::ColorDisplay; break;
1830 #ifdef WITH_WARNINGS
1831 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1834 if (old_value != rc.display_graphics) {
1835 grfx::GCache & gc = grfx::GCache::get();
1842 void FormPreferences::LnFmisc::build()
1844 dialog_.reset(build_preferences_lnf_misc(&parent_));
1846 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1847 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1849 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1850 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1852 // set up the feedback mechanism
1853 setPrehandler(dialog_->check_auto_region_delete);
1854 setPrehandler(dialog_->counter_autosave);
1855 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1856 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1857 setPrehandler(dialog_->check_preview_latex);
1858 setPrehandler(dialog_->counter_wm_jump);
1860 fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
1865 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1867 if (ob == dialog_->check_auto_region_delete)
1868 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
1869 if (ob == dialog_->check_cursor_follows_scrollbar)
1870 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1871 if (ob == dialog_->check_dialogs_iconify_with_main)
1872 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1873 if (ob == dialog_->check_preview_latex)
1874 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
1875 if (ob == dialog_->counter_autosave)
1876 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
1877 if (ob == dialog_->counter_wm_jump)
1878 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
1879 if (ob == dialog_->choice_display)
1880 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1885 void FormPreferences::LnFmisc::update(LyXRC const & rc)
1887 fl_set_button(dialog_->check_auto_region_delete,
1888 rc.auto_region_delete);
1889 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1890 rc.cursor_follows_scrollbar);
1891 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1892 rc.dialogs_iconify_with_main);
1893 fl_set_button(dialog_->check_preview_latex,
1895 fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
1896 fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
1898 switch (rc.display_graphics) {
1899 case grfx::NoDisplay: fl_set_choice(dialog_->choice_display, 4); break;
1900 case grfx::ColorDisplay: fl_set_choice(dialog_->choice_display, 3); break;
1901 case grfx::GrayscaleDisplay: fl_set_choice(dialog_->choice_display, 2); break;
1902 case grfx::MonochromeDisplay: fl_set_choice(dialog_->choice_display, 1); break;
1903 default: fl_set_choice(dialog_->choice_display, 3); break;
1908 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1913 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1915 return dialog_.get();
1919 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
1921 rc.ascii_linelen = static_cast<unsigned int>
1922 (fl_get_counter_value(dialog_->counter_line_len));
1923 rc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1926 fl_get_choice(dialog_->choice_default_papersize) - 1;
1927 rc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1929 rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1930 rc.chktex_command = fl_get_input(dialog_->input_checktex);
1931 rc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1932 rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1936 void FormPreferences::OutputsMisc::build()
1938 dialog_.reset(build_preferences_outputs_misc(&parent_));
1940 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1942 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1943 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1944 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1945 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1946 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1948 fl_addto_choice(dialog_->choice_default_papersize,
1949 _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1951 // set up the feedback mechanism
1952 setPrehandler(dialog_->counter_line_len);
1953 setPrehandler(dialog_->input_tex_encoding);
1954 setPrehandler(dialog_->choice_default_papersize);
1955 setPrehandler(dialog_->input_ascii_roff);
1956 setPrehandler(dialog_->input_checktex);
1957 setPrehandler(dialog_->input_paperoption);
1958 setPrehandler(dialog_->check_autoreset_classopt);
1963 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1965 if (ob == dialog_->counter_line_len)
1966 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
1967 if (ob == dialog_->input_tex_encoding)
1968 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
1969 if (ob == dialog_->input_ascii_roff)
1970 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1971 if (ob == dialog_->input_checktex)
1972 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
1973 if (ob == dialog_->choice_default_papersize)
1974 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1975 if (ob == dialog_->input_paperoption)
1976 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
1977 if (ob == dialog_->check_autoreset_classopt)
1978 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
1983 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
1985 fl_set_counter_value(dialog_->counter_line_len,
1987 fl_set_input(dialog_->input_tex_encoding,
1988 rc.fontenc.c_str());
1989 fl_set_choice(dialog_->choice_default_papersize,
1990 rc.default_papersize + 1);
1991 fl_set_input(dialog_->input_ascii_roff,
1992 rc.ascii_roff_command.c_str());
1993 fl_set_input(dialog_->input_checktex,
1994 rc.chktex_command.c_str());
1995 fl_set_input(dialog_->input_paperoption,
1996 rc.view_dvi_paper_option.c_str());
1997 fl_set_button(dialog_->check_autoreset_classopt,
1998 rc.auto_reset_options);
2003 FormPreferences::Paths::Paths(FormPreferences & p)
2008 FD_preferences_paths const * FormPreferences::Paths::dialog()
2010 return dialog_.get();
2014 void FormPreferences::Paths::apply(LyXRC & rc)
2016 rc.document_path = fl_get_input(dialog_->input_default_path);
2017 rc.template_path = fl_get_input(dialog_->input_template_path);
2019 int button = fl_get_button(dialog_->check_use_temp_dir);
2020 string str = fl_get_input(dialog_->input_temp_dir);
2024 rc.use_tempdir = button;
2025 rc.tempdir_path = str;
2027 button = fl_get_button(dialog_->check_last_files);
2028 str = fl_get_input(dialog_->input_lastfiles);
2029 if (!button) str.erase();
2031 rc.check_lastfiles = button;
2033 rc.num_lastfiles = static_cast<unsigned int>
2034 (fl_get_counter_value(dialog_->counter_lastfiles));
2036 button = fl_get_button(dialog_->check_make_backups);
2037 str = fl_get_input(dialog_->input_backup_path);
2041 rc.make_backup = button;
2042 rc.backupdir_path = str;
2044 rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2051 void FormPreferences::Paths::build()
2053 dialog_.reset(build_preferences_paths(&parent_));
2055 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2056 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2057 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2058 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2059 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2060 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2061 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2063 // set up the feedback mechanism
2064 setPrehandler(dialog_->input_default_path);
2065 setPrehandler(dialog_->counter_lastfiles);
2066 setPrehandler(dialog_->input_template_path);
2067 setPrehandler(dialog_->check_last_files);
2068 setPrehandler(dialog_->input_lastfiles);
2069 setPrehandler(dialog_->check_make_backups);
2070 setPrehandler(dialog_->input_backup_path);
2071 setPrehandler(dialog_->input_serverpipe);
2072 setPrehandler(dialog_->input_temp_dir);
2073 setPrehandler(dialog_->check_use_temp_dir);
2078 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2080 if (ob == dialog_->input_default_path)
2081 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2082 if (ob == dialog_->input_template_path)
2083 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2084 if (ob == dialog_->check_use_temp_dir)
2085 return LyXRC::getDescription(LyXRC::RC_USETEMPDIR);
2086 if (ob == dialog_->input_temp_dir)
2087 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2088 if (ob == dialog_->check_last_files)
2089 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2090 if (ob == dialog_->input_lastfiles)
2091 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
2092 if (ob == dialog_->counter_lastfiles)
2093 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2094 if (ob == dialog_->check_make_backups)
2095 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2096 if (ob == dialog_->input_backup_path)
2097 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2098 if (ob == dialog_->input_serverpipe)
2099 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2104 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2106 bool activate = true;
2108 // !ob if function is called from Paths::update() to de/activate
2110 // otherwise the function is called by an xforms CB via input().
2111 if (!ob || ob == dialog_->check_use_temp_dir) {
2112 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2113 setEnabled(dialog_->input_temp_dir, enable);
2116 if (!ob || ob == dialog_->check_last_files) {
2117 bool const enable = fl_get_button(dialog_->check_last_files);
2118 setEnabled(dialog_->input_lastfiles, enable);
2121 if (!ob || ob == dialog_->check_make_backups) {
2122 bool const enable = fl_get_button(dialog_->check_make_backups);
2123 setEnabled(dialog_->input_backup_path, enable);
2126 if (!ob || ob == dialog_->input_default_path) {
2127 string const name = fl_get_input(dialog_->input_default_path);
2128 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2129 parent_.postWarning(RWInfo::ErrorMessage());
2134 if (!ob || ob == dialog_->input_template_path) {
2135 string const name = fl_get_input(dialog_->input_template_path);
2136 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2137 parent_.postWarning(RWInfo::ErrorMessage());
2142 if (!ob || ob == dialog_->input_temp_dir) {
2143 string const name = fl_get_input(dialog_->input_temp_dir);
2144 if (fl_get_button(dialog_->check_make_backups)
2146 && !RWInfo::WriteableDir(name)) {
2147 parent_.postWarning(RWInfo::ErrorMessage());
2152 if (!ob || ob == dialog_->input_backup_path) {
2153 string const name = fl_get_input(dialog_->input_backup_path);
2154 if (fl_get_button(dialog_->check_make_backups)
2156 && !RWInfo::WriteableDir(name)) {
2157 parent_.postWarning(RWInfo::ErrorMessage());
2162 if (!ob || ob == dialog_->input_lastfiles) {
2163 string const name = fl_get_input(dialog_->input_lastfiles);
2164 if (fl_get_button(dialog_->check_last_files)
2166 && !RWInfo::WriteableFile(name)) {
2167 parent_.postWarning(RWInfo::ErrorMessage());
2172 if (!ob || ob == dialog_->input_serverpipe) {
2173 string const name = fl_get_input(dialog_->input_serverpipe);
2174 if (!name.empty()) {
2175 // strip off the extension
2176 string const str = ChangeExtension(name, "");
2177 if (!RWInfo::WriteableFile(str + ".in")) {
2178 parent_.postWarning(RWInfo::ErrorMessage());
2181 if (!RWInfo::WriteableFile(str + ".out")) {
2182 parent_.postWarning(RWInfo::ErrorMessage());
2188 if (ob == dialog_->button_default_path_browse) {
2189 string f = parent_.controller().browsedir(
2190 fl_get_input(dialog_->input_default_path), _("Default path"));
2192 fl_set_input(dialog_->input_default_path, f.c_str());
2193 } else if (ob == dialog_->button_template_path_browse) {
2194 string f = parent_.controller().browsedir(
2195 fl_get_input(dialog_->input_template_path), _("Template path"));
2197 fl_set_input(dialog_->input_template_path, f.c_str());
2198 } else if (ob == dialog_->button_temp_dir_browse) {
2199 string f = parent_.controller().browsedir(
2200 fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2202 fl_set_input(dialog_->input_temp_dir, f.c_str());
2203 } else if (ob == dialog_->button_lastfiles_browse) {
2204 string f = parent_.controller().browse(
2205 fl_get_input(dialog_->input_lastfiles), _("Last files"));
2207 fl_set_input(dialog_->input_lastfiles, f.c_str());
2208 } else if (ob == dialog_->button_backup_path_browse) {
2209 string f = parent_.controller().browsedir(
2210 fl_get_input(dialog_->input_backup_path), _("Backup path"));
2212 fl_set_input(dialog_->input_backup_path, f.c_str());
2213 } else if (ob == dialog_->button_serverpipe_browse) {
2214 string f = parent_.controller().browse(
2215 fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2217 fl_set_input(dialog_->input_serverpipe, f.c_str());
2224 void FormPreferences::Paths::update(LyXRC const & rc)
2226 fl_set_input(dialog_->input_default_path,
2227 rc.document_path.c_str());
2228 fl_set_input(dialog_->input_template_path,
2229 rc.template_path.c_str());
2233 str = rc.backupdir_path;
2235 fl_set_button(dialog_->check_make_backups,
2237 fl_set_input(dialog_->input_backup_path, str.c_str());
2241 str = rc.tempdir_path;
2243 fl_set_button(dialog_->check_use_temp_dir,
2245 fl_set_input(dialog_->input_temp_dir, str.c_str());
2248 if (rc.check_lastfiles)
2251 fl_set_button(dialog_->check_last_files,
2252 rc.check_lastfiles);
2253 fl_set_input(dialog_->input_lastfiles, str.c_str());
2254 fl_set_counter_value(dialog_->counter_lastfiles,
2257 fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2259 // Activate/Deactivate the input fields dependent on the state of the
2265 FormPreferences::Printer::Printer(FormPreferences & p)
2270 FD_preferences_printer const * FormPreferences::Printer::dialog()
2272 return dialog_.get();
2276 void FormPreferences::Printer::apply(LyXRC & rc) const
2278 rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2279 rc.print_command = fl_get_input(dialog_->input_command);
2280 rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2281 rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2282 rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2283 rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2284 rc.print_file_extension =
2285 fl_get_input(dialog_->input_file_extension);
2286 rc.print_spool_command =
2287 fl_get_input(dialog_->input_spool_command);
2288 rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2289 rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2290 rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2291 rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2292 rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2293 rc.print_to_file = fl_get_input(dialog_->input_to_file);
2294 rc.print_extra_options =
2295 fl_get_input(dialog_->input_extra_options);
2296 rc.print_spool_printerprefix =
2297 fl_get_input(dialog_->input_spool_prefix);
2298 rc.print_paper_dimension_flag =
2299 fl_get_input(dialog_->input_paper_size);
2300 rc.printer = fl_get_input(dialog_->input_name);
2305 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2307 if (ob == dialog_->input_command)
2308 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2309 if (ob == dialog_->check_adapt_output)
2310 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2311 if (ob == dialog_->input_to_printer)
2312 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2313 if (ob == dialog_->input_to_file)
2314 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2315 if (ob == dialog_->input_file_extension)
2316 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2317 if (ob == dialog_->input_extra_options)
2318 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2319 if (ob == dialog_->input_spool_command)
2320 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2321 if (ob == dialog_->input_spool_prefix)
2322 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2323 if (ob == dialog_->input_name)
2324 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2325 if (ob == dialog_->input_even_pages)
2326 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2327 if (ob == dialog_->input_odd_pages)
2328 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2329 if (ob == dialog_->input_page_range)
2330 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2331 if (ob == dialog_->input_reverse)
2332 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2333 if (ob == dialog_->input_landscape)
2334 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2335 if (ob == dialog_->input_copies)
2336 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2337 if (ob == dialog_->input_collated)
2338 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2339 if (ob == dialog_->input_paper_type)
2340 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2341 if (ob == dialog_->input_paper_size)
2342 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2347 void FormPreferences::Printer::build()
2349 dialog_.reset(build_preferences_printer(&parent_));
2351 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2352 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2353 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2354 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2355 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2356 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2357 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2358 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2359 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2360 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2361 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2362 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2363 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2364 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2365 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2366 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2367 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2369 // set up the feedback mechanism
2370 setPrehandler(dialog_->input_command);
2371 setPrehandler(dialog_->input_page_range);
2372 setPrehandler(dialog_->input_copies);
2373 setPrehandler(dialog_->input_reverse);
2374 setPrehandler(dialog_->input_to_printer);
2375 setPrehandler(dialog_->input_file_extension);
2376 setPrehandler(dialog_->input_spool_command);
2377 setPrehandler(dialog_->input_paper_type);
2378 setPrehandler(dialog_->input_even_pages);
2379 setPrehandler(dialog_->input_odd_pages);
2380 setPrehandler(dialog_->input_collated);
2381 setPrehandler(dialog_->input_landscape);
2382 setPrehandler(dialog_->input_to_file);
2383 setPrehandler(dialog_->input_extra_options);
2384 setPrehandler(dialog_->input_spool_prefix);
2385 setPrehandler(dialog_->input_paper_size);
2386 setPrehandler(dialog_->input_name);
2387 setPrehandler(dialog_->check_adapt_output);
2391 void FormPreferences::Printer::update(LyXRC const & rc)
2393 fl_set_button(dialog_->check_adapt_output,
2394 rc.print_adapt_output);
2395 fl_set_input(dialog_->input_command,
2396 rc.print_command.c_str());
2397 fl_set_input(dialog_->input_page_range,
2398 rc.print_pagerange_flag.c_str());
2399 fl_set_input(dialog_->input_copies,
2400 rc.print_copies_flag.c_str());
2401 fl_set_input(dialog_->input_reverse,
2402 rc.print_reverse_flag.c_str());
2403 fl_set_input(dialog_->input_to_printer,
2404 rc.print_to_printer.c_str());
2405 fl_set_input(dialog_->input_file_extension,
2406 rc.print_file_extension.c_str());
2407 fl_set_input(dialog_->input_spool_command,
2408 rc.print_spool_command.c_str());
2409 fl_set_input(dialog_->input_paper_type,
2410 rc.print_paper_flag.c_str());
2411 fl_set_input(dialog_->input_even_pages,
2412 rc.print_evenpage_flag.c_str());
2413 fl_set_input(dialog_->input_odd_pages,
2414 rc.print_oddpage_flag.c_str());
2415 fl_set_input(dialog_->input_collated,
2416 rc.print_collcopies_flag.c_str());
2417 fl_set_input(dialog_->input_landscape,
2418 rc.print_landscape_flag.c_str());
2419 fl_set_input(dialog_->input_to_file,
2420 rc.print_to_file.c_str());
2421 fl_set_input(dialog_->input_extra_options,
2422 rc.print_extra_options.c_str());
2423 fl_set_input(dialog_->input_spool_prefix,
2424 rc.print_spool_printerprefix.c_str());
2425 fl_set_input(dialog_->input_paper_size,
2426 rc.print_paper_dimension_flag.c_str());
2427 fl_set_input(dialog_->input_name,
2428 rc.printer.c_str());
2432 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2437 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2439 return dialog_.get();
2443 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2445 bool changed = false;
2447 pair<string, string> tmp =
2448 parseFontName(fl_get_input(dialog_->input_roman));
2449 if (rc.roman_font_name != tmp.first ||
2450 rc.roman_font_foundry != tmp.second) {
2452 rc.roman_font_name = tmp.first;
2453 rc.roman_font_foundry = tmp.second;
2456 tmp = parseFontName(fl_get_input(dialog_->input_sans));
2457 if (rc.sans_font_name != tmp.first ||
2458 rc.sans_font_foundry != tmp.second) {
2460 rc.sans_font_name = tmp.first;
2461 rc.sans_font_foundry = tmp.second;
2464 tmp = parseFontName(fl_get_input(dialog_->input_typewriter));
2465 if (rc.typewriter_font_name != tmp.first ||
2466 rc.typewriter_font_foundry != tmp.second) {
2468 rc.typewriter_font_name = tmp.first;
2469 rc.typewriter_font_foundry = tmp.second;
2472 string str = fl_get_input(dialog_->input_screen_encoding);
2473 if (rc.font_norm != str) {
2478 bool button = fl_get_button(dialog_->check_scalable);
2479 if (rc.use_scalable_fonts != button) {
2481 rc.use_scalable_fonts = button;
2484 unsigned int ivalue = static_cast<unsigned int>
2485 (fl_get_counter_value(dialog_->counter_zoom));
2486 if (rc.zoom != ivalue) {
2491 ivalue = static_cast<unsigned int>
2492 (fl_get_counter_value(dialog_->counter_dpi));
2493 if (rc.dpi != ivalue) {
2498 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2499 if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2501 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2504 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2505 if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2507 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2510 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2511 if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2513 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2516 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2517 if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2519 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2522 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2523 if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2525 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2528 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2529 if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2531 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2534 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2535 if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2537 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2540 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2541 if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2543 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2546 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2547 if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2549 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2552 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2553 if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2555 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2559 // Now update the buffers
2560 // Can anything below here affect the redraw process?
2561 parent_.controller().updateScreenFonts();
2566 void FormPreferences::ScreenFonts::build()
2568 dialog_.reset(build_preferences_screen_fonts(&parent_));
2570 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2571 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2573 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2574 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2575 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2576 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2577 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2578 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2579 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2580 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2581 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2582 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2583 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2584 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2585 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2586 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2587 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2588 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2590 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2591 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2592 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2593 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2594 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2595 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2596 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2597 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2598 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2599 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2601 // set up the feedback mechanism
2602 setPrehandler(dialog_->input_roman);
2603 setPrehandler(dialog_->input_sans);
2604 setPrehandler(dialog_->input_typewriter);
2605 setPrehandler(dialog_->counter_zoom);
2606 setPrehandler(dialog_->counter_dpi);
2607 setPrehandler(dialog_->check_scalable);
2608 setPrehandler(dialog_->input_screen_encoding);
2609 setPrehandler(dialog_->input_tiny);
2610 setPrehandler(dialog_->input_script);
2611 setPrehandler(dialog_->input_footnote);
2612 setPrehandler(dialog_->input_small);
2613 setPrehandler(dialog_->input_large);
2614 setPrehandler(dialog_->input_larger);
2615 setPrehandler(dialog_->input_largest);
2616 setPrehandler(dialog_->input_normal);
2617 setPrehandler(dialog_->input_huge);
2618 setPrehandler(dialog_->input_huger);
2623 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2625 if (ob == dialog_->input_roman)
2626 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2627 if (ob == dialog_->input_sans)
2628 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2629 if (ob == dialog_->input_typewriter)
2630 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2631 if (ob == dialog_->check_scalable)
2632 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2633 if (ob == dialog_->input_screen_encoding)
2634 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2635 if (ob == dialog_->counter_zoom)
2636 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2637 if (ob == dialog_->counter_dpi)
2638 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2639 if (ob == dialog_->input_tiny
2640 || ob == dialog_->input_script
2641 || ob == dialog_->input_footnote
2642 || ob == dialog_->input_small
2643 || ob == dialog_->input_large
2644 || ob == dialog_->input_larger
2645 || ob == dialog_->input_larger
2646 || ob == dialog_->input_largest
2647 || ob == dialog_->input_normal
2648 || ob == dialog_->input_huge
2649 || ob == dialog_->input_huger)
2650 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2655 bool FormPreferences::ScreenFonts::input()
2657 bool activate = true;
2660 // Make sure that all fonts all have positive entries
2661 // Also note that an empty entry is returned as 0.0 by strToDbl
2662 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2663 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2664 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2665 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2666 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2667 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2668 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2669 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2670 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2671 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2673 str = _("Fonts must be positive!");
2675 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2676 // Fontsizes -- tiny < script < footnote etc.
2677 strToDbl(fl_get_input(dialog_->input_script)) ||
2678 strToDbl(fl_get_input(dialog_->input_script)) >
2679 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2680 strToDbl(fl_get_input(dialog_->input_footnote)) >
2681 strToDbl(fl_get_input(dialog_->input_small)) ||
2682 strToDbl(fl_get_input(dialog_->input_small)) >
2683 strToDbl(fl_get_input(dialog_->input_normal)) ||
2684 strToDbl(fl_get_input(dialog_->input_normal)) >
2685 strToDbl(fl_get_input(dialog_->input_large)) ||
2686 strToDbl(fl_get_input(dialog_->input_large)) >
2687 strToDbl(fl_get_input(dialog_->input_larger)) ||
2688 strToDbl(fl_get_input(dialog_->input_larger)) >
2689 strToDbl(fl_get_input(dialog_->input_largest)) ||
2690 strToDbl(fl_get_input(dialog_->input_largest)) >
2691 strToDbl(fl_get_input(dialog_->input_huge)) ||
2692 strToDbl(fl_get_input(dialog_->input_huge)) >
2693 strToDbl(fl_get_input(dialog_->input_huger))) {
2696 str = _("Fonts must be input in the order Tiny > Smallest > Smaller > Small > Normal > Large > Larger > Largest > Huge > Huger.");
2700 parent_.postWarning(str);
2706 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2708 fl_set_input(dialog_->input_roman,
2709 makeFontName(rc.roman_font_name,
2710 rc.roman_font_foundry).c_str());
2711 fl_set_input(dialog_->input_sans,
2712 makeFontName(rc.sans_font_name,
2713 rc.sans_font_foundry).c_str());
2714 fl_set_input(dialog_->input_typewriter,
2715 makeFontName(rc.typewriter_font_name,
2716 rc.typewriter_font_foundry).c_str());
2717 fl_set_input(dialog_->input_screen_encoding,
2718 rc.font_norm.c_str());
2719 fl_set_button(dialog_->check_scalable,
2720 rc.use_scalable_fonts);
2721 fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2722 fl_set_counter_value(dialog_->counter_dpi, rc.dpi);
2723 fl_set_input(dialog_->input_tiny,
2724 tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2725 fl_set_input(dialog_->input_script,
2726 tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2727 fl_set_input(dialog_->input_footnote,
2728 tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2729 fl_set_input(dialog_->input_small,
2730 tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2731 fl_set_input(dialog_->input_normal,
2732 tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2733 fl_set_input(dialog_->input_large,
2734 tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2735 fl_set_input(dialog_->input_larger,
2736 tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2737 fl_set_input(dialog_->input_largest,
2738 tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2739 fl_set_input(dialog_->input_huge,
2740 tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2741 fl_set_input(dialog_->input_huger,
2742 tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2747 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2752 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2754 return dialog_.get();
2758 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2760 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2761 choice = trim(choice);
2763 rc.isp_command = choice;
2766 // If spell checker == "none", all other input set to off.
2767 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2768 rc.isp_use_alt_lang = false;
2769 rc.isp_alt_lang.erase();
2771 rc.isp_use_esc_chars = false;
2772 rc.isp_esc_chars.erase();
2774 rc.isp_use_pers_dict = false;
2775 rc.isp_pers_dict.erase();
2777 rc.isp_accept_compound = false;
2778 rc.isp_use_input_encoding = false;
2781 int button = fl_get_button(dialog_->check_alt_lang);
2782 choice = fl_get_input(dialog_->input_alt_lang);
2783 if (button && choice.empty()) button = 0;
2784 if (!button) choice.erase();
2786 rc.isp_use_alt_lang = static_cast<bool>(button);
2787 rc.isp_alt_lang = choice;
2789 button = fl_get_button(dialog_->check_escape_chars);
2790 choice = fl_get_input(dialog_->input_escape_chars);
2791 if (button && choice.empty()) button = 0;
2792 if (!button) choice.erase();
2794 rc.isp_use_esc_chars = static_cast<bool>(button);
2795 rc.isp_esc_chars = choice;
2797 button = fl_get_button(dialog_->check_personal_dict);
2798 choice = fl_get_input(dialog_->input_personal_dict);
2799 if (button && choice.empty()) button = 0;
2800 if (!button) choice.erase();
2802 rc.isp_use_pers_dict = static_cast<bool>(button);
2803 rc.isp_pers_dict = choice;
2805 button = fl_get_button(dialog_->check_compound_words);
2806 rc.isp_accept_compound = static_cast<bool>(button);
2808 button = fl_get_button(dialog_->check_input_enc);
2809 rc.isp_use_input_encoding = static_cast<bool>(button);
2820 void FormPreferences::SpellOptions::build()
2822 dialog_.reset(build_preferences_spelloptions(&parent_));
2824 fl_addto_choice(dialog_->choice_spell_command,
2825 _(" ispell | aspell "));
2826 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2827 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2828 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2830 // set up the feedback mechanism
2831 setPrehandler(dialog_->choice_spell_command);
2832 setPrehandler(dialog_->check_alt_lang);
2833 setPrehandler(dialog_->input_alt_lang);
2834 setPrehandler(dialog_->check_escape_chars);
2835 setPrehandler(dialog_->input_escape_chars);
2836 setPrehandler(dialog_->check_personal_dict);
2837 setPrehandler(dialog_->input_personal_dict);
2838 setPrehandler(dialog_->button_personal_dict);
2839 setPrehandler(dialog_->check_compound_words);
2840 setPrehandler(dialog_->check_input_enc);
2845 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2847 if (ob == dialog_->choice_spell_command)
2848 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2849 if (ob == dialog_->check_alt_lang)
2850 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2851 if (ob == dialog_->input_alt_lang)
2852 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2853 if (ob == dialog_->check_escape_chars)
2854 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2855 if (ob == dialog_->input_escape_chars)
2856 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2857 if (ob == dialog_->check_personal_dict)
2858 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2859 if (ob == dialog_->input_personal_dict)
2860 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2861 if (ob == dialog_->check_compound_words)
2862 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2863 if (ob == dialog_->check_input_enc)
2864 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
2869 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2871 // !ob if function is called from updateSpellOptions() to de/activate
2873 // otherwise the function is called by an xforms CB via input().
2876 // If spell checker == "none", disable all input.
2877 if (!ob || ob == dialog_->choice_spell_command) {
2878 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2879 fl_deactivate_object(dialog_->check_alt_lang);
2880 fl_deactivate_object(dialog_->input_alt_lang);
2881 fl_deactivate_object(dialog_->check_escape_chars);
2882 fl_deactivate_object(dialog_->input_escape_chars);
2883 fl_deactivate_object(dialog_->check_personal_dict);
2884 fl_deactivate_object(dialog_->input_personal_dict);
2885 fl_deactivate_object(dialog_->check_compound_words);
2886 fl_deactivate_object(dialog_->check_input_enc);
2889 fl_activate_object(dialog_->check_alt_lang);
2890 fl_activate_object(dialog_->check_escape_chars);
2891 fl_activate_object(dialog_->check_personal_dict);
2892 fl_activate_object(dialog_->check_compound_words);
2893 fl_activate_object(dialog_->check_input_enc);
2898 if (!ob || ob == dialog_->check_alt_lang) {
2899 bool const enable = fl_get_button(dialog_->check_alt_lang);
2900 setEnabled(dialog_->input_alt_lang, enable);
2903 if (!ob || ob == dialog_->check_escape_chars) {
2904 bool const enable = fl_get_button(dialog_->check_escape_chars);
2905 setEnabled(dialog_->input_escape_chars, enable);
2908 if (!ob || ob == dialog_->check_personal_dict) {
2909 bool const enable = fl_get_button(dialog_->check_personal_dict);
2910 setEnabled(dialog_->input_personal_dict, enable);
2913 if (ob == dialog_->button_personal_dict) {
2914 string f = parent_.controller().browsedict(
2915 fl_get_input(dialog_->input_personal_dict));
2916 fl_set_input(dialog_->input_personal_dict, f.c_str());
2919 return true; // All input is valid!
2923 void FormPreferences::SpellOptions::update(LyXRC const & rc)
2927 if (rc.isp_command == "none")
2929 else if (rc.isp_command == "ispell")
2931 else if (rc.isp_command == "aspell")
2934 if (rc.isp_command == "ispell")
2936 else if (rc.isp_command == "aspell")
2939 fl_set_choice(dialog_->choice_spell_command, choice);
2942 if (rc.isp_use_alt_lang)
2943 str = rc.isp_alt_lang;
2945 fl_set_button(dialog_->check_alt_lang,
2946 rc.isp_use_alt_lang);
2947 fl_set_input(dialog_->input_alt_lang, str.c_str());
2950 if (rc.isp_use_esc_chars)
2951 str = rc.isp_esc_chars;
2953 fl_set_button(dialog_->check_escape_chars,
2954 rc.isp_use_esc_chars);
2955 fl_set_input(dialog_->input_escape_chars, str.c_str());
2958 if (rc.isp_use_pers_dict)
2959 str = rc.isp_pers_dict;
2961 fl_set_button(dialog_->check_personal_dict,
2962 rc.isp_use_pers_dict);
2963 fl_set_input(dialog_->input_personal_dict, str.c_str());
2965 fl_set_button(dialog_->check_compound_words,
2966 rc.isp_accept_compound);
2967 fl_set_button(dialog_->check_input_enc,
2968 rc.isp_use_input_encoding);
2970 // Activate/Deactivate the input fields dependent on the state of the