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 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);
288 // The "Save" button has been pressed.
289 if (controller().isClosing() && colors_.modifiedXformsPrefs) {
290 string const filename =
291 AddName(user_lyxdir, "preferences.xform");
292 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
297 string const FormPreferences::getFeedback(FL_OBJECT * ob)
301 if (ob->form->fdui == colors_.dialog())
302 return colors_.feedback(ob);
303 if (ob->form->fdui == converters_.dialog())
304 return converters_.feedback(ob);
305 if (ob->form->fdui == formats_.dialog())
306 return formats_.feedback(ob);
307 if (ob->form->fdui == inputs_misc_.dialog())
308 return inputs_misc_.feedback(ob);
309 if (ob->form->fdui == interface_.dialog())
310 return interface_.feedback(ob);
311 if (ob->form->fdui == language_.dialog())
312 return language_.feedback(ob);
313 if (ob->form->fdui == lnf_misc_.dialog())
314 return lnf_misc_.feedback(ob);
315 if (ob->form->fdui == outputs_misc_.dialog())
316 return outputs_misc_.feedback(ob);
317 if (ob->form->fdui == paths_.dialog())
318 return paths_.feedback(ob);
319 if (ob->form->fdui == printer_.dialog())
320 return printer_.feedback(ob);
321 if (ob->form->fdui == screen_fonts_.dialog())
322 return screen_fonts_.feedback(ob);
323 if (ob->form->fdui == spelloptions_.dialog())
324 return spelloptions_.feedback(ob);
330 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
336 // whatever checks you need to ensure the user hasn't entered
337 // some totally ridiculous value somewhere. Change activate to suit.
338 // comments before each test describe what is _valid_
340 if (ob->form->fdui == colors_.dialog()) {
342 } else if (ob->form->fdui == converters_.dialog()) {
343 valid = converters_.input(ob);
344 } else if (ob->form->fdui == formats_.dialog()) {
345 valid = formats_.input(ob);
346 } else if (ob->form->fdui == interface_.dialog()) {
347 valid = interface_.input(ob);
348 } else if (ob->form->fdui == language_.dialog()) {
349 valid = language_.input(ob);
350 } else if (ob->form->fdui == paths_.dialog()) {
351 valid = paths_.input(ob);
352 } else if (ob->form->fdui == screen_fonts_.dialog()) {
353 valid = screen_fonts_.input();
354 } else if (ob->form->fdui == spelloptions_.dialog()) {
355 valid = spelloptions_.input(ob);
358 return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
362 void FormPreferences::update()
364 if (!dialog_.get()) return;
366 LyXRC const & rc(controller().rc());
368 // read lyxrc entries
370 formats_.update(); // Must be before converters_.update()
371 converters_.update();
372 inputs_misc_.update(rc);
373 interface_.update(rc);
374 language_.update(rc);
375 lnf_misc_.update(rc);
376 outputs_misc_.update(rc);
379 screen_fonts_.update(rc);
380 spelloptions_.update(rc);
384 FormPreferences::Colors::Colors(FormPreferences & p)
385 : modifiedXformsPrefs(false), parent_(p)
389 FD_preferences_colors const * FormPreferences::Colors::dialog()
391 return dialog_.get();
395 void FormPreferences::Colors::apply()
397 bool modifiedText = false;
398 bool modifiedBackground = false;
400 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
401 cit != xformsColorDB.end(); ++cit) {
403 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
404 if (col != cit->color()) {
405 modifiedXformsPrefs = true;
406 if (cit->colorID == FL_BLACK)
408 if (cit->colorID == FL_COL1)
409 modifiedBackground = true;
413 if (modifiedXformsPrefs) {
414 for (vector<XformsColor>::const_iterator cit =
415 xformsColorDB.begin();
416 cit != xformsColorDB.end(); ++cit) {
417 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
419 if (modifiedText && cit->colorID == FL_BLACK) {
420 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
423 if (modifiedBackground && cit->colorID == FL_COL1) {
424 AdjustVal(FL_MCOL, FL_COL1, 0.1);
425 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
426 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
428 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
429 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
432 if (cit->colorID == GUI_COLOR_CURSOR) {
433 fl_mapcolor(GUI_COLOR_CURSOR,
434 cit->r, cit->g, cit->b);
435 setCursorColor(GUI_COLOR_CURSOR);
438 parent_.controller().redrawGUI();
441 // Now do the same for the LyX LColors...
442 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
443 cit != lyxColorDB.end(); ++cit) {
444 LColor::color lc = lcolor.getFromGUIName(cit->getname());
445 if (lc == LColor::inherit) continue;
447 // Create a valid X11 name of the form "#rrggbb"
448 string const hexname = X11hexname(cit->color());
450 if (lcolor.getX11Name(lc) != hexname) {
452 << "FormPreferences::Colors::apply: "
453 << "resetting LColor " << lcolor.getGUIName(lc)
454 << " from \"" << lcolor.getX11Name(lc)
455 << "\" to \"" << hexname << "\"."
458 parent_.controller().setColor(lc, hexname);
464 void FormPreferences::Colors::build()
466 dialog_.reset(build_preferences_colors(&parent_));
468 fl_set_object_color(dialog_->button_color,
469 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
471 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
472 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
473 fl_set_dial_step(dialog_->dial_hue, 1.0);
474 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
476 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
477 fl_set_slider_step(dialog_->slider_saturation, 0.01);
478 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
480 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
481 fl_set_slider_step(dialog_->slider_value, 0.01);
482 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
484 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
485 fl_set_slider_step(dialog_->slider_red, 1.0);
486 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
488 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
489 fl_set_slider_step(dialog_->slider_green, 1.0);
490 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
492 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
493 fl_set_slider_step(dialog_->slider_blue, 1.0);
494 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
496 // set up the feedback mechanism
497 setPrehandler(dialog_->browser_lyx_objs);
498 setPrehandler(dialog_->button_color);
499 setPrehandler(dialog_->button_modify);
500 setPrehandler(dialog_->dial_hue);
501 setPrehandler(dialog_->slider_saturation);
502 setPrehandler(dialog_->slider_value);
503 setPrehandler(dialog_->slider_red);
504 setPrehandler(dialog_->slider_green);
505 setPrehandler(dialog_->slider_blue);
506 setPrehandler(dialog_->radio_rgb);
507 setPrehandler(dialog_->radio_hsv);
512 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
514 if (ob == dialog_->browser_lyx_objs)
515 return _("LyX objects that can be assigned a color.");
517 if (ob == dialog_->button_modify)
518 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
520 if (ob == dialog_->dial_hue ||
521 ob == dialog_->slider_saturation ||
522 ob == dialog_->slider_value ||
523 ob == dialog_->slider_red ||
524 ob == dialog_->slider_green ||
525 ob == dialog_->slider_blue)
526 return _("Find a new color.");
528 if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
529 return _("Toggle between RGB and HSV color spaces.");
535 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
537 if (ob == dialog_->browser_lyx_objs) {
540 } else if (ob == dialog_->dial_hue ||
541 ob == dialog_->slider_saturation ||
542 ob == dialog_->slider_value) {
545 } else if (ob == dialog_->slider_red ||
546 ob == dialog_->slider_green ||
547 ob == dialog_->slider_blue) {
550 } else if (ob == dialog_->radio_rgb ||
551 ob == dialog_->radio_hsv) {
554 } else if (ob == dialog_->button_modify) {
560 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
564 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
568 hsv.v = min(1.0, max(0.0, hsv.v));
571 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
575 void FormPreferences::Colors::InputBrowserLyX() const
577 vector<NamedColor>::size_type const selLyX =
578 fl_get_browser(dialog_->browser_lyx_objs);
579 if (selLyX < 1) return;
581 // Is the choice an Xforms color...
584 if (selLyX - 1 < xformsColorDB.size()) {
585 vector<XformsColor>::size_type const i = selLyX - 1;
586 col = xformsColorDB[i].color();
588 // or a LyX Logical color?
590 vector<NamedColor>::size_type const i = selLyX - 1 -
591 xformsColorDB.size();
592 col = lyxColorDB[i].color();
595 fl_freeze_form(dialog_->form);
597 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
598 fl_redraw_object(dialog_->button_color);
600 // Display either RGB or HSV but not both!
603 // Deactivate the modify button to begin with...
604 setEnabled(dialog_->button_modify, false);
606 fl_unfreeze_form(dialog_->form);
610 void FormPreferences::Colors::InputHSV()
612 double const hue = fl_get_dial_value(dialog_->dial_hue);
613 double const sat = fl_get_slider_value(dialog_->slider_saturation);
614 double const val = fl_get_slider_value(dialog_->slider_value);
616 int const h = int(hue);
617 int const s = int(100.0 * sat);
618 int const v = int(100.0 * val);
620 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
622 fl_set_object_label(dialog_->text_color_values, label.c_str());
624 RGBColor col = HSVColor(hue, sat, val);
626 fl_freeze_form(dialog_->form);
628 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
629 fl_redraw_object(dialog_->button_color);
631 col = HSVColor(hue, 1.0, 1.0);
632 col.r = max(col.r, 0);
633 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
634 fl_redraw_object(dialog_->dial_hue);
636 // Ascertain whether to activate the Modify button.
637 vector<NamedColor>::size_type const selLyX =
638 fl_get_browser(dialog_->browser_lyx_objs);
640 fl_unfreeze_form(dialog_->form);
641 if (selLyX < 1) return;
643 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
646 // Is the choice an Xforms color...
647 if (selLyX - 1 < xformsColorDB.size()) {
648 vector<XformsColor>::size_type const i = selLyX - 1;
649 modify = (xformsColorDB[i].color() != col);
651 // or a LyX Logical color?
653 vector<NamedColor>::size_type const i = selLyX - 1 -
654 xformsColorDB.size();
655 modify = (lyxColorDB[i].color() != col);
658 setEnabled(dialog_->button_modify, modify);
662 void FormPreferences::Colors::InputRGB()
664 int const red = int(fl_get_slider_value(dialog_->slider_red));
665 int const green = int(fl_get_slider_value(dialog_->slider_green));
666 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
668 string const label = tostr(red) + string(", ") + tostr(green) +
669 string(", ") + tostr(blue);
670 fl_set_object_label(dialog_->text_color_values, label.c_str());
672 fl_freeze_form(dialog_->form);
674 RGBColor col = RGBColor(red, green, blue);
675 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
676 fl_redraw_object(dialog_->button_color);
678 // Ascertain whether to activate the Modify button.
679 vector<NamedColor>::size_type const selLyX =
680 fl_get_browser(dialog_->browser_lyx_objs);
682 fl_unfreeze_form(dialog_->form);
683 if (selLyX < 1) return;
687 // Is the choice an Xforms color...
688 if (selLyX - 1 < xformsColorDB.size()) {
689 vector<XformsColor>::size_type const i = selLyX - 1;
690 modify = (xformsColorDB[i].color() != col);
692 // or a LyX Logical color?
694 vector<NamedColor>::size_type const i = selLyX - 1 -
695 xformsColorDB.size();
696 modify = (lyxColorDB[i].color() != col);
699 setEnabled(dialog_->button_modify, modify);
703 void FormPreferences::Colors::LoadBrowserLyX()
705 if (!dialog_->browser_lyx_objs->visible)
708 // First, define the modifiable xforms colors
709 xformsColorDB.clear();
712 xcol.name = _("GUI background");
713 xcol.colorID = FL_COL1;
714 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
716 xformsColorDB.push_back(xcol);
718 xcol.name = _("GUI text");
719 xcol.colorID = FL_BLACK;
720 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
722 xformsColorDB.push_back(xcol);
724 xcol.name = _("GUI selection");
725 xcol.colorID = FL_YELLOW;
726 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
728 xformsColorDB.push_back(xcol);
730 xcol.name = _("GUI pointer");
731 xcol.colorID = GUI_COLOR_CURSOR;
732 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
734 xformsColorDB.push_back(xcol);
736 // Now create the the LyX LColors database
738 for (int i=0; i<LColor::ignore; ++i) {
739 LColor::color lc = static_cast<LColor::color>(i);
740 if (lc == LColor::none
741 || lc == LColor::black
742 || lc == LColor::white
744 || lc == LColor::green
745 || lc == LColor::blue
746 || lc == LColor::cyan
747 || lc == LColor::magenta
748 || lc == LColor::yellow
749 || lc == LColor::inherit
750 || lc == LColor::ignore) continue;
752 string const name = lcolor.getX11Name(lc);
753 Display * display = fl_get_display();;
754 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
757 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
759 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
760 << "LColor " << lcolor.getLyXName(lc)
761 << ": X can't find color \"" << name
762 << "\". Set to \"black\"!" << endl;
764 string const arg = lcolor.getLyXName(lc) + " black";
765 parent_.controller().setColor(lc, "black");
769 // X has found the color. Now find the "appropriate" X11 name
772 // Note that X stores the RGB values in the range 0 - 65535
773 // whilst we require them in the range 0 - 255.
775 col.r = xcol.red / 256;
776 col.g = xcol.green / 256;
777 col.b = xcol.blue / 256;
779 // Create a valid X11 name of the form "#rrggbb" and change the
780 // LColor X11name to this. Don't want to trigger a redraw,
781 // as we're just changing the name not the RGB values.
782 // Also reset the system_lcolor names, so that we don't output
783 // unnecessary changes.
784 string const hexname = X11hexname(col);
786 if (lcolor.getX11Name(lc) != hexname) {
787 lcolor.setColor(lc, hexname);
788 system_lcolor.setColor(lc, hexname);
791 // Finally, push the color onto the database
792 NamedColor ncol(lcolor.getGUIName(lc), col);
793 lyxColorDB.push_back(ncol);
796 // Now construct the browser
797 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
798 fl_freeze_form(dialog_->form);
799 fl_clear_browser(colbr);
800 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
801 cit != xformsColorDB.end(); ++cit) {
802 fl_addto_browser(colbr, cit->getname().c_str());
804 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
805 cit != lyxColorDB.end(); ++cit) {
806 fl_addto_browser(colbr, cit->getname().c_str());
809 // just to be safe...
810 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
811 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
812 fl_unfreeze_form(dialog_->form);
818 void FormPreferences::Colors::Modify()
820 vector<NamedColor>::size_type const selLyX =
821 fl_get_browser(dialog_->browser_lyx_objs);
826 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
828 // Is the choice an Xforms color...
829 if (selLyX - 1 < xformsColorDB.size()) {
830 vector<XformsColor>::size_type const i = selLyX - 1;
831 xformsColorDB[i].r = col.r;
832 xformsColorDB[i].g = col.g;
833 xformsColorDB[i].b = col.b;
835 // or a LyX Logical color?
837 vector<NamedColor>::size_type const i = selLyX - 1 -
838 xformsColorDB.size();
839 lyxColorDB[i].r = col.r;
840 lyxColorDB[i].g = col.g;
841 lyxColorDB[i].b = col.b;
844 fl_freeze_form(dialog_->form);
845 setEnabled(dialog_->button_modify, false);
846 fl_unfreeze_form(dialog_->form);
850 void FormPreferences::Colors::SwitchColorSpace() const
852 bool const hsv = fl_get_button(dialog_->radio_hsv);
855 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
857 fl_freeze_form(dialog_->form);
860 fl_hide_object(dialog_->slider_red);
861 fl_hide_object(dialog_->slider_blue);
862 fl_hide_object(dialog_->slider_green);
863 fl_show_object(dialog_->dial_hue);
864 fl_show_object(dialog_->slider_saturation);
865 fl_show_object(dialog_->slider_value);
867 HSVColor hsv = HSVColor(col);
868 hsv.h = max(hsv.h, 0.0);
870 fl_set_dial_value(dialog_->dial_hue, hsv.h);
871 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
872 fl_set_slider_value(dialog_->slider_value, hsv.v);
874 col = HSVColor(hsv.h, 1.0, 1.0);
875 col.r = max(col.r, 0);
876 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
877 fl_redraw_object(dialog_->dial_hue);
879 // Adjust the label a bit, but not the actual values.
880 // Means that toggling from one space to the other has no
881 // effect on the final color.
882 int const h = int(hsv.h);
883 int const s = int(100 * hsv.s);
884 int const v = int(100 * hsv.v);
885 string const label = tostr(h) + ", " + tostr(s) +
887 fl_set_object_label(dialog_->text_color_values, label.c_str());
890 fl_show_object(dialog_->slider_red);
891 fl_show_object(dialog_->slider_blue);
892 fl_show_object(dialog_->slider_green);
893 fl_hide_object(dialog_->dial_hue);
894 fl_hide_object(dialog_->slider_saturation);
895 fl_hide_object(dialog_->slider_value);
897 fl_set_slider_value(dialog_->slider_red, col.r);
898 fl_set_slider_value(dialog_->slider_green, col.g);
899 fl_set_slider_value(dialog_->slider_blue, col.b);
901 // Adjust the label a bit. Same reasoning as above.
902 int const r = int(col.r);
903 int const g = int(col.g);
904 int const b = int(col.b);
905 string const label = tostr(r) + ", " + tostr(g) +
907 fl_set_object_label(dialog_->text_color_values, label.c_str());
910 fl_unfreeze_form(dialog_->form);
913 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
917 ostr << '#' << std::setbase(16) << setfill('0')
922 return STRCONV(ostr.str());
926 FormPreferences::Converters::Converters(FormPreferences & p)
931 FD_preferences_converters const * FormPreferences::Converters::dialog()
933 return dialog_.get();
937 void FormPreferences::Converters::apply() const
939 parent_.controller().setConverters(local_converters);
943 void FormPreferences::Converters::build()
945 dialog_.reset(build_preferences_converters(&parent_));
947 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
948 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
950 // set up the feedback mechanism
951 setPrehandler(dialog_->browser_all);
952 setPrehandler(dialog_->button_delete);
953 setPrehandler(dialog_->button_add);
954 setPrehandler(dialog_->input_converter);
955 setPrehandler(dialog_->choice_from);
956 setPrehandler(dialog_->choice_to);
957 setPrehandler(dialog_->input_flags);
962 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
964 if (ob == dialog_->browser_all)
965 return _("All the currently defined converters known to LyX.");
967 if (ob == dialog_->choice_from)
968 return _("Convert \"from\" this format");
970 if (ob == dialog_->choice_to)
971 return _("Convert \"to\" this format");
973 if (ob == dialog_->input_converter)
974 return _("The conversion command. $$i is the input file name, "
975 "$$b is the file name without its extension and $$o is "
976 "the name of the output file. $$s can be used as path to "
977 "LyX's own collection of conversion scripts.");
979 if (ob == dialog_->input_flags)
980 return _("Extra information for the Converter class, whether and "
981 "how to parse the result, and various other things.");
983 if (ob == dialog_->button_delete)
984 return _("Remove the current converter from the list of available "
985 "converters. Note: you must then \"Apply\" the change.");
987 if (ob == dialog_->button_add) {
988 if (string(ob->label) == _("Add"))
989 return _("Add the current converter to the list of available "
990 "converters. Note: you must then \"Apply\" the change.");
992 return _("Modify the contents of the current converter. "
993 "Note: you must then \"Apply\" the change.");
1000 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
1002 if (ob == dialog_->browser_all)
1005 if (ob == dialog_->choice_from
1006 || ob == dialog_->choice_to
1007 || ob == dialog_->input_converter
1008 || ob == dialog_->input_flags)
1011 if (ob == dialog_->button_add)
1014 if (ob == dialog_->button_delete)
1021 void FormPreferences::Converters::update()
1023 local_converters = converters;
1024 local_converters.update(local_formats);
1029 void FormPreferences::Converters::UpdateBrowser()
1031 local_converters.sort();
1033 fl_freeze_form(dialog_->form);
1034 fl_clear_browser(dialog_->browser_all);
1035 for (::Converters::const_iterator cit = local_converters.begin();
1036 cit != local_converters.end(); ++cit) {
1037 string const name = cit->From->prettyname() + " -> "
1038 + cit->To->prettyname();
1039 fl_addto_browser(dialog_->browser_all, name.c_str());
1042 fl_unfreeze_form(dialog_->form);
1046 bool FormPreferences::Converters::Add()
1048 string const from = GetFrom();
1049 string const to = GetTo();
1050 string const command = fl_get_input(dialog_->input_converter);
1051 string const flags = fl_get_input(dialog_->input_flags);
1053 Converter const * old = local_converters.getConverter(from, to);
1054 local_converters.add(from, to, command, flags);
1056 local_converters.updateLast(local_formats);
1059 setEnabled(dialog_->button_add, false);
1065 bool FormPreferences::Converters::Browser()
1067 int const i = fl_get_browser(dialog_->browser_all);
1068 if (i <= 0) return false;
1070 fl_freeze_form(dialog_->form);
1072 Converter const & c = local_converters.get(i - 1);
1073 int j = local_formats.getNumber(c.from);
1075 fl_set_choice(dialog_->choice_from, j + 1);
1077 j = local_formats.getNumber(c.to);
1079 fl_set_choice(dialog_->choice_to, j + 1);
1081 fl_set_input(dialog_->input_converter, c.command.c_str());
1082 fl_set_input(dialog_->input_flags, c.flags.c_str());
1084 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
1085 fl_set_button_shortcut(dialog_->button_add,
1086 scex(_("Modify|#M")).c_str(), 1);
1088 setEnabled(dialog_->button_add, false);
1089 setEnabled(dialog_->button_delete, true);
1091 fl_unfreeze_form(dialog_->form);
1096 bool FormPreferences::Converters::erase()
1098 string const from = GetFrom();
1099 string const to = GetTo();
1101 local_converters.erase(from, to);
1107 bool FormPreferences::Converters::Input()
1109 string const from = GetFrom();
1110 string const to = GetTo();
1111 int const sel = local_converters.getNumber(from, to);
1113 fl_freeze_form(dialog_->form);
1116 fl_set_object_label(dialog_->button_add,
1117 idex(_("Add|#A")).c_str());
1118 fl_set_button_shortcut(dialog_->button_add,
1119 scex(_("Add|#A")).c_str(), 1);
1121 fl_deselect_browser(dialog_->browser_all);
1122 setEnabled(dialog_->button_delete, false);
1125 fl_set_object_label(dialog_->button_add,
1126 idex(_("Modify|#M")).c_str());
1127 fl_set_button_shortcut(dialog_->button_add,
1128 scex(_("Modify|#M")).c_str(), 1);
1130 int top = max(sel-5, 0);
1131 fl_set_browser_topline(dialog_->browser_all, top);
1132 fl_select_browser_line(dialog_->browser_all, sel+1);
1133 setEnabled(dialog_->button_delete, true);
1136 string const command = rtrim(fl_get_input(dialog_->input_converter));
1137 bool const enable = !(command.empty() || from == to);
1138 setEnabled(dialog_->button_add, enable);
1140 fl_unfreeze_form(dialog_->form);
1145 string const FormPreferences::Converters::GetFrom() const
1147 ::Formats::FormatList::size_type const i =
1148 fl_get_choice(dialog_->choice_from);
1150 if (i > 0 && i <= local_formats.size())
1151 return local_formats.get(i - 1).name();
1153 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1158 string const FormPreferences::Converters::GetTo() const
1160 ::Formats::FormatList::size_type const i =
1161 fl_get_choice(dialog_->choice_to);
1163 if (i > 0 && i <= local_formats.size())
1164 return local_formats.get(i - 1).name();
1166 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1171 void FormPreferences::Converters::UpdateChoices() const
1174 for (::Formats::const_iterator cit = local_formats.begin();
1175 cit != local_formats.end(); ++cit) {
1176 if (!choice.empty())
1180 choice += cit->prettyname();
1184 fl_clear_choice(dialog_->choice_from);
1185 fl_addto_choice(dialog_->choice_from, choice.c_str());
1187 fl_clear_choice(dialog_->choice_to);
1188 fl_addto_choice(dialog_->choice_to, choice.c_str());
1192 FormPreferences::Formats::Formats(FormPreferences & p)
1197 FD_preferences_formats const * FormPreferences::Formats::dialog()
1199 return dialog_.get();
1203 void FormPreferences::Formats::apply() const
1205 parent_.controller().setFormats(local_formats);
1209 void FormPreferences::Formats::build()
1211 dialog_.reset(build_preferences_formats(&parent_));
1213 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1214 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1215 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1216 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1217 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1219 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1221 // set up the feedback mechanism
1222 setPrehandler(dialog_->browser_all);
1223 setPrehandler(dialog_->input_format);
1224 setPrehandler(dialog_->input_gui_name);
1225 setPrehandler(dialog_->button_delete);
1226 setPrehandler(dialog_->button_add);
1227 setPrehandler(dialog_->input_extension);
1228 setPrehandler(dialog_->input_viewer);
1229 setPrehandler(dialog_->input_shrtcut);
1234 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1236 if (ob == dialog_->browser_all)
1237 return _("All the currently defined formats known to LyX.");
1239 if (ob == dialog_->input_format)
1240 return _("The format identifier.");
1242 if (ob == dialog_->input_gui_name)
1243 return _("The format name as it will appear in the menus.");
1245 if (ob == dialog_->input_shrtcut)
1246 return _("The keyboard accelerator. Use a letter in the GUI name. "
1249 if (ob == dialog_->input_extension)
1250 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1252 if (ob == dialog_->input_viewer)
1253 return _("The command used to launch the viewer application.");
1255 if (ob == dialog_->button_delete)
1256 return _("Remove the current format from the list of available "
1257 "formats. Note: you must then \"Apply\" the change.");
1259 if (ob == dialog_->button_add) {
1260 if (string(ob->label) == _("Add"))
1261 return _("Add the current format to the list of available "
1262 "formats. Note: you must then \"Apply\" the change.");
1264 return _("Modify the contents of the current format. Note: "
1265 "you must then \"Apply\" the change.");
1272 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1274 if (ob == dialog_->browser_all)
1277 if (ob == dialog_->input_format
1278 || ob == dialog_->input_gui_name
1279 || ob == dialog_->input_shrtcut
1280 || ob == dialog_->input_extension
1281 || ob == dialog_->input_viewer)
1284 if (ob == dialog_->button_add)
1287 if (ob == dialog_->button_delete)
1294 void FormPreferences::Formats::update()
1296 local_formats = formats;
1301 void FormPreferences::Formats::UpdateBrowser()
1303 local_formats.sort();
1305 fl_freeze_form(dialog_->form);
1306 fl_deselect_browser(dialog_->browser_all);
1307 fl_clear_browser(dialog_->browser_all);
1308 for (::Formats::const_iterator cit = local_formats.begin();
1309 cit != local_formats.end(); ++cit)
1310 fl_addto_browser(dialog_->browser_all,
1311 cit->prettyname().c_str());
1314 fl_unfreeze_form(dialog_->form);
1316 // Mustn't forget to update the Formats available to the converters_
1317 parent_.converters_.UpdateChoices();
1318 local_converters.update(local_formats);
1322 bool FormPreferences::Formats::Add()
1324 string const name = fl_get_input(dialog_->input_format);
1325 string const prettyname = fl_get_input(dialog_->input_gui_name);
1326 string const extension = fl_get_input(dialog_->input_extension);
1327 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1328 string const viewer = fl_get_input(dialog_->input_viewer);
1330 Format const * old = local_formats.getFormat(name);
1331 string const old_prettyname = old ? old->prettyname() : string();
1332 local_formats.add(name, extension, prettyname, shortcut);
1333 local_formats.setViewer(name, viewer);
1334 if (!old || prettyname != old_prettyname) {
1337 parent_.converters_.UpdateBrowser();
1339 setEnabled(dialog_->button_add, false);
1345 bool FormPreferences::Formats::Browser()
1347 int const i = fl_get_browser(dialog_->browser_all);
1351 fl_freeze_form(dialog_->form);
1353 Format const & f = local_formats.get(i - 1);
1355 fl_set_input(dialog_->input_format, f.name().c_str());
1356 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1357 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1358 fl_set_input(dialog_->input_extension, f.extension().c_str());
1359 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1361 fl_set_object_label(dialog_->button_add,
1362 idex(_("Modify|#M")).c_str());
1363 fl_set_button_shortcut(dialog_->button_add,
1364 scex(_("Modify|#M")).c_str(), 1);
1366 setEnabled(dialog_->button_add, false);
1367 setEnabled(dialog_->button_delete, true);
1369 fl_unfreeze_form(dialog_->form);
1374 bool FormPreferences::Formats::erase()
1376 string const name = fl_get_input(dialog_->input_format);
1378 if (local_converters.formatIsUsed(name)) {
1379 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1380 "Remove the converter first."));
1381 setEnabled(dialog_->button_delete, false);
1385 local_formats.erase(name);
1391 bool FormPreferences::Formats::Input()
1393 string const name = fl_get_input(dialog_->input_format);
1394 int const sel = local_formats.getNumber(name);
1395 fl_freeze_form(dialog_->form);
1398 fl_set_object_label(dialog_->button_add,
1399 idex(_("Add|#A")).c_str());
1400 fl_set_button_shortcut(dialog_->button_add,
1401 scex(_("Add|#A")).c_str(), 1);
1403 fl_deselect_browser(dialog_->browser_all);
1404 setEnabled(dialog_->button_delete, false);
1407 fl_set_object_label(dialog_->button_add,
1408 idex(_("Modify|#M")).c_str());
1409 fl_set_button_shortcut(dialog_->button_add,
1410 scex(_("Modify|#M")).c_str(), 1);
1412 int const top = max(sel-5, 0);
1413 fl_set_browser_topline(dialog_->browser_all, top);
1414 fl_select_browser_line(dialog_->browser_all, sel+1);
1416 setEnabled(dialog_->button_add, true);
1417 setEnabled(dialog_->button_delete, true);
1420 string const prettyname = fl_get_input(dialog_->input_gui_name);
1421 bool const enable = !(name.empty() || prettyname.empty());
1422 setEnabled(dialog_->button_add, enable);
1424 fl_unfreeze_form(dialog_->form);
1429 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1434 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1436 return dialog_.get();
1440 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1442 rc.date_insert_format =
1443 fl_get_input(dialog_->input_date_format);
1447 void FormPreferences::InputsMisc::build()
1449 dialog_.reset(build_preferences_inputs_misc(&parent_));
1451 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1453 // set up the feedback mechanism
1454 setPrehandler(dialog_->input_date_format);
1459 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1461 if (ob == dialog_->input_date_format)
1462 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1467 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1469 fl_set_input(dialog_->input_date_format,
1470 rc.date_insert_format.c_str());
1474 FormPreferences::Interface::Interface(FormPreferences & p)
1479 FD_preferences_interface const * FormPreferences::Interface::dialog()
1481 return dialog_.get();
1485 void FormPreferences::Interface::apply(LyXRC & rc) const
1487 rc.popup_normal_font =
1488 fl_get_input(dialog_->input_popup_normal_font);
1489 rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1490 rc.popup_font_encoding =
1491 fl_get_input(dialog_->input_popup_font_encoding);
1492 rc.bind_file = fl_get_input(dialog_->input_bind_file);
1493 rc.ui_file = fl_get_input(dialog_->input_ui_file);
1494 rc.override_x_deadkeys =
1495 fl_get_button(dialog_->check_override_x_dead_keys);
1499 void FormPreferences::Interface::build()
1501 dialog_.reset(build_preferences_interface(&parent_));
1503 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1504 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1505 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1506 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1507 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1509 // set up the feedback mechanism
1510 setPrehandler(dialog_->input_popup_normal_font);
1511 setPrehandler(dialog_->input_popup_bold_font);
1512 setPrehandler(dialog_->input_popup_font_encoding);
1513 setPrehandler(dialog_->input_bind_file);
1514 setPrehandler(dialog_->button_bind_file_browse);
1515 setPrehandler(dialog_->input_ui_file);
1516 setPrehandler(dialog_->button_ui_file_browse);
1517 setPrehandler(dialog_->check_override_x_dead_keys);
1522 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1524 if (ob == dialog_->input_popup_normal_font)
1525 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1526 if (ob == dialog_->input_popup_bold_font)
1527 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1528 if (ob == dialog_->input_popup_font_encoding)
1529 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1530 if (ob == dialog_->input_bind_file)
1531 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1532 if (ob == dialog_->input_ui_file)
1533 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1534 if (ob == dialog_->check_override_x_dead_keys)
1535 return LyXRC::getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1540 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1542 if (ob == dialog_->button_bind_file_browse) {
1543 string f = parent_.controller().browsebind(
1544 fl_get_input(dialog_->input_bind_file));
1546 fl_set_input(dialog_->input_bind_file, f.c_str());
1547 } else if (ob == dialog_->button_ui_file_browse) {
1548 string f = parent_.controller().browseUI(
1549 fl_get_input(dialog_->input_ui_file));
1551 fl_set_input(dialog_->input_ui_file, f.c_str());
1558 void FormPreferences::Interface::update(LyXRC const & rc)
1560 fl_set_input(dialog_->input_popup_normal_font,
1561 rc.popup_normal_font.c_str());
1562 fl_set_input(dialog_->input_popup_bold_font,
1563 rc.popup_bold_font.c_str());
1564 fl_set_input(dialog_->input_popup_font_encoding,
1565 rc.popup_font_encoding.c_str());
1566 fl_set_input(dialog_->input_bind_file,
1567 rc.bind_file.c_str());
1568 fl_set_input(dialog_->input_ui_file,
1569 rc.ui_file.c_str());
1570 fl_set_button(dialog_->check_override_x_dead_keys,
1571 rc.override_x_deadkeys);
1575 FormPreferences::Language::Language(FormPreferences & p)
1580 FD_preferences_language const * FormPreferences::Language::dialog()
1582 return dialog_.get();
1586 void FormPreferences::Language::apply(LyXRC & rc)
1588 int const pos = combo_default_lang->get();
1589 rc.default_language = lang_[pos-1];
1591 int button = fl_get_button(dialog_->check_use_kbmap);
1592 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1593 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1595 button = !(name_1.empty() && name_2.empty());
1596 rc.use_kbmap = static_cast<bool>(button);
1599 rc.primary_kbmap = name_1;
1600 rc.secondary_kbmap = name_2;
1603 button = fl_get_button(dialog_->check_rtl_support);
1604 rc.rtl_support = static_cast<bool>(button);
1606 button = fl_get_button(dialog_->check_mark_foreign);
1607 rc.mark_foreign_language = static_cast<bool>(button);
1609 button = fl_get_button(dialog_->check_auto_begin);
1610 rc.language_auto_begin = static_cast<bool>(button);
1612 button = fl_get_button(dialog_->check_auto_end);
1613 rc.language_auto_end = static_cast<bool>(button);
1615 button = fl_get_button(dialog_->check_use_babel);
1616 rc.language_use_babel = static_cast<bool>(button);
1618 button = fl_get_button(dialog_->check_global_options);
1619 rc.language_global_options = static_cast<bool>(button);
1621 rc.language_package = fl_get_input(dialog_->input_package);
1622 rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1623 rc.language_command_end = fl_get_input(dialog_->input_command_end);
1625 // Ensure that all is self-consistent.
1630 void FormPreferences::Language::build()
1632 dialog_.reset(build_preferences_language(&parent_));
1634 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1635 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1636 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1638 // Store the lang identifiers for later
1639 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1640 lang_ = getSecond(langs);
1642 // The default_language is a combo-box and has to be inserted manually
1643 fl_freeze_form(dialog_->form);
1644 fl_addto_form(dialog_->form);
1646 FL_OBJECT * obj = dialog_->choice_default_lang;
1647 fl_deactivate_object(dialog_->choice_default_lang);
1648 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1649 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
1650 combo_default_lang->shortcut("#L",1);
1651 combo_default_lang->setcallback(ComboCB, &parent_);
1653 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1654 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1655 for (; lit != lend; ++lit) {
1656 combo_default_lang->addto(lit->first);
1658 combo_default_lang->select(1);
1661 fl_unfreeze_form(dialog_->form);
1663 // set up the feedback mechanism
1664 setPrehandler(dialog_->input_package);
1665 setPrehandler(dialog_->check_use_kbmap);
1667 // This is safe, as nothing is done to the pointer, other than
1668 // to use its address in a block-if statement.
1669 // No it's not! Leads to crash.
1671 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1672 // C_FormPreferencesFeedbackCB);
1674 setPrehandler(dialog_->input_kbmap1);
1675 setPrehandler(dialog_->input_kbmap2);
1676 setPrehandler(dialog_->check_rtl_support);
1677 setPrehandler(dialog_->check_mark_foreign);
1678 setPrehandler(dialog_->check_auto_begin);
1679 setPrehandler(dialog_->check_auto_end);
1680 setPrehandler(dialog_->check_use_babel);
1681 setPrehandler(dialog_->check_global_options);
1682 setPrehandler(dialog_->input_command_begin);
1683 setPrehandler(dialog_->input_command_end);
1685 // Activate/Deactivate the input fields dependent on the state of the
1692 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1694 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1695 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1696 if (ob == dialog_->check_use_kbmap)
1697 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1698 if (ob == dialog_->input_kbmap1)
1699 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1700 if (ob == dialog_->input_kbmap2)
1701 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1702 if (ob == dialog_->check_rtl_support)
1703 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1704 if (ob == dialog_->check_mark_foreign)
1705 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1706 if (ob == dialog_->check_auto_begin)
1707 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1708 if (ob == dialog_->check_auto_end)
1709 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1710 if (ob == dialog_->check_use_babel)
1711 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1712 if (ob == dialog_->check_global_options)
1713 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1714 if (ob == dialog_->input_package)
1715 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1716 if (ob == dialog_->input_command_begin)
1717 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1718 if (ob == dialog_->input_command_end)
1719 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1724 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1726 bool activate = true;
1728 // !ob if function is called from Language::build() to de/activate
1730 // otherwise the function is called by an xforms CB via input().
1731 if (!ob || ob == dialog_->check_use_kbmap) {
1732 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1733 setEnabled(dialog_->button_kbmap1_browse, enable);
1734 setEnabled(dialog_->button_kbmap2_browse, enable);
1735 setEnabled(dialog_->input_kbmap1, enable);
1736 setEnabled(dialog_->input_kbmap2, enable);
1739 if (ob == dialog_->button_kbmap1_browse) {
1740 string f = parent_.controller().browsekbmap(
1741 fl_get_input(dialog_->input_kbmap1));
1743 fl_set_input(dialog_->input_kbmap1, f.c_str());
1744 } else if (ob == dialog_->button_kbmap2_browse) {
1745 string f = parent_.controller().browsekbmap(
1746 fl_get_input(dialog_->input_kbmap2));
1748 fl_set_input(dialog_->input_kbmap2, f.c_str());
1755 void FormPreferences::Language::update(LyXRC const & rc)
1757 fl_set_button(dialog_->check_use_kbmap,
1760 int const pos = int(findPos(lang_, rc.default_language));
1761 combo_default_lang->select(pos + 1);
1764 fl_set_input(dialog_->input_kbmap1,
1765 rc.primary_kbmap.c_str());
1766 fl_set_input(dialog_->input_kbmap2,
1767 rc.secondary_kbmap.c_str());
1769 fl_set_input(dialog_->input_kbmap1, "");
1770 fl_set_input(dialog_->input_kbmap2, "");
1773 fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1774 fl_set_button(dialog_->check_mark_foreign,
1775 rc.mark_foreign_language);
1776 fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1777 fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1778 fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1779 fl_set_button(dialog_->check_global_options,
1780 rc.language_global_options);
1782 fl_set_input(dialog_->input_package,
1783 rc.language_package.c_str());
1784 fl_set_input(dialog_->input_command_begin,
1785 rc.language_command_begin.c_str());
1786 fl_set_input(dialog_->input_command_end,
1787 rc.language_command_end.c_str());
1789 // Activate/Deactivate the input fields dependent on the state of the
1795 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1797 FormPreferences * pre = static_cast<FormPreferences*>(v);
1798 // This is safe, as nothing is done to the pointer, other than
1799 // to use its address in a block-if statement.
1800 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1804 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1809 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1811 return dialog_.get();
1815 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1817 rc.auto_region_delete =
1818 fl_get_button(dialog_->check_auto_region_delete);
1819 rc.cursor_follows_scrollbar =
1820 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1821 rc.dialogs_iconify_with_main =
1822 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1823 rc.preview = fl_get_button(dialog_->check_preview_latex);
1824 rc.autosave = static_cast<unsigned int>
1825 (fl_get_counter_value(dialog_->counter_autosave));
1826 rc.wheel_jump = static_cast<unsigned int>
1827 (fl_get_counter_value(dialog_->counter_wm_jump));
1830 // grfx::DisplayType old_value = rc.display_graphics;
1831 switch (fl_get_choice(dialog_->choice_display)) {
1832 case 4: rc.display_graphics = grfx::NoDisplay; break;
1833 case 3: rc.display_graphics = grfx::ColorDisplay; break;
1834 case 2: rc.display_graphics = grfx::GrayscaleDisplay; break;
1835 case 1: rc.display_graphics = grfx::MonochromeDisplay; break;
1836 default: rc.display_graphics = grfx::ColorDisplay; break;
1839 #ifdef WITH_WARNINGS
1840 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1843 if (old_value != rc.display_graphics) {
1844 grfx::GCache & gc = grfx::GCache::get();
1851 void FormPreferences::LnFmisc::build()
1853 dialog_.reset(build_preferences_lnf_misc(&parent_));
1855 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1856 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1858 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1859 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1861 // set up the feedback mechanism
1862 setPrehandler(dialog_->check_auto_region_delete);
1863 setPrehandler(dialog_->counter_autosave);
1864 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1865 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1866 setPrehandler(dialog_->check_preview_latex);
1867 setPrehandler(dialog_->counter_wm_jump);
1869 fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
1874 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1876 if (ob == dialog_->check_auto_region_delete)
1877 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
1878 if (ob == dialog_->check_cursor_follows_scrollbar)
1879 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1880 if (ob == dialog_->check_dialogs_iconify_with_main)
1881 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1882 if (ob == dialog_->check_preview_latex)
1883 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
1884 if (ob == dialog_->counter_autosave)
1885 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
1886 if (ob == dialog_->counter_wm_jump)
1887 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
1888 if (ob == dialog_->choice_display)
1889 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1894 void FormPreferences::LnFmisc::update(LyXRC const & rc)
1896 fl_set_button(dialog_->check_auto_region_delete,
1897 rc.auto_region_delete);
1898 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1899 rc.cursor_follows_scrollbar);
1900 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1901 rc.dialogs_iconify_with_main);
1902 fl_set_button(dialog_->check_preview_latex,
1904 fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
1905 fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
1907 switch (rc.display_graphics) {
1908 case grfx::NoDisplay: fl_set_choice(dialog_->choice_display, 4); break;
1909 case grfx::ColorDisplay: fl_set_choice(dialog_->choice_display, 3); break;
1910 case grfx::GrayscaleDisplay: fl_set_choice(dialog_->choice_display, 2); break;
1911 case grfx::MonochromeDisplay: fl_set_choice(dialog_->choice_display, 1); break;
1912 default: fl_set_choice(dialog_->choice_display, 3); break;
1917 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1922 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1924 return dialog_.get();
1928 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
1930 rc.ascii_linelen = static_cast<unsigned int>
1931 (fl_get_counter_value(dialog_->counter_line_len));
1932 rc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1935 fl_get_choice(dialog_->choice_default_papersize) - 1;
1936 rc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1938 rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1939 rc.chktex_command = fl_get_input(dialog_->input_checktex);
1940 rc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1941 rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1945 void FormPreferences::OutputsMisc::build()
1947 dialog_.reset(build_preferences_outputs_misc(&parent_));
1949 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1951 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1952 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1953 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1954 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1955 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1957 fl_addto_choice(dialog_->choice_default_papersize,
1958 _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1960 // set up the feedback mechanism
1961 setPrehandler(dialog_->counter_line_len);
1962 setPrehandler(dialog_->input_tex_encoding);
1963 setPrehandler(dialog_->choice_default_papersize);
1964 setPrehandler(dialog_->input_ascii_roff);
1965 setPrehandler(dialog_->input_checktex);
1966 setPrehandler(dialog_->input_paperoption);
1967 setPrehandler(dialog_->check_autoreset_classopt);
1972 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1974 if (ob == dialog_->counter_line_len)
1975 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
1976 if (ob == dialog_->input_tex_encoding)
1977 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
1978 if (ob == dialog_->input_ascii_roff)
1979 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1980 if (ob == dialog_->input_checktex)
1981 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
1982 if (ob == dialog_->choice_default_papersize)
1983 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1984 if (ob == dialog_->input_paperoption)
1985 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
1986 if (ob == dialog_->check_autoreset_classopt)
1987 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
1992 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
1994 fl_set_counter_value(dialog_->counter_line_len,
1996 fl_set_input(dialog_->input_tex_encoding,
1997 rc.fontenc.c_str());
1998 fl_set_choice(dialog_->choice_default_papersize,
1999 rc.default_papersize + 1);
2000 fl_set_input(dialog_->input_ascii_roff,
2001 rc.ascii_roff_command.c_str());
2002 fl_set_input(dialog_->input_checktex,
2003 rc.chktex_command.c_str());
2004 fl_set_input(dialog_->input_paperoption,
2005 rc.view_dvi_paper_option.c_str());
2006 fl_set_button(dialog_->check_autoreset_classopt,
2007 rc.auto_reset_options);
2012 FormPreferences::Paths::Paths(FormPreferences & p)
2017 FD_preferences_paths const * FormPreferences::Paths::dialog()
2019 return dialog_.get();
2023 void FormPreferences::Paths::apply(LyXRC & rc)
2025 rc.document_path = fl_get_input(dialog_->input_default_path);
2026 rc.template_path = fl_get_input(dialog_->input_template_path);
2028 int button = fl_get_button(dialog_->check_use_temp_dir);
2029 string str = fl_get_input(dialog_->input_temp_dir);
2033 rc.use_tempdir = button;
2034 rc.tempdir_path = str;
2036 button = fl_get_button(dialog_->check_last_files);
2037 str = fl_get_input(dialog_->input_lastfiles);
2038 if (!button) str.erase();
2040 rc.check_lastfiles = button;
2042 rc.num_lastfiles = static_cast<unsigned int>
2043 (fl_get_counter_value(dialog_->counter_lastfiles));
2045 button = fl_get_button(dialog_->check_make_backups);
2046 str = fl_get_input(dialog_->input_backup_path);
2050 rc.make_backup = button;
2051 rc.backupdir_path = str;
2053 rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2060 void FormPreferences::Paths::build()
2062 dialog_.reset(build_preferences_paths(&parent_));
2064 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2065 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2066 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2067 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2068 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2069 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2070 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2072 // set up the feedback mechanism
2073 setPrehandler(dialog_->input_default_path);
2074 setPrehandler(dialog_->counter_lastfiles);
2075 setPrehandler(dialog_->input_template_path);
2076 setPrehandler(dialog_->check_last_files);
2077 setPrehandler(dialog_->input_lastfiles);
2078 setPrehandler(dialog_->check_make_backups);
2079 setPrehandler(dialog_->input_backup_path);
2080 setPrehandler(dialog_->input_serverpipe);
2081 setPrehandler(dialog_->input_temp_dir);
2082 setPrehandler(dialog_->check_use_temp_dir);
2087 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2089 if (ob == dialog_->input_default_path)
2090 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2091 if (ob == dialog_->input_template_path)
2092 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2093 if (ob == dialog_->check_use_temp_dir)
2094 return LyXRC::getDescription(LyXRC::RC_USETEMPDIR);
2095 if (ob == dialog_->input_temp_dir)
2096 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2097 if (ob == dialog_->check_last_files)
2098 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2099 if (ob == dialog_->input_lastfiles)
2100 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
2101 if (ob == dialog_->counter_lastfiles)
2102 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2103 if (ob == dialog_->check_make_backups)
2104 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2105 if (ob == dialog_->input_backup_path)
2106 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2107 if (ob == dialog_->input_serverpipe)
2108 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2113 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2115 bool activate = true;
2117 // !ob if function is called from Paths::update() to de/activate
2119 // otherwise the function is called by an xforms CB via input().
2120 if (!ob || ob == dialog_->check_use_temp_dir) {
2121 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2122 setEnabled(dialog_->input_temp_dir, enable);
2125 if (!ob || ob == dialog_->check_last_files) {
2126 bool const enable = fl_get_button(dialog_->check_last_files);
2127 setEnabled(dialog_->input_lastfiles, enable);
2130 if (!ob || ob == dialog_->check_make_backups) {
2131 bool const enable = fl_get_button(dialog_->check_make_backups);
2132 setEnabled(dialog_->input_backup_path, enable);
2135 if (!ob || ob == dialog_->input_default_path) {
2136 string const name = fl_get_input(dialog_->input_default_path);
2137 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2138 parent_.postWarning(RWInfo::ErrorMessage());
2143 if (!ob || ob == dialog_->input_template_path) {
2144 string const name = fl_get_input(dialog_->input_template_path);
2145 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2146 parent_.postWarning(RWInfo::ErrorMessage());
2151 if (!ob || ob == dialog_->input_temp_dir) {
2152 string const name = fl_get_input(dialog_->input_temp_dir);
2153 if (fl_get_button(dialog_->check_make_backups)
2155 && !RWInfo::WriteableDir(name)) {
2156 parent_.postWarning(RWInfo::ErrorMessage());
2161 if (!ob || ob == dialog_->input_backup_path) {
2162 string const name = fl_get_input(dialog_->input_backup_path);
2163 if (fl_get_button(dialog_->check_make_backups)
2165 && !RWInfo::WriteableDir(name)) {
2166 parent_.postWarning(RWInfo::ErrorMessage());
2171 if (!ob || ob == dialog_->input_lastfiles) {
2172 string const name = fl_get_input(dialog_->input_lastfiles);
2173 if (fl_get_button(dialog_->check_last_files)
2175 && !RWInfo::WriteableFile(name)) {
2176 parent_.postWarning(RWInfo::ErrorMessage());
2181 if (!ob || ob == dialog_->input_serverpipe) {
2182 string const name = fl_get_input(dialog_->input_serverpipe);
2183 if (!name.empty()) {
2184 // strip off the extension
2185 string const str = ChangeExtension(name, "");
2186 if (!RWInfo::WriteableFile(str + ".in")) {
2187 parent_.postWarning(RWInfo::ErrorMessage());
2190 if (!RWInfo::WriteableFile(str + ".out")) {
2191 parent_.postWarning(RWInfo::ErrorMessage());
2197 if (ob == dialog_->button_default_path_browse) {
2198 string f = parent_.controller().browse(
2199 fl_get_input(dialog_->input_default_path), _("Default path"));
2200 fl_set_input(dialog_->input_default_path, f.c_str());
2201 } else if (ob == dialog_->button_template_path_browse) {
2202 string f = parent_.controller().browse(
2203 fl_get_input(dialog_->input_template_path), _("Template path"));
2204 fl_set_input(dialog_->input_template_path, f.c_str());
2205 } else if (ob == dialog_->button_temp_dir_browse) {
2206 string f = parent_.controller().browse(
2207 fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2208 fl_set_input(dialog_->input_temp_dir, f.c_str());
2209 } else if (ob == dialog_->button_lastfiles_browse) {
2210 string f = parent_.controller().browse(
2211 fl_get_input(dialog_->input_lastfiles), _("Last files"));
2212 fl_set_input(dialog_->input_lastfiles, f.c_str());
2213 } else if (ob == dialog_->button_backup_path_browse) {
2214 string f = parent_.controller().browse(
2215 fl_get_input(dialog_->input_backup_path), _("Backup path"));
2216 fl_set_input(dialog_->input_backup_path, f.c_str());
2217 } else if (ob == dialog_->button_serverpipe_browse) {
2218 string f = parent_.controller().browse(
2219 fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2220 fl_set_input(dialog_->input_serverpipe, f.c_str());
2227 void FormPreferences::Paths::update(LyXRC const & rc)
2229 fl_set_input(dialog_->input_default_path,
2230 rc.document_path.c_str());
2231 fl_set_input(dialog_->input_template_path,
2232 rc.template_path.c_str());
2236 str = rc.backupdir_path;
2238 fl_set_button(dialog_->check_make_backups,
2240 fl_set_input(dialog_->input_backup_path, str.c_str());
2244 str = rc.tempdir_path;
2246 fl_set_button(dialog_->check_use_temp_dir,
2248 fl_set_input(dialog_->input_temp_dir, str.c_str());
2251 if (rc.check_lastfiles)
2254 fl_set_button(dialog_->check_last_files,
2255 rc.check_lastfiles);
2256 fl_set_input(dialog_->input_lastfiles, str.c_str());
2257 fl_set_counter_value(dialog_->counter_lastfiles,
2260 fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2262 // Activate/Deactivate the input fields dependent on the state of the
2268 FormPreferences::Printer::Printer(FormPreferences & p)
2273 FD_preferences_printer const * FormPreferences::Printer::dialog()
2275 return dialog_.get();
2279 void FormPreferences::Printer::apply(LyXRC & rc) const
2281 rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2282 rc.print_command = fl_get_input(dialog_->input_command);
2283 rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2284 rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2285 rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2286 rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2287 rc.print_file_extension =
2288 fl_get_input(dialog_->input_file_extension);
2289 rc.print_spool_command =
2290 fl_get_input(dialog_->input_spool_command);
2291 rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2292 rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2293 rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2294 rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2295 rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2296 rc.print_to_file = fl_get_input(dialog_->input_to_file);
2297 rc.print_extra_options =
2298 fl_get_input(dialog_->input_extra_options);
2299 rc.print_spool_printerprefix =
2300 fl_get_input(dialog_->input_spool_prefix);
2301 rc.print_paper_dimension_flag =
2302 fl_get_input(dialog_->input_paper_size);
2303 rc.printer = fl_get_input(dialog_->input_name);
2308 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2310 if (ob == dialog_->input_command)
2311 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2312 if (ob == dialog_->check_adapt_output)
2313 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2314 if (ob == dialog_->input_to_printer)
2315 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2316 if (ob == dialog_->input_to_file)
2317 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2318 if (ob == dialog_->input_file_extension)
2319 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2320 if (ob == dialog_->input_extra_options)
2321 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2322 if (ob == dialog_->input_spool_command)
2323 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2324 if (ob == dialog_->input_spool_prefix)
2325 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2326 if (ob == dialog_->input_name)
2327 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2328 if (ob == dialog_->input_even_pages)
2329 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2330 if (ob == dialog_->input_odd_pages)
2331 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2332 if (ob == dialog_->input_page_range)
2333 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2334 if (ob == dialog_->input_reverse)
2335 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2336 if (ob == dialog_->input_landscape)
2337 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2338 if (ob == dialog_->input_copies)
2339 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2340 if (ob == dialog_->input_collated)
2341 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2342 if (ob == dialog_->input_paper_type)
2343 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2344 if (ob == dialog_->input_paper_size)
2345 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2350 void FormPreferences::Printer::build()
2352 dialog_.reset(build_preferences_printer(&parent_));
2354 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2355 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2356 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2357 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2358 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2359 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2360 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2361 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2362 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2363 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2364 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2365 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2366 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2367 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2368 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2369 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2370 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2372 // set up the feedback mechanism
2373 setPrehandler(dialog_->input_command);
2374 setPrehandler(dialog_->input_page_range);
2375 setPrehandler(dialog_->input_copies);
2376 setPrehandler(dialog_->input_reverse);
2377 setPrehandler(dialog_->input_to_printer);
2378 setPrehandler(dialog_->input_file_extension);
2379 setPrehandler(dialog_->input_spool_command);
2380 setPrehandler(dialog_->input_paper_type);
2381 setPrehandler(dialog_->input_even_pages);
2382 setPrehandler(dialog_->input_odd_pages);
2383 setPrehandler(dialog_->input_collated);
2384 setPrehandler(dialog_->input_landscape);
2385 setPrehandler(dialog_->input_to_file);
2386 setPrehandler(dialog_->input_extra_options);
2387 setPrehandler(dialog_->input_spool_prefix);
2388 setPrehandler(dialog_->input_paper_size);
2389 setPrehandler(dialog_->input_name);
2390 setPrehandler(dialog_->check_adapt_output);
2394 void FormPreferences::Printer::update(LyXRC const & rc)
2396 fl_set_button(dialog_->check_adapt_output,
2397 rc.print_adapt_output);
2398 fl_set_input(dialog_->input_command,
2399 rc.print_command.c_str());
2400 fl_set_input(dialog_->input_page_range,
2401 rc.print_pagerange_flag.c_str());
2402 fl_set_input(dialog_->input_copies,
2403 rc.print_copies_flag.c_str());
2404 fl_set_input(dialog_->input_reverse,
2405 rc.print_reverse_flag.c_str());
2406 fl_set_input(dialog_->input_to_printer,
2407 rc.print_to_printer.c_str());
2408 fl_set_input(dialog_->input_file_extension,
2409 rc.print_file_extension.c_str());
2410 fl_set_input(dialog_->input_spool_command,
2411 rc.print_spool_command.c_str());
2412 fl_set_input(dialog_->input_paper_type,
2413 rc.print_paper_flag.c_str());
2414 fl_set_input(dialog_->input_even_pages,
2415 rc.print_evenpage_flag.c_str());
2416 fl_set_input(dialog_->input_odd_pages,
2417 rc.print_oddpage_flag.c_str());
2418 fl_set_input(dialog_->input_collated,
2419 rc.print_collcopies_flag.c_str());
2420 fl_set_input(dialog_->input_landscape,
2421 rc.print_landscape_flag.c_str());
2422 fl_set_input(dialog_->input_to_file,
2423 rc.print_to_file.c_str());
2424 fl_set_input(dialog_->input_extra_options,
2425 rc.print_extra_options.c_str());
2426 fl_set_input(dialog_->input_spool_prefix,
2427 rc.print_spool_printerprefix.c_str());
2428 fl_set_input(dialog_->input_paper_size,
2429 rc.print_paper_dimension_flag.c_str());
2430 fl_set_input(dialog_->input_name,
2431 rc.printer.c_str());
2435 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2440 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2442 return dialog_.get();
2446 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2448 bool changed = false;
2450 pair<string, string> tmp =
2451 parseFontName(fl_get_input(dialog_->input_roman));
2452 if (rc.roman_font_name != tmp.first ||
2453 rc.roman_font_foundry != tmp.second) {
2455 rc.roman_font_name = tmp.first;
2456 rc.roman_font_foundry = tmp.second;
2459 tmp = parseFontName(fl_get_input(dialog_->input_sans));
2460 if (rc.sans_font_name != tmp.first ||
2461 rc.sans_font_foundry != tmp.second) {
2463 rc.sans_font_name = tmp.first;
2464 rc.sans_font_foundry = tmp.second;
2467 tmp = parseFontName(fl_get_input(dialog_->input_typewriter));
2468 if (rc.typewriter_font_name != tmp.first ||
2469 rc.typewriter_font_foundry != tmp.second) {
2471 rc.typewriter_font_name = tmp.first;
2472 rc.typewriter_font_foundry = tmp.second;
2475 string str = fl_get_input(dialog_->input_screen_encoding);
2476 if (rc.font_norm != str) {
2481 bool button = fl_get_button(dialog_->check_scalable);
2482 if (rc.use_scalable_fonts != button) {
2484 rc.use_scalable_fonts = button;
2487 unsigned int ivalue = static_cast<unsigned int>
2488 (fl_get_counter_value(dialog_->counter_zoom));
2489 if (rc.zoom != ivalue) {
2494 ivalue = static_cast<unsigned int>
2495 (fl_get_counter_value(dialog_->counter_dpi));
2496 if (rc.dpi != ivalue) {
2501 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2502 if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2504 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2507 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2508 if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2510 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2513 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2514 if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2516 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2519 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2520 if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2522 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2525 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2526 if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2528 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2531 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2532 if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2534 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2537 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2538 if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2540 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2543 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2544 if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2546 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2549 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2550 if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2552 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2555 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2556 if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2558 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2562 // Now update the buffers
2563 // Can anything below here affect the redraw process?
2564 parent_.controller().updateScreenFonts();
2569 void FormPreferences::ScreenFonts::build()
2571 dialog_.reset(build_preferences_screen_fonts(&parent_));
2573 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2574 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2576 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2577 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2578 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2579 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2580 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2581 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2582 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2583 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2584 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2585 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2586 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2587 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2588 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2589 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2590 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2591 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2593 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2594 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2595 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2596 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2597 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2598 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2599 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2600 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2601 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2602 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2604 // set up the feedback mechanism
2605 setPrehandler(dialog_->input_roman);
2606 setPrehandler(dialog_->input_sans);
2607 setPrehandler(dialog_->input_typewriter);
2608 setPrehandler(dialog_->counter_zoom);
2609 setPrehandler(dialog_->counter_dpi);
2610 setPrehandler(dialog_->check_scalable);
2611 setPrehandler(dialog_->input_screen_encoding);
2612 setPrehandler(dialog_->input_tiny);
2613 setPrehandler(dialog_->input_script);
2614 setPrehandler(dialog_->input_footnote);
2615 setPrehandler(dialog_->input_small);
2616 setPrehandler(dialog_->input_large);
2617 setPrehandler(dialog_->input_larger);
2618 setPrehandler(dialog_->input_largest);
2619 setPrehandler(dialog_->input_normal);
2620 setPrehandler(dialog_->input_huge);
2621 setPrehandler(dialog_->input_huger);
2626 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2628 if (ob == dialog_->input_roman)
2629 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2630 if (ob == dialog_->input_sans)
2631 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2632 if (ob == dialog_->input_typewriter)
2633 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2634 if (ob == dialog_->check_scalable)
2635 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2636 if (ob == dialog_->input_screen_encoding)
2637 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2638 if (ob == dialog_->counter_zoom)
2639 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2640 if (ob == dialog_->counter_dpi)
2641 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2642 if (ob == dialog_->input_tiny
2643 || ob == dialog_->input_script
2644 || ob == dialog_->input_footnote
2645 || ob == dialog_->input_small
2646 || ob == dialog_->input_large
2647 || ob == dialog_->input_larger
2648 || ob == dialog_->input_larger
2649 || ob == dialog_->input_largest
2650 || ob == dialog_->input_normal
2651 || ob == dialog_->input_huge
2652 || ob == dialog_->input_huger)
2653 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2658 bool FormPreferences::ScreenFonts::input()
2660 bool activate = true;
2663 // Make sure that all fonts all have positive entries
2664 // Also note that an empty entry is returned as 0.0 by strToDbl
2665 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2666 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2667 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2668 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2669 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2670 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2671 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2672 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2673 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2674 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2676 str = _("Fonts must be positive!");
2678 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2679 // Fontsizes -- tiny < script < footnote etc.
2680 strToDbl(fl_get_input(dialog_->input_script)) ||
2681 strToDbl(fl_get_input(dialog_->input_script)) >
2682 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2683 strToDbl(fl_get_input(dialog_->input_footnote)) >
2684 strToDbl(fl_get_input(dialog_->input_small)) ||
2685 strToDbl(fl_get_input(dialog_->input_small)) >
2686 strToDbl(fl_get_input(dialog_->input_normal)) ||
2687 strToDbl(fl_get_input(dialog_->input_normal)) >
2688 strToDbl(fl_get_input(dialog_->input_large)) ||
2689 strToDbl(fl_get_input(dialog_->input_large)) >
2690 strToDbl(fl_get_input(dialog_->input_larger)) ||
2691 strToDbl(fl_get_input(dialog_->input_larger)) >
2692 strToDbl(fl_get_input(dialog_->input_largest)) ||
2693 strToDbl(fl_get_input(dialog_->input_largest)) >
2694 strToDbl(fl_get_input(dialog_->input_huge)) ||
2695 strToDbl(fl_get_input(dialog_->input_huge)) >
2696 strToDbl(fl_get_input(dialog_->input_huger))) {
2699 str = _("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2703 parent_.postWarning(str);
2709 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2711 fl_set_input(dialog_->input_roman,
2712 makeFontName(rc.roman_font_name,
2713 rc.roman_font_foundry).c_str());
2714 fl_set_input(dialog_->input_sans,
2715 makeFontName(rc.sans_font_name,
2716 rc.sans_font_foundry).c_str());
2717 fl_set_input(dialog_->input_typewriter,
2718 makeFontName(rc.typewriter_font_name,
2719 rc.typewriter_font_foundry).c_str());
2720 fl_set_input(dialog_->input_screen_encoding,
2721 rc.font_norm.c_str());
2722 fl_set_button(dialog_->check_scalable,
2723 rc.use_scalable_fonts);
2724 fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2725 fl_set_counter_value(dialog_->counter_dpi, rc.dpi);
2726 fl_set_input(dialog_->input_tiny,
2727 tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2728 fl_set_input(dialog_->input_script,
2729 tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2730 fl_set_input(dialog_->input_footnote,
2731 tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2732 fl_set_input(dialog_->input_small,
2733 tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2734 fl_set_input(dialog_->input_normal,
2735 tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2736 fl_set_input(dialog_->input_large,
2737 tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2738 fl_set_input(dialog_->input_larger,
2739 tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2740 fl_set_input(dialog_->input_largest,
2741 tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2742 fl_set_input(dialog_->input_huge,
2743 tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2744 fl_set_input(dialog_->input_huger,
2745 tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2750 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2755 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2757 return dialog_.get();
2761 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2763 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2764 choice = trim(choice);
2766 rc.isp_command = choice;
2769 // If spell checker == "none", all other input set to off.
2770 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2771 rc.isp_use_alt_lang = false;
2772 rc.isp_alt_lang.erase();
2774 rc.isp_use_esc_chars = false;
2775 rc.isp_esc_chars.erase();
2777 rc.isp_use_pers_dict = false;
2778 rc.isp_pers_dict.erase();
2780 rc.isp_accept_compound = false;
2781 rc.isp_use_input_encoding = false;
2784 int button = fl_get_button(dialog_->check_alt_lang);
2785 choice = fl_get_input(dialog_->input_alt_lang);
2786 if (button && choice.empty()) button = 0;
2787 if (!button) choice.erase();
2789 rc.isp_use_alt_lang = static_cast<bool>(button);
2790 rc.isp_alt_lang = choice;
2792 button = fl_get_button(dialog_->check_escape_chars);
2793 choice = fl_get_input(dialog_->input_escape_chars);
2794 if (button && choice.empty()) button = 0;
2795 if (!button) choice.erase();
2797 rc.isp_use_esc_chars = static_cast<bool>(button);
2798 rc.isp_esc_chars = choice;
2800 button = fl_get_button(dialog_->check_personal_dict);
2801 choice = fl_get_input(dialog_->input_personal_dict);
2802 if (button && choice.empty()) button = 0;
2803 if (!button) choice.erase();
2805 rc.isp_use_pers_dict = static_cast<bool>(button);
2806 rc.isp_pers_dict = choice;
2808 button = fl_get_button(dialog_->check_compound_words);
2809 rc.isp_accept_compound = static_cast<bool>(button);
2811 button = fl_get_button(dialog_->check_input_enc);
2812 rc.isp_use_input_encoding = static_cast<bool>(button);
2823 void FormPreferences::SpellOptions::build()
2825 dialog_.reset(build_preferences_spelloptions(&parent_));
2827 fl_addto_choice(dialog_->choice_spell_command,
2828 _(" ispell | aspell "));
2829 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2830 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2831 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2833 // set up the feedback mechanism
2834 setPrehandler(dialog_->choice_spell_command);
2835 setPrehandler(dialog_->check_alt_lang);
2836 setPrehandler(dialog_->input_alt_lang);
2837 setPrehandler(dialog_->check_escape_chars);
2838 setPrehandler(dialog_->input_escape_chars);
2839 setPrehandler(dialog_->check_personal_dict);
2840 setPrehandler(dialog_->input_personal_dict);
2841 setPrehandler(dialog_->button_personal_dict);
2842 setPrehandler(dialog_->check_compound_words);
2843 setPrehandler(dialog_->check_input_enc);
2848 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2850 if (ob == dialog_->choice_spell_command)
2851 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2852 if (ob == dialog_->check_alt_lang)
2853 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2854 if (ob == dialog_->input_alt_lang)
2855 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2856 if (ob == dialog_->check_escape_chars)
2857 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2858 if (ob == dialog_->input_escape_chars)
2859 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2860 if (ob == dialog_->check_personal_dict)
2861 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2862 if (ob == dialog_->input_personal_dict)
2863 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2864 if (ob == dialog_->check_compound_words)
2865 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2866 if (ob == dialog_->check_input_enc)
2867 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
2872 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2874 // !ob if function is called from updateSpellOptions() to de/activate
2876 // otherwise the function is called by an xforms CB via input().
2879 // If spell checker == "none", disable all input.
2880 if (!ob || ob == dialog_->choice_spell_command) {
2881 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2882 fl_deactivate_object(dialog_->check_alt_lang);
2883 fl_deactivate_object(dialog_->input_alt_lang);
2884 fl_deactivate_object(dialog_->check_escape_chars);
2885 fl_deactivate_object(dialog_->input_escape_chars);
2886 fl_deactivate_object(dialog_->check_personal_dict);
2887 fl_deactivate_object(dialog_->input_personal_dict);
2888 fl_deactivate_object(dialog_->check_compound_words);
2889 fl_deactivate_object(dialog_->check_input_enc);
2892 fl_activate_object(dialog_->check_alt_lang);
2893 fl_activate_object(dialog_->check_escape_chars);
2894 fl_activate_object(dialog_->check_personal_dict);
2895 fl_activate_object(dialog_->check_compound_words);
2896 fl_activate_object(dialog_->check_input_enc);
2901 if (!ob || ob == dialog_->check_alt_lang) {
2902 bool const enable = fl_get_button(dialog_->check_alt_lang);
2903 setEnabled(dialog_->input_alt_lang, enable);
2906 if (!ob || ob == dialog_->check_escape_chars) {
2907 bool const enable = fl_get_button(dialog_->check_escape_chars);
2908 setEnabled(dialog_->input_escape_chars, enable);
2911 if (!ob || ob == dialog_->check_personal_dict) {
2912 bool const enable = fl_get_button(dialog_->check_personal_dict);
2913 setEnabled(dialog_->input_personal_dict, enable);
2916 if (ob == dialog_->button_personal_dict) {
2917 string f = parent_.controller().browsedict(
2918 fl_get_input(dialog_->input_personal_dict));
2919 fl_set_input(dialog_->input_personal_dict, f.c_str());
2922 return true; // All input is valid!
2926 void FormPreferences::SpellOptions::update(LyXRC const & rc)
2930 if (rc.isp_command == "none")
2932 else if (rc.isp_command == "ispell")
2934 else if (rc.isp_command == "aspell")
2937 if (rc.isp_command == "ispell")
2939 else if (rc.isp_command == "aspell")
2942 fl_set_choice(dialog_->choice_spell_command, choice);
2945 if (rc.isp_use_alt_lang)
2946 str = rc.isp_alt_lang;
2948 fl_set_button(dialog_->check_alt_lang,
2949 rc.isp_use_alt_lang);
2950 fl_set_input(dialog_->input_alt_lang, str.c_str());
2953 if (rc.isp_use_esc_chars)
2954 str = rc.isp_esc_chars;
2956 fl_set_button(dialog_->check_escape_chars,
2957 rc.isp_use_esc_chars);
2958 fl_set_input(dialog_->input_escape_chars, str.c_str());
2961 if (rc.isp_use_pers_dict)
2962 str = rc.isp_pers_dict;
2964 fl_set_button(dialog_->check_personal_dict,
2965 rc.isp_use_pers_dict);
2966 fl_set_input(dialog_->input_personal_dict, str.c_str());
2968 fl_set_button(dialog_->check_compound_words,
2969 rc.isp_accept_compound);
2970 fl_set_button(dialog_->check_input_enc,
2971 rc.isp_use_input_encoding);
2973 // Activate/Deactivate the input fields dependent on the state of the