2 * \file FormPreferences.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS
14 #include "ControlPrefs.h"
15 #include "FormPreferences.h"
16 #include "forms/form_preferences.h"
21 #include "input_validators.h"
22 #include "forms_gettext.h"
23 #include "xforms_helpers.h"
24 #include "helper_funcs.h" // getSecond
27 #include "converter.h"
30 #include "frnt_lang.h"
35 #include "funcrequest.h"
38 #include "support/lyxfunctional.h"
39 #include "support/lyxmanip.h"
40 #include "support/filetools.h"
41 #include "support/LAssert.h"
43 #include "graphics/GraphicsCache.h"
44 #include "graphics/GraphicsTypes.h"
46 #include <boost/bind.hpp>
48 #include FORMS_H_LOCATION
62 extern string system_lyxdir;
63 extern string user_lyxdir;
67 // These should probably go inside the class definition...
68 Formats local_formats;
69 Converters local_converters;
71 string makeFontName(string const & family, string const & foundry)
75 return family + ',' + foundry;
79 pair<string,string> parseFontName(string const & name)
81 string::size_type const idx = name.find(',');
82 if (idx == string::npos)
83 return make_pair(name, string());
84 return make_pair(name.substr(0, idx),
89 string const X11hexname(RGBColor const & col)
93 ostr << '#' << std::setbase(16) << setfill('0')
98 return STRCONV(ostr.str());
104 typedef FormCB<ControlPrefs, FormDB<FD_preferences> > base_class;
106 FormPreferences::FormPreferences()
107 : base_class(_("Preferences"), false),
108 colors_(*this), converters_(*this), inputs_misc_(*this),
109 formats_(*this), interface_(*this), language_(*this),
110 lnf_misc_(*this), identity_(*this), outputs_misc_(*this),
111 paths_(*this), printer_(*this), screen_fonts_(*this),
117 void FormPreferences::redraw()
119 if (!(form() && form()->visible))
121 fl_redraw_form(form());
123 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
124 if (!(form2 && form2->visible))
126 fl_redraw_form(form2);
129 if (form2 == converters_tab_->form)
130 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
132 else if (form2 == look_n_feel_tab_->form)
133 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
135 else if (form2 == inputs_tab_->form)
136 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
138 else if (form2 == outputs_tab_->form)
139 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
141 else if (form2 == lang_opts_tab_->form)
142 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
144 if (form3 && form3->visible)
145 fl_redraw_form(form3);
149 void FormPreferences::hide()
151 // We need to hide the active tabfolder otherwise we get a
152 // BadDrawable error from X window and LyX crashes without saving.
153 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
154 if (inner_form && inner_form->visible)
155 fl_hide_form(inner_form);
160 void FormPreferences::build()
162 dialog_.reset(build_preferences(this));
164 // Manage the restore, save, apply and cancel/close buttons
165 bc().setOK(dialog_->button_ok);
166 bc().setApply(dialog_->button_apply);
167 bc().setCancel(dialog_->button_close);
168 bc().setRestore(dialog_->button_restore);
170 // Allow the base class to control messages
171 setMessageWidget(dialog_->text_warning);
173 // build the tab folders
174 converters_tab_.reset(build_preferences_inner_tab(this));
175 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
176 inputs_tab_.reset(build_preferences_inner_tab(this));
177 outputs_tab_.reset(build_preferences_inner_tab(this));
178 lang_opts_tab_.reset(build_preferences_inner_tab(this));
180 // build actual tabfolder contents
181 // these will become nested tabfolders
185 inputs_misc_.build();
190 outputs_misc_.build();
193 screen_fonts_.build();
194 spelloptions_.build();
196 // Now add them to the tabfolder
197 fl_addto_tabfolder(dialog_->tabfolder_prefs,
199 look_n_feel_tab_->form);
200 fl_addto_tabfolder(dialog_->tabfolder_prefs,
202 lang_opts_tab_->form);
203 fl_addto_tabfolder(dialog_->tabfolder_prefs,
205 converters_tab_->form);
206 fl_addto_tabfolder(dialog_->tabfolder_prefs,
209 fl_addto_tabfolder(dialog_->tabfolder_prefs,
213 // now build the nested tabfolders
214 // Starting with look and feel
215 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
217 screen_fonts_.dialog()->form);
218 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
220 interface_.dialog()->form);
221 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
223 colors_.dialog()->form);
224 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
226 lnf_misc_.dialog()->form);
227 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
229 identity_.dialog()->form);
231 // then build converters
232 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
234 formats_.dialog()->form);
235 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
237 converters_.dialog()->form);
240 // Paths should probably go in a few inner_tab called Files
241 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
243 paths_.dialog()->form);
244 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
246 inputs_misc_.dialog()->form);
248 // then building outputs
249 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
251 printer_.dialog()->form);
252 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
254 outputs_misc_.dialog()->form);
256 // then building usage
257 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
259 spelloptions_.dialog()->form);
260 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
262 language_.dialog()->form);
264 // work-around xforms bug re update of folder->x, folder->y coords.
265 setPrehandler(look_n_feel_tab_->tabfolder_inner);
266 setPrehandler(converters_tab_->tabfolder_inner);
267 setPrehandler(inputs_tab_->tabfolder_inner);
268 setPrehandler(outputs_tab_->tabfolder_inner);
269 setPrehandler(lang_opts_tab_->tabfolder_inner);
273 void FormPreferences::apply()
275 // set the new lyxrc entries
276 // many of these need to trigger other functions when the assignment
277 // is made. For example, screen zoom and font types. These could be
278 // handled either by signals/slots in lyxrc or just directly call the
279 // associated functions here.
280 // There are other problems with this scheme. We really should check
281 // what we copy to make sure that it really is necessary to do things
282 // like update the screen fonts because that flushes the textcache
283 // and other stuff which may cost us a lot on slower/high-load
286 LyXRC & rc(controller().rc());
289 formats_.apply(); // Must be before converters_.apply()
291 inputs_misc_.apply(rc);
292 interface_.apply(rc);
296 outputs_misc_.apply(rc);
299 screen_fonts_.apply(rc);
300 spelloptions_.apply(rc);
302 // The "Save" button has been pressed.
303 if (controller().isClosing() && colors_.modifiedXformsPrefs) {
304 string const filename =
305 AddName(user_lyxdir, "preferences.xform");
306 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
311 string const FormPreferences::getFeedback(FL_OBJECT * ob)
315 if (ob->form->fdui == colors_.dialog())
316 return colors_.feedback(ob);
317 if (ob->form->fdui == converters_.dialog())
318 return converters_.feedback(ob);
319 if (ob->form->fdui == formats_.dialog())
320 return formats_.feedback(ob);
321 if (ob->form->fdui == inputs_misc_.dialog())
322 return inputs_misc_.feedback(ob);
323 if (ob->form->fdui == interface_.dialog())
324 return interface_.feedback(ob);
325 if (ob->form->fdui == language_.dialog())
326 return language_.feedback(ob);
327 if (ob->form->fdui == lnf_misc_.dialog())
328 return lnf_misc_.feedback(ob);
329 if (ob->form->fdui == outputs_misc_.dialog())
330 return outputs_misc_.feedback(ob);
331 if (ob->form->fdui == paths_.dialog())
332 return paths_.feedback(ob);
333 if (ob->form->fdui == printer_.dialog())
334 return printer_.feedback(ob);
335 if (ob->form->fdui == screen_fonts_.dialog())
336 return screen_fonts_.feedback(ob);
337 if (ob->form->fdui == spelloptions_.dialog())
338 return spelloptions_.feedback(ob);
344 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
350 // whatever checks you need to ensure the user hasn't entered
351 // some totally ridiculous value somewhere. Change activate to suit.
352 // comments before each test describe what is _valid_
354 if (ob->form->fdui == colors_.dialog()) {
356 } else if (ob->form->fdui == converters_.dialog()) {
357 valid = converters_.input(ob);
358 } else if (ob->form->fdui == formats_.dialog()) {
359 valid = formats_.input(ob);
360 } else if (ob->form->fdui == interface_.dialog()) {
361 valid = interface_.input(ob);
362 } else if (ob->form->fdui == language_.dialog()) {
363 valid = language_.input(ob);
364 } else if (ob->form->fdui == paths_.dialog()) {
365 valid = paths_.input(ob);
366 } else if (ob->form->fdui == screen_fonts_.dialog()) {
367 valid = screen_fonts_.input();
368 } else if (ob->form->fdui == spelloptions_.dialog()) {
369 valid = spelloptions_.input(ob);
372 return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
376 void FormPreferences::update()
378 if (!dialog_.get()) return;
380 LyXRC const & rc(controller().rc());
382 // read lyxrc entries
384 formats_.update(); // Must be before converters_.update()
385 converters_.update();
386 inputs_misc_.update(rc);
387 interface_.update(rc);
388 language_.update(rc);
389 lnf_misc_.update(rc);
390 identity_.update(rc);
391 outputs_misc_.update(rc);
394 screen_fonts_.update(rc);
395 spelloptions_.update(rc);
399 FormPreferences::Colors::Colors(FormPreferences & p)
400 : modifiedXformsPrefs(false), parent_(p)
404 FD_preferences_colors const * FormPreferences::Colors::dialog()
406 return dialog_.get();
410 void FormPreferences::Colors::apply()
412 bool modifiedText = false;
413 bool modifiedBackground = false;
415 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
416 cit != xformsColorDB.end(); ++cit) {
418 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
419 if (col != cit->color()) {
420 modifiedXformsPrefs = true;
421 if (cit->colorID == FL_BLACK)
423 if (cit->colorID == FL_COL1)
424 modifiedBackground = true;
428 if (modifiedXformsPrefs) {
429 for (vector<XformsColor>::const_iterator cit =
430 xformsColorDB.begin();
431 cit != xformsColorDB.end(); ++cit) {
432 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
434 if (modifiedText && cit->colorID == FL_BLACK) {
435 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
438 if (modifiedBackground && cit->colorID == FL_COL1) {
439 AdjustVal(FL_MCOL, FL_COL1, 0.1);
440 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
441 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
443 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
444 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
447 if (cit->colorID == GUI_COLOR_CURSOR) {
448 fl_mapcolor(GUI_COLOR_CURSOR,
449 cit->r, cit->g, cit->b);
450 setCursorColor(GUI_COLOR_CURSOR);
453 parent_.controller().redrawGUI();
456 // Now do the same for the LyX LColors...
457 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
458 cit != lyxColorDB.end(); ++cit) {
459 LColor::color lc = lcolor.getFromGUIName(cit->getname());
460 if (lc == LColor::inherit) continue;
462 // Create a valid X11 name of the form "#rrggbb"
463 string const hexname = X11hexname(cit->color());
465 if (lcolor.getX11Name(lc) != hexname) {
467 << "FormPreferences::Colors::apply: "
468 << "resetting LColor " << lcolor.getGUIName(lc)
469 << " from \"" << lcolor.getX11Name(lc)
470 << "\" to \"" << hexname << "\"."
473 parent_.controller().setColor(lc, hexname);
479 void FormPreferences::Colors::build()
481 dialog_.reset(build_preferences_colors(&parent_));
483 fl_set_object_color(dialog_->button_color,
484 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
486 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
487 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
488 fl_set_dial_step(dialog_->dial_hue, 1.0);
489 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
491 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
492 fl_set_slider_step(dialog_->slider_saturation, 0.01);
493 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
495 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
496 fl_set_slider_step(dialog_->slider_value, 0.01);
497 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
499 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
500 fl_set_slider_step(dialog_->slider_red, 1.0);
501 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
503 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
504 fl_set_slider_step(dialog_->slider_green, 1.0);
505 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
507 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
508 fl_set_slider_step(dialog_->slider_blue, 1.0);
509 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
511 // set up the feedback mechanism
512 setPrehandler(dialog_->browser_lyx_objs);
513 setPrehandler(dialog_->button_color);
514 setPrehandler(dialog_->button_modify);
515 setPrehandler(dialog_->dial_hue);
516 setPrehandler(dialog_->slider_saturation);
517 setPrehandler(dialog_->slider_value);
518 setPrehandler(dialog_->slider_red);
519 setPrehandler(dialog_->slider_green);
520 setPrehandler(dialog_->slider_blue);
521 setPrehandler(dialog_->radio_rgb);
522 setPrehandler(dialog_->radio_hsv);
527 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
529 if (ob == dialog_->browser_lyx_objs)
530 return _("LyX objects that can be assigned a color.");
532 if (ob == dialog_->button_modify)
533 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
535 if (ob == dialog_->dial_hue ||
536 ob == dialog_->slider_saturation ||
537 ob == dialog_->slider_value ||
538 ob == dialog_->slider_red ||
539 ob == dialog_->slider_green ||
540 ob == dialog_->slider_blue)
541 return _("Find a new color.");
543 if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
544 return _("Toggle between RGB and HSV color spaces.");
550 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
552 if (ob == dialog_->browser_lyx_objs) {
555 } else if (ob == dialog_->dial_hue ||
556 ob == dialog_->slider_saturation ||
557 ob == dialog_->slider_value) {
560 } else if (ob == dialog_->slider_red ||
561 ob == dialog_->slider_green ||
562 ob == dialog_->slider_blue) {
565 } else if (ob == dialog_->radio_rgb ||
566 ob == dialog_->radio_hsv) {
569 } else if (ob == dialog_->button_modify) {
575 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
579 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
583 hsv.v = min(1.0, max(0.0, hsv.v));
586 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
590 void FormPreferences::Colors::InputBrowserLyX() const
592 vector<NamedColor>::size_type const selLyX =
593 fl_get_browser(dialog_->browser_lyx_objs);
594 if (selLyX < 1) return;
596 // Is the choice an Xforms color...
599 if (selLyX - 1 < xformsColorDB.size()) {
600 vector<XformsColor>::size_type const i = selLyX - 1;
601 col = xformsColorDB[i].color();
603 // or a LyX Logical color?
605 vector<NamedColor>::size_type const i = selLyX - 1 -
606 xformsColorDB.size();
607 col = lyxColorDB[i].color();
610 fl_freeze_form(dialog_->form);
612 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
613 fl_redraw_object(dialog_->button_color);
615 // Display either RGB or HSV but not both!
618 // Deactivate the modify button to begin with...
619 setEnabled(dialog_->button_modify, false);
621 fl_unfreeze_form(dialog_->form);
625 void FormPreferences::Colors::InputHSV()
627 double const hue = fl_get_dial_value(dialog_->dial_hue);
628 double const sat = fl_get_slider_value(dialog_->slider_saturation);
629 double const val = fl_get_slider_value(dialog_->slider_value);
631 int const h = int(hue);
632 int const s = int(100.0 * sat);
633 int const v = int(100.0 * val);
635 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
637 fl_set_object_label(dialog_->text_color_values, label.c_str());
639 RGBColor col = HSVColor(hue, sat, val);
641 fl_freeze_form(dialog_->form);
643 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
644 fl_redraw_object(dialog_->button_color);
646 col = HSVColor(hue, 1.0, 1.0);
647 col.r = max(col.r, 0u);
648 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
649 fl_redraw_object(dialog_->dial_hue);
651 // Ascertain whether to activate the Modify button.
652 vector<NamedColor>::size_type const selLyX =
653 fl_get_browser(dialog_->browser_lyx_objs);
655 fl_unfreeze_form(dialog_->form);
656 if (selLyX < 1) return;
658 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
661 // Is the choice an Xforms color...
662 if (selLyX - 1 < xformsColorDB.size()) {
663 vector<XformsColor>::size_type const i = selLyX - 1;
664 modify = (xformsColorDB[i].color() != col);
666 // or a LyX Logical color?
668 vector<NamedColor>::size_type const i = selLyX - 1 -
669 xformsColorDB.size();
670 modify = (lyxColorDB[i].color() != col);
673 setEnabled(dialog_->button_modify, modify);
677 void FormPreferences::Colors::InputRGB()
679 int const red = int(fl_get_slider_value(dialog_->slider_red));
680 int const green = int(fl_get_slider_value(dialog_->slider_green));
681 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
683 string const label = tostr(red) + string(", ") + tostr(green) +
684 string(", ") + tostr(blue);
685 fl_set_object_label(dialog_->text_color_values, label.c_str());
687 fl_freeze_form(dialog_->form);
689 RGBColor col = RGBColor(red, green, blue);
690 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
691 fl_redraw_object(dialog_->button_color);
693 // Ascertain whether to activate the Modify button.
694 vector<NamedColor>::size_type const selLyX =
695 fl_get_browser(dialog_->browser_lyx_objs);
697 fl_unfreeze_form(dialog_->form);
698 if (selLyX < 1) return;
702 // Is the choice an Xforms color...
703 if (selLyX - 1 < xformsColorDB.size()) {
704 vector<XformsColor>::size_type const i = selLyX - 1;
705 modify = (xformsColorDB[i].color() != col);
707 // or a LyX Logical color?
709 vector<NamedColor>::size_type const i = selLyX - 1 -
710 xformsColorDB.size();
711 modify = (lyxColorDB[i].color() != col);
714 setEnabled(dialog_->button_modify, modify);
718 void FormPreferences::Colors::LoadBrowserLyX()
720 if (!dialog_->browser_lyx_objs->visible)
723 // First, define the modifiable xforms colors
724 xformsColorDB.clear();
727 xcol.name = _("GUI background");
728 xcol.colorID = FL_COL1;
729 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
731 xformsColorDB.push_back(xcol);
733 xcol.name = _("GUI text");
734 xcol.colorID = FL_BLACK;
735 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
737 xformsColorDB.push_back(xcol);
739 xcol.name = _("GUI selection");
740 xcol.colorID = FL_YELLOW;
741 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
743 xformsColorDB.push_back(xcol);
745 xcol.name = _("GUI pointer");
746 xcol.colorID = GUI_COLOR_CURSOR;
747 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
749 xformsColorDB.push_back(xcol);
751 // Now create the the LyX LColors database
753 for (int i=0; i<LColor::ignore; ++i) {
754 LColor::color lc = static_cast<LColor::color>(i);
755 if (lc == LColor::none
756 || lc == LColor::black
757 || lc == LColor::white
759 || lc == LColor::green
760 || lc == LColor::blue
761 || lc == LColor::cyan
762 || lc == LColor::magenta
763 || lc == LColor::yellow
764 || lc == LColor::inherit
765 || lc == LColor::ignore) continue;
768 bool const success = getRGBColor(lc, col.r, col.g, col.b);
770 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
771 << "LColor " << lcolor.getLyXName(lc)
772 << ": X can't find color \""
773 << lcolor.getX11Name(lc)
774 << "\". Set to \"black\"!" << endl;
776 string const arg = lcolor.getLyXName(lc) + " black";
777 parent_.controller().setColor(lc, "black");
781 // Create a valid X11 name of the form "#rrggbb" and change the
782 // LColor X11name to this. Don't want to trigger a redraw,
783 // as we're just changing the name not the RGB values.
784 // Also reset the system_lcolor names, so that we don't output
785 // unnecessary changes.
786 string const hexname = X11hexname(col);
788 if (lcolor.getX11Name(lc) != hexname) {
789 lcolor.setColor(lc, hexname);
790 system_lcolor.setColor(lc, hexname);
793 // Finally, push the color onto the database
794 NamedColor ncol(lcolor.getGUIName(lc), col);
795 lyxColorDB.push_back(ncol);
798 // Now construct the browser
799 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
800 fl_freeze_form(dialog_->form);
801 fl_clear_browser(colbr);
802 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
803 cit != xformsColorDB.end(); ++cit) {
804 fl_addto_browser(colbr, cit->getname().c_str());
806 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
807 cit != lyxColorDB.end(); ++cit) {
808 fl_addto_browser(colbr, cit->getname().c_str());
811 // just to be safe...
812 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
813 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
814 fl_unfreeze_form(dialog_->form);
820 void FormPreferences::Colors::Modify()
822 vector<NamedColor>::size_type const selLyX =
823 fl_get_browser(dialog_->browser_lyx_objs);
828 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
830 // Is the choice an Xforms color...
831 if (selLyX - 1 < xformsColorDB.size()) {
832 vector<XformsColor>::size_type const i = selLyX - 1;
833 xformsColorDB[i].r = col.r;
834 xformsColorDB[i].g = col.g;
835 xformsColorDB[i].b = col.b;
837 // or a LyX Logical color?
839 vector<NamedColor>::size_type const i = selLyX - 1 -
840 xformsColorDB.size();
841 lyxColorDB[i].r = col.r;
842 lyxColorDB[i].g = col.g;
843 lyxColorDB[i].b = col.b;
846 fl_freeze_form(dialog_->form);
847 setEnabled(dialog_->button_modify, false);
848 fl_unfreeze_form(dialog_->form);
852 void FormPreferences::Colors::SwitchColorSpace() const
854 bool const hsv = fl_get_button(dialog_->radio_hsv);
857 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
859 fl_freeze_form(dialog_->form);
862 fl_hide_object(dialog_->slider_red);
863 fl_hide_object(dialog_->slider_blue);
864 fl_hide_object(dialog_->slider_green);
865 fl_show_object(dialog_->dial_hue);
866 fl_show_object(dialog_->slider_saturation);
867 fl_show_object(dialog_->slider_value);
869 HSVColor hsv = HSVColor(col);
870 hsv.h = max(hsv.h, 0.0);
872 fl_set_dial_value(dialog_->dial_hue, hsv.h);
873 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
874 fl_set_slider_value(dialog_->slider_value, hsv.v);
876 col = HSVColor(hsv.h, 1.0, 1.0);
877 col.r = max(col.r, 0u);
878 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
879 fl_redraw_object(dialog_->dial_hue);
881 // Adjust the label a bit, but not the actual values.
882 // Means that toggling from one space to the other has no
883 // effect on the final color.
884 int const h = int(hsv.h);
885 int const s = int(100 * hsv.s);
886 int const v = int(100 * hsv.v);
887 string const label = tostr(h) + ", " + tostr(s) +
889 fl_set_object_label(dialog_->text_color_values, label.c_str());
892 fl_show_object(dialog_->slider_red);
893 fl_show_object(dialog_->slider_blue);
894 fl_show_object(dialog_->slider_green);
895 fl_hide_object(dialog_->dial_hue);
896 fl_hide_object(dialog_->slider_saturation);
897 fl_hide_object(dialog_->slider_value);
899 fl_set_slider_value(dialog_->slider_red, col.r);
900 fl_set_slider_value(dialog_->slider_green, col.g);
901 fl_set_slider_value(dialog_->slider_blue, col.b);
903 // Adjust the label a bit. Same reasoning as above.
904 int const r = int(col.r);
905 int const g = int(col.g);
906 int const b = int(col.b);
907 string const label = tostr(r) + ", " + tostr(g) +
909 fl_set_object_label(dialog_->text_color_values, label.c_str());
912 fl_unfreeze_form(dialog_->form);
916 FormPreferences::Converters::Converters(FormPreferences & p)
921 FD_preferences_converters const * FormPreferences::Converters::dialog()
923 return dialog_.get();
927 void FormPreferences::Converters::apply() const
929 parent_.controller().setConverters(local_converters);
933 void FormPreferences::Converters::build()
935 dialog_.reset(build_preferences_converters(&parent_));
937 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
938 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
940 // set up the feedback mechanism
941 setPrehandler(dialog_->browser_all);
942 setPrehandler(dialog_->button_delete);
943 setPrehandler(dialog_->button_add);
944 setPrehandler(dialog_->input_converter);
945 setPrehandler(dialog_->choice_from);
946 setPrehandler(dialog_->choice_to);
947 setPrehandler(dialog_->input_flags);
952 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
954 if (ob == dialog_->browser_all)
955 return _("All the currently defined converters known to LyX.");
957 if (ob == dialog_->choice_from)
958 return _("Convert \"from\" this format");
960 if (ob == dialog_->choice_to)
961 return _("Convert \"to\" this format");
963 if (ob == dialog_->input_converter)
964 return _("The conversion command. $$i is the input file name, "
965 "$$b is the file name without its extension and $$o is "
966 "the name of the output file. $$s can be used as path to "
967 "LyX's own collection of conversion scripts.");
969 if (ob == dialog_->input_flags)
970 return _("Extra information for the Converter class, whether and "
971 "how to parse the result, and various other things.");
973 if (ob == dialog_->button_delete)
974 return _("Remove the current converter from the list of available "
975 "converters. Note: you must then \"Apply\" the change.");
977 if (ob == dialog_->button_add) {
978 if (string(ob->label) == _("Add"))
979 return _("Add the current converter to the list of available "
980 "converters. Note: you must then \"Apply\" the change.");
982 return _("Modify the contents of the current converter. "
983 "Note: you must then \"Apply\" the change.");
990 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
992 if (ob == dialog_->browser_all)
995 if (ob == dialog_->choice_from
996 || ob == dialog_->choice_to
997 || ob == dialog_->input_converter
998 || ob == dialog_->input_flags)
1001 if (ob == dialog_->button_add)
1004 if (ob == dialog_->button_delete)
1011 void FormPreferences::Converters::update()
1013 local_converters = converters;
1014 local_converters.update(local_formats);
1019 void FormPreferences::Converters::UpdateBrowser()
1021 local_converters.sort();
1023 fl_freeze_form(dialog_->form);
1024 fl_clear_browser(dialog_->browser_all);
1025 for (::Converters::const_iterator cit = local_converters.begin();
1026 cit != local_converters.end(); ++cit) {
1027 string const name = cit->From->prettyname() + " -> "
1028 + cit->To->prettyname();
1029 fl_addto_browser(dialog_->browser_all, name.c_str());
1032 fl_unfreeze_form(dialog_->form);
1036 bool FormPreferences::Converters::Add()
1038 string const from = GetFrom();
1039 string const to = GetTo();
1040 string const command = fl_get_input(dialog_->input_converter);
1041 string const flags = fl_get_input(dialog_->input_flags);
1043 Converter const * old = local_converters.getConverter(from, to);
1044 local_converters.add(from, to, command, flags);
1046 local_converters.updateLast(local_formats);
1049 setEnabled(dialog_->button_add, false);
1055 bool FormPreferences::Converters::Browser()
1057 int const i = fl_get_browser(dialog_->browser_all);
1058 if (i <= 0) return false;
1060 fl_freeze_form(dialog_->form);
1062 Converter const & c = local_converters.get(i - 1);
1063 int j = local_formats.getNumber(c.from);
1065 fl_set_choice(dialog_->choice_from, j + 1);
1067 j = local_formats.getNumber(c.to);
1069 fl_set_choice(dialog_->choice_to, j + 1);
1071 fl_set_input(dialog_->input_converter, c.command.c_str());
1072 fl_set_input(dialog_->input_flags, c.flags.c_str());
1074 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
1075 fl_set_button_shortcut(dialog_->button_add,
1076 scex(_("Modify|#M")).c_str(), 1);
1078 setEnabled(dialog_->button_add, false);
1079 setEnabled(dialog_->button_delete, true);
1081 fl_unfreeze_form(dialog_->form);
1086 bool FormPreferences::Converters::erase()
1088 string const from = GetFrom();
1089 string const to = GetTo();
1091 local_converters.erase(from, to);
1097 bool FormPreferences::Converters::Input()
1099 string const from = GetFrom();
1100 string const to = GetTo();
1101 int const sel = local_converters.getNumber(from, to);
1103 fl_freeze_form(dialog_->form);
1106 fl_set_object_label(dialog_->button_add,
1107 idex(_("Add|#A")).c_str());
1108 fl_set_button_shortcut(dialog_->button_add,
1109 scex(_("Add|#A")).c_str(), 1);
1111 fl_deselect_browser(dialog_->browser_all);
1112 setEnabled(dialog_->button_delete, false);
1115 fl_set_object_label(dialog_->button_add,
1116 idex(_("Modify|#M")).c_str());
1117 fl_set_button_shortcut(dialog_->button_add,
1118 scex(_("Modify|#M")).c_str(), 1);
1120 int top = max(sel-5, 0);
1121 fl_set_browser_topline(dialog_->browser_all, top);
1122 fl_select_browser_line(dialog_->browser_all, sel+1);
1123 setEnabled(dialog_->button_delete, true);
1126 string const command = rtrim(fl_get_input(dialog_->input_converter));
1127 bool const enable = !(command.empty() || from == to);
1128 setEnabled(dialog_->button_add, enable);
1130 fl_unfreeze_form(dialog_->form);
1135 string const FormPreferences::Converters::GetFrom() const
1137 ::Formats::FormatList::size_type const i =
1138 fl_get_choice(dialog_->choice_from);
1140 if (i > 0 && i <= local_formats.size())
1141 return local_formats.get(i - 1).name();
1143 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1148 string const FormPreferences::Converters::GetTo() const
1150 ::Formats::FormatList::size_type const i =
1151 fl_get_choice(dialog_->choice_to);
1153 if (i > 0 && i <= local_formats.size())
1154 return local_formats.get(i - 1).name();
1156 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1161 void FormPreferences::Converters::UpdateChoices() const
1164 for (::Formats::const_iterator cit = local_formats.begin();
1165 cit != local_formats.end(); ++cit) {
1166 if (!choice.empty())
1170 choice += cit->prettyname();
1174 fl_clear_choice(dialog_->choice_from);
1175 fl_addto_choice(dialog_->choice_from, choice.c_str());
1177 fl_clear_choice(dialog_->choice_to);
1178 fl_addto_choice(dialog_->choice_to, choice.c_str());
1182 FormPreferences::Formats::Formats(FormPreferences & p)
1187 FD_preferences_formats const * FormPreferences::Formats::dialog()
1189 return dialog_.get();
1193 void FormPreferences::Formats::apply() const
1195 parent_.controller().setFormats(local_formats);
1199 void FormPreferences::Formats::build()
1201 dialog_.reset(build_preferences_formats(&parent_));
1203 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1204 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1205 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1206 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1207 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1209 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1211 // set up the feedback mechanism
1212 setPrehandler(dialog_->browser_all);
1213 setPrehandler(dialog_->input_format);
1214 setPrehandler(dialog_->input_gui_name);
1215 setPrehandler(dialog_->button_delete);
1216 setPrehandler(dialog_->button_add);
1217 setPrehandler(dialog_->input_extension);
1218 setPrehandler(dialog_->input_viewer);
1219 setPrehandler(dialog_->input_shrtcut);
1224 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1226 if (ob == dialog_->browser_all)
1227 return _("All the currently defined formats known to LyX.");
1229 if (ob == dialog_->input_format)
1230 return _("The format identifier.");
1232 if (ob == dialog_->input_gui_name)
1233 return _("The format name as it will appear in the menus.");
1235 if (ob == dialog_->input_shrtcut)
1236 return _("The keyboard accelerator. Use a letter in the GUI name. "
1239 if (ob == dialog_->input_extension)
1240 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1242 if (ob == dialog_->input_viewer)
1243 return _("The command used to launch the viewer application.");
1245 if (ob == dialog_->button_delete)
1246 return _("Remove the current format from the list of available "
1247 "formats. Note: you must then \"Apply\" the change.");
1249 if (ob == dialog_->button_add) {
1250 if (string(ob->label) == _("Add"))
1251 return _("Add the current format to the list of available "
1252 "formats. Note: you must then \"Apply\" the change.");
1254 return _("Modify the contents of the current format. Note: "
1255 "you must then \"Apply\" the change.");
1262 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1264 if (ob == dialog_->browser_all)
1267 if (ob == dialog_->input_format
1268 || ob == dialog_->input_gui_name
1269 || ob == dialog_->input_shrtcut
1270 || ob == dialog_->input_extension
1271 || ob == dialog_->input_viewer)
1274 if (ob == dialog_->button_add)
1277 if (ob == dialog_->button_delete)
1284 void FormPreferences::Formats::update()
1286 local_formats = formats;
1291 void FormPreferences::Formats::UpdateBrowser()
1293 local_formats.sort();
1295 fl_freeze_form(dialog_->form);
1296 fl_deselect_browser(dialog_->browser_all);
1297 fl_clear_browser(dialog_->browser_all);
1298 for (::Formats::const_iterator cit = local_formats.begin();
1299 cit != local_formats.end(); ++cit)
1300 fl_addto_browser(dialog_->browser_all,
1301 cit->prettyname().c_str());
1304 fl_unfreeze_form(dialog_->form);
1306 // Mustn't forget to update the Formats available to the converters_
1307 parent_.converters_.UpdateChoices();
1308 local_converters.update(local_formats);
1312 bool FormPreferences::Formats::Add()
1314 string const name = fl_get_input(dialog_->input_format);
1315 string const prettyname = fl_get_input(dialog_->input_gui_name);
1316 string const extension = fl_get_input(dialog_->input_extension);
1317 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1318 string const viewer = fl_get_input(dialog_->input_viewer);
1320 Format const * old = local_formats.getFormat(name);
1321 string const old_prettyname = old ? old->prettyname() : string();
1322 local_formats.add(name, extension, prettyname, shortcut);
1323 local_formats.setViewer(name, viewer);
1324 if (!old || prettyname != old_prettyname) {
1327 parent_.converters_.UpdateBrowser();
1329 setEnabled(dialog_->button_add, false);
1335 bool FormPreferences::Formats::Browser()
1337 int const i = fl_get_browser(dialog_->browser_all);
1341 fl_freeze_form(dialog_->form);
1343 Format const & f = local_formats.get(i - 1);
1345 fl_set_input(dialog_->input_format, f.name().c_str());
1346 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1347 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1348 fl_set_input(dialog_->input_extension, f.extension().c_str());
1349 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1351 fl_set_object_label(dialog_->button_add,
1352 idex(_("Modify|#M")).c_str());
1353 fl_set_button_shortcut(dialog_->button_add,
1354 scex(_("Modify|#M")).c_str(), 1);
1356 setEnabled(dialog_->button_add, false);
1357 setEnabled(dialog_->button_delete, true);
1359 fl_unfreeze_form(dialog_->form);
1364 bool FormPreferences::Formats::erase()
1366 string const name = fl_get_input(dialog_->input_format);
1368 if (local_converters.formatIsUsed(name)) {
1369 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1370 "Remove the converter first."));
1371 setEnabled(dialog_->button_delete, false);
1375 local_formats.erase(name);
1381 bool FormPreferences::Formats::Input()
1383 string const name = fl_get_input(dialog_->input_format);
1384 int const sel = local_formats.getNumber(name);
1385 fl_freeze_form(dialog_->form);
1388 fl_set_object_label(dialog_->button_add,
1389 idex(_("Add|#A")).c_str());
1390 fl_set_button_shortcut(dialog_->button_add,
1391 scex(_("Add|#A")).c_str(), 1);
1393 fl_deselect_browser(dialog_->browser_all);
1394 setEnabled(dialog_->button_delete, false);
1397 fl_set_object_label(dialog_->button_add,
1398 idex(_("Modify|#M")).c_str());
1399 fl_set_button_shortcut(dialog_->button_add,
1400 scex(_("Modify|#M")).c_str(), 1);
1402 int const top = max(sel-5, 0);
1403 fl_set_browser_topline(dialog_->browser_all, top);
1404 fl_select_browser_line(dialog_->browser_all, sel+1);
1406 setEnabled(dialog_->button_add, true);
1407 setEnabled(dialog_->button_delete, true);
1410 string const prettyname = fl_get_input(dialog_->input_gui_name);
1411 bool const enable = !(name.empty() || prettyname.empty());
1412 setEnabled(dialog_->button_add, enable);
1414 fl_unfreeze_form(dialog_->form);
1419 FormPreferences::Identity::Identity(FormPreferences & p)
1424 FD_preferences_identity const * FormPreferences::Identity::dialog()
1426 return dialog_.get();
1430 void FormPreferences::Identity::apply(LyXRC & rc) const
1432 rc.user_name = fl_get_input(dialog_->input_user_name);
1433 rc.user_email = fl_get_input(dialog_->input_user_email);
1437 void FormPreferences::Identity::build()
1439 dialog_.reset(build_preferences_identity(&parent_));
1440 fl_set_input_return(dialog_->input_user_name, FL_RETURN_CHANGED);
1441 fl_set_input_return(dialog_->input_user_email, FL_RETURN_CHANGED);
1445 void FormPreferences::Identity::update(LyXRC const & rc)
1447 fl_set_input(dialog_->input_user_name, rc.user_name.c_str());
1448 fl_set_input(dialog_->input_user_email, rc.user_email.c_str());
1452 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1457 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1459 return dialog_.get();
1463 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1465 rc.date_insert_format =
1466 fl_get_input(dialog_->input_date_format);
1470 void FormPreferences::InputsMisc::build()
1472 dialog_.reset(build_preferences_inputs_misc(&parent_));
1474 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1476 // set up the feedback mechanism
1477 setPrehandler(dialog_->input_date_format);
1482 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1484 if (ob == dialog_->input_date_format)
1485 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1490 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1492 fl_set_input(dialog_->input_date_format,
1493 rc.date_insert_format.c_str());
1497 FormPreferences::Interface::Interface(FormPreferences & p)
1502 FD_preferences_interface const * FormPreferences::Interface::dialog()
1504 return dialog_.get();
1508 void FormPreferences::Interface::apply(LyXRC & rc) const
1510 rc.popup_normal_font =
1511 fl_get_input(dialog_->input_popup_normal_font);
1512 rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1513 rc.popup_font_encoding =
1514 fl_get_input(dialog_->input_popup_font_encoding);
1515 rc.bind_file = fl_get_input(dialog_->input_bind_file);
1516 rc.ui_file = fl_get_input(dialog_->input_ui_file);
1520 void FormPreferences::Interface::build()
1522 dialog_.reset(build_preferences_interface(&parent_));
1524 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1525 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1526 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1527 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1528 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1530 // set up the feedback mechanism
1531 setPrehandler(dialog_->input_popup_normal_font);
1532 setPrehandler(dialog_->input_popup_bold_font);
1533 setPrehandler(dialog_->input_popup_font_encoding);
1534 setPrehandler(dialog_->input_bind_file);
1535 setPrehandler(dialog_->button_bind_file_browse);
1536 setPrehandler(dialog_->input_ui_file);
1537 setPrehandler(dialog_->button_ui_file_browse);
1542 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1544 if (ob == dialog_->input_popup_normal_font)
1545 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1546 if (ob == dialog_->input_popup_bold_font)
1547 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1548 if (ob == dialog_->input_popup_font_encoding)
1549 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1550 if (ob == dialog_->input_bind_file)
1551 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1552 if (ob == dialog_->input_ui_file)
1553 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1558 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1560 if (ob == dialog_->button_bind_file_browse) {
1561 string f = parent_.controller().browsebind(
1562 fl_get_input(dialog_->input_bind_file));
1564 fl_set_input(dialog_->input_bind_file, f.c_str());
1565 } else if (ob == dialog_->button_ui_file_browse) {
1566 string f = parent_.controller().browseUI(
1567 fl_get_input(dialog_->input_ui_file));
1569 fl_set_input(dialog_->input_ui_file, f.c_str());
1576 void FormPreferences::Interface::update(LyXRC const & rc)
1578 fl_set_input(dialog_->input_popup_normal_font,
1579 rc.popup_normal_font.c_str());
1580 fl_set_input(dialog_->input_popup_bold_font,
1581 rc.popup_bold_font.c_str());
1582 fl_set_input(dialog_->input_popup_font_encoding,
1583 rc.popup_font_encoding.c_str());
1584 fl_set_input(dialog_->input_bind_file,
1585 rc.bind_file.c_str());
1586 fl_set_input(dialog_->input_ui_file,
1587 rc.ui_file.c_str());
1591 FormPreferences::Language::Language(FormPreferences & p)
1596 FD_preferences_language const * FormPreferences::Language::dialog()
1598 return dialog_.get();
1602 void FormPreferences::Language::apply(LyXRC & rc)
1604 int const pos = combo_default_lang->get();
1605 rc.default_language = lang_[pos-1];
1607 int button = fl_get_button(dialog_->check_use_kbmap);
1608 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1609 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1611 button = !(name_1.empty() && name_2.empty());
1612 rc.use_kbmap = static_cast<bool>(button);
1615 rc.primary_kbmap = name_1;
1616 rc.secondary_kbmap = name_2;
1619 button = fl_get_button(dialog_->check_rtl_support);
1620 rc.rtl_support = static_cast<bool>(button);
1622 button = fl_get_button(dialog_->check_mark_foreign);
1623 rc.mark_foreign_language = static_cast<bool>(button);
1625 button = fl_get_button(dialog_->check_auto_begin);
1626 rc.language_auto_begin = static_cast<bool>(button);
1628 button = fl_get_button(dialog_->check_auto_end);
1629 rc.language_auto_end = static_cast<bool>(button);
1631 button = fl_get_button(dialog_->check_use_babel);
1632 rc.language_use_babel = static_cast<bool>(button);
1634 button = fl_get_button(dialog_->check_global_options);
1635 rc.language_global_options = static_cast<bool>(button);
1637 rc.language_package = fl_get_input(dialog_->input_package);
1638 rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1639 rc.language_command_end = fl_get_input(dialog_->input_command_end);
1641 // Ensure that all is self-consistent.
1646 void FormPreferences::Language::build()
1648 dialog_.reset(build_preferences_language(&parent_));
1650 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1651 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1652 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1654 // Store the lang identifiers for later
1655 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1656 lang_ = getSecond(langs);
1658 // The default_language is a combo-box and has to be inserted manually
1659 fl_freeze_form(dialog_->form);
1660 fl_addto_form(dialog_->form);
1662 FL_OBJECT * obj = dialog_->choice_default_lang;
1663 fl_deactivate_object(dialog_->choice_default_lang);
1664 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1665 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
1666 combo_default_lang->shortcut("#L",1);
1667 combo_default_lang->setcallback(ComboCB, &parent_);
1669 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1670 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1671 for (; lit != lend; ++lit) {
1672 combo_default_lang->addto(lit->first);
1674 combo_default_lang->select(1);
1677 fl_unfreeze_form(dialog_->form);
1679 // set up the feedback mechanism
1680 setPrehandler(dialog_->input_package);
1681 setPrehandler(dialog_->check_use_kbmap);
1683 // This is safe, as nothing is done to the pointer, other than
1684 // to use its address in a block-if statement.
1685 // No it's not! Leads to crash.
1687 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1688 // C_FormPreferencesFeedbackCB);
1690 setPrehandler(dialog_->input_kbmap1);
1691 setPrehandler(dialog_->input_kbmap2);
1692 setPrehandler(dialog_->check_rtl_support);
1693 setPrehandler(dialog_->check_mark_foreign);
1694 setPrehandler(dialog_->check_auto_begin);
1695 setPrehandler(dialog_->check_auto_end);
1696 setPrehandler(dialog_->check_use_babel);
1697 setPrehandler(dialog_->check_global_options);
1698 setPrehandler(dialog_->input_command_begin);
1699 setPrehandler(dialog_->input_command_end);
1701 // Activate/Deactivate the input fields dependent on the state of the
1708 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1710 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1711 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1712 if (ob == dialog_->check_use_kbmap)
1713 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1714 if (ob == dialog_->input_kbmap1)
1715 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1716 if (ob == dialog_->input_kbmap2)
1717 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1718 if (ob == dialog_->check_rtl_support)
1719 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1720 if (ob == dialog_->check_mark_foreign)
1721 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1722 if (ob == dialog_->check_auto_begin)
1723 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1724 if (ob == dialog_->check_auto_end)
1725 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1726 if (ob == dialog_->check_use_babel)
1727 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1728 if (ob == dialog_->check_global_options)
1729 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1730 if (ob == dialog_->input_package)
1731 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1732 if (ob == dialog_->input_command_begin)
1733 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1734 if (ob == dialog_->input_command_end)
1735 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1740 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1742 bool activate = true;
1744 // !ob if function is called from Language::build() to de/activate
1746 // otherwise the function is called by an xforms CB via input().
1747 if (!ob || ob == dialog_->check_use_kbmap) {
1748 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1749 setEnabled(dialog_->button_kbmap1_browse, enable);
1750 setEnabled(dialog_->button_kbmap2_browse, enable);
1751 setEnabled(dialog_->input_kbmap1, enable);
1752 setEnabled(dialog_->input_kbmap2, enable);
1755 if (ob == dialog_->button_kbmap1_browse) {
1756 string f = parent_.controller().browsekbmap(
1757 fl_get_input(dialog_->input_kbmap1));
1759 fl_set_input(dialog_->input_kbmap1, f.c_str());
1760 } else if (ob == dialog_->button_kbmap2_browse) {
1761 string f = parent_.controller().browsekbmap(
1762 fl_get_input(dialog_->input_kbmap2));
1764 fl_set_input(dialog_->input_kbmap2, f.c_str());
1771 void FormPreferences::Language::update(LyXRC const & rc)
1773 fl_set_button(dialog_->check_use_kbmap,
1776 int const pos = int(findPos(lang_, rc.default_language));
1777 combo_default_lang->select(pos + 1);
1780 fl_set_input(dialog_->input_kbmap1,
1781 rc.primary_kbmap.c_str());
1782 fl_set_input(dialog_->input_kbmap2,
1783 rc.secondary_kbmap.c_str());
1785 fl_set_input(dialog_->input_kbmap1, "");
1786 fl_set_input(dialog_->input_kbmap2, "");
1789 fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1790 fl_set_button(dialog_->check_mark_foreign,
1791 rc.mark_foreign_language);
1792 fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1793 fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1794 fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1795 fl_set_button(dialog_->check_global_options,
1796 rc.language_global_options);
1798 fl_set_input(dialog_->input_package,
1799 rc.language_package.c_str());
1800 fl_set_input(dialog_->input_command_begin,
1801 rc.language_command_begin.c_str());
1802 fl_set_input(dialog_->input_command_end,
1803 rc.language_command_end.c_str());
1805 // Activate/Deactivate the input fields dependent on the state of the
1811 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1813 FormPreferences * pre = static_cast<FormPreferences*>(v);
1814 // This is safe, as nothing is done to the pointer, other than
1815 // to use its address in a block-if statement.
1816 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1820 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1825 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1827 return dialog_.get();
1831 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1833 rc.auto_region_delete =
1834 fl_get_button(dialog_->check_auto_region_delete);
1835 rc.cursor_follows_scrollbar =
1836 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1837 rc.dialogs_iconify_with_main =
1838 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1839 rc.preview = fl_get_button(dialog_->check_preview_latex);
1840 rc.autosave = static_cast<unsigned int>
1841 (fl_get_counter_value(dialog_->counter_autosave));
1842 rc.wheel_jump = static_cast<unsigned int>
1843 (fl_get_counter_value(dialog_->counter_wm_jump));
1846 // grfx::DisplayType old_value = rc.display_graphics;
1847 switch (fl_get_choice(dialog_->choice_display)) {
1848 case 4: rc.display_graphics = grfx::NoDisplay; break;
1849 case 3: rc.display_graphics = grfx::ColorDisplay; break;
1850 case 2: rc.display_graphics = grfx::GrayscaleDisplay; break;
1851 case 1: rc.display_graphics = grfx::MonochromeDisplay; break;
1852 default: rc.display_graphics = grfx::ColorDisplay; break;
1855 #ifdef WITH_WARNINGS
1856 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1859 if (old_value != rc.display_graphics) {
1860 grfx::GCache & gc = grfx::GCache::get();
1867 void FormPreferences::LnFmisc::build()
1869 dialog_.reset(build_preferences_lnf_misc(&parent_));
1871 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1872 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1874 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1875 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1877 // set up the feedback mechanism
1878 setPrehandler(dialog_->check_auto_region_delete);
1879 setPrehandler(dialog_->counter_autosave);
1880 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1881 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1882 setPrehandler(dialog_->check_preview_latex);
1883 setPrehandler(dialog_->counter_wm_jump);
1885 fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
1890 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1892 if (ob == dialog_->check_auto_region_delete)
1893 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
1894 if (ob == dialog_->check_cursor_follows_scrollbar)
1895 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1896 if (ob == dialog_->check_dialogs_iconify_with_main)
1897 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1898 if (ob == dialog_->check_preview_latex)
1899 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
1900 if (ob == dialog_->counter_autosave)
1901 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
1902 if (ob == dialog_->counter_wm_jump)
1903 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
1904 if (ob == dialog_->choice_display)
1905 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1910 void FormPreferences::LnFmisc::update(LyXRC const & rc)
1912 fl_set_button(dialog_->check_auto_region_delete,
1913 rc.auto_region_delete);
1914 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1915 rc.cursor_follows_scrollbar);
1916 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1917 rc.dialogs_iconify_with_main);
1918 fl_set_button(dialog_->check_preview_latex,
1920 fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
1921 fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
1923 switch (rc.display_graphics) {
1924 case grfx::NoDisplay: fl_set_choice(dialog_->choice_display, 4); break;
1925 case grfx::ColorDisplay: fl_set_choice(dialog_->choice_display, 3); break;
1926 case grfx::GrayscaleDisplay: fl_set_choice(dialog_->choice_display, 2); break;
1927 case grfx::MonochromeDisplay: fl_set_choice(dialog_->choice_display, 1); break;
1928 default: fl_set_choice(dialog_->choice_display, 3); break;
1933 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1938 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1940 return dialog_.get();
1944 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
1946 rc.ascii_linelen = static_cast<unsigned int>
1947 (fl_get_counter_value(dialog_->counter_line_len));
1948 rc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1951 fl_get_choice(dialog_->choice_default_papersize) - 1;
1952 rc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1954 rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1955 rc.chktex_command = fl_get_input(dialog_->input_checktex);
1956 rc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1957 rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1961 void FormPreferences::OutputsMisc::build()
1963 dialog_.reset(build_preferences_outputs_misc(&parent_));
1965 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1967 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1968 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1969 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1970 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1971 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1973 fl_addto_choice(dialog_->choice_default_papersize,
1974 _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1976 // set up the feedback mechanism
1977 setPrehandler(dialog_->counter_line_len);
1978 setPrehandler(dialog_->input_tex_encoding);
1979 setPrehandler(dialog_->choice_default_papersize);
1980 setPrehandler(dialog_->input_ascii_roff);
1981 setPrehandler(dialog_->input_checktex);
1982 setPrehandler(dialog_->input_paperoption);
1983 setPrehandler(dialog_->check_autoreset_classopt);
1988 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1990 if (ob == dialog_->counter_line_len)
1991 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
1992 if (ob == dialog_->input_tex_encoding)
1993 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
1994 if (ob == dialog_->input_ascii_roff)
1995 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1996 if (ob == dialog_->input_checktex)
1997 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
1998 if (ob == dialog_->choice_default_papersize)
1999 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2000 if (ob == dialog_->input_paperoption)
2001 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
2002 if (ob == dialog_->check_autoreset_classopt)
2003 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2008 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
2010 fl_set_counter_value(dialog_->counter_line_len,
2012 fl_set_input(dialog_->input_tex_encoding,
2013 rc.fontenc.c_str());
2014 fl_set_choice(dialog_->choice_default_papersize,
2015 rc.default_papersize + 1);
2016 fl_set_input(dialog_->input_ascii_roff,
2017 rc.ascii_roff_command.c_str());
2018 fl_set_input(dialog_->input_checktex,
2019 rc.chktex_command.c_str());
2020 fl_set_input(dialog_->input_paperoption,
2021 rc.view_dvi_paper_option.c_str());
2022 fl_set_button(dialog_->check_autoreset_classopt,
2023 rc.auto_reset_options);
2028 FormPreferences::Paths::Paths(FormPreferences & p)
2033 FD_preferences_paths const * FormPreferences::Paths::dialog()
2035 return dialog_.get();
2039 void FormPreferences::Paths::apply(LyXRC & rc)
2041 rc.document_path = fl_get_input(dialog_->input_default_path);
2042 rc.template_path = fl_get_input(dialog_->input_template_path);
2044 int button = fl_get_button(dialog_->check_use_temp_dir);
2045 string str = fl_get_input(dialog_->input_temp_dir);
2049 rc.use_tempdir = button;
2050 rc.tempdir_path = str;
2052 button = fl_get_button(dialog_->check_last_files);
2053 str = fl_get_input(dialog_->input_lastfiles);
2054 if (!button) str.erase();
2056 rc.check_lastfiles = button;
2058 rc.num_lastfiles = static_cast<unsigned int>
2059 (fl_get_counter_value(dialog_->counter_lastfiles));
2061 button = fl_get_button(dialog_->check_make_backups);
2062 str = fl_get_input(dialog_->input_backup_path);
2066 rc.make_backup = button;
2067 rc.backupdir_path = str;
2069 rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2076 void FormPreferences::Paths::build()
2078 dialog_.reset(build_preferences_paths(&parent_));
2080 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2081 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2082 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2083 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2084 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2085 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2086 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2088 // set up the feedback mechanism
2089 setPrehandler(dialog_->input_default_path);
2090 setPrehandler(dialog_->counter_lastfiles);
2091 setPrehandler(dialog_->input_template_path);
2092 setPrehandler(dialog_->check_last_files);
2093 setPrehandler(dialog_->input_lastfiles);
2094 setPrehandler(dialog_->check_make_backups);
2095 setPrehandler(dialog_->input_backup_path);
2096 setPrehandler(dialog_->input_serverpipe);
2097 setPrehandler(dialog_->input_temp_dir);
2098 setPrehandler(dialog_->check_use_temp_dir);
2103 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2105 if (ob == dialog_->input_default_path)
2106 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2107 if (ob == dialog_->input_template_path)
2108 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2109 if (ob == dialog_->check_use_temp_dir)
2110 return LyXRC::getDescription(LyXRC::RC_USETEMPDIR);
2111 if (ob == dialog_->input_temp_dir)
2112 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2113 if (ob == dialog_->check_last_files)
2114 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2115 if (ob == dialog_->input_lastfiles)
2116 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
2117 if (ob == dialog_->counter_lastfiles)
2118 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2119 if (ob == dialog_->check_make_backups)
2120 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2121 if (ob == dialog_->input_backup_path)
2122 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2123 if (ob == dialog_->input_serverpipe)
2124 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2129 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2131 bool activate = true;
2133 // !ob if function is called from Paths::update() to de/activate
2135 // otherwise the function is called by an xforms CB via input().
2136 if (!ob || ob == dialog_->check_use_temp_dir) {
2137 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2138 setEnabled(dialog_->input_temp_dir, enable);
2141 if (!ob || ob == dialog_->check_last_files) {
2142 bool const enable = fl_get_button(dialog_->check_last_files);
2143 setEnabled(dialog_->input_lastfiles, enable);
2146 if (!ob || ob == dialog_->check_make_backups) {
2147 bool const enable = fl_get_button(dialog_->check_make_backups);
2148 setEnabled(dialog_->input_backup_path, enable);
2151 if (!ob || ob == dialog_->input_default_path) {
2152 string const name = fl_get_input(dialog_->input_default_path);
2153 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2154 parent_.postWarning(RWInfo::ErrorMessage());
2159 if (!ob || ob == dialog_->input_template_path) {
2160 string const name = fl_get_input(dialog_->input_template_path);
2161 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2162 parent_.postWarning(RWInfo::ErrorMessage());
2167 if (!ob || ob == dialog_->input_temp_dir) {
2168 string const name = fl_get_input(dialog_->input_temp_dir);
2169 if (fl_get_button(dialog_->check_make_backups)
2171 && !RWInfo::WriteableDir(name)) {
2172 parent_.postWarning(RWInfo::ErrorMessage());
2177 if (!ob || ob == dialog_->input_backup_path) {
2178 string const name = fl_get_input(dialog_->input_backup_path);
2179 if (fl_get_button(dialog_->check_make_backups)
2181 && !RWInfo::WriteableDir(name)) {
2182 parent_.postWarning(RWInfo::ErrorMessage());
2187 if (!ob || ob == dialog_->input_lastfiles) {
2188 string const name = fl_get_input(dialog_->input_lastfiles);
2189 if (fl_get_button(dialog_->check_last_files)
2191 && !RWInfo::WriteableFile(name)) {
2192 parent_.postWarning(RWInfo::ErrorMessage());
2197 if (!ob || ob == dialog_->input_serverpipe) {
2198 string const name = fl_get_input(dialog_->input_serverpipe);
2199 if (!name.empty()) {
2200 // strip off the extension
2201 string const str = ChangeExtension(name, "");
2202 if (!RWInfo::WriteableFile(str + ".in")) {
2203 parent_.postWarning(RWInfo::ErrorMessage());
2206 if (!RWInfo::WriteableFile(str + ".out")) {
2207 parent_.postWarning(RWInfo::ErrorMessage());
2213 if (ob == dialog_->button_default_path_browse) {
2214 string f = parent_.controller().browsedir(
2215 fl_get_input(dialog_->input_default_path), _("Default path"));
2217 fl_set_input(dialog_->input_default_path, f.c_str());
2218 } else if (ob == dialog_->button_template_path_browse) {
2219 string f = parent_.controller().browsedir(
2220 fl_get_input(dialog_->input_template_path), _("Template path"));
2222 fl_set_input(dialog_->input_template_path, f.c_str());
2223 } else if (ob == dialog_->button_temp_dir_browse) {
2224 string f = parent_.controller().browsedir(
2225 fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2227 fl_set_input(dialog_->input_temp_dir, f.c_str());
2228 } else if (ob == dialog_->button_lastfiles_browse) {
2229 string f = parent_.controller().browse(
2230 fl_get_input(dialog_->input_lastfiles), _("Last files"));
2232 fl_set_input(dialog_->input_lastfiles, f.c_str());
2233 } else if (ob == dialog_->button_backup_path_browse) {
2234 string f = parent_.controller().browsedir(
2235 fl_get_input(dialog_->input_backup_path), _("Backup path"));
2237 fl_set_input(dialog_->input_backup_path, f.c_str());
2238 } else if (ob == dialog_->button_serverpipe_browse) {
2239 string f = parent_.controller().browse(
2240 fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2242 fl_set_input(dialog_->input_serverpipe, f.c_str());
2249 void FormPreferences::Paths::update(LyXRC const & rc)
2251 fl_set_input(dialog_->input_default_path,
2252 rc.document_path.c_str());
2253 fl_set_input(dialog_->input_template_path,
2254 rc.template_path.c_str());
2258 str = rc.backupdir_path;
2260 fl_set_button(dialog_->check_make_backups,
2262 fl_set_input(dialog_->input_backup_path, str.c_str());
2266 str = rc.tempdir_path;
2268 fl_set_button(dialog_->check_use_temp_dir,
2270 fl_set_input(dialog_->input_temp_dir, str.c_str());
2273 if (rc.check_lastfiles)
2276 fl_set_button(dialog_->check_last_files,
2277 rc.check_lastfiles);
2278 fl_set_input(dialog_->input_lastfiles, str.c_str());
2279 fl_set_counter_value(dialog_->counter_lastfiles,
2282 fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2284 // Activate/Deactivate the input fields dependent on the state of the
2290 FormPreferences::Printer::Printer(FormPreferences & p)
2295 FD_preferences_printer const * FormPreferences::Printer::dialog()
2297 return dialog_.get();
2301 void FormPreferences::Printer::apply(LyXRC & rc) const
2303 rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2304 rc.print_command = fl_get_input(dialog_->input_command);
2305 rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2306 rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2307 rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2308 rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2309 rc.print_file_extension =
2310 fl_get_input(dialog_->input_file_extension);
2311 rc.print_spool_command =
2312 fl_get_input(dialog_->input_spool_command);
2313 rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2314 rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2315 rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2316 rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2317 rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2318 rc.print_to_file = fl_get_input(dialog_->input_to_file);
2319 rc.print_extra_options =
2320 fl_get_input(dialog_->input_extra_options);
2321 rc.print_spool_printerprefix =
2322 fl_get_input(dialog_->input_spool_prefix);
2323 rc.print_paper_dimension_flag =
2324 fl_get_input(dialog_->input_paper_size);
2325 rc.printer = fl_get_input(dialog_->input_name);
2330 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2332 if (ob == dialog_->input_command)
2333 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2334 if (ob == dialog_->check_adapt_output)
2335 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2336 if (ob == dialog_->input_to_printer)
2337 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2338 if (ob == dialog_->input_to_file)
2339 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2340 if (ob == dialog_->input_file_extension)
2341 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2342 if (ob == dialog_->input_extra_options)
2343 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2344 if (ob == dialog_->input_spool_command)
2345 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2346 if (ob == dialog_->input_spool_prefix)
2347 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2348 if (ob == dialog_->input_name)
2349 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2350 if (ob == dialog_->input_even_pages)
2351 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2352 if (ob == dialog_->input_odd_pages)
2353 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2354 if (ob == dialog_->input_page_range)
2355 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2356 if (ob == dialog_->input_reverse)
2357 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2358 if (ob == dialog_->input_landscape)
2359 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2360 if (ob == dialog_->input_copies)
2361 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2362 if (ob == dialog_->input_collated)
2363 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2364 if (ob == dialog_->input_paper_type)
2365 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2366 if (ob == dialog_->input_paper_size)
2367 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2372 void FormPreferences::Printer::build()
2374 dialog_.reset(build_preferences_printer(&parent_));
2376 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2377 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2378 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2379 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2380 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2381 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2382 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2383 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2384 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2385 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2386 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2387 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2388 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2389 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2390 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2391 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2392 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2394 // set up the feedback mechanism
2395 setPrehandler(dialog_->input_command);
2396 setPrehandler(dialog_->input_page_range);
2397 setPrehandler(dialog_->input_copies);
2398 setPrehandler(dialog_->input_reverse);
2399 setPrehandler(dialog_->input_to_printer);
2400 setPrehandler(dialog_->input_file_extension);
2401 setPrehandler(dialog_->input_spool_command);
2402 setPrehandler(dialog_->input_paper_type);
2403 setPrehandler(dialog_->input_even_pages);
2404 setPrehandler(dialog_->input_odd_pages);
2405 setPrehandler(dialog_->input_collated);
2406 setPrehandler(dialog_->input_landscape);
2407 setPrehandler(dialog_->input_to_file);
2408 setPrehandler(dialog_->input_extra_options);
2409 setPrehandler(dialog_->input_spool_prefix);
2410 setPrehandler(dialog_->input_paper_size);
2411 setPrehandler(dialog_->input_name);
2412 setPrehandler(dialog_->check_adapt_output);
2416 void FormPreferences::Printer::update(LyXRC const & rc)
2418 fl_set_button(dialog_->check_adapt_output,
2419 rc.print_adapt_output);
2420 fl_set_input(dialog_->input_command,
2421 rc.print_command.c_str());
2422 fl_set_input(dialog_->input_page_range,
2423 rc.print_pagerange_flag.c_str());
2424 fl_set_input(dialog_->input_copies,
2425 rc.print_copies_flag.c_str());
2426 fl_set_input(dialog_->input_reverse,
2427 rc.print_reverse_flag.c_str());
2428 fl_set_input(dialog_->input_to_printer,
2429 rc.print_to_printer.c_str());
2430 fl_set_input(dialog_->input_file_extension,
2431 rc.print_file_extension.c_str());
2432 fl_set_input(dialog_->input_spool_command,
2433 rc.print_spool_command.c_str());
2434 fl_set_input(dialog_->input_paper_type,
2435 rc.print_paper_flag.c_str());
2436 fl_set_input(dialog_->input_even_pages,
2437 rc.print_evenpage_flag.c_str());
2438 fl_set_input(dialog_->input_odd_pages,
2439 rc.print_oddpage_flag.c_str());
2440 fl_set_input(dialog_->input_collated,
2441 rc.print_collcopies_flag.c_str());
2442 fl_set_input(dialog_->input_landscape,
2443 rc.print_landscape_flag.c_str());
2444 fl_set_input(dialog_->input_to_file,
2445 rc.print_to_file.c_str());
2446 fl_set_input(dialog_->input_extra_options,
2447 rc.print_extra_options.c_str());
2448 fl_set_input(dialog_->input_spool_prefix,
2449 rc.print_spool_printerprefix.c_str());
2450 fl_set_input(dialog_->input_paper_size,
2451 rc.print_paper_dimension_flag.c_str());
2452 fl_set_input(dialog_->input_name,
2453 rc.printer.c_str());
2457 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2462 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2464 return dialog_.get();
2468 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2470 bool changed = false;
2472 pair<string, string> tmp =
2473 parseFontName(fl_get_input(dialog_->input_roman));
2474 if (rc.roman_font_name != tmp.first ||
2475 rc.roman_font_foundry != tmp.second) {
2477 rc.roman_font_name = tmp.first;
2478 rc.roman_font_foundry = tmp.second;
2481 tmp = parseFontName(fl_get_input(dialog_->input_sans));
2482 if (rc.sans_font_name != tmp.first ||
2483 rc.sans_font_foundry != tmp.second) {
2485 rc.sans_font_name = tmp.first;
2486 rc.sans_font_foundry = tmp.second;
2489 tmp = parseFontName(fl_get_input(dialog_->input_typewriter));
2490 if (rc.typewriter_font_name != tmp.first ||
2491 rc.typewriter_font_foundry != tmp.second) {
2493 rc.typewriter_font_name = tmp.first;
2494 rc.typewriter_font_foundry = tmp.second;
2497 string str = fl_get_input(dialog_->input_screen_encoding);
2498 if (rc.font_norm != str) {
2503 bool button = fl_get_button(dialog_->check_scalable);
2504 if (rc.use_scalable_fonts != button) {
2506 rc.use_scalable_fonts = button;
2509 unsigned int ivalue = static_cast<unsigned int>
2510 (fl_get_counter_value(dialog_->counter_zoom));
2511 if (rc.zoom != ivalue) {
2516 ivalue = static_cast<unsigned int>
2517 (fl_get_counter_value(dialog_->counter_dpi));
2518 if (rc.dpi != ivalue) {
2523 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2524 if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2526 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2529 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2530 if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2532 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2535 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2536 if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2538 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2541 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2542 if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2544 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2547 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2548 if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2550 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2553 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2554 if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2556 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2559 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2560 if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2562 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2565 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2566 if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2568 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2571 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2572 if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2574 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2577 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2578 if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2580 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2584 // Now update the buffers
2585 // Can anything below here affect the redraw process?
2586 parent_.controller().updateScreenFonts();
2591 void FormPreferences::ScreenFonts::build()
2593 dialog_.reset(build_preferences_screen_fonts(&parent_));
2595 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2596 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2598 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2599 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2600 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2601 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2602 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2603 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2604 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2605 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2606 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2607 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2608 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2609 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2610 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2611 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2612 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2613 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2615 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2616 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2617 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2618 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2619 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2620 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2621 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2622 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2623 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2624 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2626 // set up the feedback mechanism
2627 setPrehandler(dialog_->input_roman);
2628 setPrehandler(dialog_->input_sans);
2629 setPrehandler(dialog_->input_typewriter);
2630 setPrehandler(dialog_->counter_zoom);
2631 setPrehandler(dialog_->counter_dpi);
2632 setPrehandler(dialog_->check_scalable);
2633 setPrehandler(dialog_->input_screen_encoding);
2634 setPrehandler(dialog_->input_tiny);
2635 setPrehandler(dialog_->input_script);
2636 setPrehandler(dialog_->input_footnote);
2637 setPrehandler(dialog_->input_small);
2638 setPrehandler(dialog_->input_large);
2639 setPrehandler(dialog_->input_larger);
2640 setPrehandler(dialog_->input_largest);
2641 setPrehandler(dialog_->input_normal);
2642 setPrehandler(dialog_->input_huge);
2643 setPrehandler(dialog_->input_huger);
2648 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2650 if (ob == dialog_->input_roman)
2651 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2652 if (ob == dialog_->input_sans)
2653 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2654 if (ob == dialog_->input_typewriter)
2655 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2656 if (ob == dialog_->check_scalable)
2657 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2658 if (ob == dialog_->input_screen_encoding)
2659 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2660 if (ob == dialog_->counter_zoom)
2661 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2662 if (ob == dialog_->counter_dpi)
2663 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2664 if (ob == dialog_->input_tiny
2665 || ob == dialog_->input_script
2666 || ob == dialog_->input_footnote
2667 || ob == dialog_->input_small
2668 || ob == dialog_->input_large
2669 || ob == dialog_->input_larger
2670 || ob == dialog_->input_larger
2671 || ob == dialog_->input_largest
2672 || ob == dialog_->input_normal
2673 || ob == dialog_->input_huge
2674 || ob == dialog_->input_huger)
2675 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2680 bool FormPreferences::ScreenFonts::input()
2682 bool activate = true;
2685 // Make sure that all fonts all have positive entries
2686 // Also note that an empty entry is returned as 0.0 by strToDbl
2687 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2688 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2689 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2690 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2691 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2692 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2693 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2694 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2695 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2696 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2698 str = _("Fonts must be positive!");
2700 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2701 // Fontsizes -- tiny < script < footnote etc.
2702 strToDbl(fl_get_input(dialog_->input_script)) ||
2703 strToDbl(fl_get_input(dialog_->input_script)) >
2704 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2705 strToDbl(fl_get_input(dialog_->input_footnote)) >
2706 strToDbl(fl_get_input(dialog_->input_small)) ||
2707 strToDbl(fl_get_input(dialog_->input_small)) >
2708 strToDbl(fl_get_input(dialog_->input_normal)) ||
2709 strToDbl(fl_get_input(dialog_->input_normal)) >
2710 strToDbl(fl_get_input(dialog_->input_large)) ||
2711 strToDbl(fl_get_input(dialog_->input_large)) >
2712 strToDbl(fl_get_input(dialog_->input_larger)) ||
2713 strToDbl(fl_get_input(dialog_->input_larger)) >
2714 strToDbl(fl_get_input(dialog_->input_largest)) ||
2715 strToDbl(fl_get_input(dialog_->input_largest)) >
2716 strToDbl(fl_get_input(dialog_->input_huge)) ||
2717 strToDbl(fl_get_input(dialog_->input_huge)) >
2718 strToDbl(fl_get_input(dialog_->input_huger))) {
2721 str = _("Fonts must be input in the order Tiny > Smallest > Smaller > Small > Normal > Large > Larger > Largest > Huge > Huger.");
2725 parent_.postWarning(str);
2731 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2733 fl_set_input(dialog_->input_roman,
2734 makeFontName(rc.roman_font_name,
2735 rc.roman_font_foundry).c_str());
2736 fl_set_input(dialog_->input_sans,
2737 makeFontName(rc.sans_font_name,
2738 rc.sans_font_foundry).c_str());
2739 fl_set_input(dialog_->input_typewriter,
2740 makeFontName(rc.typewriter_font_name,
2741 rc.typewriter_font_foundry).c_str());
2742 fl_set_input(dialog_->input_screen_encoding,
2743 rc.font_norm.c_str());
2744 fl_set_button(dialog_->check_scalable,
2745 rc.use_scalable_fonts);
2746 fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2747 fl_set_counter_value(dialog_->counter_dpi, rc.dpi);
2748 fl_set_input(dialog_->input_tiny,
2749 tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2750 fl_set_input(dialog_->input_script,
2751 tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2752 fl_set_input(dialog_->input_footnote,
2753 tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2754 fl_set_input(dialog_->input_small,
2755 tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2756 fl_set_input(dialog_->input_normal,
2757 tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2758 fl_set_input(dialog_->input_large,
2759 tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2760 fl_set_input(dialog_->input_larger,
2761 tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2762 fl_set_input(dialog_->input_largest,
2763 tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2764 fl_set_input(dialog_->input_huge,
2765 tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2766 fl_set_input(dialog_->input_huger,
2767 tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2772 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2777 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2779 return dialog_.get();
2783 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2785 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2786 choice = trim(choice);
2788 rc.isp_command = choice;
2791 // If spell checker == "none", all other input set to off.
2792 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2793 rc.isp_use_alt_lang = false;
2794 rc.isp_alt_lang.erase();
2796 rc.isp_use_esc_chars = false;
2797 rc.isp_esc_chars.erase();
2799 rc.isp_use_pers_dict = false;
2800 rc.isp_pers_dict.erase();
2802 rc.isp_accept_compound = false;
2803 rc.isp_use_input_encoding = false;
2806 int button = fl_get_button(dialog_->check_alt_lang);
2807 choice = fl_get_input(dialog_->input_alt_lang);
2808 if (button && choice.empty()) button = 0;
2809 if (!button) choice.erase();
2811 rc.isp_use_alt_lang = static_cast<bool>(button);
2812 rc.isp_alt_lang = choice;
2814 button = fl_get_button(dialog_->check_escape_chars);
2815 choice = fl_get_input(dialog_->input_escape_chars);
2816 if (button && choice.empty()) button = 0;
2817 if (!button) choice.erase();
2819 rc.isp_use_esc_chars = static_cast<bool>(button);
2820 rc.isp_esc_chars = choice;
2822 button = fl_get_button(dialog_->check_personal_dict);
2823 choice = fl_get_input(dialog_->input_personal_dict);
2824 if (button && choice.empty()) button = 0;
2825 if (!button) choice.erase();
2827 rc.isp_use_pers_dict = static_cast<bool>(button);
2828 rc.isp_pers_dict = choice;
2830 button = fl_get_button(dialog_->check_compound_words);
2831 rc.isp_accept_compound = static_cast<bool>(button);
2833 button = fl_get_button(dialog_->check_input_enc);
2834 rc.isp_use_input_encoding = static_cast<bool>(button);
2845 void FormPreferences::SpellOptions::build()
2847 dialog_.reset(build_preferences_spelloptions(&parent_));
2849 fl_addto_choice(dialog_->choice_spell_command,
2850 _(" ispell | aspell "));
2851 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2852 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2853 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2855 // set up the feedback mechanism
2856 setPrehandler(dialog_->choice_spell_command);
2857 setPrehandler(dialog_->check_alt_lang);
2858 setPrehandler(dialog_->input_alt_lang);
2859 setPrehandler(dialog_->check_escape_chars);
2860 setPrehandler(dialog_->input_escape_chars);
2861 setPrehandler(dialog_->check_personal_dict);
2862 setPrehandler(dialog_->input_personal_dict);
2863 setPrehandler(dialog_->button_personal_dict);
2864 setPrehandler(dialog_->check_compound_words);
2865 setPrehandler(dialog_->check_input_enc);
2870 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2872 if (ob == dialog_->choice_spell_command)
2873 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2874 if (ob == dialog_->check_alt_lang)
2875 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2876 if (ob == dialog_->input_alt_lang)
2877 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2878 if (ob == dialog_->check_escape_chars)
2879 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2880 if (ob == dialog_->input_escape_chars)
2881 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2882 if (ob == dialog_->check_personal_dict)
2883 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2884 if (ob == dialog_->input_personal_dict)
2885 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2886 if (ob == dialog_->check_compound_words)
2887 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2888 if (ob == dialog_->check_input_enc)
2889 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
2894 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2896 // !ob if function is called from updateSpellOptions() to de/activate
2898 // otherwise the function is called by an xforms CB via input().
2901 // If spell checker == "none", disable all input.
2902 if (!ob || ob == dialog_->choice_spell_command) {
2903 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2904 fl_deactivate_object(dialog_->check_alt_lang);
2905 fl_deactivate_object(dialog_->input_alt_lang);
2906 fl_deactivate_object(dialog_->check_escape_chars);
2907 fl_deactivate_object(dialog_->input_escape_chars);
2908 fl_deactivate_object(dialog_->check_personal_dict);
2909 fl_deactivate_object(dialog_->input_personal_dict);
2910 fl_deactivate_object(dialog_->check_compound_words);
2911 fl_deactivate_object(dialog_->check_input_enc);
2914 fl_activate_object(dialog_->check_alt_lang);
2915 fl_activate_object(dialog_->check_escape_chars);
2916 fl_activate_object(dialog_->check_personal_dict);
2917 fl_activate_object(dialog_->check_compound_words);
2918 fl_activate_object(dialog_->check_input_enc);
2923 if (!ob || ob == dialog_->check_alt_lang) {
2924 bool const enable = fl_get_button(dialog_->check_alt_lang);
2925 setEnabled(dialog_->input_alt_lang, enable);
2928 if (!ob || ob == dialog_->check_escape_chars) {
2929 bool const enable = fl_get_button(dialog_->check_escape_chars);
2930 setEnabled(dialog_->input_escape_chars, enable);
2933 if (!ob || ob == dialog_->check_personal_dict) {
2934 bool const enable = fl_get_button(dialog_->check_personal_dict);
2935 setEnabled(dialog_->input_personal_dict, enable);
2938 if (ob == dialog_->button_personal_dict) {
2939 string f = parent_.controller().browsedict(
2940 fl_get_input(dialog_->input_personal_dict));
2941 fl_set_input(dialog_->input_personal_dict, f.c_str());
2944 return true; // All input is valid!
2948 void FormPreferences::SpellOptions::update(LyXRC const & rc)
2952 if (rc.isp_command == "none")
2954 else if (rc.isp_command == "ispell")
2956 else if (rc.isp_command == "aspell")
2959 if (rc.isp_command == "ispell")
2961 else if (rc.isp_command == "aspell")
2964 fl_set_choice(dialog_->choice_spell_command, choice);
2967 if (rc.isp_use_alt_lang)
2968 str = rc.isp_alt_lang;
2970 fl_set_button(dialog_->check_alt_lang,
2971 rc.isp_use_alt_lang);
2972 fl_set_input(dialog_->input_alt_lang, str.c_str());
2975 if (rc.isp_use_esc_chars)
2976 str = rc.isp_esc_chars;
2978 fl_set_button(dialog_->check_escape_chars,
2979 rc.isp_use_esc_chars);
2980 fl_set_input(dialog_->input_escape_chars, str.c_str());
2983 if (rc.isp_use_pers_dict)
2984 str = rc.isp_pers_dict;
2986 fl_set_button(dialog_->check_personal_dict,
2987 rc.isp_use_pers_dict);
2988 fl_set_input(dialog_->input_personal_dict, str.c_str());
2990 fl_set_button(dialog_->check_compound_words,
2991 rc.isp_accept_compound);
2992 fl_set_button(dialog_->check_input_enc,
2993 rc.isp_use_input_encoding);
2995 // Activate/Deactivate the input fields dependent on the state of the