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 "FormPreferences.h"
18 #include "forms/form_preferences.h"
22 #include "input_validators.h"
23 #include "forms_gettext.h"
24 #include "xforms_helpers.h"
25 #include "helper_funcs.h"
28 #include "converter.h"
31 #include "frnt_lang.h"
36 #include "funcrequest.h"
38 #include "frontends/LyXView.h"
39 #include "frontends/Dialogs.h"
41 #include "support/lyxfunctional.h"
42 #include "support/lyxmanip.h"
43 #include "support/filetools.h"
44 #include "support/LAssert.h"
46 #include "graphics/GraphicsCache.h"
47 #include "graphics/GraphicsTypes.h"
49 #include <boost/bind.hpp>
51 #include FORMS_H_LOCATION
65 extern string system_lyxdir;
66 extern string user_lyxdir;
70 // These should probably go inside the class definition...
71 Formats local_formats;
72 Converters local_converters;
77 FormPreferences::FormPreferences(LyXView & lv, Dialogs & d)
78 : FormBaseBI(lv, d, _("Preferences"), false),
79 colors_(*this), converters_(*this), inputs_misc_(*this),
80 formats_(*this), interface_(*this), language_(*this),
81 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
82 printer_(*this), screen_fonts_(*this), spelloptions_(*this)
84 // let the dialog be shown
85 // This is a permanent connection so we won't bother
86 // storing a copy because we won't be disconnecting.
90 void FormPreferences::redraw()
92 if (!(form() && form()->visible))
94 fl_redraw_form(form());
96 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
97 if (!(form2 && form2->visible))
99 fl_redraw_form(form2);
102 if (form2 == converters_tab_->form)
103 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
105 else if (form2 == look_n_feel_tab_->form)
106 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
108 else if (form2 == inputs_tab_->form)
109 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
111 else if (form2 == outputs_tab_->form)
112 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
114 else if (form2 == lang_opts_tab_->form)
115 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
117 if (form3 && form3->visible)
118 fl_redraw_form(form3);
122 FL_FORM * FormPreferences::form() const
124 return dialog_.get() ? dialog_->form : 0;
128 void FormPreferences::ok()
130 FormBaseDeprecated::ok();
132 if (colors_.modifiedXformsPrefs) {
133 string const filename =
134 AddName(user_lyxdir, "preferences.xform");
135 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
138 lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
142 void FormPreferences::hide()
144 // We need to hide the active tabfolder otherwise we get a
145 // BadDrawable error from X window and LyX crashes without saving.
146 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
147 if (inner_form && inner_form->visible)
148 fl_hide_form(inner_form);
149 FormBaseDeprecated::hide();
153 void FormPreferences::build()
155 dialog_.reset(build_preferences(this));
157 // Manage the restore, save, apply and cancel/close buttons
158 bc().setOK(dialog_->button_ok);
159 bc().setApply(dialog_->button_apply);
160 bc().setCancel(dialog_->button_close);
161 bc().setRestore(dialog_->button_restore);
163 // Allow the base class to control messages
164 setMessageWidget(dialog_->text_warning);
166 // build the tab folders
167 converters_tab_.reset(build_preferences_inner_tab(this));
168 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
169 inputs_tab_.reset(build_preferences_inner_tab(this));
170 outputs_tab_.reset(build_preferences_inner_tab(this));
171 lang_opts_tab_.reset(build_preferences_inner_tab(this));
173 // build actual tabfolder contents
174 // these will become nested tabfolders
178 inputs_misc_.build();
182 outputs_misc_.build();
185 screen_fonts_.build();
186 spelloptions_.build();
188 // Now add them to the tabfolder
189 fl_addto_tabfolder(dialog_->tabfolder_prefs,
191 look_n_feel_tab_->form);
192 fl_addto_tabfolder(dialog_->tabfolder_prefs,
194 lang_opts_tab_->form);
195 fl_addto_tabfolder(dialog_->tabfolder_prefs,
197 converters_tab_->form);
198 fl_addto_tabfolder(dialog_->tabfolder_prefs,
201 fl_addto_tabfolder(dialog_->tabfolder_prefs,
205 // now build the nested tabfolders
206 // Starting with look and feel
207 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
209 screen_fonts_.dialog()->form);
210 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
212 interface_.dialog()->form);
213 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
215 colors_.dialog()->form);
216 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
218 lnf_misc_.dialog()->form);
220 // then build converters
221 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
223 formats_.dialog()->form);
224 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
226 converters_.dialog()->form);
229 // Paths should probably go in a few inner_tab called Files
230 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
232 paths_.dialog()->form);
233 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
235 inputs_misc_.dialog()->form);
237 // then building outputs
238 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
240 printer_.dialog()->form);
241 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
243 outputs_misc_.dialog()->form);
245 // then building usage
246 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
248 spelloptions_.dialog()->form);
249 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
251 language_.dialog()->form);
255 void FormPreferences::apply()
257 // set the new lyxrc entries
258 // many of these need to trigger other functions when the assignment
259 // is made. For example, screen zoom and font types. These could be
260 // handled either by signals/slots in lyxrc or just directly call the
261 // associated functions here.
262 // There are other problems with this scheme. We really should check
263 // what we copy to make sure that it really is necessary to do things
264 // like update the screen fonts because that flushes the textcache
265 // and other stuff which may cost us a lot on slower/high-load
269 formats_.apply(); // Must be before converters_.apply()
271 inputs_misc_.apply();
275 outputs_misc_.apply();
278 screen_fonts_.apply();
279 spelloptions_.apply();
283 string const FormPreferences::getFeedback(FL_OBJECT * ob)
287 if (ob->form->fdui == colors_.dialog())
288 return colors_.feedback(ob);
289 if (ob->form->fdui == converters_.dialog())
290 return converters_.feedback(ob);
291 if (ob->form->fdui == formats_.dialog())
292 return formats_.feedback(ob);
293 if (ob->form->fdui == inputs_misc_.dialog())
294 return inputs_misc_.feedback(ob);
295 if (ob->form->fdui == interface_.dialog())
296 return interface_.feedback(ob);
297 if (ob->form->fdui == language_.dialog())
298 return language_.feedback(ob);
299 if (ob->form->fdui == lnf_misc_.dialog())
300 return lnf_misc_.feedback(ob);
301 if (ob->form->fdui == outputs_misc_.dialog())
302 return outputs_misc_.feedback(ob);
303 if (ob->form->fdui == paths_.dialog())
304 return paths_.feedback(ob);
305 if (ob->form->fdui == printer_.dialog())
306 return printer_.feedback(ob);
307 if (ob->form->fdui == screen_fonts_.dialog())
308 return screen_fonts_.feedback(ob);
309 if (ob->form->fdui == spelloptions_.dialog())
310 return spelloptions_.feedback(ob);
316 bool FormPreferences::input(FL_OBJECT * ob, long)
320 // whatever checks you need to ensure the user hasn't entered
321 // some totally ridiculous value somewhere. Change activate to suit.
322 // comments before each test describe what is _valid_
324 if (ob->form->fdui == colors_.dialog()) {
328 if (ob->form->fdui == converters_.dialog())
329 return converters_.input(ob);
330 if (ob->form->fdui == formats_.dialog())
331 return formats_.input(ob);
332 if (ob->form->fdui == interface_.dialog())
333 return interface_.input(ob);
334 if (ob->form->fdui == language_.dialog())
335 return language_.input(ob);
336 if (ob->form->fdui == paths_.dialog())
337 return paths_.input(ob);
338 if (ob->form->fdui == screen_fonts_.dialog())
339 return screen_fonts_.input();
340 if (ob->form->fdui == spelloptions_.dialog())
341 return spelloptions_.input(ob);
347 void FormPreferences::update()
349 if (!dialog_.get()) return;
351 // read lyxrc entries
353 formats_.update(); // Must be before converters_.update()
354 converters_.update();
355 inputs_misc_.update();
359 outputs_misc_.update();
362 screen_fonts_.update();
363 spelloptions_.update();
367 FormPreferences::Colors::Colors(FormPreferences & p)
368 : modifiedXformsPrefs(false), parent_(p)
372 FD_preferences_colors const * FormPreferences::Colors::dialog()
374 return dialog_.get();
378 void FormPreferences::Colors::apply()
380 bool modifiedText = false;
381 bool modifiedBackground = false;
383 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
384 cit != xformsColorDB.end(); ++cit) {
386 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
387 if (col != cit->color()) {
388 modifiedXformsPrefs = true;
389 if (cit->colorID == FL_BLACK)
391 if (cit->colorID == FL_COL1)
392 modifiedBackground = true;
396 if (modifiedXformsPrefs) {
397 for (vector<XformsColor>::const_iterator cit =
398 xformsColorDB.begin();
399 cit != xformsColorDB.end(); ++cit) {
400 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
402 if (modifiedText && cit->colorID == FL_BLACK) {
403 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
406 if (modifiedBackground && cit->colorID == FL_COL1) {
407 AdjustVal(FL_MCOL, FL_COL1, 0.1);
408 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
409 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
411 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
412 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
415 if (cit->colorID == GUI_COLOR_CURSOR) {
416 fl_mapcolor(GUI_COLOR_CURSOR,
417 cit->r, cit->g, cit->b);
418 setCursorColor(GUI_COLOR_CURSOR);
421 parent_.lv_.getDialogs().redrawGUI();
424 // Now do the same for the LyX LColors...
425 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
426 cit != lyxColorDB.end(); ++cit) {
427 LColor::color lc = lcolor.getFromGUIName(cit->getname());
428 if (lc == LColor::inherit) continue;
430 // Create a valid X11 name of the form "#rrggbb"
431 string const hexname = X11hexname(cit->color());
433 if (lcolor.getX11Name(lc) != hexname) {
435 << "FormPreferences::Colors::apply: "
436 << "resetting LColor " << lcolor.getGUIName(lc)
437 << " from \"" << lcolor.getX11Name(lc)
438 << "\" to \"" << hexname << "\"."
441 string const s = lcolor.getLyXName(lc) + string(" ") +
443 parent_.lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s));
449 void FormPreferences::Colors::build()
451 dialog_.reset(build_preferences_colors(&parent_));
453 fl_set_object_color(dialog_->button_color,
454 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
456 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
457 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
458 fl_set_dial_step(dialog_->dial_hue, 1.0);
459 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
461 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
462 fl_set_slider_step(dialog_->slider_saturation, 0.01);
463 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
465 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
466 fl_set_slider_step(dialog_->slider_value, 0.01);
467 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
469 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
470 fl_set_slider_step(dialog_->slider_red, 1.0);
471 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
473 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
474 fl_set_slider_step(dialog_->slider_green, 1.0);
475 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
477 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
478 fl_set_slider_step(dialog_->slider_blue, 1.0);
479 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
481 // set up the feedback mechanism
482 setPrehandler(dialog_->browser_lyx_objs);
483 setPrehandler(dialog_->button_color);
484 setPrehandler(dialog_->button_modify);
485 setPrehandler(dialog_->dial_hue);
486 setPrehandler(dialog_->slider_saturation);
487 setPrehandler(dialog_->slider_value);
488 setPrehandler(dialog_->slider_red);
489 setPrehandler(dialog_->slider_green);
490 setPrehandler(dialog_->slider_blue);
491 setPrehandler(dialog_->radio_rgb);
492 setPrehandler(dialog_->radio_hsv);
497 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
499 if (ob == dialog_->browser_lyx_objs)
500 return _("LyX objects that can be assigned a color.");
502 if (ob == dialog_->button_modify)
503 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
505 if (ob == dialog_->dial_hue ||
506 ob == dialog_->slider_saturation ||
507 ob == dialog_->slider_value ||
508 ob == dialog_->slider_red ||
509 ob == dialog_->slider_green ||
510 ob == dialog_->slider_blue)
511 return _("Find a new color.");
513 if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
514 return _("Toggle between RGB and HSV color spaces.");
520 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
522 if (ob == dialog_->browser_lyx_objs) {
525 } else if (ob == dialog_->dial_hue ||
526 ob == dialog_->slider_saturation ||
527 ob == dialog_->slider_value) {
530 } else if (ob == dialog_->slider_red ||
531 ob == dialog_->slider_green ||
532 ob == dialog_->slider_blue) {
535 } else if (ob == dialog_->radio_rgb ||
536 ob == dialog_->radio_hsv) {
539 } else if (ob == dialog_->button_modify) {
545 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
549 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
553 hsv.v = min(1.0, max(0.0, hsv.v));
556 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
560 void FormPreferences::Colors::InputBrowserLyX() const
562 vector<NamedColor>::size_type const selLyX =
563 fl_get_browser(dialog_->browser_lyx_objs);
564 if (selLyX < 1) return;
566 // Is the choice an Xforms color...
569 if (selLyX - 1 < xformsColorDB.size()) {
570 vector<XformsColor>::size_type const i = selLyX - 1;
571 col = xformsColorDB[i].color();
573 // or a LyX Logical color?
575 vector<NamedColor>::size_type const i = selLyX - 1 -
576 xformsColorDB.size();
577 col = lyxColorDB[i].color();
580 fl_freeze_form(dialog_->form);
582 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
583 fl_redraw_object(dialog_->button_color);
585 // Display either RGB or HSV but not both!
588 // Deactivate the modify button to begin with...
589 setEnabled(dialog_->button_modify, false);
591 fl_unfreeze_form(dialog_->form);
595 void FormPreferences::Colors::InputHSV()
597 double const hue = fl_get_dial_value(dialog_->dial_hue);
598 double const sat = fl_get_slider_value(dialog_->slider_saturation);
599 double const val = fl_get_slider_value(dialog_->slider_value);
601 int const h = int(hue);
602 int const s = int(100.0 * sat);
603 int const v = int(100.0 * val);
605 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
607 fl_set_object_label(dialog_->text_color_values, label.c_str());
609 RGBColor col = HSVColor(hue, sat, val);
611 fl_freeze_form(dialog_->form);
613 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
614 fl_redraw_object(dialog_->button_color);
616 col = HSVColor(hue, 1.0, 1.0);
617 col.r = max(col.r, 0);
618 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
619 fl_redraw_object(dialog_->dial_hue);
621 // Ascertain whether to activate the Modify button.
622 vector<NamedColor>::size_type const selLyX =
623 fl_get_browser(dialog_->browser_lyx_objs);
625 fl_unfreeze_form(dialog_->form);
626 if (selLyX < 1) return;
628 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
631 // Is the choice an Xforms color...
632 if (selLyX - 1 < xformsColorDB.size()) {
633 vector<XformsColor>::size_type const i = selLyX - 1;
634 modify = (xformsColorDB[i].color() != col);
636 // or a LyX Logical color?
638 vector<NamedColor>::size_type const i = selLyX - 1 -
639 xformsColorDB.size();
640 modify = (lyxColorDB[i].color() != col);
643 setEnabled(dialog_->button_modify, modify);
647 void FormPreferences::Colors::InputRGB()
649 int const red = int(fl_get_slider_value(dialog_->slider_red));
650 int const green = int(fl_get_slider_value(dialog_->slider_green));
651 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
653 string const label = tostr(red) + string(", ") + tostr(green) +
654 string(", ") + tostr(blue);
655 fl_set_object_label(dialog_->text_color_values, label.c_str());
657 fl_freeze_form(dialog_->form);
659 RGBColor col = RGBColor(red, green, blue);
660 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
661 fl_redraw_object(dialog_->button_color);
663 // Ascertain whether to activate the Modify button.
664 vector<NamedColor>::size_type const selLyX =
665 fl_get_browser(dialog_->browser_lyx_objs);
667 fl_unfreeze_form(dialog_->form);
668 if (selLyX < 1) return;
672 // Is the choice an Xforms color...
673 if (selLyX - 1 < xformsColorDB.size()) {
674 vector<XformsColor>::size_type const i = selLyX - 1;
675 modify = (xformsColorDB[i].color() != col);
677 // or a LyX Logical color?
679 vector<NamedColor>::size_type const i = selLyX - 1 -
680 xformsColorDB.size();
681 modify = (lyxColorDB[i].color() != col);
684 setEnabled(dialog_->button_modify, modify);
688 void FormPreferences::Colors::LoadBrowserLyX()
690 if (!dialog_->browser_lyx_objs->visible)
693 // First, define the modifiable xforms colors
694 xformsColorDB.clear();
697 xcol.name = _("GUI background");
698 xcol.colorID = FL_COL1;
699 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
701 xformsColorDB.push_back(xcol);
703 xcol.name = _("GUI text");
704 xcol.colorID = FL_BLACK;
705 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
707 xformsColorDB.push_back(xcol);
709 xcol.name = _("GUI selection");
710 xcol.colorID = FL_YELLOW;
711 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
713 xformsColorDB.push_back(xcol);
715 xcol.name = _("GUI pointer");
716 xcol.colorID = GUI_COLOR_CURSOR;
717 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
719 xformsColorDB.push_back(xcol);
721 // Now create the the LyX LColors database
723 for (int i=0; i<LColor::ignore; ++i) {
724 LColor::color lc = static_cast<LColor::color>(i);
725 if (lc == LColor::none
726 || lc == LColor::black
727 || lc == LColor::white
729 || lc == LColor::green
730 || lc == LColor::blue
731 || lc == LColor::cyan
732 || lc == LColor::magenta
733 || lc == LColor::yellow
734 || lc == LColor::inherit
735 || lc == LColor::ignore) continue;
737 string const name = lcolor.getX11Name(lc);
738 Display * display = fl_get_display();;
739 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
742 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
744 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
745 << "LColor " << lcolor.getLyXName(lc)
746 << ": X can't find color \"" << name
747 << "\". Set to \"black\"!" << endl;
749 string const arg = lcolor.getLyXName(lc) + " black";
750 parent_.lv_.dispatch(FuncRequest(LFUN_SET_COLOR, arg));
754 // X has found the color. Now find the "appropriate" X11 name
757 // Note that X stores the RGB values in the range 0 - 65535
758 // whilst we require them in the range 0 - 255.
760 col.r = xcol.red / 256;
761 col.g = xcol.green / 256;
762 col.b = xcol.blue / 256;
764 // Create a valid X11 name of the form "#rrggbb" and change the
765 // LColor X11name to this. Don't want to trigger a redraw,
766 // as we're just changing the name not the RGB values.
767 // Also reset the system_lcolor names, so that we don't output
768 // unnecessary changes.
769 string const hexname = X11hexname(col);
771 if (lcolor.getX11Name(lc) != hexname) {
772 lcolor.setColor(lc, hexname);
773 system_lcolor.setColor(lc, hexname);
776 // Finally, push the color onto the database
777 NamedColor ncol(lcolor.getGUIName(lc), col);
778 lyxColorDB.push_back(ncol);
781 // Now construct the browser
782 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
783 fl_freeze_form(dialog_->form);
784 fl_clear_browser(colbr);
785 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
786 cit != xformsColorDB.end(); ++cit) {
787 fl_addto_browser(colbr, cit->getname().c_str());
789 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
790 cit != lyxColorDB.end(); ++cit) {
791 fl_addto_browser(colbr, cit->getname().c_str());
794 // just to be safe...
795 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
796 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
797 fl_unfreeze_form(dialog_->form);
803 void FormPreferences::Colors::Modify()
805 vector<NamedColor>::size_type const selLyX =
806 fl_get_browser(dialog_->browser_lyx_objs);
811 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
813 // Is the choice an Xforms color...
814 if (selLyX - 1 < xformsColorDB.size()) {
815 vector<XformsColor>::size_type const i = selLyX - 1;
816 xformsColorDB[i].r = col.r;
817 xformsColorDB[i].g = col.g;
818 xformsColorDB[i].b = col.b;
820 // or a LyX Logical color?
822 vector<NamedColor>::size_type const i = selLyX - 1 -
823 xformsColorDB.size();
824 lyxColorDB[i].r = col.r;
825 lyxColorDB[i].g = col.g;
826 lyxColorDB[i].b = col.b;
829 fl_freeze_form(dialog_->form);
830 setEnabled(dialog_->button_modify, false);
831 fl_unfreeze_form(dialog_->form);
835 void FormPreferences::Colors::SwitchColorSpace() const
837 bool const hsv = fl_get_button(dialog_->radio_hsv);
840 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
842 fl_freeze_form(dialog_->form);
845 fl_hide_object(dialog_->slider_red);
846 fl_hide_object(dialog_->slider_blue);
847 fl_hide_object(dialog_->slider_green);
848 fl_show_object(dialog_->dial_hue);
849 fl_show_object(dialog_->slider_saturation);
850 fl_show_object(dialog_->slider_value);
852 HSVColor hsv = HSVColor(col);
853 hsv.h = max(hsv.h, 0.0);
855 fl_set_dial_value(dialog_->dial_hue, hsv.h);
856 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
857 fl_set_slider_value(dialog_->slider_value, hsv.v);
859 col = HSVColor(hsv.h, 1.0, 1.0);
860 col.r = max(col.r, 0);
861 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
862 fl_redraw_object(dialog_->dial_hue);
864 // Adjust the label a bit, but not the actual values.
865 // Means that toggling from one space to the other has no
866 // effect on the final color.
867 int const h = int(hsv.h);
868 int const s = int(100 * hsv.s);
869 int const v = int(100 * hsv.v);
870 string const label = tostr(h) + ", " + tostr(s) +
872 fl_set_object_label(dialog_->text_color_values, label.c_str());
875 fl_show_object(dialog_->slider_red);
876 fl_show_object(dialog_->slider_blue);
877 fl_show_object(dialog_->slider_green);
878 fl_hide_object(dialog_->dial_hue);
879 fl_hide_object(dialog_->slider_saturation);
880 fl_hide_object(dialog_->slider_value);
882 fl_set_slider_value(dialog_->slider_red, col.r);
883 fl_set_slider_value(dialog_->slider_green, col.g);
884 fl_set_slider_value(dialog_->slider_blue, col.b);
886 // Adjust the label a bit. Same reasoning as above.
887 int const r = int(col.r);
888 int const g = int(col.g);
889 int const b = int(col.b);
890 string const label = tostr(r) + ", " + tostr(g) +
892 fl_set_object_label(dialog_->text_color_values, label.c_str());
895 fl_unfreeze_form(dialog_->form);
898 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
902 ostr << "#" << std::setbase(16) << setfill('0')
907 return ostr.str().c_str();
911 FormPreferences::Converters::Converters(FormPreferences & p)
916 FD_preferences_converters const * FormPreferences::Converters::dialog()
918 return dialog_.get();
922 void FormPreferences::Converters::apply() const
924 converters = local_converters;
925 converters.update(formats);
926 converters.buildGraph();
930 void FormPreferences::Converters::build()
932 dialog_.reset(build_preferences_converters(&parent_));
934 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
935 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
937 // set up the feedback mechanism
938 setPrehandler(dialog_->browser_all);
939 setPrehandler(dialog_->button_delete);
940 setPrehandler(dialog_->button_add);
941 setPrehandler(dialog_->input_converter);
942 setPrehandler(dialog_->choice_from);
943 setPrehandler(dialog_->choice_to);
944 setPrehandler(dialog_->input_flags);
949 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
951 if (ob == dialog_->browser_all)
952 return _("All the currently defined converters known to LyX.");
954 if (ob == dialog_->choice_from)
955 return _("Convert \"from\" this format");
957 if (ob == dialog_->choice_to)
958 return _("Convert \"to\" this format");
960 if (ob == dialog_->input_converter)
961 return _("The conversion command. $$i is the input file name, "
962 "$$b is the file name without its extension and $$o is "
963 "the name of the output file. $$s can be used as path to "
964 "LyX's own collection of conversion scripts.");
966 if (ob == dialog_->input_flags)
967 return _("Extra information for the Converter class, whether and "
968 "how to parse the result, and various other things.");
970 if (ob == dialog_->button_delete)
971 return _("Remove the current converter from the list of available "
972 "converters. Note: you must then \"Apply\" the change.");
974 if (ob == dialog_->button_add) {
975 if (string(ob->label) == _("Add"))
976 return _("Add the current converter to the list of available "
977 "converters. Note: you must then \"Apply\" the change.");
979 return _("Modify the contents of the current converter. "
980 "Note: you must then \"Apply\" the change.");
987 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
989 if (ob == dialog_->browser_all)
992 if (ob == dialog_->choice_from
993 || ob == dialog_->choice_to
994 || ob == dialog_->input_converter
995 || ob == dialog_->input_flags)
998 if (ob == dialog_->button_add)
1001 if (ob == dialog_->button_delete)
1008 void FormPreferences::Converters::update()
1010 local_converters = converters;
1011 local_converters.update(local_formats);
1016 void FormPreferences::Converters::UpdateBrowser()
1018 local_converters.sort();
1020 fl_freeze_form(dialog_->form);
1021 fl_clear_browser(dialog_->browser_all);
1022 for (::Converters::const_iterator cit = local_converters.begin();
1023 cit != local_converters.end(); ++cit) {
1024 string const name = cit->From->prettyname() + " -> "
1025 + cit->To->prettyname();
1026 fl_addto_browser(dialog_->browser_all, name.c_str());
1029 fl_unfreeze_form(dialog_->form);
1033 bool FormPreferences::Converters::Add()
1035 string const from = GetFrom();
1036 string const to = GetTo();
1037 string const command = fl_get_input(dialog_->input_converter);
1038 string const flags = fl_get_input(dialog_->input_flags);
1040 Converter const * old = local_converters.getConverter(from, to);
1041 local_converters.add(from, to, command, flags);
1043 local_converters.updateLast(local_formats);
1046 setEnabled(dialog_->button_add, false);
1052 bool FormPreferences::Converters::Browser()
1054 int const i = fl_get_browser(dialog_->browser_all);
1055 if (i <= 0) return false;
1057 fl_freeze_form(dialog_->form);
1059 Converter const & c = local_converters.get(i - 1);
1060 int j = local_formats.getNumber(c.from);
1062 fl_set_choice(dialog_->choice_from, j + 1);
1064 j = local_formats.getNumber(c.to);
1066 fl_set_choice(dialog_->choice_to, j + 1);
1068 fl_set_input(dialog_->input_converter, c.command.c_str());
1069 fl_set_input(dialog_->input_flags, c.flags.c_str());
1071 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1072 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1074 setEnabled(dialog_->button_add, false);
1075 setEnabled(dialog_->button_delete, true);
1077 fl_unfreeze_form(dialog_->form);
1082 bool FormPreferences::Converters::erase()
1084 string const from = GetFrom();
1085 string const to = GetTo();
1087 local_converters.erase(from, to);
1093 bool FormPreferences::Converters::Input()
1095 string const from = GetFrom();
1096 string const to = GetTo();
1097 int const sel = local_converters.getNumber(from, to);
1099 fl_freeze_form(dialog_->form);
1102 fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
1103 fl_set_button_shortcut(dialog_->button_add,
1104 scex(_("Add|#A")), 1);
1106 fl_deselect_browser(dialog_->browser_all);
1107 setEnabled(dialog_->button_delete, false);
1110 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1111 fl_set_button_shortcut(dialog_->button_add,
1112 scex(_("Modify|#M")), 1);
1114 int top = max(sel-5, 0);
1115 fl_set_browser_topline(dialog_->browser_all, top);
1116 fl_select_browser_line(dialog_->browser_all, sel+1);
1117 setEnabled(dialog_->button_delete, true);
1120 string const command = rtrim(fl_get_input(dialog_->input_converter));
1121 bool const enable = !(command.empty() || from == to);
1122 setEnabled(dialog_->button_add, enable);
1124 fl_unfreeze_form(dialog_->form);
1129 string const FormPreferences::Converters::GetFrom() const
1131 ::Formats::FormatList::size_type const i =
1132 fl_get_choice(dialog_->choice_from);
1134 if (i > 0 && i <= local_formats.size())
1135 return local_formats.get(i - 1).name();
1137 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1142 string const FormPreferences::Converters::GetTo() const
1144 ::Formats::FormatList::size_type const i =
1145 fl_get_choice(dialog_->choice_to);
1147 if (i > 0 && i <= local_formats.size())
1148 return local_formats.get(i - 1).name();
1150 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1155 void FormPreferences::Converters::UpdateChoices() const
1158 for (::Formats::const_iterator cit = local_formats.begin();
1159 cit != local_formats.end(); ++cit) {
1160 if (!choice.empty())
1164 choice += cit->prettyname();
1168 fl_clear_choice(dialog_->choice_from);
1169 fl_addto_choice(dialog_->choice_from, choice.c_str());
1171 fl_clear_choice(dialog_->choice_to);
1172 fl_addto_choice(dialog_->choice_to, choice.c_str());
1176 FormPreferences::Formats::Formats(FormPreferences & p)
1181 FD_preferences_formats const * FormPreferences::Formats::dialog()
1183 return dialog_.get();
1187 void FormPreferences::Formats::apply() const
1189 formats = local_formats;
1193 void FormPreferences::Formats::build()
1195 dialog_.reset(build_preferences_formats(&parent_));
1197 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1198 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1199 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1200 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1201 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1203 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1205 // set up the feedback mechanism
1206 setPrehandler(dialog_->browser_all);
1207 setPrehandler(dialog_->input_format);
1208 setPrehandler(dialog_->input_gui_name);
1209 setPrehandler(dialog_->button_delete);
1210 setPrehandler(dialog_->button_add);
1211 setPrehandler(dialog_->input_extension);
1212 setPrehandler(dialog_->input_viewer);
1213 setPrehandler(dialog_->input_shrtcut);
1218 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1220 if (ob == dialog_->browser_all)
1221 return _("All the currently defined formats known to LyX.");
1223 if (ob == dialog_->input_format)
1224 return _("The format identifier.");
1226 if (ob == dialog_->input_gui_name)
1227 return _("The format name as it will appear in the menus.");
1229 if (ob == dialog_->input_shrtcut)
1230 return _("The keyboard accelerator. Use a letter in the GUI name. "
1233 if (ob == dialog_->input_extension)
1234 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1236 if (ob == dialog_->input_viewer)
1237 return _("The command used to launch the viewer application.");
1239 if (ob == dialog_->button_delete)
1240 return _("Remove the current format from the list of available "
1241 "formats. Note: you must then \"Apply\" the change.");
1243 if (ob == dialog_->button_add) {
1244 if (string(ob->label) == _("Add"))
1245 return _("Add the current format to the list of available "
1246 "formats. Note: you must then \"Apply\" the change.");
1248 return _("Modify the contents of the current format. Note: "
1249 "you must then \"Apply\" the change.");
1256 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1258 if (ob == dialog_->browser_all)
1261 if (ob == dialog_->input_format
1262 || ob == dialog_->input_gui_name
1263 || ob == dialog_->input_shrtcut
1264 || ob == dialog_->input_extension
1265 || ob == dialog_->input_viewer)
1268 if (ob == dialog_->button_add)
1271 if (ob == dialog_->button_delete)
1278 void FormPreferences::Formats::update()
1280 local_formats = formats;
1285 void FormPreferences::Formats::UpdateBrowser()
1287 local_formats.sort();
1289 fl_freeze_form(dialog_->form);
1290 fl_deselect_browser(dialog_->browser_all);
1291 fl_clear_browser(dialog_->browser_all);
1292 for (::Formats::const_iterator cit = local_formats.begin();
1293 cit != local_formats.end(); ++cit)
1294 fl_addto_browser(dialog_->browser_all,
1295 cit->prettyname().c_str());
1298 fl_unfreeze_form(dialog_->form);
1300 // Mustn't forget to update the Formats available to the converters_
1301 parent_.converters_.UpdateChoices();
1302 local_converters.update(local_formats);
1306 bool FormPreferences::Formats::Add()
1308 string const name = fl_get_input(dialog_->input_format);
1309 string const prettyname = fl_get_input(dialog_->input_gui_name);
1310 string const extension = fl_get_input(dialog_->input_extension);
1311 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1312 string const viewer = fl_get_input(dialog_->input_viewer);
1314 Format const * old = local_formats.getFormat(name);
1315 string const old_prettyname = old ? old->prettyname() : string();
1316 local_formats.add(name, extension, prettyname, shortcut);
1317 local_formats.setViewer(name, viewer);
1318 if (!old || prettyname != old_prettyname) {
1321 parent_.converters_.UpdateBrowser();
1323 setEnabled(dialog_->button_add, false);
1329 bool FormPreferences::Formats::Browser()
1331 int const i = fl_get_browser(dialog_->browser_all);
1335 fl_freeze_form(dialog_->form);
1337 Format const & f = local_formats.get(i - 1);
1339 fl_set_input(dialog_->input_format, f.name().c_str());
1340 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1341 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1342 fl_set_input(dialog_->input_extension, f.extension().c_str());
1343 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1345 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1346 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1348 setEnabled(dialog_->button_add, false);
1349 setEnabled(dialog_->button_delete, true);
1351 fl_unfreeze_form(dialog_->form);
1356 bool FormPreferences::Formats::erase()
1358 string const name = fl_get_input(dialog_->input_format);
1360 if (local_converters.formatIsUsed(name)) {
1361 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1362 "Remove the converter first."));
1363 setEnabled(dialog_->button_delete, false);
1367 local_formats.erase(name);
1373 bool FormPreferences::Formats::Input()
1375 string const name = fl_get_input(dialog_->input_format);
1376 int const sel = local_formats.getNumber(name);
1377 fl_freeze_form(dialog_->form);
1380 fl_set_object_label(dialog_->button_add,
1382 fl_set_button_shortcut(dialog_->button_add,
1383 scex(_("Add|#A")), 1);
1385 fl_deselect_browser(dialog_->browser_all);
1386 setEnabled(dialog_->button_delete, false);
1389 fl_set_object_label(dialog_->button_add,
1390 idex(_("Modify|#M")));
1391 fl_set_button_shortcut(dialog_->button_add,
1392 scex(_("Modify|#M")), 1);
1394 int const top = max(sel-5, 0);
1395 fl_set_browser_topline(dialog_->browser_all, top);
1396 fl_select_browser_line(dialog_->browser_all, sel+1);
1398 setEnabled(dialog_->button_add, true);
1399 setEnabled(dialog_->button_delete, true);
1402 string const prettyname = fl_get_input(dialog_->input_gui_name);
1403 bool const enable = !(name.empty() || prettyname.empty());
1404 setEnabled(dialog_->button_add, enable);
1406 fl_unfreeze_form(dialog_->form);
1411 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1416 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1418 return dialog_.get();
1422 void FormPreferences::InputsMisc::apply() const
1424 lyxrc.date_insert_format =
1425 fl_get_input(dialog_->input_date_format);
1429 void FormPreferences::InputsMisc::build()
1431 dialog_.reset(build_preferences_inputs_misc(&parent_));
1433 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1435 // set up the feedback mechanism
1436 setPrehandler(dialog_->input_date_format);
1441 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1443 if (ob == dialog_->input_date_format)
1444 return lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1449 void FormPreferences::InputsMisc::update()
1451 fl_set_input(dialog_->input_date_format,
1452 lyxrc.date_insert_format.c_str());
1456 FormPreferences::Interface::Interface(FormPreferences & p)
1461 FD_preferences_interface const * FormPreferences::Interface::dialog()
1463 return dialog_.get();
1467 void FormPreferences::Interface::apply() const
1469 lyxrc.popup_normal_font =
1470 fl_get_input(dialog_->input_popup_normal_font);
1471 lyxrc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1472 lyxrc.popup_font_encoding =
1473 fl_get_input(dialog_->input_popup_font_encoding);
1474 lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
1475 lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
1476 lyxrc.override_x_deadkeys =
1477 fl_get_button(dialog_->check_override_x_dead_keys);
1481 void FormPreferences::Interface::build()
1483 dialog_.reset(build_preferences_interface(&parent_));
1485 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1486 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1487 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1488 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1489 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1491 // set up the feedback mechanism
1492 setPrehandler(dialog_->input_popup_normal_font);
1493 setPrehandler(dialog_->input_popup_bold_font);
1494 setPrehandler(dialog_->input_popup_font_encoding);
1495 setPrehandler(dialog_->input_bind_file);
1496 setPrehandler(dialog_->button_bind_file_browse);
1497 setPrehandler(dialog_->input_ui_file);
1498 setPrehandler(dialog_->button_ui_file_browse);
1499 setPrehandler(dialog_->check_override_x_dead_keys);
1504 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1506 if (ob == dialog_->input_popup_normal_font)
1507 return lyxrc.getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1508 if (ob == dialog_->input_popup_bold_font)
1509 return lyxrc.getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1510 if (ob == dialog_->input_popup_font_encoding)
1511 return lyxrc.getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1512 if (ob == dialog_->input_bind_file)
1513 return lyxrc.getDescription(LyXRC::RC_BINDFILE);
1514 if (ob == dialog_->input_ui_file)
1515 return lyxrc.getDescription(LyXRC::RC_UIFILE);
1516 if (ob == dialog_->check_override_x_dead_keys)
1517 return lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1522 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1524 if (ob == dialog_->button_bind_file_browse) {
1525 string dir = AddName(system_lyxdir, "bind");
1526 string name = _("Sys Bind|#S#s");
1527 pair<string,string> dir1(name, dir);
1529 dir = AddName(user_lyxdir, "bind");
1530 name = _("User Bind|#U#u");
1531 pair<string,string> dir2(name, dir);
1533 parent_.browse(dialog_->input_bind_file,
1534 _("Bind file"), "*.bind", dir1, dir2);
1536 } else if (ob == dialog_->button_ui_file_browse) {
1537 string dir = AddName(system_lyxdir, "ui");
1538 string name = _("Sys UI|#S#s");
1539 pair<string,string> dir1(name, dir);
1541 dir = AddName(user_lyxdir, "ui");
1542 name = _("User UI|#U#u");
1543 pair<string,string> dir2(name, dir);
1545 parent_.browse(dialog_->input_ui_file,
1546 _("UI file"), "*.ui", dir1, dir2);
1553 void FormPreferences::Interface::update()
1555 fl_set_input(dialog_->input_popup_normal_font,
1556 lyxrc.popup_normal_font.c_str());
1557 fl_set_input(dialog_->input_popup_bold_font,
1558 lyxrc.popup_bold_font.c_str());
1559 fl_set_input(dialog_->input_popup_font_encoding,
1560 lyxrc.popup_font_encoding.c_str());
1561 fl_set_input(dialog_->input_bind_file,
1562 lyxrc.bind_file.c_str());
1563 fl_set_input(dialog_->input_ui_file,
1564 lyxrc.ui_file.c_str());
1565 fl_set_button(dialog_->check_override_x_dead_keys,
1566 lyxrc.override_x_deadkeys);
1570 FormPreferences::Language::Language(FormPreferences & p)
1575 FD_preferences_language const * FormPreferences::Language::dialog()
1577 return dialog_.get();
1581 void FormPreferences::Language::apply()
1583 int const pos = combo_default_lang->get();
1584 lyxrc.default_language = lang_[pos-1];
1586 int button = fl_get_button(dialog_->check_use_kbmap);
1587 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1588 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1590 button = !(name_1.empty() && name_2.empty());
1591 lyxrc.use_kbmap = static_cast<bool>(button);
1593 if (lyxrc.use_kbmap) {
1594 lyxrc.primary_kbmap = name_1;
1595 lyxrc.secondary_kbmap = name_2;
1598 button = fl_get_button(dialog_->check_rtl_support);
1599 lyxrc.rtl_support = static_cast<bool>(button);
1601 button = fl_get_button(dialog_->check_mark_foreign);
1602 lyxrc.mark_foreign_language = static_cast<bool>(button);
1604 button = fl_get_button(dialog_->check_auto_begin);
1605 lyxrc.language_auto_begin = static_cast<bool>(button);
1607 button = fl_get_button(dialog_->check_auto_end);
1608 lyxrc.language_auto_end = static_cast<bool>(button);
1610 button = fl_get_button(dialog_->check_use_babel);
1611 lyxrc.language_use_babel = static_cast<bool>(button);
1613 button = fl_get_button(dialog_->check_global_options);
1614 lyxrc.language_global_options = static_cast<bool>(button);
1616 lyxrc.language_package = fl_get_input(dialog_->input_package);
1617 lyxrc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1618 lyxrc.language_command_end = fl_get_input(dialog_->input_command_end);
1620 // Ensure that all is self-consistent.
1625 void FormPreferences::Language::build()
1627 dialog_.reset(build_preferences_language(&parent_));
1629 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1630 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1631 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1633 // Store the lang identifiers for later
1634 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1635 lang_ = getSecond(langs);
1637 // The default_language is a combo-box and has to be inserted manually
1638 fl_freeze_form(dialog_->form);
1639 fl_addto_form(dialog_->form);
1641 FL_OBJECT * obj = dialog_->choice_default_lang;
1642 fl_deactivate_object(dialog_->choice_default_lang);
1643 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1644 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
1645 parent_.lang_opts_tab_->tabfolder_inner,
1646 parent_.dialog_->tabfolder_prefs);
1647 combo_default_lang->shortcut("#L",1);
1648 combo_default_lang->setcallback(ComboCB, &parent_);
1650 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1651 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1652 for (; lit != lend; ++lit) {
1653 combo_default_lang->addto(lit->first);
1655 combo_default_lang->select(1);
1658 fl_unfreeze_form(dialog_->form);
1660 // set up the feedback mechanism
1661 setPrehandler(dialog_->input_package);
1662 setPrehandler(dialog_->check_use_kbmap);
1664 // This is safe, as nothing is done to the pointer, other than
1665 // to use its address in a block-if statement.
1666 // No it's not! Leads to crash.
1668 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1669 // C_FormPreferencesFeedbackCB);
1671 setPrehandler(dialog_->input_kbmap1);
1672 setPrehandler(dialog_->input_kbmap2);
1673 setPrehandler(dialog_->check_rtl_support);
1674 setPrehandler(dialog_->check_mark_foreign);
1675 setPrehandler(dialog_->check_auto_begin);
1676 setPrehandler(dialog_->check_auto_end);
1677 setPrehandler(dialog_->check_use_babel);
1678 setPrehandler(dialog_->check_global_options);
1679 setPrehandler(dialog_->input_command_begin);
1680 setPrehandler(dialog_->input_command_end);
1682 // Activate/Deactivate the input fields dependent on the state of the
1689 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1691 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1692 return lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1693 if (ob == dialog_->check_use_kbmap)
1694 return lyxrc.getDescription(LyXRC::RC_KBMAP);
1695 if (ob == dialog_->input_kbmap1)
1696 return lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1697 if (ob == dialog_->input_kbmap2)
1698 return lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1699 if (ob == dialog_->check_rtl_support)
1700 return lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1701 if (ob == dialog_->check_mark_foreign)
1702 return lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1703 if (ob == dialog_->check_auto_begin)
1704 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1705 if (ob == dialog_->check_auto_end)
1706 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1707 if (ob == dialog_->check_use_babel)
1708 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1709 if (ob == dialog_->check_global_options)
1710 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1711 if (ob == dialog_->input_package)
1712 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1713 if (ob == dialog_->input_command_begin)
1714 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1715 if (ob == dialog_->input_command_end)
1716 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1721 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1723 bool activate = true;
1725 // !ob if function is called from Language::build() to de/activate
1727 // otherwise the function is called by an xforms CB via input().
1728 if (!ob || ob == dialog_->check_use_kbmap) {
1729 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1730 setEnabled(dialog_->button_kbmap1_browse, enable);
1731 setEnabled(dialog_->button_kbmap2_browse, enable);
1732 setEnabled(dialog_->input_kbmap1, enable);
1733 setEnabled(dialog_->input_kbmap2, enable);
1736 if (ob == dialog_->button_kbmap1_browse) {
1737 string const dir = AddName(system_lyxdir, "kbd");
1738 string const name = _("Key maps|#K#k");
1739 pair<string, string> dir1(name, dir);
1741 parent_.browse(dialog_->input_kbmap1,
1742 _("Keyboard map"), "*.kmap", dir1);
1743 } else if (ob == dialog_->button_kbmap2_browse) {
1744 string const dir = AddName(system_lyxdir, "kbd");
1745 string const name = _("Key maps|#K#k");
1746 pair<string, string> dir1(name, dir);
1748 parent_.browse(dialog_->input_kbmap2,
1749 _("Keyboard map"), "*.kmap", dir1);
1756 void FormPreferences::Language::update()
1758 fl_set_button(dialog_->check_use_kbmap,
1761 int const pos = int(findPos(lang_, lyxrc.default_language));
1762 combo_default_lang->select(pos + 1);
1764 if (lyxrc.use_kbmap) {
1765 fl_set_input(dialog_->input_kbmap1,
1766 lyxrc.primary_kbmap.c_str());
1767 fl_set_input(dialog_->input_kbmap2,
1768 lyxrc.secondary_kbmap.c_str());
1770 fl_set_input(dialog_->input_kbmap1, "");
1771 fl_set_input(dialog_->input_kbmap2, "");
1774 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1775 fl_set_button(dialog_->check_mark_foreign,
1776 lyxrc.mark_foreign_language);
1777 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1778 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1779 fl_set_button(dialog_->check_use_babel, lyxrc.language_use_babel);
1780 fl_set_button(dialog_->check_global_options,
1781 lyxrc.language_global_options);
1783 fl_set_input(dialog_->input_package,
1784 lyxrc.language_package.c_str());
1785 fl_set_input(dialog_->input_command_begin,
1786 lyxrc.language_command_begin.c_str());
1787 fl_set_input(dialog_->input_command_end,
1788 lyxrc.language_command_end.c_str());
1790 // Activate/Deactivate the input fields dependent on the state of the
1796 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1798 FormPreferences * pre = static_cast<FormPreferences*>(v);
1799 // This is safe, as nothing is done to the pointer, other than
1800 // to use its address in a block-if statement.
1801 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1805 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1810 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1812 return dialog_.get();
1816 void FormPreferences::LnFmisc::apply() const
1818 lyxrc.auto_region_delete =
1819 fl_get_button(dialog_->check_auto_region_delete);
1820 lyxrc.cursor_follows_scrollbar =
1821 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1822 lyxrc.dialogs_iconify_with_main =
1823 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1824 lyxrc.preview = fl_get_button(dialog_->check_preview_latex);
1825 lyxrc.autosave = static_cast<unsigned int>
1826 (fl_get_counter_value(dialog_->counter_autosave));
1827 lyxrc.wheel_jump = static_cast<unsigned int>
1828 (fl_get_counter_value(dialog_->counter_wm_jump));
1831 // grfx::DisplayType old_value = lyxrc.display_graphics;
1832 switch (fl_get_choice(dialog_->choice_display)) {
1833 case 4: lyxrc.display_graphics = grfx::NoDisplay; break;
1834 case 3: lyxrc.display_graphics = grfx::ColorDisplay; break;
1835 case 2: lyxrc.display_graphics = grfx::GrayscaleDisplay; break;
1836 case 1: lyxrc.display_graphics = grfx::MonochromeDisplay; break;
1837 default: lyxrc.display_graphics = grfx::ColorDisplay; break;
1840 #ifdef WITH_WARNINGS
1841 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1844 if (old_value != lyxrc.display_graphics) {
1845 grfx::GCache & gc = grfx::GCache::get();
1852 void FormPreferences::LnFmisc::build()
1854 dialog_.reset(build_preferences_lnf_misc(&parent_));
1856 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1857 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1859 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1860 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1862 // set up the feedback mechanism
1863 setPrehandler(dialog_->check_auto_region_delete);
1864 setPrehandler(dialog_->counter_autosave);
1865 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1866 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1867 setPrehandler(dialog_->check_preview_latex);
1868 setPrehandler(dialog_->counter_wm_jump);
1870 fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
1875 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1877 if (ob == dialog_->check_auto_region_delete)
1878 return lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1879 if (ob == dialog_->check_cursor_follows_scrollbar)
1880 return lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1881 if (ob == dialog_->check_dialogs_iconify_with_main)
1882 return lyxrc.getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1883 if (ob == dialog_->check_preview_latex)
1884 return lyxrc.getDescription(LyXRC::RC_PREVIEW);
1885 if (ob == dialog_->counter_autosave)
1886 return lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1887 if (ob == dialog_->counter_wm_jump)
1888 return lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1889 if (ob == dialog_->choice_display)
1890 return lyxrc.getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1895 void FormPreferences::LnFmisc::update()
1897 fl_set_button(dialog_->check_auto_region_delete,
1898 lyxrc.auto_region_delete);
1899 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1900 lyxrc.cursor_follows_scrollbar);
1901 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1902 lyxrc.dialogs_iconify_with_main);
1903 fl_set_button(dialog_->check_preview_latex,
1905 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1906 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1908 switch (lyxrc.display_graphics) {
1909 case grfx::NoDisplay: fl_set_choice(dialog_->choice_display, 4); break;
1910 case grfx::ColorDisplay: fl_set_choice(dialog_->choice_display, 3); break;
1911 case grfx::GrayscaleDisplay: fl_set_choice(dialog_->choice_display, 2); break;
1912 case grfx::MonochromeDisplay: fl_set_choice(dialog_->choice_display, 1); break;
1913 default: fl_set_choice(dialog_->choice_display, 3); break;
1918 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1923 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1925 return dialog_.get();
1929 void FormPreferences::OutputsMisc::apply() const
1931 lyxrc.ascii_linelen = static_cast<unsigned int>
1932 (fl_get_counter_value(dialog_->counter_line_len));
1933 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1936 fl_get_choice(dialog_->choice_default_papersize) - 1;
1937 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1939 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1940 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1941 lyxrc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1942 lyxrc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1946 void FormPreferences::OutputsMisc::build()
1948 dialog_.reset(build_preferences_outputs_misc(&parent_));
1950 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1952 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1953 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1954 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1955 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1956 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1958 fl_addto_choice(dialog_->choice_default_papersize,
1959 _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1961 // set up the feedback mechanism
1962 setPrehandler(dialog_->counter_line_len);
1963 setPrehandler(dialog_->input_tex_encoding);
1964 setPrehandler(dialog_->choice_default_papersize);
1965 setPrehandler(dialog_->input_ascii_roff);
1966 setPrehandler(dialog_->input_checktex);
1967 setPrehandler(dialog_->input_paperoption);
1968 setPrehandler(dialog_->check_autoreset_classopt);
1973 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1975 if (ob == dialog_->counter_line_len)
1976 return lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
1977 if (ob == dialog_->input_tex_encoding)
1978 return lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
1979 if (ob == dialog_->input_ascii_roff)
1980 return lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1981 if (ob == dialog_->input_checktex)
1982 return lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
1983 if (ob == dialog_->choice_default_papersize)
1984 return lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1985 if (ob == dialog_->input_paperoption)
1986 return lyxrc.getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
1987 if (ob == dialog_->check_autoreset_classopt)
1988 return lyxrc.getDescription(LyXRC::RC_AUTORESET_OPTIONS);
1993 void FormPreferences::OutputsMisc::update()
1995 fl_set_counter_value(dialog_->counter_line_len,
1996 lyxrc.ascii_linelen);
1997 fl_set_input(dialog_->input_tex_encoding,
1998 lyxrc.fontenc.c_str());
1999 fl_set_choice(dialog_->choice_default_papersize,
2000 lyxrc.default_papersize+1);
2001 fl_set_input(dialog_->input_ascii_roff,
2002 lyxrc.ascii_roff_command.c_str());
2003 fl_set_input(dialog_->input_checktex,
2004 lyxrc.chktex_command.c_str());
2005 fl_set_input(dialog_->input_paperoption,
2006 lyxrc.view_dvi_paper_option.c_str());
2007 fl_set_button(dialog_->check_autoreset_classopt,
2008 lyxrc.auto_reset_options);
2013 FormPreferences::Paths::Paths(FormPreferences & p)
2018 FD_preferences_paths const * FormPreferences::Paths::dialog()
2020 return dialog_.get();
2024 void FormPreferences::Paths::apply()
2026 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2027 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2029 int button = fl_get_button(dialog_->check_use_temp_dir);
2030 string str = fl_get_input(dialog_->input_temp_dir);
2034 lyxrc.use_tempdir = button;
2035 lyxrc.tempdir_path = str;
2037 button = fl_get_button(dialog_->check_last_files);
2038 str = fl_get_input(dialog_->input_lastfiles);
2039 if (!button) str.erase();
2041 lyxrc.check_lastfiles = button;
2042 lyxrc.lastfiles = str;
2043 lyxrc.num_lastfiles = static_cast<unsigned int>
2044 (fl_get_counter_value(dialog_->counter_lastfiles));
2046 button = fl_get_button(dialog_->check_make_backups);
2047 str = fl_get_input(dialog_->input_backup_path);
2051 lyxrc.make_backup = button;
2052 lyxrc.backupdir_path = str;
2054 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2061 void FormPreferences::Paths::build()
2063 dialog_.reset(build_preferences_paths(&parent_));
2065 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2066 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2067 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2068 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2069 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2070 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2071 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2073 // set up the feedback mechanism
2074 setPrehandler(dialog_->input_default_path);
2075 setPrehandler(dialog_->counter_lastfiles);
2076 setPrehandler(dialog_->input_template_path);
2077 setPrehandler(dialog_->check_last_files);
2078 setPrehandler(dialog_->input_lastfiles);
2079 setPrehandler(dialog_->check_make_backups);
2080 setPrehandler(dialog_->input_backup_path);
2081 setPrehandler(dialog_->input_serverpipe);
2082 setPrehandler(dialog_->input_temp_dir);
2083 setPrehandler(dialog_->check_use_temp_dir);
2088 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2090 if (ob == dialog_->input_default_path)
2091 return lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2092 if (ob == dialog_->input_template_path)
2093 return lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2094 if (ob == dialog_->check_use_temp_dir)
2095 return lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2096 if (ob == dialog_->input_temp_dir)
2097 return lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2098 if (ob == dialog_->check_last_files)
2099 return lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2100 if (ob == dialog_->input_lastfiles)
2101 return lyxrc.getDescription(LyXRC::RC_LASTFILES);
2102 if (ob == dialog_->counter_lastfiles)
2103 return lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2104 if (ob == dialog_->check_make_backups)
2105 return lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2106 if (ob == dialog_->input_backup_path)
2107 return lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2108 if (ob == dialog_->input_serverpipe)
2109 return lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2114 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2116 bool activate = true;
2118 // !ob if function is called from Paths::update() to de/activate
2120 // otherwise the function is called by an xforms CB via input().
2121 if (!ob || ob == dialog_->check_use_temp_dir) {
2122 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2123 setEnabled(dialog_->input_temp_dir, enable);
2126 if (!ob || ob == dialog_->check_last_files) {
2127 bool const enable = fl_get_button(dialog_->check_last_files);
2128 setEnabled(dialog_->input_lastfiles, enable);
2131 if (!ob || ob == dialog_->check_make_backups) {
2132 bool const enable = fl_get_button(dialog_->check_make_backups);
2133 setEnabled(dialog_->input_backup_path, enable);
2136 if (!ob || ob == dialog_->input_default_path) {
2137 string const name = fl_get_input(dialog_->input_default_path);
2138 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2139 parent_.postWarning(RWInfo::ErrorMessage());
2144 if (!ob || ob == dialog_->input_template_path) {
2145 string const name = fl_get_input(dialog_->input_template_path);
2146 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2147 parent_.postWarning(RWInfo::ErrorMessage());
2152 if (!ob || ob == dialog_->input_temp_dir) {
2153 string const name = fl_get_input(dialog_->input_temp_dir);
2154 if (fl_get_button(dialog_->check_make_backups)
2156 && !RWInfo::WriteableDir(name)) {
2157 parent_.postWarning(RWInfo::ErrorMessage());
2162 if (!ob || ob == dialog_->input_backup_path) {
2163 string const name = fl_get_input(dialog_->input_backup_path);
2164 if (fl_get_button(dialog_->check_make_backups)
2166 && !RWInfo::WriteableDir(name)) {
2167 parent_.postWarning(RWInfo::ErrorMessage());
2172 if (!ob || ob == dialog_->input_lastfiles) {
2173 string const name = fl_get_input(dialog_->input_lastfiles);
2174 if (fl_get_button(dialog_->check_last_files)
2176 && !RWInfo::WriteableFile(name)) {
2177 parent_.postWarning(RWInfo::ErrorMessage());
2182 if (!ob || ob == dialog_->input_serverpipe) {
2183 string const name = fl_get_input(dialog_->input_serverpipe);
2184 if (!name.empty()) {
2185 // strip off the extension
2186 string const str = ChangeExtension(name, "");
2187 if (!RWInfo::WriteableFile(str + ".in")) {
2188 parent_.postWarning(RWInfo::ErrorMessage());
2191 if (!RWInfo::WriteableFile(str + ".out")) {
2192 parent_.postWarning(RWInfo::ErrorMessage());
2198 if (ob == dialog_->button_default_path_browse) {
2199 parent_.browse(dialog_->input_default_path,
2200 _("Default path"), string());
2201 } else if (ob == dialog_->button_template_path_browse) {
2202 parent_.browse(dialog_->input_template_path,
2203 _("Template path"), string());
2204 } else if (ob == dialog_->button_temp_dir_browse) {
2205 parent_.browse(dialog_->input_temp_dir,
2206 _("Temp dir"), string());
2207 } else if (ob == dialog_->button_lastfiles_browse) {
2208 pair<string, string> dir(_("User|#U#u"), user_lyxdir);
2210 parent_.browse(dialog_->input_lastfiles,
2211 _("Lastfiles"), string(), dir);
2212 } else if (ob == dialog_->button_backup_path_browse) {
2213 parent_.browse(dialog_->input_backup_path,
2214 _("Backup path"), string());
2215 } else if (ob == dialog_->button_serverpipe_browse) {
2216 parent_.browse(dialog_->input_serverpipe,
2217 _("LyX Server pipes"), string());
2224 void FormPreferences::Paths::update()
2226 fl_set_input(dialog_->input_default_path,
2227 lyxrc.document_path.c_str());
2228 fl_set_input(dialog_->input_template_path,
2229 lyxrc.template_path.c_str());
2232 if (lyxrc.make_backup)
2233 str = lyxrc.backupdir_path;
2235 fl_set_button(dialog_->check_make_backups,
2237 fl_set_input(dialog_->input_backup_path, str.c_str());
2240 if (lyxrc.use_tempdir)
2241 str = lyxrc.tempdir_path;
2243 fl_set_button(dialog_->check_use_temp_dir,
2245 fl_set_input(dialog_->input_temp_dir, str.c_str());
2248 if (lyxrc.check_lastfiles)
2249 str = lyxrc.lastfiles;
2251 fl_set_button(dialog_->check_last_files,
2252 lyxrc.check_lastfiles);
2253 fl_set_input(dialog_->input_lastfiles, str.c_str());
2254 fl_set_counter_value(dialog_->counter_lastfiles,
2255 lyxrc.num_lastfiles);
2257 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2259 // Activate/Deactivate the input fields dependent on the state of the
2265 FormPreferences::Printer::Printer(FormPreferences & p)
2270 FD_preferences_printer const * FormPreferences::Printer::dialog()
2272 return dialog_.get();
2276 void FormPreferences::Printer::apply() const
2278 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2279 lyxrc.print_command = fl_get_input(dialog_->input_command);
2280 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2281 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2282 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2283 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2284 lyxrc.print_file_extension =
2285 fl_get_input(dialog_->input_file_extension);
2286 lyxrc.print_spool_command =
2287 fl_get_input(dialog_->input_spool_command);
2288 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2289 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2290 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2291 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2292 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2293 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2294 lyxrc.print_extra_options =
2295 fl_get_input(dialog_->input_extra_options);
2296 lyxrc.print_spool_printerprefix =
2297 fl_get_input(dialog_->input_spool_prefix);
2298 lyxrc.print_paper_dimension_flag =
2299 fl_get_input(dialog_->input_paper_size);
2300 lyxrc.printer = fl_get_input(dialog_->input_name);
2305 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2307 if (ob == dialog_->input_command)
2308 return lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2309 if (ob == dialog_->check_adapt_output)
2310 return lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2311 if (ob == dialog_->input_to_printer)
2312 return lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2313 if (ob == dialog_->input_to_file)
2314 return lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2315 if (ob == dialog_->input_file_extension)
2316 return lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2317 if (ob == dialog_->input_extra_options)
2318 return lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2319 if (ob == dialog_->input_spool_command)
2320 return lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2321 if (ob == dialog_->input_spool_prefix)
2322 return lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2323 if (ob == dialog_->input_name)
2324 return lyxrc.getDescription(LyXRC::RC_PRINTER);
2325 if (ob == dialog_->input_even_pages)
2326 return lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2327 if (ob == dialog_->input_odd_pages)
2328 return lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2329 if (ob == dialog_->input_page_range)
2330 return lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2331 if (ob == dialog_->input_reverse)
2332 return lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2333 if (ob == dialog_->input_landscape)
2334 return lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2335 if (ob == dialog_->input_copies)
2336 return lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2337 if (ob == dialog_->input_collated)
2338 return lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2339 if (ob == dialog_->input_paper_type)
2340 return lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2341 if (ob == dialog_->input_paper_size)
2342 return lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2347 void FormPreferences::Printer::build()
2349 dialog_.reset(build_preferences_printer(&parent_));
2351 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2352 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2353 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2354 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2355 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2356 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2357 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2358 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2359 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2360 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2361 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2362 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2363 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2364 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2365 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2366 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2367 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2369 // set up the feedback mechanism
2370 setPrehandler(dialog_->input_command);
2371 setPrehandler(dialog_->input_page_range);
2372 setPrehandler(dialog_->input_copies);
2373 setPrehandler(dialog_->input_reverse);
2374 setPrehandler(dialog_->input_to_printer);
2375 setPrehandler(dialog_->input_file_extension);
2376 setPrehandler(dialog_->input_spool_command);
2377 setPrehandler(dialog_->input_paper_type);
2378 setPrehandler(dialog_->input_even_pages);
2379 setPrehandler(dialog_->input_odd_pages);
2380 setPrehandler(dialog_->input_collated);
2381 setPrehandler(dialog_->input_landscape);
2382 setPrehandler(dialog_->input_to_file);
2383 setPrehandler(dialog_->input_extra_options);
2384 setPrehandler(dialog_->input_spool_prefix);
2385 setPrehandler(dialog_->input_paper_size);
2386 setPrehandler(dialog_->input_name);
2387 setPrehandler(dialog_->check_adapt_output);
2391 void FormPreferences::Printer::update()
2393 fl_set_button(dialog_->check_adapt_output,
2394 lyxrc.print_adapt_output);
2395 fl_set_input(dialog_->input_command,
2396 lyxrc.print_command.c_str());
2397 fl_set_input(dialog_->input_page_range,
2398 lyxrc.print_pagerange_flag.c_str());
2399 fl_set_input(dialog_->input_copies,
2400 lyxrc.print_copies_flag.c_str());
2401 fl_set_input(dialog_->input_reverse,
2402 lyxrc.print_reverse_flag.c_str());
2403 fl_set_input(dialog_->input_to_printer,
2404 lyxrc.print_to_printer.c_str());
2405 fl_set_input(dialog_->input_file_extension,
2406 lyxrc.print_file_extension.c_str());
2407 fl_set_input(dialog_->input_spool_command,
2408 lyxrc.print_spool_command.c_str());
2409 fl_set_input(dialog_->input_paper_type,
2410 lyxrc.print_paper_flag.c_str());
2411 fl_set_input(dialog_->input_even_pages,
2412 lyxrc.print_evenpage_flag.c_str());
2413 fl_set_input(dialog_->input_odd_pages,
2414 lyxrc.print_oddpage_flag.c_str());
2415 fl_set_input(dialog_->input_collated,
2416 lyxrc.print_collcopies_flag.c_str());
2417 fl_set_input(dialog_->input_landscape,
2418 lyxrc.print_landscape_flag.c_str());
2419 fl_set_input(dialog_->input_to_file,
2420 lyxrc.print_to_file.c_str());
2421 fl_set_input(dialog_->input_extra_options,
2422 lyxrc.print_extra_options.c_str());
2423 fl_set_input(dialog_->input_spool_prefix,
2424 lyxrc.print_spool_printerprefix.c_str());
2425 fl_set_input(dialog_->input_paper_size,
2426 lyxrc.print_paper_dimension_flag.c_str());
2427 fl_set_input(dialog_->input_name,
2428 lyxrc.printer.c_str());
2432 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2437 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2439 return dialog_.get();
2443 void FormPreferences::ScreenFonts::apply() const
2445 bool changed = false;
2447 string str = fl_get_input(dialog_->input_roman);
2448 if (lyxrc.roman_font_name != str) {
2450 lyxrc.roman_font_name = str;
2453 str = fl_get_input(dialog_->input_sans);
2454 if (lyxrc.sans_font_name != str) {
2456 lyxrc.sans_font_name = str;
2459 str = fl_get_input(dialog_->input_typewriter);
2460 if (lyxrc.typewriter_font_name != str) {
2462 lyxrc.typewriter_font_name = str;
2465 str = fl_get_input(dialog_->input_screen_encoding);
2466 if (lyxrc.font_norm != str) {
2468 lyxrc.font_norm = str;
2471 bool button = fl_get_button(dialog_->check_scalable);
2472 if (lyxrc.use_scalable_fonts != button) {
2474 lyxrc.use_scalable_fonts = button;
2477 unsigned int ivalue = static_cast<unsigned int>
2478 (fl_get_counter_value(dialog_->counter_zoom));
2479 if (lyxrc.zoom != ivalue) {
2481 lyxrc.zoom = ivalue;
2484 ivalue = static_cast<unsigned int>
2485 (fl_get_counter_value(dialog_->counter_dpi));
2486 if (lyxrc.dpi != ivalue) {
2491 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2492 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2494 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2497 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2498 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2500 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2503 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2504 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2506 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2509 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2510 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2512 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2515 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2516 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2518 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2521 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2522 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2524 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2527 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2528 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2530 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2533 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2534 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2536 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2539 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2540 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2542 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2545 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2546 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2548 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2552 // Now update the buffers
2553 // Can anything below here affect the redraw process?
2554 parent_.lv_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
2559 void FormPreferences::ScreenFonts::build()
2561 dialog_.reset(build_preferences_screen_fonts(&parent_));
2563 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2564 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2566 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2567 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2568 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2569 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2570 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2571 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2572 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2573 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2574 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2575 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2576 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2577 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2578 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2579 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2580 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2581 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2583 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2584 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2585 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2586 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2587 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2588 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2589 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2590 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2591 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2592 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2594 // set up the feedback mechanism
2595 setPrehandler(dialog_->input_roman);
2596 setPrehandler(dialog_->input_sans);
2597 setPrehandler(dialog_->input_typewriter);
2598 setPrehandler(dialog_->counter_zoom);
2599 setPrehandler(dialog_->counter_dpi);
2600 setPrehandler(dialog_->check_scalable);
2601 setPrehandler(dialog_->input_screen_encoding);
2602 setPrehandler(dialog_->input_tiny);
2603 setPrehandler(dialog_->input_script);
2604 setPrehandler(dialog_->input_footnote);
2605 setPrehandler(dialog_->input_small);
2606 setPrehandler(dialog_->input_large);
2607 setPrehandler(dialog_->input_larger);
2608 setPrehandler(dialog_->input_largest);
2609 setPrehandler(dialog_->input_normal);
2610 setPrehandler(dialog_->input_huge);
2611 setPrehandler(dialog_->input_huger);
2616 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2618 if (ob == dialog_->input_roman)
2619 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2620 if (ob == dialog_->input_sans)
2621 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2622 if (ob == dialog_->input_typewriter)
2623 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2624 if (ob == dialog_->check_scalable)
2625 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2626 if (ob == dialog_->input_screen_encoding)
2627 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2628 if (ob == dialog_->counter_zoom)
2629 return lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2630 if (ob == dialog_->counter_dpi)
2631 return lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2632 if (ob == dialog_->input_tiny
2633 || ob == dialog_->input_script
2634 || ob == dialog_->input_footnote
2635 || ob == dialog_->input_small
2636 || ob == dialog_->input_large
2637 || ob == dialog_->input_larger
2638 || ob == dialog_->input_larger
2639 || ob == dialog_->input_largest
2640 || ob == dialog_->input_normal
2641 || ob == dialog_->input_huge
2642 || ob == dialog_->input_huger)
2643 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2648 bool FormPreferences::ScreenFonts::input()
2650 bool activate = true;
2653 // Make sure that all fonts all have positive entries
2654 // Also note that an empty entry is returned as 0.0 by strToDbl
2655 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2656 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2657 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2658 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2659 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2660 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2661 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2662 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2663 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2664 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2666 str = _("Fonts must be positive!");
2668 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2669 // Fontsizes -- tiny < script < footnote etc.
2670 strToDbl(fl_get_input(dialog_->input_script)) ||
2671 strToDbl(fl_get_input(dialog_->input_script)) >
2672 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2673 strToDbl(fl_get_input(dialog_->input_footnote)) >
2674 strToDbl(fl_get_input(dialog_->input_small)) ||
2675 strToDbl(fl_get_input(dialog_->input_small)) >
2676 strToDbl(fl_get_input(dialog_->input_normal)) ||
2677 strToDbl(fl_get_input(dialog_->input_normal)) >
2678 strToDbl(fl_get_input(dialog_->input_large)) ||
2679 strToDbl(fl_get_input(dialog_->input_large)) >
2680 strToDbl(fl_get_input(dialog_->input_larger)) ||
2681 strToDbl(fl_get_input(dialog_->input_larger)) >
2682 strToDbl(fl_get_input(dialog_->input_largest)) ||
2683 strToDbl(fl_get_input(dialog_->input_largest)) >
2684 strToDbl(fl_get_input(dialog_->input_huge)) ||
2685 strToDbl(fl_get_input(dialog_->input_huge)) >
2686 strToDbl(fl_get_input(dialog_->input_huger))) {
2689 str = _("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2693 parent_.postWarning(str);
2699 void FormPreferences::ScreenFonts::update()
2701 fl_set_input(dialog_->input_roman,
2702 lyxrc.roman_font_name.c_str());
2703 fl_set_input(dialog_->input_sans,
2704 lyxrc.sans_font_name.c_str());
2705 fl_set_input(dialog_->input_typewriter,
2706 lyxrc.typewriter_font_name.c_str());
2707 fl_set_input(dialog_->input_screen_encoding,
2708 lyxrc.font_norm.c_str());
2709 fl_set_button(dialog_->check_scalable,
2710 lyxrc.use_scalable_fonts);
2711 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2712 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2713 fl_set_input(dialog_->input_tiny,
2714 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2715 fl_set_input(dialog_->input_script,
2716 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2717 fl_set_input(dialog_->input_footnote,
2718 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2719 fl_set_input(dialog_->input_small,
2720 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2721 fl_set_input(dialog_->input_normal,
2722 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2723 fl_set_input(dialog_->input_large,
2724 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2725 fl_set_input(dialog_->input_larger,
2726 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2727 fl_set_input(dialog_->input_largest,
2728 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2729 fl_set_input(dialog_->input_huge,
2730 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2731 fl_set_input(dialog_->input_huger,
2732 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2737 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2742 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2744 return dialog_.get();
2748 void FormPreferences::SpellOptions::apply()
2751 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2752 choice = trim(choice);
2754 lyxrc.isp_command = choice;
2757 // If spell checker == "none", all other input set to off.
2758 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2759 lyxrc.isp_use_alt_lang = false;
2760 lyxrc.isp_alt_lang.erase();
2762 lyxrc.isp_use_esc_chars = false;
2763 lyxrc.isp_esc_chars.erase();
2765 lyxrc.isp_use_pers_dict = false;
2766 lyxrc.isp_pers_dict.erase();
2768 lyxrc.isp_accept_compound = false;
2769 lyxrc.isp_use_input_encoding = false;
2772 int button = fl_get_button(dialog_->check_alt_lang);
2773 choice = fl_get_input(dialog_->input_alt_lang);
2774 if (button && choice.empty()) button = 0;
2775 if (!button) choice.erase();
2777 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2778 lyxrc.isp_alt_lang = choice;
2780 button = fl_get_button(dialog_->check_escape_chars);
2781 choice = fl_get_input(dialog_->input_escape_chars);
2782 if (button && choice.empty()) button = 0;
2783 if (!button) choice.erase();
2785 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2786 lyxrc.isp_esc_chars = choice;
2788 button = fl_get_button(dialog_->check_personal_dict);
2789 choice = fl_get_input(dialog_->input_personal_dict);
2790 if (button && choice.empty()) button = 0;
2791 if (!button) choice.erase();
2793 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2794 lyxrc.isp_pers_dict = choice;
2796 button = fl_get_button(dialog_->check_compound_words);
2797 lyxrc.isp_accept_compound = static_cast<bool>(button);
2799 button = fl_get_button(dialog_->check_input_enc);
2800 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2811 void FormPreferences::SpellOptions::build()
2813 dialog_.reset(build_preferences_spelloptions(&parent_));
2815 fl_addto_choice(dialog_->choice_spell_command,
2816 _(" ispell | aspell "));
2817 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2818 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2819 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2821 // set up the feedback mechanism
2822 setPrehandler(dialog_->choice_spell_command);
2823 setPrehandler(dialog_->check_alt_lang);
2824 setPrehandler(dialog_->input_alt_lang);
2825 setPrehandler(dialog_->check_escape_chars);
2826 setPrehandler(dialog_->input_escape_chars);
2827 setPrehandler(dialog_->check_personal_dict);
2828 setPrehandler(dialog_->input_personal_dict);
2829 setPrehandler(dialog_->button_personal_dict);
2830 setPrehandler(dialog_->check_compound_words);
2831 setPrehandler(dialog_->check_input_enc);
2836 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2838 if (ob == dialog_->choice_spell_command)
2839 return lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2840 if (ob == dialog_->check_alt_lang)
2841 return lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2842 if (ob == dialog_->input_alt_lang)
2843 return lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2844 if (ob == dialog_->check_escape_chars)
2845 return lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2846 if (ob == dialog_->input_escape_chars)
2847 return lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2848 if (ob == dialog_->check_personal_dict)
2849 return lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2850 if (ob == dialog_->input_personal_dict)
2851 return lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2852 if (ob == dialog_->check_compound_words)
2853 return lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2854 if (ob == dialog_->check_input_enc)
2855 return lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2860 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2862 // !ob if function is called from updateSpellOptions() to de/activate
2864 // otherwise the function is called by an xforms CB via input().
2867 // If spell checker == "none", disable all input.
2868 if (!ob || ob == dialog_->choice_spell_command) {
2869 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2870 fl_deactivate_object(dialog_->check_alt_lang);
2871 fl_deactivate_object(dialog_->input_alt_lang);
2872 fl_deactivate_object(dialog_->check_escape_chars);
2873 fl_deactivate_object(dialog_->input_escape_chars);
2874 fl_deactivate_object(dialog_->check_personal_dict);
2875 fl_deactivate_object(dialog_->input_personal_dict);
2876 fl_deactivate_object(dialog_->check_compound_words);
2877 fl_deactivate_object(dialog_->check_input_enc);
2880 fl_activate_object(dialog_->check_alt_lang);
2881 fl_activate_object(dialog_->check_escape_chars);
2882 fl_activate_object(dialog_->check_personal_dict);
2883 fl_activate_object(dialog_->check_compound_words);
2884 fl_activate_object(dialog_->check_input_enc);
2889 if (!ob || ob == dialog_->check_alt_lang) {
2890 bool const enable = fl_get_button(dialog_->check_alt_lang);
2891 setEnabled(dialog_->input_alt_lang, enable);
2894 if (!ob || ob == dialog_->check_escape_chars) {
2895 bool const enable = fl_get_button(dialog_->check_escape_chars);
2896 setEnabled(dialog_->input_escape_chars, enable);
2899 if (!ob || ob == dialog_->check_personal_dict) {
2900 bool const enable = fl_get_button(dialog_->check_personal_dict);
2901 setEnabled(dialog_->input_personal_dict, enable);
2904 if (ob == dialog_->button_personal_dict) {
2905 parent_.browse(dialog_->input_personal_dict,
2906 _("Personal dictionary"), "*.ispell");
2909 return true; // All input is valid!
2913 void FormPreferences::SpellOptions::update()
2917 if (lyxrc.isp_command == "none")
2919 else if (lyxrc.isp_command == "ispell")
2921 else if (lyxrc.isp_command == "aspell")
2924 if (lyxrc.isp_command == "ispell")
2926 else if (lyxrc.isp_command == "aspell")
2929 fl_set_choice(dialog_->choice_spell_command, choice);
2932 if (lyxrc.isp_use_alt_lang)
2933 str = lyxrc.isp_alt_lang;
2935 fl_set_button(dialog_->check_alt_lang,
2936 lyxrc.isp_use_alt_lang);
2937 fl_set_input(dialog_->input_alt_lang, str.c_str());
2940 if (lyxrc.isp_use_esc_chars)
2941 str = lyxrc.isp_esc_chars;
2943 fl_set_button(dialog_->check_escape_chars,
2944 lyxrc.isp_use_esc_chars);
2945 fl_set_input(dialog_->input_escape_chars, str.c_str());
2948 if (lyxrc.isp_use_pers_dict)
2949 str = lyxrc.isp_pers_dict;
2951 fl_set_button(dialog_->check_personal_dict,
2952 lyxrc.isp_use_pers_dict);
2953 fl_set_input(dialog_->input_personal_dict, str.c_str());
2955 fl_set_button(dialog_->check_compound_words,
2956 lyxrc.isp_accept_compound);
2957 fl_set_button(dialog_->check_input_enc,
2958 lyxrc.isp_use_input_encoding);
2960 // Activate/Deactivate the input fields dependent on the state of the
2966 void FormPreferences::browse(FL_OBJECT * inpt,
2967 string const & title,
2968 string const & pattern,
2969 pair<string,string> const & dir1,
2970 pair<string,string> const & dir2)
2972 // Get the filename from the dialog
2973 string const filename = fl_get_input(inpt);
2975 // Show the file browser dialog
2976 string const new_filename =
2977 browseFile(&lv_, filename, title, pattern, dir1, dir2);
2979 // Save the filename to the dialog
2980 if (new_filename != filename && !new_filename.empty()) {
2981 fl_set_input(inpt, new_filename.c_str());