2 * \file FormPreferences.C
3 * Copyright 2000-2001 The LyX Team.
4 * See the file COPYING.
6 * \author Angus Leeming, a.leeming@ic.ac.uk
12 #pragma implementation
15 #include "FormPreferences.h"
16 #include "forms/form_preferences.h"
20 #include "converter.h"
22 #include "frontends/LyXView.h"
24 #include "frnt_lang.h"
30 #include "funcrequest.h"
34 #include "input_validators.h"
35 #include "forms_gettext.h"
36 #include "xforms_helpers.h"
37 #include "helper_funcs.h"
39 #include "support/lyxfunctional.h"
40 #include "support/lyxmanip.h"
41 #include "support/filetools.h"
42 #include "support/LAssert.h"
44 #include "graphics/GraphicsCache.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;
74 FormPreferences::FormPreferences(LyXView & lv, Dialogs & d)
75 : FormBaseBI(&lv, &d, _("Preferences"), false),
76 colors_(*this), converters_(*this), inputs_misc_(*this),
77 formats_(*this), interface_(*this), language_(*this),
78 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
79 printer_(*this), screen_fonts_(*this), spelloptions_(*this)
81 // let the dialog be shown
82 // This is a permanent connection so we won't bother
83 // storing a copy because we won't be disconnecting.
87 void FormPreferences::redraw()
89 if (!(form() && form()->visible))
91 fl_redraw_form(form());
93 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
94 if (!(form2 && form2->visible))
96 fl_redraw_form(form2);
99 if (form2 == converters_tab_->form)
100 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
102 else if (form2 == look_n_feel_tab_->form)
103 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
105 else if (form2 == inputs_tab_->form)
106 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
108 else if (form2 == outputs_tab_->form)
109 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
111 else if (form2 == lang_opts_tab_->form)
112 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
114 if (form3 && form3->visible)
115 fl_redraw_form(form3);
119 FL_FORM * FormPreferences::form() const
121 return dialog_.get() ? dialog_->form : 0;
125 void FormPreferences::ok()
127 FormBaseDeprecated::ok();
129 if (colors_.modifiedXformsPrefs) {
130 string const filename =
131 AddName(user_lyxdir, "preferences.xform");
132 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
135 lv_->getLyXFunc()->dispatch(LFUN_SAVEPREFERENCES);
139 void FormPreferences::hide()
141 // We need to hide the active tabfolder otherwise we get a
142 // BadDrawable error from X window and LyX crashes without saving.
143 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
144 if (inner_form && inner_form->visible)
145 fl_hide_form(inner_form);
146 FormBaseDeprecated::hide();
150 void FormPreferences::build()
152 dialog_.reset(build_preferences(this));
154 // Manage the restore, save, apply and cancel/close buttons
155 bc().setOK(dialog_->button_ok);
156 bc().setApply(dialog_->button_apply);
157 bc().setCancel(dialog_->button_close);
158 bc().setRestore(dialog_->button_restore);
160 // Allow the base class to control messages
161 setMessageWidget(dialog_->text_warning);
163 // build the tab folders
164 converters_tab_.reset(build_preferences_inner_tab(this));
165 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
166 inputs_tab_.reset(build_preferences_inner_tab(this));
167 outputs_tab_.reset(build_preferences_inner_tab(this));
168 lang_opts_tab_.reset(build_preferences_inner_tab(this));
170 // build actual tabfolder contents
171 // these will become nested tabfolders
175 inputs_misc_.build();
179 outputs_misc_.build();
182 screen_fonts_.build();
183 spelloptions_.build();
185 // Now add them to the tabfolder
186 fl_addto_tabfolder(dialog_->tabfolder_prefs,
188 look_n_feel_tab_->form);
189 fl_addto_tabfolder(dialog_->tabfolder_prefs,
191 lang_opts_tab_->form);
192 fl_addto_tabfolder(dialog_->tabfolder_prefs,
194 converters_tab_->form);
195 fl_addto_tabfolder(dialog_->tabfolder_prefs,
198 fl_addto_tabfolder(dialog_->tabfolder_prefs,
202 // now build the nested tabfolders
203 // Starting with look and feel
204 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
206 screen_fonts_.dialog()->form);
207 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
209 interface_.dialog()->form);
210 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
212 colors_.dialog()->form);
213 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
215 lnf_misc_.dialog()->form);
217 // then build converters
218 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
220 formats_.dialog()->form);
221 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
223 converters_.dialog()->form);
226 // Paths should probably go in a few inner_tab called Files
227 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
229 paths_.dialog()->form);
230 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
232 inputs_misc_.dialog()->form);
234 // then building outputs
235 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
237 printer_.dialog()->form);
238 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
240 outputs_misc_.dialog()->form);
242 // then building usage
243 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
245 spelloptions_.dialog()->form);
246 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
248 language_.dialog()->form);
252 void FormPreferences::apply()
254 // set the new lyxrc entries
255 // many of these need to trigger other functions when the assignment
256 // is made. For example, screen zoom and font types. These could be
257 // handled either by signals/slots in lyxrc or just directly call the
258 // associated functions here.
259 // There are other problems with this scheme. We really should check
260 // what we copy to make sure that it really is necessary to do things
261 // like update the screen fonts because that flushes the textcache
262 // and other stuff which may cost us a lot on slower/high-load
266 formats_.apply(); // Must be before converters_.apply()
268 inputs_misc_.apply();
272 outputs_misc_.apply();
275 screen_fonts_.apply();
276 spelloptions_.apply();
280 string const FormPreferences::getFeedback(FL_OBJECT * ob)
284 if (ob->form->fdui == colors_.dialog())
285 return colors_.feedback(ob);
286 if (ob->form->fdui == converters_.dialog())
287 return converters_.feedback(ob);
288 if (ob->form->fdui == formats_.dialog())
289 return formats_.feedback(ob);
290 if (ob->form->fdui == inputs_misc_.dialog())
291 return inputs_misc_.feedback(ob);
292 if (ob->form->fdui == interface_.dialog())
293 return interface_.feedback(ob);
294 if (ob->form->fdui == language_.dialog())
295 return language_.feedback(ob);
296 if (ob->form->fdui == lnf_misc_.dialog())
297 return lnf_misc_.feedback(ob);
298 if (ob->form->fdui == outputs_misc_.dialog())
299 return outputs_misc_.feedback(ob);
300 if (ob->form->fdui == paths_.dialog())
301 return paths_.feedback(ob);
302 if (ob->form->fdui == printer_.dialog())
303 return printer_.feedback(ob);
304 if (ob->form->fdui == screen_fonts_.dialog())
305 return screen_fonts_.feedback(ob);
306 if (ob->form->fdui == spelloptions_.dialog())
307 return spelloptions_.feedback(ob);
313 bool FormPreferences::input(FL_OBJECT * ob, long)
317 // whatever checks you need to ensure the user hasn't entered
318 // some totally ridiculous value somewhere. Change activate to suit.
319 // comments before each test describe what is _valid_
321 if (ob->form->fdui == colors_.dialog()) {
325 if (ob->form->fdui == converters_.dialog())
326 return converters_.input(ob);
327 if (ob->form->fdui == formats_.dialog())
328 return formats_.input(ob);
329 if (ob->form->fdui == interface_.dialog())
330 return interface_.input(ob);
331 if (ob->form->fdui == language_.dialog())
332 return language_.input(ob);
333 if (ob->form->fdui == paths_.dialog())
334 return paths_.input(ob);
335 if (ob->form->fdui == screen_fonts_.dialog())
336 return screen_fonts_.input();
337 if (ob->form->fdui == spelloptions_.dialog())
338 return spelloptions_.input(ob);
344 void FormPreferences::update()
346 if (!dialog_.get()) return;
348 // read lyxrc entries
350 formats_.update(); // Must be before converters_.update()
351 converters_.update();
352 inputs_misc_.update();
356 outputs_misc_.update();
359 screen_fonts_.update();
360 spelloptions_.update();
364 FormPreferences::Colors::Colors(FormPreferences & p)
365 : modifiedXformsPrefs(false), parent_(p)
369 FD_preferences_colors const * FormPreferences::Colors::dialog()
371 return dialog_.get();
375 void FormPreferences::Colors::apply()
377 bool modifiedText = false;
378 bool modifiedBackground = false;
380 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
381 cit != xformsColorDB.end(); ++cit) {
383 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
384 if (col != cit->color()) {
385 modifiedXformsPrefs = true;
386 if (cit->colorID == FL_BLACK)
388 if (cit->colorID == FL_COL1)
389 modifiedBackground = true;
393 if (modifiedXformsPrefs) {
394 for (vector<XformsColor>::const_iterator cit =
395 xformsColorDB.begin();
396 cit != xformsColorDB.end(); ++cit) {
397 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
399 if (modifiedText && cit->colorID == FL_BLACK) {
400 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
403 if (modifiedBackground && cit->colorID == FL_COL1) {
404 AdjustVal(FL_MCOL, FL_COL1, 0.1);
405 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
406 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
408 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
409 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
412 if (cit->colorID == GUI_COLOR_CURSOR) {
413 fl_mapcolor(GUI_COLOR_CURSOR,
414 cit->r, cit->g, cit->b);
415 setCursorColor(GUI_COLOR_CURSOR);
418 parent_.lv_->getDialogs()->redrawGUI();
421 // Now do the same for the LyX LColors...
422 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
423 cit != lyxColorDB.end(); ++cit) {
424 LColor::color lc = lcolor.getFromGUIName(cit->getname());
425 if (lc == LColor::inherit) continue;
427 // Create a valid X11 name of the form "#rrggbb"
428 string const hexname = X11hexname(cit->color());
430 if (lcolor.getX11Name(lc) != hexname) {
432 << "FormPreferences::Colors::apply: "
433 << "resetting LColor " << lcolor.getGUIName(lc)
434 << " from \"" << lcolor.getX11Name(lc)
435 << "\" to \"" << hexname << "\"."
438 string const s = lcolor.getLyXName(lc) + string(" ") +
440 parent_.lv_->getLyXFunc()->dispatch(FuncRequest(LFUN_SET_COLOR, s));
446 void FormPreferences::Colors::build()
448 dialog_.reset(build_preferences_colors(&parent_));
450 fl_set_object_color(dialog_->button_color,
451 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
453 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
454 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
455 fl_set_dial_step(dialog_->dial_hue, 1.0);
456 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
458 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
459 fl_set_slider_step(dialog_->slider_saturation, 0.01);
460 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
462 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
463 fl_set_slider_step(dialog_->slider_value, 0.01);
464 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
466 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
467 fl_set_slider_step(dialog_->slider_red, 1.0);
468 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
470 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
471 fl_set_slider_step(dialog_->slider_green, 1.0);
472 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
474 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
475 fl_set_slider_step(dialog_->slider_blue, 1.0);
476 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
478 // set up the feedback mechanism
479 setPrehandler(dialog_->browser_lyx_objs);
480 setPrehandler(dialog_->button_color);
481 setPrehandler(dialog_->button_modify);
482 setPrehandler(dialog_->dial_hue);
483 setPrehandler(dialog_->slider_saturation);
484 setPrehandler(dialog_->slider_value);
485 setPrehandler(dialog_->slider_red);
486 setPrehandler(dialog_->slider_green);
487 setPrehandler(dialog_->slider_blue);
488 setPrehandler(dialog_->radio_rgb);
489 setPrehandler(dialog_->radio_hsv);
494 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
496 if (ob == dialog_->browser_lyx_objs)
497 return _("LyX objects that can be assigned a color.");
499 if (ob == dialog_->button_modify)
500 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
502 if (ob == dialog_->dial_hue ||
503 ob == dialog_->slider_saturation ||
504 ob == dialog_->slider_value ||
505 ob == dialog_->slider_red ||
506 ob == dialog_->slider_green ||
507 ob == dialog_->slider_blue)
508 return _("Find a new color.");
510 if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
511 return _("Toggle between RGB and HSV color spaces.");
517 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
519 if (ob == dialog_->browser_lyx_objs) {
522 } else if (ob == dialog_->dial_hue ||
523 ob == dialog_->slider_saturation ||
524 ob == dialog_->slider_value) {
527 } else if (ob == dialog_->slider_red ||
528 ob == dialog_->slider_green ||
529 ob == dialog_->slider_blue) {
532 } else if (ob == dialog_->radio_rgb ||
533 ob == dialog_->radio_hsv) {
536 } else if (ob == dialog_->button_modify) {
542 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
546 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
550 hsv.v = min(1.0, max(0.0, hsv.v));
553 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
557 void FormPreferences::Colors::InputBrowserLyX() const
559 vector<NamedColor>::size_type const selLyX =
560 fl_get_browser(dialog_->browser_lyx_objs);
561 if (selLyX < 1) return;
563 // Is the choice an Xforms color...
566 if (selLyX - 1 < xformsColorDB.size()) {
567 vector<XformsColor>::size_type const i = selLyX - 1;
568 col = xformsColorDB[i].color();
570 // or a LyX Logical color?
572 vector<NamedColor>::size_type const i = selLyX - 1 -
573 xformsColorDB.size();
574 col = lyxColorDB[i].color();
577 fl_freeze_form(dialog_->form);
579 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
580 fl_redraw_object(dialog_->button_color);
582 // Display either RGB or HSV but not both!
585 // Deactivate the modify button to begin with...
586 setEnabled(dialog_->button_modify, false);
588 fl_unfreeze_form(dialog_->form);
592 void FormPreferences::Colors::InputHSV()
594 double const hue = fl_get_dial_value(dialog_->dial_hue);
595 double const sat = fl_get_slider_value(dialog_->slider_saturation);
596 double const val = fl_get_slider_value(dialog_->slider_value);
598 int const h = int(hue);
599 int const s = int(100.0 * sat);
600 int const v = int(100.0 * val);
602 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
604 fl_set_object_label(dialog_->text_color_values, label.c_str());
606 RGBColor col = HSVColor(hue, sat, val);
608 fl_freeze_form(dialog_->form);
610 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
611 fl_redraw_object(dialog_->button_color);
613 col = HSVColor(hue, 1.0, 1.0);
614 col.r = max(col.r, 0);
615 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
616 fl_redraw_object(dialog_->dial_hue);
618 // Ascertain whether to activate the Modify button.
619 vector<NamedColor>::size_type const selLyX =
620 fl_get_browser(dialog_->browser_lyx_objs);
622 fl_unfreeze_form(dialog_->form);
623 if (selLyX < 1) return;
625 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
628 // Is the choice an Xforms color...
629 if (selLyX - 1 < xformsColorDB.size()) {
630 vector<XformsColor>::size_type const i = selLyX - 1;
631 modify = (xformsColorDB[i].color() != col);
633 // or a LyX Logical color?
635 vector<NamedColor>::size_type const i = selLyX - 1 -
636 xformsColorDB.size();
637 modify = (lyxColorDB[i].color() != col);
640 setEnabled(dialog_->button_modify, modify);
644 void FormPreferences::Colors::InputRGB()
646 int const red = int(fl_get_slider_value(dialog_->slider_red));
647 int const green = int(fl_get_slider_value(dialog_->slider_green));
648 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
650 string const label = tostr(red) + string(", ") + tostr(green) +
651 string(", ") + tostr(blue);
652 fl_set_object_label(dialog_->text_color_values, label.c_str());
654 fl_freeze_form(dialog_->form);
656 RGBColor col = RGBColor(red, green, blue);
657 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
658 fl_redraw_object(dialog_->button_color);
660 // Ascertain whether to activate the Modify button.
661 vector<NamedColor>::size_type const selLyX =
662 fl_get_browser(dialog_->browser_lyx_objs);
664 fl_unfreeze_form(dialog_->form);
665 if (selLyX < 1) return;
669 // Is the choice an Xforms color...
670 if (selLyX - 1 < xformsColorDB.size()) {
671 vector<XformsColor>::size_type const i = selLyX - 1;
672 modify = (xformsColorDB[i].color() != col);
674 // or a LyX Logical color?
676 vector<NamedColor>::size_type const i = selLyX - 1 -
677 xformsColorDB.size();
678 modify = (lyxColorDB[i].color() != col);
681 setEnabled(dialog_->button_modify, modify);
685 void FormPreferences::Colors::LoadBrowserLyX()
687 if (!dialog_->browser_lyx_objs->visible)
690 // First, define the modifiable xforms colors
691 xformsColorDB.clear();
694 xcol.name = _("GUI background");
695 xcol.colorID = FL_COL1;
696 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
698 xformsColorDB.push_back(xcol);
700 xcol.name = _("GUI text");
701 xcol.colorID = FL_BLACK;
702 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
704 xformsColorDB.push_back(xcol);
706 xcol.name = _("GUI selection");
707 xcol.colorID = FL_YELLOW;
708 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
710 xformsColorDB.push_back(xcol);
712 xcol.name = _("GUI pointer");
713 xcol.colorID = GUI_COLOR_CURSOR;
714 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
716 xformsColorDB.push_back(xcol);
718 // Now create the the LyX LColors database
720 for (int i=0; i<LColor::ignore; ++i) {
721 LColor::color lc = static_cast<LColor::color>(i);
722 if (lc == LColor::none
723 || lc == LColor::black
724 || lc == LColor::white
726 || lc == LColor::green
727 || lc == LColor::blue
728 || lc == LColor::cyan
729 || lc == LColor::magenta
730 || lc == LColor::yellow
731 || lc == LColor::inherit
732 || lc == LColor::ignore) continue;
734 string const name = lcolor.getX11Name(lc);
735 Display * display = fl_get_display();;
736 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
739 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
741 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
742 << "LColor " << lcolor.getLyXName(lc)
743 << ": X can't find color \"" << name
744 << "\". Set to \"black\"!" << endl;
746 string const arg = lcolor.getLyXName(lc) + " black";
747 parent_.lv_->getLyXFunc()->
748 dispatch(FuncRequest(LFUN_SET_COLOR, arg));
752 // X has found the color. Now find the "appropriate" X11 name
755 // Note that X stores the RGB values in the range 0 - 65535
756 // whilst we require them in the range 0 - 255.
758 col.r = xcol.red / 256;
759 col.g = xcol.green / 256;
760 col.b = xcol.blue / 256;
762 // Create a valid X11 name of the form "#rrggbb" and change the
763 // LColor X11name to this. Don't want to trigger a redraw,
764 // as we're just changing the name not the RGB values.
765 // Also reset the system_lcolor names, so that we don't output
766 // unnecessary changes.
767 string const hexname = X11hexname(col);
769 if (lcolor.getX11Name(lc) != hexname) {
770 lcolor.setColor(lc, hexname);
771 system_lcolor.setColor(lc, hexname);
774 // Finally, push the color onto the database
775 NamedColor ncol(lcolor.getGUIName(lc), col);
776 lyxColorDB.push_back(ncol);
779 // Now construct the browser
780 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
781 fl_freeze_form(dialog_->form);
782 fl_clear_browser(colbr);
783 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
784 cit != xformsColorDB.end(); ++cit) {
785 fl_addto_browser(colbr, cit->getname().c_str());
787 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
788 cit != lyxColorDB.end(); ++cit) {
789 fl_addto_browser(colbr, cit->getname().c_str());
792 // just to be safe...
793 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
794 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
795 fl_unfreeze_form(dialog_->form);
801 void FormPreferences::Colors::Modify()
803 vector<NamedColor>::size_type const selLyX =
804 fl_get_browser(dialog_->browser_lyx_objs);
809 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
811 // Is the choice an Xforms color...
812 if (selLyX - 1 < xformsColorDB.size()) {
813 vector<XformsColor>::size_type const i = selLyX - 1;
814 xformsColorDB[i].r = col.r;
815 xformsColorDB[i].g = col.g;
816 xformsColorDB[i].b = col.b;
818 // or a LyX Logical color?
820 vector<NamedColor>::size_type const i = selLyX - 1 -
821 xformsColorDB.size();
822 lyxColorDB[i].r = col.r;
823 lyxColorDB[i].g = col.g;
824 lyxColorDB[i].b = col.b;
827 fl_freeze_form(dialog_->form);
828 setEnabled(dialog_->button_modify, false);
829 fl_unfreeze_form(dialog_->form);
833 void FormPreferences::Colors::SwitchColorSpace() const
835 bool const hsv = fl_get_button(dialog_->radio_hsv);
838 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
840 fl_freeze_form(dialog_->form);
843 fl_hide_object(dialog_->slider_red);
844 fl_hide_object(dialog_->slider_blue);
845 fl_hide_object(dialog_->slider_green);
846 fl_show_object(dialog_->dial_hue);
847 fl_show_object(dialog_->slider_saturation);
848 fl_show_object(dialog_->slider_value);
850 HSVColor hsv = HSVColor(col);
851 hsv.h = max(hsv.h, 0.0);
853 fl_set_dial_value(dialog_->dial_hue, hsv.h);
854 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
855 fl_set_slider_value(dialog_->slider_value, hsv.v);
857 col = HSVColor(hsv.h, 1.0, 1.0);
858 col.r = max(col.r, 0);
859 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
860 fl_redraw_object(dialog_->dial_hue);
862 // Adjust the label a bit, but not the actual values.
863 // Means that toggling from one space to the other has no
864 // effect on the final color.
865 int const h = int(hsv.h);
866 int const s = int(100 * hsv.s);
867 int const v = int(100 * hsv.v);
868 string const label = tostr(h) + ", " + tostr(s) +
870 fl_set_object_label(dialog_->text_color_values, label.c_str());
873 fl_show_object(dialog_->slider_red);
874 fl_show_object(dialog_->slider_blue);
875 fl_show_object(dialog_->slider_green);
876 fl_hide_object(dialog_->dial_hue);
877 fl_hide_object(dialog_->slider_saturation);
878 fl_hide_object(dialog_->slider_value);
880 fl_set_slider_value(dialog_->slider_red, col.r);
881 fl_set_slider_value(dialog_->slider_green, col.g);
882 fl_set_slider_value(dialog_->slider_blue, col.b);
884 // Adjust the label a bit. Same reasoning as above.
885 int const r = int(col.r);
886 int const g = int(col.g);
887 int const b = int(col.b);
888 string const label = tostr(r) + ", " + tostr(g) +
890 fl_set_object_label(dialog_->text_color_values, label.c_str());
893 fl_unfreeze_form(dialog_->form);
896 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
900 ostr << "#" << std::setbase(16) << setfill('0')
905 return ostr.str().c_str();
909 FormPreferences::Converters::Converters(FormPreferences & p)
914 FD_preferences_converters const * FormPreferences::Converters::dialog()
916 return dialog_.get();
920 void FormPreferences::Converters::apply() const
922 converters = local_converters;
923 converters.update(formats);
924 converters.buildGraph();
928 void FormPreferences::Converters::build()
930 dialog_.reset(build_preferences_converters(&parent_));
932 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
933 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
935 // set up the feedback mechanism
936 setPrehandler(dialog_->browser_all);
937 setPrehandler(dialog_->button_delete);
938 setPrehandler(dialog_->button_add);
939 setPrehandler(dialog_->input_converter);
940 setPrehandler(dialog_->choice_from);
941 setPrehandler(dialog_->choice_to);
942 setPrehandler(dialog_->input_flags);
947 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
949 if (ob == dialog_->browser_all)
950 return _("All the currently defined converters known to LyX.");
952 if (ob == dialog_->choice_from)
953 return _("Convert \"from\" this format");
955 if (ob == dialog_->choice_to)
956 return _("Convert \"to\" this format");
958 if (ob == dialog_->input_converter)
959 return _("The conversion command. $$i is the input file name, "
960 "$$b is the file name without its extension and $$o is "
961 "the name of the output file. $$s can be used as path to "
962 "LyX's own collection of conversion scripts.");
964 if (ob == dialog_->input_flags)
965 return _("Extra information for the Converter class, whether and "
966 "how to parse the result, and various other things.");
968 if (ob == dialog_->button_delete)
969 return _("Remove the current converter from the list of available "
970 "converters. Note: you must then \"Apply\" the change.");
972 if (ob == dialog_->button_add) {
973 if (string(ob->label) == _("Add"))
974 return _("Add the current converter to the list of available "
975 "converters. Note: you must then \"Apply\" the change.");
977 return _("Modify the contents of the current converter. "
978 "Note: you must then \"Apply\" the change.");
985 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
987 if (ob == dialog_->browser_all)
990 if (ob == dialog_->choice_from
991 || ob == dialog_->choice_to
992 || ob == dialog_->input_converter
993 || ob == dialog_->input_flags)
996 if (ob == dialog_->button_add)
999 if (ob == dialog_->button_delete)
1006 void FormPreferences::Converters::update()
1008 local_converters = converters;
1009 local_converters.update(local_formats);
1014 void FormPreferences::Converters::UpdateBrowser()
1016 local_converters.sort();
1018 fl_freeze_form(dialog_->form);
1019 fl_clear_browser(dialog_->browser_all);
1020 for (::Converters::const_iterator cit = local_converters.begin();
1021 cit != local_converters.end(); ++cit) {
1022 string const name = cit->From->prettyname() + " -> "
1023 + cit->To->prettyname();
1024 fl_addto_browser(dialog_->browser_all, name.c_str());
1027 fl_unfreeze_form(dialog_->form);
1031 bool FormPreferences::Converters::Add()
1033 string const from = GetFrom();
1034 string const to = GetTo();
1035 string const command = fl_get_input(dialog_->input_converter);
1036 string const flags = fl_get_input(dialog_->input_flags);
1038 Converter const * old = local_converters.getConverter(from, to);
1039 local_converters.add(from, to, command, flags);
1041 local_converters.updateLast(local_formats);
1044 setEnabled(dialog_->button_add, false);
1050 bool FormPreferences::Converters::Browser()
1052 int const i = fl_get_browser(dialog_->browser_all);
1053 if (i <= 0) return false;
1055 fl_freeze_form(dialog_->form);
1057 Converter const & c = local_converters.get(i - 1);
1058 int j = local_formats.getNumber(c.from);
1060 fl_set_choice(dialog_->choice_from, j + 1);
1062 j = local_formats.getNumber(c.to);
1064 fl_set_choice(dialog_->choice_to, j + 1);
1066 fl_set_input(dialog_->input_converter, c.command.c_str());
1067 fl_set_input(dialog_->input_flags, c.flags.c_str());
1069 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1070 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1072 setEnabled(dialog_->button_add, false);
1073 setEnabled(dialog_->button_delete, true);
1075 fl_unfreeze_form(dialog_->form);
1080 bool FormPreferences::Converters::erase()
1082 string const from = GetFrom();
1083 string const to = GetTo();
1085 local_converters.erase(from, to);
1091 bool FormPreferences::Converters::Input()
1093 string const from = GetFrom();
1094 string const to = GetTo();
1095 int const sel = local_converters.getNumber(from, to);
1097 fl_freeze_form(dialog_->form);
1100 fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
1101 fl_set_button_shortcut(dialog_->button_add,
1102 scex(_("Add|#A")), 1);
1104 fl_deselect_browser(dialog_->browser_all);
1105 setEnabled(dialog_->button_delete, false);
1108 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1109 fl_set_button_shortcut(dialog_->button_add,
1110 scex(_("Modify|#M")), 1);
1112 int top = max(sel-5, 0);
1113 fl_set_browser_topline(dialog_->browser_all, top);
1114 fl_select_browser_line(dialog_->browser_all, sel+1);
1115 setEnabled(dialog_->button_delete, true);
1118 string const command = rtrim(fl_get_input(dialog_->input_converter));
1119 bool const enable = !(command.empty() || from == to);
1120 setEnabled(dialog_->button_add, enable);
1122 fl_unfreeze_form(dialog_->form);
1127 string const FormPreferences::Converters::GetFrom() const
1129 ::Formats::FormatList::size_type const i =
1130 fl_get_choice(dialog_->choice_from);
1132 if (i > 0 && i <= local_formats.size())
1133 return local_formats.get(i - 1).name();
1135 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1140 string const FormPreferences::Converters::GetTo() const
1142 ::Formats::FormatList::size_type const i =
1143 fl_get_choice(dialog_->choice_to);
1145 if (i > 0 && i <= local_formats.size())
1146 return local_formats.get(i - 1).name();
1148 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1153 void FormPreferences::Converters::UpdateChoices() const
1156 for (::Formats::const_iterator cit = local_formats.begin();
1157 cit != local_formats.end(); ++cit) {
1158 if (!choice.empty())
1162 choice += cit->prettyname();
1166 fl_clear_choice(dialog_->choice_from);
1167 fl_addto_choice(dialog_->choice_from, choice.c_str());
1169 fl_clear_choice(dialog_->choice_to);
1170 fl_addto_choice(dialog_->choice_to, choice.c_str());
1174 FormPreferences::Formats::Formats(FormPreferences & p)
1179 FD_preferences_formats const * FormPreferences::Formats::dialog()
1181 return dialog_.get();
1185 void FormPreferences::Formats::apply() const
1187 formats = local_formats;
1191 void FormPreferences::Formats::build()
1193 dialog_.reset(build_preferences_formats(&parent_));
1195 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1196 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1197 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1198 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1199 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1201 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1203 // set up the feedback mechanism
1204 setPrehandler(dialog_->browser_all);
1205 setPrehandler(dialog_->input_format);
1206 setPrehandler(dialog_->input_gui_name);
1207 setPrehandler(dialog_->button_delete);
1208 setPrehandler(dialog_->button_add);
1209 setPrehandler(dialog_->input_extension);
1210 setPrehandler(dialog_->input_viewer);
1211 setPrehandler(dialog_->input_shrtcut);
1216 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1218 if (ob == dialog_->browser_all)
1219 return _("All the currently defined formats known to LyX.");
1221 if (ob == dialog_->input_format)
1222 return _("The format identifier.");
1224 if (ob == dialog_->input_gui_name)
1225 return _("The format name as it will appear in the menus.");
1227 if (ob == dialog_->input_shrtcut)
1228 return _("The keyboard accelerator. Use a letter in the GUI name. "
1231 if (ob == dialog_->input_extension)
1232 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1234 if (ob == dialog_->input_viewer)
1235 return _("The command used to launch the viewer application.");
1237 if (ob == dialog_->button_delete)
1238 return _("Remove the current format from the list of available "
1239 "formats. Note: you must then \"Apply\" the change.");
1241 if (ob == dialog_->button_add) {
1242 if (string(ob->label) == _("Add"))
1243 return _("Add the current format to the list of available "
1244 "formats. Note: you must then \"Apply\" the change.");
1246 return _("Modify the contents of the current format. Note: "
1247 "you must then \"Apply\" the change.");
1254 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1256 if (ob == dialog_->browser_all)
1259 if (ob == dialog_->input_format
1260 || ob == dialog_->input_gui_name
1261 || ob == dialog_->input_shrtcut
1262 || ob == dialog_->input_extension
1263 || ob == dialog_->input_viewer)
1266 if (ob == dialog_->button_add)
1269 if (ob == dialog_->button_delete)
1276 void FormPreferences::Formats::update()
1278 local_formats = formats;
1283 void FormPreferences::Formats::UpdateBrowser()
1285 local_formats.sort();
1287 fl_freeze_form(dialog_->form);
1288 fl_deselect_browser(dialog_->browser_all);
1289 fl_clear_browser(dialog_->browser_all);
1290 for (::Formats::const_iterator cit = local_formats.begin();
1291 cit != local_formats.end(); ++cit)
1292 fl_addto_browser(dialog_->browser_all,
1293 cit->prettyname().c_str());
1296 fl_unfreeze_form(dialog_->form);
1298 // Mustn't forget to update the Formats available to the converters_
1299 parent_.converters_.UpdateChoices();
1300 local_converters.update(local_formats);
1304 bool FormPreferences::Formats::Add()
1306 string const name = fl_get_input(dialog_->input_format);
1307 string const prettyname = fl_get_input(dialog_->input_gui_name);
1308 string const extension = fl_get_input(dialog_->input_extension);
1309 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1310 string const viewer = fl_get_input(dialog_->input_viewer);
1312 Format const * old = local_formats.getFormat(name);
1313 string const old_prettyname = old ? old->prettyname() : string();
1314 local_formats.add(name, extension, prettyname, shortcut);
1315 local_formats.setViewer(name, viewer);
1316 if (!old || prettyname != old_prettyname) {
1319 parent_.converters_.UpdateBrowser();
1321 setEnabled(dialog_->button_add, false);
1327 bool FormPreferences::Formats::Browser()
1329 int const i = fl_get_browser(dialog_->browser_all);
1333 fl_freeze_form(dialog_->form);
1335 Format const & f = local_formats.get(i - 1);
1337 fl_set_input(dialog_->input_format, f.name().c_str());
1338 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1339 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1340 fl_set_input(dialog_->input_extension, f.extension().c_str());
1341 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1343 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1344 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1346 setEnabled(dialog_->button_add, false);
1347 setEnabled(dialog_->button_delete, true);
1349 fl_unfreeze_form(dialog_->form);
1354 bool FormPreferences::Formats::erase()
1356 string const name = fl_get_input(dialog_->input_format);
1358 if (local_converters.formatIsUsed(name)) {
1359 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1360 "Remove the converter first."));
1361 setEnabled(dialog_->button_delete, false);
1365 local_formats.erase(name);
1371 bool FormPreferences::Formats::Input()
1373 string const name = fl_get_input(dialog_->input_format);
1374 int const sel = local_formats.getNumber(name);
1375 fl_freeze_form(dialog_->form);
1378 fl_set_object_label(dialog_->button_add,
1380 fl_set_button_shortcut(dialog_->button_add,
1381 scex(_("Add|#A")), 1);
1383 fl_deselect_browser(dialog_->browser_all);
1384 setEnabled(dialog_->button_delete, false);
1387 fl_set_object_label(dialog_->button_add,
1388 idex(_("Modify|#M")));
1389 fl_set_button_shortcut(dialog_->button_add,
1390 scex(_("Modify|#M")), 1);
1392 int const top = max(sel-5, 0);
1393 fl_set_browser_topline(dialog_->browser_all, top);
1394 fl_select_browser_line(dialog_->browser_all, sel+1);
1396 setEnabled(dialog_->button_add, true);
1397 setEnabled(dialog_->button_delete, true);
1400 string const prettyname = fl_get_input(dialog_->input_gui_name);
1401 bool const enable = !(name.empty() || prettyname.empty());
1402 setEnabled(dialog_->button_add, enable);
1404 fl_unfreeze_form(dialog_->form);
1409 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1414 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1416 return dialog_.get();
1420 void FormPreferences::InputsMisc::apply() const
1422 lyxrc.date_insert_format =
1423 fl_get_input(dialog_->input_date_format);
1427 void FormPreferences::InputsMisc::build()
1429 dialog_.reset(build_preferences_inputs_misc(&parent_));
1431 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1433 // set up the feedback mechanism
1434 setPrehandler(dialog_->input_date_format);
1439 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1441 if (ob == dialog_->input_date_format)
1442 return lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1447 void FormPreferences::InputsMisc::update()
1449 fl_set_input(dialog_->input_date_format,
1450 lyxrc.date_insert_format.c_str());
1454 FormPreferences::Interface::Interface(FormPreferences & p)
1459 FD_preferences_interface const * FormPreferences::Interface::dialog()
1461 return dialog_.get();
1465 void FormPreferences::Interface::apply() const
1467 lyxrc.popup_normal_font =
1468 fl_get_input(dialog_->input_popup_normal_font);
1469 lyxrc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1470 lyxrc.popup_font_encoding =
1471 fl_get_input(dialog_->input_popup_font_encoding);
1472 lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
1473 lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
1474 lyxrc.override_x_deadkeys =
1475 fl_get_button(dialog_->check_override_x_dead_keys);
1479 void FormPreferences::Interface::build()
1481 dialog_.reset(build_preferences_interface(&parent_));
1483 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1484 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1485 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1486 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1487 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1489 // set up the feedback mechanism
1490 setPrehandler(dialog_->input_popup_normal_font);
1491 setPrehandler(dialog_->input_popup_bold_font);
1492 setPrehandler(dialog_->input_popup_font_encoding);
1493 setPrehandler(dialog_->input_bind_file);
1494 setPrehandler(dialog_->button_bind_file_browse);
1495 setPrehandler(dialog_->input_ui_file);
1496 setPrehandler(dialog_->button_ui_file_browse);
1497 setPrehandler(dialog_->check_override_x_dead_keys);
1502 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1504 if (ob == dialog_->input_popup_normal_font)
1505 return lyxrc.getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1506 if (ob == dialog_->input_popup_bold_font)
1507 return lyxrc.getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1508 if (ob == dialog_->input_popup_font_encoding)
1509 return lyxrc.getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1510 if (ob == dialog_->input_bind_file)
1511 return lyxrc.getDescription(LyXRC::RC_BINDFILE);
1512 if (ob == dialog_->input_ui_file)
1513 return lyxrc.getDescription(LyXRC::RC_UIFILE);
1514 if (ob == dialog_->check_override_x_dead_keys)
1515 return lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1520 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1522 if (ob == dialog_->button_bind_file_browse) {
1523 string dir = AddName(system_lyxdir, "bind");
1524 string name = _("Sys Bind|#S#s");
1525 pair<string,string> dir1(name, dir);
1527 dir = AddName(user_lyxdir, "bind");
1528 name = _("User Bind|#U#u");
1529 pair<string,string> dir2(name, dir);
1531 parent_.browse(dialog_->input_bind_file,
1532 _("Bind file"), "*.bind", dir1, dir2);
1534 } else if (ob == dialog_->button_ui_file_browse) {
1535 string dir = AddName(system_lyxdir, "ui");
1536 string name = _("Sys UI|#S#s");
1537 pair<string,string> dir1(name, dir);
1539 dir = AddName(user_lyxdir, "ui");
1540 name = _("User UI|#U#u");
1541 pair<string,string> dir2(name, dir);
1543 parent_.browse(dialog_->input_ui_file,
1544 _("UI file"), "*.ui", dir1, dir2);
1551 void FormPreferences::Interface::update()
1553 fl_set_input(dialog_->input_popup_normal_font,
1554 lyxrc.popup_normal_font.c_str());
1555 fl_set_input(dialog_->input_popup_bold_font,
1556 lyxrc.popup_bold_font.c_str());
1557 fl_set_input(dialog_->input_popup_font_encoding,
1558 lyxrc.popup_font_encoding.c_str());
1559 fl_set_input(dialog_->input_bind_file,
1560 lyxrc.bind_file.c_str());
1561 fl_set_input(dialog_->input_ui_file,
1562 lyxrc.ui_file.c_str());
1563 fl_set_button(dialog_->check_override_x_dead_keys,
1564 lyxrc.override_x_deadkeys);
1568 FormPreferences::Language::Language(FormPreferences & p)
1573 FD_preferences_language const * FormPreferences::Language::dialog()
1575 return dialog_.get();
1579 void FormPreferences::Language::apply()
1581 int const pos = combo_default_lang->get();
1582 lyxrc.default_language = lang_[pos-1];
1584 int button = fl_get_button(dialog_->check_use_kbmap);
1585 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1586 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1588 button = !(name_1.empty() && name_2.empty());
1589 lyxrc.use_kbmap = static_cast<bool>(button);
1591 if (lyxrc.use_kbmap) {
1592 lyxrc.primary_kbmap = name_1;
1593 lyxrc.secondary_kbmap = name_2;
1596 button = fl_get_button(dialog_->check_rtl_support);
1597 lyxrc.rtl_support = static_cast<bool>(button);
1599 button = fl_get_button(dialog_->check_mark_foreign);
1600 lyxrc.mark_foreign_language = static_cast<bool>(button);
1602 button = fl_get_button(dialog_->check_auto_begin);
1603 lyxrc.language_auto_begin = static_cast<bool>(button);
1605 button = fl_get_button(dialog_->check_auto_end);
1606 lyxrc.language_auto_end = static_cast<bool>(button);
1608 button = fl_get_button(dialog_->check_use_babel);
1609 lyxrc.language_use_babel = static_cast<bool>(button);
1611 button = fl_get_button(dialog_->check_global_options);
1612 lyxrc.language_global_options = static_cast<bool>(button);
1614 lyxrc.language_package = fl_get_input(dialog_->input_package);
1615 lyxrc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1616 lyxrc.language_command_end = fl_get_input(dialog_->input_command_end);
1618 // Ensure that all is self-consistent.
1623 void FormPreferences::Language::build()
1625 dialog_.reset(build_preferences_language(&parent_));
1627 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1628 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1629 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1631 // Store the lang identifiers for later
1632 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1633 lang_ = getSecond(langs);
1635 // The default_language is a combo-box and has to be inserted manually
1636 fl_freeze_form(dialog_->form);
1637 fl_addto_form(dialog_->form);
1639 FL_OBJECT * obj = dialog_->choice_default_lang;
1640 fl_deactivate_object(dialog_->choice_default_lang);
1641 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1642 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
1643 parent_.lang_opts_tab_->tabfolder_inner,
1644 parent_.dialog_->tabfolder_prefs);
1645 combo_default_lang->shortcut("#L",1);
1646 combo_default_lang->setcallback(ComboCB, &parent_);
1648 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1649 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1650 for (; lit != lend; ++lit) {
1651 combo_default_lang->addto(lit->first);
1653 combo_default_lang->select(1);
1656 fl_unfreeze_form(dialog_->form);
1658 // set up the feedback mechanism
1659 setPrehandler(dialog_->input_package);
1660 setPrehandler(dialog_->check_use_kbmap);
1662 // This is safe, as nothing is done to the pointer, other than
1663 // to use its address in a block-if statement.
1664 // No it's not! Leads to crash.
1666 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1667 // C_FormPreferencesFeedbackCB);
1669 setPrehandler(dialog_->input_kbmap1);
1670 setPrehandler(dialog_->input_kbmap2);
1671 setPrehandler(dialog_->check_rtl_support);
1672 setPrehandler(dialog_->check_mark_foreign);
1673 setPrehandler(dialog_->check_auto_begin);
1674 setPrehandler(dialog_->check_auto_end);
1675 setPrehandler(dialog_->check_use_babel);
1676 setPrehandler(dialog_->check_global_options);
1677 setPrehandler(dialog_->input_command_begin);
1678 setPrehandler(dialog_->input_command_end);
1680 // Activate/Deactivate the input fields dependent on the state of the
1687 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1689 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1690 return lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1691 if (ob == dialog_->check_use_kbmap)
1692 return lyxrc.getDescription(LyXRC::RC_KBMAP);
1693 if (ob == dialog_->input_kbmap1)
1694 return lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1695 if (ob == dialog_->input_kbmap2)
1696 return lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1697 if (ob == dialog_->check_rtl_support)
1698 return lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1699 if (ob == dialog_->check_mark_foreign)
1700 return lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1701 if (ob == dialog_->check_auto_begin)
1702 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1703 if (ob == dialog_->check_auto_end)
1704 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1705 if (ob == dialog_->check_use_babel)
1706 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1707 if (ob == dialog_->check_global_options)
1708 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1709 if (ob == dialog_->input_package)
1710 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1711 if (ob == dialog_->input_command_begin)
1712 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1713 if (ob == dialog_->input_command_end)
1714 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1719 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1721 bool activate = true;
1723 // !ob if function is called from Language::build() to de/activate
1725 // otherwise the function is called by an xforms CB via input().
1726 if (!ob || ob == dialog_->check_use_kbmap) {
1727 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1728 setEnabled(dialog_->button_kbmap1_browse, enable);
1729 setEnabled(dialog_->button_kbmap2_browse, enable);
1730 setEnabled(dialog_->input_kbmap1, enable);
1731 setEnabled(dialog_->input_kbmap2, enable);
1734 if (ob == dialog_->button_kbmap1_browse) {
1735 string const dir = AddName(system_lyxdir, "kbd");
1736 string const name = _("Key maps|#K#k");
1737 pair<string, string> dir1(name, dir);
1739 parent_.browse(dialog_->input_kbmap1,
1740 _("Keyboard map"), "*.kmap", dir1);
1741 } else if (ob == dialog_->button_kbmap2_browse) {
1742 string const dir = AddName(system_lyxdir, "kbd");
1743 string const name = _("Key maps|#K#k");
1744 pair<string, string> dir1(name, dir);
1746 parent_.browse(dialog_->input_kbmap2,
1747 _("Keyboard map"), "*.kmap", dir1);
1754 void FormPreferences::Language::update()
1756 fl_set_button(dialog_->check_use_kbmap,
1759 int const pos = int(findPos(lang_, lyxrc.default_language));
1760 combo_default_lang->select(pos + 1);
1762 if (lyxrc.use_kbmap) {
1763 fl_set_input(dialog_->input_kbmap1,
1764 lyxrc.primary_kbmap.c_str());
1765 fl_set_input(dialog_->input_kbmap2,
1766 lyxrc.secondary_kbmap.c_str());
1768 fl_set_input(dialog_->input_kbmap1, "");
1769 fl_set_input(dialog_->input_kbmap2, "");
1772 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1773 fl_set_button(dialog_->check_mark_foreign,
1774 lyxrc.mark_foreign_language);
1775 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1776 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1777 fl_set_button(dialog_->check_use_babel, lyxrc.language_use_babel);
1778 fl_set_button(dialog_->check_global_options,
1779 lyxrc.language_global_options);
1781 fl_set_input(dialog_->input_package,
1782 lyxrc.language_package.c_str());
1783 fl_set_input(dialog_->input_command_begin,
1784 lyxrc.language_command_begin.c_str());
1785 fl_set_input(dialog_->input_command_end,
1786 lyxrc.language_command_end.c_str());
1788 // Activate/Deactivate the input fields dependent on the state of the
1794 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1796 FormPreferences * pre = static_cast<FormPreferences*>(v);
1797 // This is safe, as nothing is done to the pointer, other than
1798 // to use its address in a block-if statement.
1799 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1803 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1808 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1810 return dialog_.get();
1814 void FormPreferences::LnFmisc::apply() const
1816 lyxrc.auto_region_delete =
1817 fl_get_button(dialog_->check_auto_region_delete);
1818 lyxrc.cursor_follows_scrollbar =
1819 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1820 lyxrc.dialogs_iconify_with_main =
1821 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1822 lyxrc.preview = fl_get_button(dialog_->check_preview_latex);
1823 lyxrc.autosave = static_cast<unsigned int>
1824 (fl_get_counter_value(dialog_->counter_autosave));
1825 lyxrc.wheel_jump = static_cast<unsigned int>
1826 (fl_get_counter_value(dialog_->counter_wm_jump));
1828 string const old_value = lyxrc.display_graphics;
1829 if (fl_get_button(dialog_->radio_display_monochrome)) {
1830 lyxrc.display_graphics = "mono";
1831 } else if (fl_get_button(dialog_->radio_display_grayscale)) {
1832 lyxrc.display_graphics = "gray";
1833 } else if (fl_get_button(dialog_->radio_display_color)) {
1834 lyxrc.display_graphics = "color";
1836 lyxrc.display_graphics = "no";
1839 #ifdef WITH_WARNINGS
1840 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1843 if (old_value != lyxrc.display_graphics) {
1844 grfx::GCache & gc = grfx::GCache::get();
1851 void FormPreferences::LnFmisc::build()
1853 dialog_.reset(build_preferences_lnf_misc(&parent_));
1855 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1856 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1858 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1859 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1861 // set up the feedback mechanism
1862 setPrehandler(dialog_->check_auto_region_delete);
1863 setPrehandler(dialog_->counter_autosave);
1864 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1865 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1866 setPrehandler(dialog_->check_preview_latex);
1867 setPrehandler(dialog_->counter_wm_jump);
1868 setPrehandler(dialog_->radio_display_monochrome);
1869 setPrehandler(dialog_->radio_display_grayscale);
1870 setPrehandler(dialog_->radio_display_color);
1871 setPrehandler(dialog_->radio_no_display);
1876 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1878 if (ob == dialog_->check_auto_region_delete)
1879 return lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1880 if (ob == dialog_->check_cursor_follows_scrollbar)
1881 return lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1882 if (ob == dialog_->check_dialogs_iconify_with_main)
1883 return lyxrc.getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1884 if (ob == dialog_->check_preview_latex)
1885 return lyxrc.getDescription(LyXRC::RC_PREVIEW);
1886 if (ob == dialog_->counter_autosave)
1887 return lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1888 if (ob == dialog_->counter_wm_jump)
1889 return lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1890 if (ob == dialog_->radio_display_monochrome ||
1891 ob == dialog_->radio_display_grayscale ||
1892 ob == dialog_->radio_display_color ||
1893 ob == dialog_->radio_no_display)
1894 return lyxrc.getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1899 void FormPreferences::LnFmisc::update()
1901 fl_set_button(dialog_->check_auto_region_delete,
1902 lyxrc.auto_region_delete);
1903 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1904 lyxrc.cursor_follows_scrollbar);
1905 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1906 lyxrc.dialogs_iconify_with_main);
1907 fl_set_button(dialog_->check_preview_latex,
1909 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1910 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1912 if (lyxrc.display_graphics == "mono") {
1913 fl_set_button(dialog_->radio_display_monochrome, 1);
1914 } else if (lyxrc.display_graphics == "gray") {
1915 fl_set_button(dialog_->radio_display_grayscale, 1);
1916 } else if (lyxrc.display_graphics == "color") {
1917 fl_set_button(dialog_->radio_display_color, 1);
1919 fl_set_button(dialog_->radio_no_display, 1);
1924 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1929 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1931 return dialog_.get();
1935 void FormPreferences::OutputsMisc::apply() const
1937 lyxrc.ascii_linelen = static_cast<unsigned int>
1938 (fl_get_counter_value(dialog_->counter_line_len));
1939 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1942 fl_get_choice(dialog_->choice_default_papersize) - 1;
1943 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1945 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1946 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1947 lyxrc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1948 lyxrc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1952 void FormPreferences::OutputsMisc::build()
1954 dialog_.reset(build_preferences_outputs_misc(&parent_));
1956 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1958 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1959 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1960 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1961 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1962 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1964 fl_addto_choice(dialog_->choice_default_papersize,
1965 _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1967 // set up the feedback mechanism
1968 setPrehandler(dialog_->counter_line_len);
1969 setPrehandler(dialog_->input_tex_encoding);
1970 setPrehandler(dialog_->choice_default_papersize);
1971 setPrehandler(dialog_->input_ascii_roff);
1972 setPrehandler(dialog_->input_checktex);
1973 setPrehandler(dialog_->input_paperoption);
1974 setPrehandler(dialog_->check_autoreset_classopt);
1979 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1981 if (ob == dialog_->counter_line_len)
1982 return lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
1983 if (ob == dialog_->input_tex_encoding)
1984 return lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
1985 if (ob == dialog_->input_ascii_roff)
1986 return lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1987 if (ob == dialog_->input_checktex)
1988 return lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
1989 if (ob == dialog_->choice_default_papersize)
1990 return lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1991 if (ob == dialog_->input_paperoption)
1992 return lyxrc.getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
1993 if (ob == dialog_->check_autoreset_classopt)
1994 return lyxrc.getDescription(LyXRC::RC_AUTORESET_OPTIONS);
1999 void FormPreferences::OutputsMisc::update()
2001 fl_set_counter_value(dialog_->counter_line_len,
2002 lyxrc.ascii_linelen);
2003 fl_set_input(dialog_->input_tex_encoding,
2004 lyxrc.fontenc.c_str());
2005 fl_set_choice(dialog_->choice_default_papersize,
2006 lyxrc.default_papersize+1);
2007 fl_set_input(dialog_->input_ascii_roff,
2008 lyxrc.ascii_roff_command.c_str());
2009 fl_set_input(dialog_->input_checktex,
2010 lyxrc.chktex_command.c_str());
2011 fl_set_input(dialog_->input_paperoption,
2012 lyxrc.view_dvi_paper_option.c_str());
2013 fl_set_button(dialog_->check_autoreset_classopt,
2014 lyxrc.auto_reset_options);
2019 FormPreferences::Paths::Paths(FormPreferences & p)
2024 FD_preferences_paths const * FormPreferences::Paths::dialog()
2026 return dialog_.get();
2030 void FormPreferences::Paths::apply()
2032 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2033 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2035 int button = fl_get_button(dialog_->check_use_temp_dir);
2036 string str = fl_get_input(dialog_->input_temp_dir);
2040 lyxrc.use_tempdir = button;
2041 lyxrc.tempdir_path = str;
2043 button = fl_get_button(dialog_->check_last_files);
2044 str = fl_get_input(dialog_->input_lastfiles);
2045 if (!button) str.erase();
2047 lyxrc.check_lastfiles = button;
2048 lyxrc.lastfiles = str;
2049 lyxrc.num_lastfiles = static_cast<unsigned int>
2050 (fl_get_counter_value(dialog_->counter_lastfiles));
2052 button = fl_get_button(dialog_->check_make_backups);
2053 str = fl_get_input(dialog_->input_backup_path);
2057 lyxrc.make_backup = button;
2058 lyxrc.backupdir_path = str;
2060 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2067 void FormPreferences::Paths::build()
2069 dialog_.reset(build_preferences_paths(&parent_));
2071 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2072 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2073 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2074 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2075 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2076 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2077 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2079 // set up the feedback mechanism
2080 setPrehandler(dialog_->input_default_path);
2081 setPrehandler(dialog_->counter_lastfiles);
2082 setPrehandler(dialog_->input_template_path);
2083 setPrehandler(dialog_->check_last_files);
2084 setPrehandler(dialog_->input_lastfiles);
2085 setPrehandler(dialog_->check_make_backups);
2086 setPrehandler(dialog_->input_backup_path);
2087 setPrehandler(dialog_->input_serverpipe);
2088 setPrehandler(dialog_->input_temp_dir);
2089 setPrehandler(dialog_->check_use_temp_dir);
2094 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2096 if (ob == dialog_->input_default_path)
2097 return lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2098 if (ob == dialog_->input_template_path)
2099 return lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2100 if (ob == dialog_->check_use_temp_dir)
2101 return lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2102 if (ob == dialog_->input_temp_dir)
2103 return lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2104 if (ob == dialog_->check_last_files)
2105 return lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2106 if (ob == dialog_->input_lastfiles)
2107 return lyxrc.getDescription(LyXRC::RC_LASTFILES);
2108 if (ob == dialog_->counter_lastfiles)
2109 return lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2110 if (ob == dialog_->check_make_backups)
2111 return lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2112 if (ob == dialog_->input_backup_path)
2113 return lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2114 if (ob == dialog_->input_serverpipe)
2115 return lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2120 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2122 bool activate = true;
2124 // !ob if function is called from Paths::update() to de/activate
2126 // otherwise the function is called by an xforms CB via input().
2127 if (!ob || ob == dialog_->check_use_temp_dir) {
2128 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2129 setEnabled(dialog_->input_temp_dir, enable);
2132 if (!ob || ob == dialog_->check_last_files) {
2133 bool const enable = fl_get_button(dialog_->check_last_files);
2134 setEnabled(dialog_->input_lastfiles, enable);
2137 if (!ob || ob == dialog_->check_make_backups) {
2138 bool const enable = fl_get_button(dialog_->check_make_backups);
2139 setEnabled(dialog_->input_backup_path, enable);
2142 if (!ob || ob == dialog_->input_default_path) {
2143 string const name = fl_get_input(dialog_->input_default_path);
2144 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2145 parent_.postWarning(RWInfo::ErrorMessage());
2150 if (!ob || ob == dialog_->input_template_path) {
2151 string const name = fl_get_input(dialog_->input_template_path);
2152 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2153 parent_.postWarning(RWInfo::ErrorMessage());
2158 if (!ob || ob == dialog_->input_temp_dir) {
2159 string const name = fl_get_input(dialog_->input_temp_dir);
2160 if (fl_get_button(dialog_->check_make_backups)
2162 && !RWInfo::WriteableDir(name)) {
2163 parent_.postWarning(RWInfo::ErrorMessage());
2168 if (!ob || ob == dialog_->input_backup_path) {
2169 string const name = fl_get_input(dialog_->input_backup_path);
2170 if (fl_get_button(dialog_->check_make_backups)
2172 && !RWInfo::WriteableDir(name)) {
2173 parent_.postWarning(RWInfo::ErrorMessage());
2178 if (!ob || ob == dialog_->input_lastfiles) {
2179 string const name = fl_get_input(dialog_->input_lastfiles);
2180 if (fl_get_button(dialog_->check_last_files)
2182 && !RWInfo::WriteableFile(name)) {
2183 parent_.postWarning(RWInfo::ErrorMessage());
2188 if (!ob || ob == dialog_->input_serverpipe) {
2189 string const name = fl_get_input(dialog_->input_serverpipe);
2190 if (!name.empty()) {
2191 // strip off the extension
2192 string const str = ChangeExtension(name, "");
2193 if (!RWInfo::WriteableFile(str + ".in")) {
2194 parent_.postWarning(RWInfo::ErrorMessage());
2197 if (!RWInfo::WriteableFile(str + ".out")) {
2198 parent_.postWarning(RWInfo::ErrorMessage());
2204 if (ob == dialog_->button_default_path_browse) {
2205 parent_.browse(dialog_->input_default_path,
2206 _("Default path"), string());
2207 } else if (ob == dialog_->button_template_path_browse) {
2208 parent_.browse(dialog_->input_template_path,
2209 _("Template path"), string());
2210 } else if (ob == dialog_->button_temp_dir_browse) {
2211 parent_.browse(dialog_->input_temp_dir,
2212 _("Temp dir"), string());
2213 } else if (ob == dialog_->button_lastfiles_browse) {
2214 pair<string, string> dir(_("User|#U#u"), user_lyxdir);
2216 parent_.browse(dialog_->input_lastfiles,
2217 _("Lastfiles"), string(), dir);
2218 } else if (ob == dialog_->button_backup_path_browse) {
2219 parent_.browse(dialog_->input_backup_path,
2220 _("Backup path"), string());
2221 } else if (ob == dialog_->button_serverpipe_browse) {
2222 parent_.browse(dialog_->input_serverpipe,
2223 _("LyX Server pipes"), string());
2230 void FormPreferences::Paths::update()
2232 fl_set_input(dialog_->input_default_path,
2233 lyxrc.document_path.c_str());
2234 fl_set_input(dialog_->input_template_path,
2235 lyxrc.template_path.c_str());
2238 if (lyxrc.make_backup)
2239 str = lyxrc.backupdir_path;
2241 fl_set_button(dialog_->check_make_backups,
2243 fl_set_input(dialog_->input_backup_path, str.c_str());
2246 if (lyxrc.use_tempdir)
2247 str = lyxrc.tempdir_path;
2249 fl_set_button(dialog_->check_use_temp_dir,
2251 fl_set_input(dialog_->input_temp_dir, str.c_str());
2254 if (lyxrc.check_lastfiles)
2255 str = lyxrc.lastfiles;
2257 fl_set_button(dialog_->check_last_files,
2258 lyxrc.check_lastfiles);
2259 fl_set_input(dialog_->input_lastfiles, str.c_str());
2260 fl_set_counter_value(dialog_->counter_lastfiles,
2261 lyxrc.num_lastfiles);
2263 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2265 // Activate/Deactivate the input fields dependent on the state of the
2271 FormPreferences::Printer::Printer(FormPreferences & p)
2276 FD_preferences_printer const * FormPreferences::Printer::dialog()
2278 return dialog_.get();
2282 void FormPreferences::Printer::apply() const
2284 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2285 lyxrc.print_command = fl_get_input(dialog_->input_command);
2286 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2287 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2288 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2289 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2290 lyxrc.print_file_extension =
2291 fl_get_input(dialog_->input_file_extension);
2292 lyxrc.print_spool_command =
2293 fl_get_input(dialog_->input_spool_command);
2294 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2295 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2296 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2297 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2298 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2299 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2300 lyxrc.print_extra_options =
2301 fl_get_input(dialog_->input_extra_options);
2302 lyxrc.print_spool_printerprefix =
2303 fl_get_input(dialog_->input_spool_prefix);
2304 lyxrc.print_paper_dimension_flag =
2305 fl_get_input(dialog_->input_paper_size);
2306 lyxrc.printer = fl_get_input(dialog_->input_name);
2311 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2313 if (ob == dialog_->input_command)
2314 return lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2315 if (ob == dialog_->check_adapt_output)
2316 return lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2317 if (ob == dialog_->input_to_printer)
2318 return lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2319 if (ob == dialog_->input_to_file)
2320 return lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2321 if (ob == dialog_->input_file_extension)
2322 return lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2323 if (ob == dialog_->input_extra_options)
2324 return lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2325 if (ob == dialog_->input_spool_command)
2326 return lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2327 if (ob == dialog_->input_spool_prefix)
2328 return lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2329 if (ob == dialog_->input_name)
2330 return lyxrc.getDescription(LyXRC::RC_PRINTER);
2331 if (ob == dialog_->input_even_pages)
2332 return lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2333 if (ob == dialog_->input_odd_pages)
2334 return lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2335 if (ob == dialog_->input_page_range)
2336 return lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2337 if (ob == dialog_->input_reverse)
2338 return lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2339 if (ob == dialog_->input_landscape)
2340 return lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2341 if (ob == dialog_->input_copies)
2342 return lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2343 if (ob == dialog_->input_collated)
2344 return lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2345 if (ob == dialog_->input_paper_type)
2346 return lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2347 if (ob == dialog_->input_paper_size)
2348 return lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2353 void FormPreferences::Printer::build()
2355 dialog_.reset(build_preferences_printer(&parent_));
2357 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2358 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2359 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2360 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2361 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2362 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2363 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2364 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2365 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2366 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2367 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2368 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2369 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2370 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2371 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2372 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2373 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2375 // set up the feedback mechanism
2376 setPrehandler(dialog_->input_command);
2377 setPrehandler(dialog_->input_page_range);
2378 setPrehandler(dialog_->input_copies);
2379 setPrehandler(dialog_->input_reverse);
2380 setPrehandler(dialog_->input_to_printer);
2381 setPrehandler(dialog_->input_file_extension);
2382 setPrehandler(dialog_->input_spool_command);
2383 setPrehandler(dialog_->input_paper_type);
2384 setPrehandler(dialog_->input_even_pages);
2385 setPrehandler(dialog_->input_odd_pages);
2386 setPrehandler(dialog_->input_collated);
2387 setPrehandler(dialog_->input_landscape);
2388 setPrehandler(dialog_->input_to_file);
2389 setPrehandler(dialog_->input_extra_options);
2390 setPrehandler(dialog_->input_spool_prefix);
2391 setPrehandler(dialog_->input_paper_size);
2392 setPrehandler(dialog_->input_name);
2393 setPrehandler(dialog_->check_adapt_output);
2397 void FormPreferences::Printer::update()
2399 fl_set_button(dialog_->check_adapt_output,
2400 lyxrc.print_adapt_output);
2401 fl_set_input(dialog_->input_command,
2402 lyxrc.print_command.c_str());
2403 fl_set_input(dialog_->input_page_range,
2404 lyxrc.print_pagerange_flag.c_str());
2405 fl_set_input(dialog_->input_copies,
2406 lyxrc.print_copies_flag.c_str());
2407 fl_set_input(dialog_->input_reverse,
2408 lyxrc.print_reverse_flag.c_str());
2409 fl_set_input(dialog_->input_to_printer,
2410 lyxrc.print_to_printer.c_str());
2411 fl_set_input(dialog_->input_file_extension,
2412 lyxrc.print_file_extension.c_str());
2413 fl_set_input(dialog_->input_spool_command,
2414 lyxrc.print_spool_command.c_str());
2415 fl_set_input(dialog_->input_paper_type,
2416 lyxrc.print_paper_flag.c_str());
2417 fl_set_input(dialog_->input_even_pages,
2418 lyxrc.print_evenpage_flag.c_str());
2419 fl_set_input(dialog_->input_odd_pages,
2420 lyxrc.print_oddpage_flag.c_str());
2421 fl_set_input(dialog_->input_collated,
2422 lyxrc.print_collcopies_flag.c_str());
2423 fl_set_input(dialog_->input_landscape,
2424 lyxrc.print_landscape_flag.c_str());
2425 fl_set_input(dialog_->input_to_file,
2426 lyxrc.print_to_file.c_str());
2427 fl_set_input(dialog_->input_extra_options,
2428 lyxrc.print_extra_options.c_str());
2429 fl_set_input(dialog_->input_spool_prefix,
2430 lyxrc.print_spool_printerprefix.c_str());
2431 fl_set_input(dialog_->input_paper_size,
2432 lyxrc.print_paper_dimension_flag.c_str());
2433 fl_set_input(dialog_->input_name,
2434 lyxrc.printer.c_str());
2438 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2443 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2445 return dialog_.get();
2449 void FormPreferences::ScreenFonts::apply() const
2451 bool changed = false;
2453 string str = fl_get_input(dialog_->input_roman);
2454 if (lyxrc.roman_font_name != str) {
2456 lyxrc.roman_font_name = str;
2459 str = fl_get_input(dialog_->input_sans);
2460 if (lyxrc.sans_font_name != str) {
2462 lyxrc.sans_font_name = str;
2465 str = fl_get_input(dialog_->input_typewriter);
2466 if (lyxrc.typewriter_font_name != str) {
2468 lyxrc.typewriter_font_name = str;
2471 str = fl_get_input(dialog_->input_screen_encoding);
2472 if (lyxrc.font_norm != str) {
2474 lyxrc.font_norm = str;
2477 bool button = fl_get_button(dialog_->check_scalable);
2478 if (lyxrc.use_scalable_fonts != button) {
2480 lyxrc.use_scalable_fonts = button;
2483 unsigned int ivalue = static_cast<unsigned int>
2484 (fl_get_counter_value(dialog_->counter_zoom));
2485 if (lyxrc.zoom != ivalue) {
2487 lyxrc.zoom = ivalue;
2490 ivalue = static_cast<unsigned int>
2491 (fl_get_counter_value(dialog_->counter_dpi));
2492 if (lyxrc.dpi != ivalue) {
2497 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2498 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2500 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2503 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2504 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2506 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2509 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2510 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2512 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2515 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2516 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2518 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2521 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2522 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2524 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2527 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2528 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2530 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2533 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2534 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2536 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2539 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2540 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2542 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2545 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2546 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2548 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2551 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2552 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2554 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2558 // Now update the buffers
2559 // Can anything below here affect the redraw process?
2560 parent_.lv_->getLyXFunc()->dispatch(LFUN_SCREEN_FONT_UPDATE);
2565 void FormPreferences::ScreenFonts::build()
2567 dialog_.reset(build_preferences_screen_fonts(&parent_));
2569 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2570 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2572 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2573 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2574 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2575 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2576 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2577 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2578 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2579 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2580 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2581 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2582 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2583 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2584 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2585 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2586 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2587 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2589 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2590 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2591 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2592 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2593 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2594 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2595 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2596 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2597 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2598 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2600 // set up the feedback mechanism
2601 setPrehandler(dialog_->input_roman);
2602 setPrehandler(dialog_->input_sans);
2603 setPrehandler(dialog_->input_typewriter);
2604 setPrehandler(dialog_->counter_zoom);
2605 setPrehandler(dialog_->counter_dpi);
2606 setPrehandler(dialog_->check_scalable);
2607 setPrehandler(dialog_->input_screen_encoding);
2608 setPrehandler(dialog_->input_tiny);
2609 setPrehandler(dialog_->input_script);
2610 setPrehandler(dialog_->input_footnote);
2611 setPrehandler(dialog_->input_small);
2612 setPrehandler(dialog_->input_large);
2613 setPrehandler(dialog_->input_larger);
2614 setPrehandler(dialog_->input_largest);
2615 setPrehandler(dialog_->input_normal);
2616 setPrehandler(dialog_->input_huge);
2617 setPrehandler(dialog_->input_huger);
2622 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2624 if (ob == dialog_->input_roman)
2625 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2626 if (ob == dialog_->input_sans)
2627 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2628 if (ob == dialog_->input_typewriter)
2629 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2630 if (ob == dialog_->check_scalable)
2631 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2632 if (ob == dialog_->input_screen_encoding)
2633 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2634 if (ob == dialog_->counter_zoom)
2635 return lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2636 if (ob == dialog_->counter_dpi)
2637 return lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2638 if (ob == dialog_->input_tiny
2639 || ob == dialog_->input_script
2640 || ob == dialog_->input_footnote
2641 || ob == dialog_->input_small
2642 || ob == dialog_->input_large
2643 || ob == dialog_->input_larger
2644 || ob == dialog_->input_larger
2645 || ob == dialog_->input_largest
2646 || ob == dialog_->input_normal
2647 || ob == dialog_->input_huge
2648 || ob == dialog_->input_huger)
2649 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2654 bool FormPreferences::ScreenFonts::input()
2656 bool activate = true;
2659 // Make sure that all fonts all have positive entries
2660 // Also note that an empty entry is returned as 0.0 by strToDbl
2661 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2662 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2663 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2664 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2665 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2666 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2667 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2668 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2669 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2670 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2672 str = _("Fonts must be positive!");
2674 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2675 // Fontsizes -- tiny < script < footnote etc.
2676 strToDbl(fl_get_input(dialog_->input_script)) ||
2677 strToDbl(fl_get_input(dialog_->input_script)) >
2678 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2679 strToDbl(fl_get_input(dialog_->input_footnote)) >
2680 strToDbl(fl_get_input(dialog_->input_small)) ||
2681 strToDbl(fl_get_input(dialog_->input_small)) >
2682 strToDbl(fl_get_input(dialog_->input_normal)) ||
2683 strToDbl(fl_get_input(dialog_->input_normal)) >
2684 strToDbl(fl_get_input(dialog_->input_large)) ||
2685 strToDbl(fl_get_input(dialog_->input_large)) >
2686 strToDbl(fl_get_input(dialog_->input_larger)) ||
2687 strToDbl(fl_get_input(dialog_->input_larger)) >
2688 strToDbl(fl_get_input(dialog_->input_largest)) ||
2689 strToDbl(fl_get_input(dialog_->input_largest)) >
2690 strToDbl(fl_get_input(dialog_->input_huge)) ||
2691 strToDbl(fl_get_input(dialog_->input_huge)) >
2692 strToDbl(fl_get_input(dialog_->input_huger))) {
2695 str = _("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2699 parent_.postWarning(str);
2705 void FormPreferences::ScreenFonts::update()
2707 fl_set_input(dialog_->input_roman,
2708 lyxrc.roman_font_name.c_str());
2709 fl_set_input(dialog_->input_sans,
2710 lyxrc.sans_font_name.c_str());
2711 fl_set_input(dialog_->input_typewriter,
2712 lyxrc.typewriter_font_name.c_str());
2713 fl_set_input(dialog_->input_screen_encoding,
2714 lyxrc.font_norm.c_str());
2715 fl_set_button(dialog_->check_scalable,
2716 lyxrc.use_scalable_fonts);
2717 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2718 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2719 fl_set_input(dialog_->input_tiny,
2720 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2721 fl_set_input(dialog_->input_script,
2722 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2723 fl_set_input(dialog_->input_footnote,
2724 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2725 fl_set_input(dialog_->input_small,
2726 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2727 fl_set_input(dialog_->input_normal,
2728 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2729 fl_set_input(dialog_->input_large,
2730 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2731 fl_set_input(dialog_->input_larger,
2732 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2733 fl_set_input(dialog_->input_largest,
2734 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2735 fl_set_input(dialog_->input_huge,
2736 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2737 fl_set_input(dialog_->input_huger,
2738 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2743 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2748 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2750 return dialog_.get();
2754 void FormPreferences::SpellOptions::apply()
2757 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2758 choice = trim(choice);
2760 lyxrc.isp_command = choice;
2763 // If spell checker == "none", all other input set to off.
2764 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2765 lyxrc.isp_use_alt_lang = false;
2766 lyxrc.isp_alt_lang.erase();
2768 lyxrc.isp_use_esc_chars = false;
2769 lyxrc.isp_esc_chars.erase();
2771 lyxrc.isp_use_pers_dict = false;
2772 lyxrc.isp_pers_dict.erase();
2774 lyxrc.isp_accept_compound = false;
2775 lyxrc.isp_use_input_encoding = false;
2778 int button = fl_get_button(dialog_->check_alt_lang);
2779 choice = fl_get_input(dialog_->input_alt_lang);
2780 if (button && choice.empty()) button = 0;
2781 if (!button) choice.erase();
2783 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2784 lyxrc.isp_alt_lang = choice;
2786 button = fl_get_button(dialog_->check_escape_chars);
2787 choice = fl_get_input(dialog_->input_escape_chars);
2788 if (button && choice.empty()) button = 0;
2789 if (!button) choice.erase();
2791 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2792 lyxrc.isp_esc_chars = choice;
2794 button = fl_get_button(dialog_->check_personal_dict);
2795 choice = fl_get_input(dialog_->input_personal_dict);
2796 if (button && choice.empty()) button = 0;
2797 if (!button) choice.erase();
2799 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2800 lyxrc.isp_pers_dict = choice;
2802 button = fl_get_button(dialog_->check_compound_words);
2803 lyxrc.isp_accept_compound = static_cast<bool>(button);
2805 button = fl_get_button(dialog_->check_input_enc);
2806 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2817 void FormPreferences::SpellOptions::build()
2819 dialog_.reset(build_preferences_spelloptions(&parent_));
2821 fl_addto_choice(dialog_->choice_spell_command,
2822 _(" ispell | aspell "));
2823 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2824 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2825 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2827 // set up the feedback mechanism
2828 setPrehandler(dialog_->choice_spell_command);
2829 setPrehandler(dialog_->check_alt_lang);
2830 setPrehandler(dialog_->input_alt_lang);
2831 setPrehandler(dialog_->check_escape_chars);
2832 setPrehandler(dialog_->input_escape_chars);
2833 setPrehandler(dialog_->check_personal_dict);
2834 setPrehandler(dialog_->input_personal_dict);
2835 setPrehandler(dialog_->button_personal_dict);
2836 setPrehandler(dialog_->check_compound_words);
2837 setPrehandler(dialog_->check_input_enc);
2842 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2844 if (ob == dialog_->choice_spell_command)
2845 return lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2846 if (ob == dialog_->check_alt_lang)
2847 return lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2848 if (ob == dialog_->input_alt_lang)
2849 return lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2850 if (ob == dialog_->check_escape_chars)
2851 return lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2852 if (ob == dialog_->input_escape_chars)
2853 return lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2854 if (ob == dialog_->check_personal_dict)
2855 return lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2856 if (ob == dialog_->input_personal_dict)
2857 return lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2858 if (ob == dialog_->check_compound_words)
2859 return lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2860 if (ob == dialog_->check_input_enc)
2861 return lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2866 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2868 // !ob if function is called from updateSpellOptions() to de/activate
2870 // otherwise the function is called by an xforms CB via input().
2873 // If spell checker == "none", disable all input.
2874 if (!ob || ob == dialog_->choice_spell_command) {
2875 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2876 fl_deactivate_object(dialog_->check_alt_lang);
2877 fl_deactivate_object(dialog_->input_alt_lang);
2878 fl_deactivate_object(dialog_->check_escape_chars);
2879 fl_deactivate_object(dialog_->input_escape_chars);
2880 fl_deactivate_object(dialog_->check_personal_dict);
2881 fl_deactivate_object(dialog_->input_personal_dict);
2882 fl_deactivate_object(dialog_->check_compound_words);
2883 fl_deactivate_object(dialog_->check_input_enc);
2886 fl_activate_object(dialog_->check_alt_lang);
2887 fl_activate_object(dialog_->check_escape_chars);
2888 fl_activate_object(dialog_->check_personal_dict);
2889 fl_activate_object(dialog_->check_compound_words);
2890 fl_activate_object(dialog_->check_input_enc);
2895 if (!ob || ob == dialog_->check_alt_lang) {
2896 bool const enable = fl_get_button(dialog_->check_alt_lang);
2897 setEnabled(dialog_->input_alt_lang, enable);
2900 if (!ob || ob == dialog_->check_escape_chars) {
2901 bool const enable = fl_get_button(dialog_->check_escape_chars);
2902 setEnabled(dialog_->input_escape_chars, enable);
2905 if (!ob || ob == dialog_->check_personal_dict) {
2906 bool const enable = fl_get_button(dialog_->check_personal_dict);
2907 setEnabled(dialog_->input_personal_dict, enable);
2910 if (ob == dialog_->button_personal_dict) {
2911 parent_.browse(dialog_->input_personal_dict,
2912 _("Personal dictionary"), "*.ispell");
2915 return true; // All input is valid!
2919 void FormPreferences::SpellOptions::update()
2923 if (lyxrc.isp_command == "none")
2925 else if (lyxrc.isp_command == "ispell")
2927 else if (lyxrc.isp_command == "aspell")
2930 if (lyxrc.isp_command == "ispell")
2932 else if (lyxrc.isp_command == "aspell")
2935 fl_set_choice(dialog_->choice_spell_command, choice);
2938 if (lyxrc.isp_use_alt_lang)
2939 str = lyxrc.isp_alt_lang;
2941 fl_set_button(dialog_->check_alt_lang,
2942 lyxrc.isp_use_alt_lang);
2943 fl_set_input(dialog_->input_alt_lang, str.c_str());
2946 if (lyxrc.isp_use_esc_chars)
2947 str = lyxrc.isp_esc_chars;
2949 fl_set_button(dialog_->check_escape_chars,
2950 lyxrc.isp_use_esc_chars);
2951 fl_set_input(dialog_->input_escape_chars, str.c_str());
2954 if (lyxrc.isp_use_pers_dict)
2955 str = lyxrc.isp_pers_dict;
2957 fl_set_button(dialog_->check_personal_dict,
2958 lyxrc.isp_use_pers_dict);
2959 fl_set_input(dialog_->input_personal_dict, str.c_str());
2961 fl_set_button(dialog_->check_compound_words,
2962 lyxrc.isp_accept_compound);
2963 fl_set_button(dialog_->check_input_enc,
2964 lyxrc.isp_use_input_encoding);
2966 // Activate/Deactivate the input fields dependent on the state of the
2972 void FormPreferences::browse(FL_OBJECT * inpt,
2973 string const & title,
2974 string const & pattern,
2975 pair<string,string> const & dir1,
2976 pair<string,string> const & dir2)
2978 // Get the filename from the dialog
2979 string const filename = fl_get_input(inpt);
2981 // Show the file browser dialog
2982 string const new_filename =
2983 browseFile(lv_, filename, title, pattern, dir1, dir2);
2985 // Save the filename to the dialog
2986 if (new_filename != filename && !new_filename.empty()) {
2987 fl_set_input(inpt, new_filename.c_str());