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 "form_preferences.h"
17 #include "ButtonController.tmpl"
21 #include "converter.h"
33 #include "input_validators.h"
34 #include "xforms_helpers.h"
35 #include "helper_funcs.h"
37 #include "support/lyxfunctional.h"
38 #include "support/lyxmanip.h"
39 #include "support/filetools.h"
40 #include "support/LAssert.h"
42 #include "graphics/GraphicsCache.h"
59 extern string system_lyxdir;
60 extern string user_lyxdir;
61 extern Languages languages;
65 // These should probably go inside the class definition...
66 Formats local_formats;
67 Converters local_converters;
72 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
73 : FormBaseBI(lv, d, _("Preferences"), false),
74 colors_(*this), converters_(*this), inputs_misc_(*this),
75 formats_(*this), interface_(*this), language_(*this),
76 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
77 printer_(*this), screen_fonts_(*this), spelloptions_(*this)
79 // let the dialog be shown
80 // This is a permanent connection so we won't bother
81 // storing a copy because we won't be disconnecting.
82 d->showPreferences.connect(slot(this, &FormPreferences::show));
83 d->showSpellcheckerPreferences.connect(slot(this, &FormPreferences::showSpellPref));
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 if (dialog_.get()) return dialog_->form;
126 void FormPreferences::showSpellPref()
129 fl_set_folder(dialog_->tabfolder_prefs, lang_opts_tab_->form);
130 fl_set_folder(lang_opts_tab_->tabfolder_inner, spelloptions_.dialog()->form);
134 void FormPreferences::ok()
136 FormBaseDeprecated::ok();
138 if (colors_.modifiedXformsPrefs) {
139 string const filename =
140 AddName(user_lyxdir, "preferences.xform");
141 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
144 lv_->getLyXFunc()->dispatch(LFUN_SAVEPREFERENCES);
148 void FormPreferences::hide()
150 // We need to hide the active tabfolder otherwise we get a
151 // BadDrawable error from X window and LyX crashes without saving.
152 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
154 && inner_form->visible) {
155 fl_hide_form(inner_form);
157 FormBaseDeprecated::hide();
161 void FormPreferences::build()
163 dialog_.reset(build_preferences());
165 // Manage the restore, save, apply and cancel/close buttons
166 bc().setOK(dialog_->button_ok);
167 bc().setApply(dialog_->button_apply);
168 bc().setCancel(dialog_->button_close);
169 bc().setRestore(dialog_->button_restore);
171 // Allow the base class to control messages
172 setMessageWidget(dialog_->text_warning);
174 // build the tab folders
175 converters_tab_.reset(build_inner_tab());
176 look_n_feel_tab_.reset(build_inner_tab());
177 inputs_tab_.reset(build_inner_tab());
178 outputs_tab_.reset(build_inner_tab());
179 lang_opts_tab_.reset(build_inner_tab());
181 // build actual tabfolder contents
182 // these will become nested tabfolders
186 inputs_misc_.build();
190 outputs_misc_.build();
193 screen_fonts_.build();
194 spelloptions_.build();
196 // Now add them to the tabfolder
197 fl_addto_tabfolder(dialog_->tabfolder_prefs,
199 look_n_feel_tab_->form);
200 fl_addto_tabfolder(dialog_->tabfolder_prefs,
202 lang_opts_tab_->form);
203 fl_addto_tabfolder(dialog_->tabfolder_prefs,
205 converters_tab_->form);
206 fl_addto_tabfolder(dialog_->tabfolder_prefs,
209 fl_addto_tabfolder(dialog_->tabfolder_prefs,
213 // now build the nested tabfolders
214 // Starting with look and feel
215 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
217 screen_fonts_.dialog()->form);
218 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
220 interface_.dialog()->form);
221 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
223 colors_.dialog()->form);
224 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
226 lnf_misc_.dialog()->form);
228 // then build converters
229 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
231 formats_.dialog()->form);
232 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
234 converters_.dialog()->form);
237 // Paths should probably go in a few inner_tab called Files
238 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
240 paths_.dialog()->form);
241 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
243 inputs_misc_.dialog()->form);
245 // then building outputs
246 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
248 printer_.dialog()->form);
249 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
251 outputs_misc_.dialog()->form);
253 // then building usage
254 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
256 spelloptions_.dialog()->form);
257 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
259 language_.dialog()->form);
263 void FormPreferences::apply()
265 // set the new lyxrc entries
266 // many of these need to trigger other functions when the assignment
267 // is made. For example, screen zoom and font types. These could be
268 // handled either by signals/slots in lyxrc or just directly call the
269 // associated functions here.
270 // There are other problems with this scheme. We really should check
271 // what we copy to make sure that it really is necessary to do things
272 // like update the screen fonts because that flushes the textcache
273 // and other stuff which may cost us a lot on slower/high-load
277 formats_.apply(); // Must be before converters_.apply()
279 inputs_misc_.apply();
283 outputs_misc_.apply();
286 screen_fonts_.apply();
287 spelloptions_.apply();
291 string const FormPreferences::getFeedback(FL_OBJECT * ob)
297 if (ob->form->fdui == colors_.dialog()) {
298 str = colors_.feedback(ob);
299 } else if (ob->form->fdui == converters_.dialog()) {
300 str = converters_.feedback(ob);
301 } else if (ob->form->fdui == formats_.dialog()) {
302 str = formats_.feedback(ob);
303 } else if (ob->form->fdui == inputs_misc_.dialog()) {
304 str = inputs_misc_.feedback(ob);
305 } else if (ob->form->fdui == interface_.dialog()) {
306 str = interface_.feedback(ob);
307 } else if (ob->form->fdui == language_.dialog()) {
308 str = language_.feedback(ob);
309 } else if (ob->form->fdui == lnf_misc_.dialog()) {
310 str = lnf_misc_.feedback(ob);
311 } else if (ob->form->fdui == outputs_misc_.dialog()) {
312 str = outputs_misc_.feedback(ob);
313 } else if (ob->form->fdui == paths_.dialog()) {
314 str = paths_.feedback(ob);
315 } else if (ob->form->fdui == printer_.dialog()) {
316 str = printer_.feedback(ob);
317 } else if (ob->form->fdui == screen_fonts_.dialog()) {
318 str = screen_fonts_.feedback(ob);
319 } else if (ob->form->fdui == spelloptions_.dialog()) {
320 str = spelloptions_.feedback(ob);
327 bool FormPreferences::input(FL_OBJECT * ob, long)
331 // whatever checks you need to ensure the user hasn't entered
332 // some totally ridiculous value somewhere. Change activate to suit.
333 // comments before each test describe what is _valid_
335 if (ob->form->fdui == colors_.dialog()) {
338 } else if (ob->form->fdui == converters_.dialog())
339 return converters_.input(ob);
340 else if (ob->form->fdui == formats_.dialog())
341 return formats_.input(ob);
342 else if (ob->form->fdui == interface_.dialog())
343 return interface_.input(ob);
344 else if (ob->form->fdui == language_.dialog())
345 return language_.input(ob);
346 else if (ob->form->fdui == paths_.dialog())
347 return paths_.input(ob);
348 else if (ob->form->fdui == screen_fonts_.dialog())
349 return screen_fonts_.input();
350 else if (ob->form->fdui == spelloptions_.dialog())
351 return spelloptions_.input(ob);
357 void FormPreferences::update()
359 if (!dialog_.get()) return;
361 // read lyxrc entries
363 formats_.update(); // Must be before converters_.update()
364 converters_.update();
365 inputs_misc_.update();
369 outputs_misc_.update();
372 screen_fonts_.update();
373 spelloptions_.update();
377 FormPreferences::Colors::Colors(FormPreferences & p)
378 : modifiedXformsPrefs(false), parent_(p)
382 FD_form_colors const * FormPreferences::Colors::dialog()
384 return dialog_.get();
388 void FormPreferences::Colors::apply()
390 bool modifiedText = false;
391 bool modifiedBackground = false;
393 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
394 cit != xformsColorDB.end(); ++cit) {
396 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
397 if (col != cit->color()) {
398 modifiedXformsPrefs = true;
399 if (cit->colorID == FL_BLACK)
401 if (cit->colorID == FL_COL1)
402 modifiedBackground = true;
406 if (modifiedXformsPrefs) {
407 for (vector<XformsColor>::const_iterator cit =
408 xformsColorDB.begin();
409 cit != xformsColorDB.end(); ++cit) {
410 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
412 if (modifiedText && cit->colorID == FL_BLACK) {
413 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
416 if (modifiedBackground && cit->colorID == FL_COL1) {
417 AdjustVal(FL_MCOL, FL_COL1, 0.1);
418 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
419 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
421 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
422 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
425 if (cit->colorID == GUI_COLOR_CURSOR) {
426 fl_mapcolor(GUI_COLOR_CURSOR,
427 cit->r, cit->g, cit->b);
428 setCursorColor(GUI_COLOR_CURSOR);
431 Dialogs::redrawGUI();
434 // Now do the same for the LyX LColors...
435 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
436 cit != lyxColorDB.end(); ++cit) {
437 LColor::color lc = lcolor.getFromGUIName(cit->getname());
438 if (lc == LColor::inherit) continue;
440 // Create a valid X11 name of the form "#rrggbb"
441 string const hexname = X11hexname(cit->color());
443 if (lcolor.getX11Name(lc) != hexname) {
445 << "FormPreferences::Colors::apply: "
446 << "resetting LColor " << lcolor.getGUIName(lc)
447 << " from \"" << lcolor.getX11Name(lc)
448 << "\" to \"" << hexname << "\"."
451 string const s = lcolor.getLyXName(lc) + string(" ") +
453 parent_.lv_->getLyXFunc()->dispatch(LFUN_SET_COLOR, s);
459 void FormPreferences::Colors::build()
461 dialog_.reset(parent_.build_colors());
463 fl_set_object_color(dialog_->button_color,
464 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
466 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
467 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
468 fl_set_dial_step(dialog_->dial_hue, 1.0);
469 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
471 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
472 fl_set_slider_step(dialog_->slider_saturation, 0.01);
473 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
475 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
476 fl_set_slider_step(dialog_->slider_value, 0.01);
477 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
479 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
480 fl_set_slider_step(dialog_->slider_red, 1.0);
481 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
483 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
484 fl_set_slider_step(dialog_->slider_green, 1.0);
485 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
487 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
488 fl_set_slider_step(dialog_->slider_blue, 1.0);
489 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
491 // set up the feedback mechanism
492 setPrehandler(dialog_->browser_lyx_objs);
493 setPrehandler(dialog_->button_color);
494 setPrehandler(dialog_->button_modify);
495 setPrehandler(dialog_->dial_hue);
496 setPrehandler(dialog_->slider_saturation);
497 setPrehandler(dialog_->slider_value);
498 setPrehandler(dialog_->slider_red);
499 setPrehandler(dialog_->slider_green);
500 setPrehandler(dialog_->slider_blue);
501 setPrehandler(dialog_->radio_rgb);
502 setPrehandler(dialog_->radio_hsv);
506 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
510 if (ob == dialog_->browser_lyx_objs) {
511 str = N_("LyX objects that can be assigned a color.");
513 } else if (ob == dialog_->button_modify) {
514 str = N_("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
516 } else if (ob == dialog_->dial_hue ||
517 ob == dialog_->slider_saturation ||
518 ob == dialog_->slider_value ||
519 ob == dialog_->slider_red ||
520 ob == dialog_->slider_green ||
521 ob == dialog_->slider_blue) {
522 str = N_("Find a new color.");
524 } else if (ob == dialog_->radio_rgb ||
525 ob == dialog_->radio_hsv) {
526 str = N_("Toggle between RGB and HSV color spaces.");
533 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
535 if (ob == dialog_->browser_lyx_objs) {
538 } else if (ob == dialog_->dial_hue ||
539 ob == dialog_->slider_saturation ||
540 ob == dialog_->slider_value) {
543 } else if (ob == dialog_->slider_red ||
544 ob == dialog_->slider_green ||
545 ob == dialog_->slider_blue) {
548 } else if (ob == dialog_->radio_rgb ||
549 ob == dialog_->radio_hsv) {
552 } else if (ob == dialog_->button_modify) {
558 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
562 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
566 hsv.v = min(1.0, max(0.0, hsv.v));
569 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
573 void FormPreferences::Colors::InputBrowserLyX() const
575 vector<NamedColor>::size_type const selLyX =
576 fl_get_browser(dialog_->browser_lyx_objs);
577 if (selLyX < 1) return;
579 // Is the choice an Xforms color...
582 if (selLyX - 1 < xformsColorDB.size()) {
583 vector<XformsColor>::size_type const i = selLyX - 1;
584 col = xformsColorDB[i].color();
586 // or a LyX Logical color?
588 vector<NamedColor>::size_type const i = selLyX - 1 -
589 xformsColorDB.size();
590 col = lyxColorDB[i].color();
593 fl_freeze_form(dialog_->form);
595 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
596 fl_redraw_object(dialog_->button_color);
598 // Display either RGB or HSV but not both!
601 // Deactivate the modify button to begin with...
602 setEnabled(dialog_->button_modify, false);
604 fl_unfreeze_form(dialog_->form);
608 void FormPreferences::Colors::InputHSV()
610 double const hue = fl_get_dial_value(dialog_->dial_hue);
611 double const sat = fl_get_slider_value(dialog_->slider_saturation);
612 double const val = fl_get_slider_value(dialog_->slider_value);
614 int const h = int(hue);
615 int const s = int(100.0 * sat);
616 int const v = int(100.0 * val);
618 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
620 fl_set_object_label(dialog_->text_color_values, label.c_str());
622 RGBColor col = HSVColor(hue, sat, val);
624 fl_freeze_form(dialog_->form);
626 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
627 fl_redraw_object(dialog_->button_color);
629 col = HSVColor(hue, 1.0, 1.0);
630 col.r = max(col.r, 0);
631 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
632 fl_redraw_object(dialog_->dial_hue);
634 // Ascertain whether to activate the Modify button.
635 vector<NamedColor>::size_type const selLyX =
636 fl_get_browser(dialog_->browser_lyx_objs);
638 fl_unfreeze_form(dialog_->form);
639 if (selLyX < 1) return;
641 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
644 // Is the choice an Xforms color...
645 if (selLyX - 1 < xformsColorDB.size()) {
646 vector<XformsColor>::size_type const i = selLyX - 1;
647 modify = (xformsColorDB[i].color() != col);
649 // or a LyX Logical color?
651 vector<NamedColor>::size_type const i = selLyX - 1 -
652 xformsColorDB.size();
653 modify = (lyxColorDB[i].color() != col);
656 setEnabled(dialog_->button_modify, modify);
660 void FormPreferences::Colors::InputRGB()
662 int const red = int(fl_get_slider_value(dialog_->slider_red));
663 int const green = int(fl_get_slider_value(dialog_->slider_green));
664 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
666 string const label = tostr(red) + string(", ") + tostr(green) +
667 string(", ") + tostr(blue);
668 fl_set_object_label(dialog_->text_color_values, label.c_str());
670 fl_freeze_form(dialog_->form);
672 RGBColor col = RGBColor(red, green, blue);
673 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
674 fl_redraw_object(dialog_->button_color);
676 // Ascertain whether to activate the Modify button.
677 vector<NamedColor>::size_type const selLyX =
678 fl_get_browser(dialog_->browser_lyx_objs);
680 fl_unfreeze_form(dialog_->form);
681 if (selLyX < 1) return;
685 // Is the choice an Xforms color...
686 if (selLyX - 1 < xformsColorDB.size()) {
687 vector<XformsColor>::size_type const i = selLyX - 1;
688 modify = (xformsColorDB[i].color() != col);
690 // or a LyX Logical color?
692 vector<NamedColor>::size_type const i = selLyX - 1 -
693 xformsColorDB.size();
694 modify = (lyxColorDB[i].color() != col);
697 setEnabled(dialog_->button_modify, modify);
701 void FormPreferences::Colors::LoadBrowserLyX()
703 if (!dialog_->browser_lyx_objs->visible) return;
705 // First, define the modifiable xforms colors
706 xformsColorDB.clear();
709 xcol.name = _("GUI background");
710 xcol.colorID = FL_COL1;
711 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
713 xformsColorDB.push_back(xcol);
715 xcol.name = _("GUI text");
716 xcol.colorID = FL_BLACK;
717 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
719 xformsColorDB.push_back(xcol);
721 xcol.name = _("GUI selection");
722 xcol.colorID = FL_YELLOW;
723 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
725 xformsColorDB.push_back(xcol);
727 xcol.name = _("GUI pointer");
728 xcol.colorID = GUI_COLOR_CURSOR;
729 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
731 xformsColorDB.push_back(xcol);
733 // Now create the the LyX LColors database
735 for (int i=0; i<LColor::ignore; ++i) {
736 LColor::color lc = static_cast<LColor::color>(i);
737 if (lc == LColor::none
738 || lc == LColor::black
739 || lc == LColor::white
741 || lc == LColor::green
742 || lc == LColor::blue
743 || lc == LColor::cyan
744 || lc == LColor::magenta
745 || lc == LColor::yellow
746 || lc == LColor::inherit
747 || lc == LColor::ignore) continue;
749 string const name = lcolor.getX11Name(lc);
750 Display * display = fl_get_display();;
751 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
754 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
756 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
757 << "LColor " << lcolor.getLyXName(lc)
758 << ": X can't find color \"" << name
759 << "\". Set to \"black\"!" << endl;
761 string const arg = lcolor.getLyXName(lc) + " black";
762 parent_.lv_->getLyXFunc()->
763 dispatch(LFUN_SET_COLOR, arg);
767 // X has found the color. Now find the "appropriate" X11 name
770 // Note that X stores the RGB values in the range 0 - 65535
771 // whilst we require them in the range 0 - 255.
773 col.r = xcol.red / 256;
774 col.g = xcol.green / 256;
775 col.b = xcol.blue / 256;
777 // Create a valid X11 name of the form "#rrggbb" and change the
778 // LColor X11name to this. Don't want to trigger a redraw,
779 // as we're just changing the name not the RGB values.
780 // Also reset the system_lcolor names, so that we don't output
781 // unnecessary changes.
782 string const hexname = X11hexname(col);
784 if (lcolor.getX11Name(lc) != hexname) {
785 lcolor.setColor(lc, hexname);
786 system_lcolor.setColor(lc, hexname);
789 // Finally, push the color onto the database
790 NamedColor ncol(lcolor.getGUIName(lc), col);
791 lyxColorDB.push_back(ncol);
794 // Now construct the browser
795 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
796 fl_freeze_form(dialog_->form);
797 fl_clear_browser(colbr);
798 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
799 cit != xformsColorDB.end(); ++cit) {
800 fl_addto_browser(colbr, cit->getname().c_str());
802 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
803 cit != lyxColorDB.end(); ++cit) {
804 fl_addto_browser(colbr, cit->getname().c_str());
807 // just to be safe...
808 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
809 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
810 fl_unfreeze_form(dialog_->form);
816 void FormPreferences::Colors::Modify()
818 vector<NamedColor>::size_type const selLyX =
819 fl_get_browser(dialog_->browser_lyx_objs);
820 if (selLyX < 1) return;
823 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
825 // Is the choice an Xforms color...
826 if (selLyX - 1 < xformsColorDB.size()) {
827 vector<XformsColor>::size_type const i = selLyX - 1;
828 xformsColorDB[i].r = col.r;
829 xformsColorDB[i].g = col.g;
830 xformsColorDB[i].b = col.b;
832 // or a LyX Logical color?
834 vector<NamedColor>::size_type const i = selLyX - 1 -
835 xformsColorDB.size();
836 lyxColorDB[i].r = col.r;
837 lyxColorDB[i].g = col.g;
838 lyxColorDB[i].b = col.b;
841 fl_freeze_form(dialog_->form);
842 setEnabled(dialog_->button_modify, false);
843 fl_unfreeze_form(dialog_->form);
847 void FormPreferences::Colors::SwitchColorSpace() const
849 bool const hsv = fl_get_button(dialog_->radio_hsv);
852 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
854 fl_freeze_form(dialog_->form);
857 fl_hide_object(dialog_->slider_red);
858 fl_hide_object(dialog_->slider_blue);
859 fl_hide_object(dialog_->slider_green);
860 fl_show_object(dialog_->dial_hue);
861 fl_show_object(dialog_->slider_saturation);
862 fl_show_object(dialog_->slider_value);
864 HSVColor hsv = HSVColor(col);
865 hsv.h = max(hsv.h, 0.0);
867 fl_set_dial_value(dialog_->dial_hue, hsv.h);
868 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
869 fl_set_slider_value(dialog_->slider_value, hsv.v);
871 col = HSVColor(hsv.h, 1.0, 1.0);
872 col.r = max(col.r,0);
873 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
874 fl_redraw_object(dialog_->dial_hue);
876 // Adjust the label a bit, but not the actual values.
877 // Means that toggling from one space to the other has no
878 // effect on the final color.
879 int const h = int(hsv.h);
880 int const s = int(100*hsv.s);
881 int const v = int(100*hsv.v);
882 string const label = tostr(h) + string(", ") + tostr(s) +
883 string(", ") + tostr(v);
884 fl_set_object_label(dialog_->text_color_values, label.c_str());
887 fl_show_object(dialog_->slider_red);
888 fl_show_object(dialog_->slider_blue);
889 fl_show_object(dialog_->slider_green);
890 fl_hide_object(dialog_->dial_hue);
891 fl_hide_object(dialog_->slider_saturation);
892 fl_hide_object(dialog_->slider_value);
894 fl_set_slider_value(dialog_->slider_red, col.r);
895 fl_set_slider_value(dialog_->slider_green, col.g);
896 fl_set_slider_value(dialog_->slider_blue, col.b);
898 // Adjust the label a bit. Same reasoning as above.
899 int const r = int(col.r);
900 int const g = int(col.g);
901 int const b = int(col.b);
902 string const label = tostr(r) + string(", ") + tostr(g) +
903 string(", ") + tostr(b);
904 fl_set_object_label(dialog_->text_color_values, label.c_str());
907 fl_unfreeze_form(dialog_->form);
910 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
914 ostr << "#" << std::setbase(16) << setfill('0')
919 return ostr.str().c_str();
923 FormPreferences::Converters::Converters(FormPreferences & p)
928 FD_form_converters const * FormPreferences::Converters::dialog()
930 return dialog_.get();
934 void FormPreferences::Converters::apply() const
936 converters = local_converters;
937 converters.update(formats);
938 converters.buildGraph();
942 void FormPreferences::Converters::build()
944 dialog_.reset(parent_.build_converters());
946 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
947 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
949 // set up the feedback mechanism
950 setPrehandler(dialog_->browser_all);
951 setPrehandler(dialog_->button_delete);
952 setPrehandler(dialog_->button_add);
953 setPrehandler(dialog_->input_converter);
954 setPrehandler(dialog_->choice_from);
955 setPrehandler(dialog_->choice_to);
956 setPrehandler(dialog_->input_flags);
961 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
965 if (ob == dialog_->browser_all) {
966 str = N_("All the currently defined converters known to LyX.");
967 } else if (ob == dialog_->choice_from) {
968 str = N_("Convert \"from\" this format");
969 } else if (ob == dialog_->choice_to) {
970 str = N_("Convert \"to\" this format");
971 } else if (ob == dialog_->input_converter) {
972 str = N_("The conversion command. $$i is the input file name, $$b is the file name without its extension and $$o is the name of the output file.");
973 } else if (ob == dialog_->input_flags) {
974 str = N_("Flags that control the converter behavior");
975 } else if (ob == dialog_->button_delete) {
976 str = N_("Remove the current converter from the list of available converters. Note: you must then \"Apply\" the change.");
977 } else if (ob == dialog_->button_add) {
978 if (string(ob->label) == _("Add"))
979 str = N_("Add the current converter to the list of available converters. Note: you must then \"Apply\" the change.");
981 str = N_("Modify the contents of the current converter. Note: you must then \"Apply\" the change.");
988 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
990 if (ob == dialog_->browser_all) {
993 } else if (ob == dialog_->choice_from
994 || ob == dialog_->choice_to
995 || ob == dialog_->input_converter
996 || ob == dialog_->input_flags) {
999 } else if (ob == dialog_->button_add) {
1002 } else if (ob == dialog_->button_delete) {
1010 void FormPreferences::Converters::update()
1012 local_converters = converters;
1013 local_converters.update(local_formats);
1018 void FormPreferences::Converters::UpdateBrowser()
1020 local_converters.sort();
1022 fl_freeze_form(dialog_->form);
1023 fl_clear_browser(dialog_->browser_all);
1024 for (::Converters::const_iterator cit = local_converters.begin();
1025 cit != local_converters.end(); ++cit) {
1026 string const name = cit->From->prettyname() + " -> "
1027 + cit->To->prettyname();
1028 fl_addto_browser(dialog_->browser_all, name.c_str());
1031 fl_unfreeze_form(dialog_->form);
1035 bool FormPreferences::Converters::Add()
1037 string const from = GetFrom();
1038 string const to = GetTo();
1039 string const command = fl_get_input(dialog_->input_converter);
1040 string const flags = fl_get_input(dialog_->input_flags);
1042 Converter const * old = local_converters.getConverter(from, to);
1043 local_converters.add(from, to, command, flags);
1045 local_converters.updateLast(local_formats);
1048 setEnabled(dialog_->button_add, false);
1054 bool FormPreferences::Converters::Browser()
1056 int const i = fl_get_browser(dialog_->browser_all);
1057 if (i <= 0) return false;
1059 fl_freeze_form(dialog_->form);
1061 Converter const & c = local_converters.get(i - 1);
1062 int j = local_formats.getNumber(c.from);
1064 fl_set_choice(dialog_->choice_from, j + 1);
1066 j = local_formats.getNumber(c.to);
1068 fl_set_choice(dialog_->choice_to, j + 1);
1070 fl_set_input(dialog_->input_converter, c.command.c_str());
1071 fl_set_input(dialog_->input_flags, c.flags.c_str());
1073 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1074 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1076 setEnabled(dialog_->button_add, false);
1077 setEnabled(dialog_->button_delete, true);
1079 fl_unfreeze_form(dialog_->form);
1084 bool FormPreferences::Converters::erase()
1086 string const from = GetFrom();
1087 string const to = GetTo();
1089 local_converters.erase(from, to);
1095 bool FormPreferences::Converters::Input()
1097 string const from = GetFrom();
1098 string const to = GetTo();
1099 int const sel = local_converters.getNumber(from, to);
1101 fl_freeze_form(dialog_->form);
1104 fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
1105 fl_set_button_shortcut(dialog_->button_add,
1106 scex(_("Add|#A")), 1);
1108 fl_deselect_browser(dialog_->browser_all);
1109 setEnabled(dialog_->button_delete, false);
1112 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1113 fl_set_button_shortcut(dialog_->button_add,
1114 scex(_("Modify|#M")), 1);
1116 int top = max(sel-5, 0);
1117 fl_set_browser_topline(dialog_->browser_all, top);
1118 fl_select_browser_line(dialog_->browser_all, sel+1);
1119 setEnabled(dialog_->button_delete, true);
1122 string const command = strip(fl_get_input(dialog_->input_converter));
1123 bool const enable = !(command.empty() || from == to);
1124 setEnabled(dialog_->button_add, enable);
1126 fl_unfreeze_form(dialog_->form);
1131 string const FormPreferences::Converters::GetFrom() const
1133 ::Formats::FormatList::size_type const i =
1134 fl_get_choice(dialog_->choice_from);
1136 if (i > 0 && i <= local_formats.size())
1137 return local_formats.get(i - 1).name();
1139 lyxerr << "FormPreferences::Converters::GetFrom: No choice!"
1146 string const FormPreferences::Converters::GetTo() const
1148 ::Formats::FormatList::size_type const i =
1149 fl_get_choice(dialog_->choice_to);
1151 if (i > 0 && i <= local_formats.size())
1152 return local_formats.get(i - 1).name();
1154 lyxerr << "FormPreferences::Converters::GetTo: No choice!"
1161 void FormPreferences::Converters::UpdateChoices() const
1164 for (::Formats::const_iterator cit = local_formats.begin();
1165 cit != local_formats.end(); ++cit) {
1166 if (!choice.empty())
1170 choice += cit->prettyname();
1174 fl_clear_choice(dialog_->choice_from);
1175 fl_addto_choice(dialog_->choice_from, choice.c_str());
1177 fl_clear_choice(dialog_->choice_to);
1178 fl_addto_choice(dialog_->choice_to, choice.c_str());
1182 FormPreferences::Formats::Formats(FormPreferences & p)
1187 FD_form_formats const * FormPreferences::Formats::dialog()
1189 return dialog_.get();
1193 void FormPreferences::Formats::apply() const
1195 formats = local_formats;
1199 void FormPreferences::Formats::build()
1201 dialog_.reset(parent_.build_formats());
1203 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1204 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1205 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1206 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1207 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1209 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1211 // set up the feedback mechanism
1212 setPrehandler(dialog_->browser_all);
1213 setPrehandler(dialog_->input_format);
1214 setPrehandler(dialog_->input_gui_name);
1215 setPrehandler(dialog_->button_delete);
1216 setPrehandler(dialog_->button_add);
1217 setPrehandler(dialog_->input_extension);
1218 setPrehandler(dialog_->input_viewer);
1219 setPrehandler(dialog_->input_shrtcut);
1224 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1228 if (ob == dialog_->browser_all) {
1229 str = N_("All the currently defined formats known to LyX.");
1230 } else if (ob == dialog_->input_format) {
1231 str = N_("The format identifier.");
1232 } else if (ob == dialog_->input_gui_name) {
1233 str = N_("The format name as it will appear in the menus.");
1234 } else if (ob == dialog_->input_shrtcut) {
1235 str = N_("The keyboard accelerator. Use a letter in the GUI name. Case sensitive.");
1236 } else if (ob == dialog_->input_extension) {
1237 str = N_("Used to recognize the file. E.g., ps, pdf, tex.");
1238 } else if (ob == dialog_->input_viewer) {
1239 str = N_("The command used to launch the viewer application.");
1240 } else if (ob == dialog_->button_delete) {
1241 str = N_("Remove the current format from the list of available formats. Note: you must then \"Apply\" the change.");
1242 } else if (ob == dialog_->button_add) {
1243 if (string(ob->label) == _("Add"))
1244 str = N_("Add the current format to the list of available formats. Note: you must then \"Apply\" the change.");
1246 str = N_("Modify the contents of the current format. Note: you must then \"Apply\" the change.");
1253 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1255 if (ob == dialog_->browser_all) {
1258 } else if (ob == dialog_->input_format
1259 || ob == dialog_->input_gui_name
1260 || ob == dialog_->input_shrtcut
1261 || ob == dialog_->input_extension
1262 || ob == dialog_->input_viewer) {
1265 } else if (ob == dialog_->button_add) {
1268 } else 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);
1330 if (i <= 0) return false;
1332 fl_freeze_form(dialog_->form);
1334 Format const & f = local_formats.get(i - 1);
1336 fl_set_input(dialog_->input_format, f.name().c_str());
1337 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1338 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1339 fl_set_input(dialog_->input_extension, f.extension().c_str());
1340 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1342 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1343 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1345 setEnabled(dialog_->button_add, false);
1346 setEnabled(dialog_->button_delete, true);
1348 fl_unfreeze_form(dialog_->form);
1353 bool FormPreferences::Formats::erase()
1355 string const name = fl_get_input(dialog_->input_format);
1357 if (local_converters.formatIsUsed(name)) {
1358 parent_.postWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
1359 setEnabled(dialog_->button_delete, false);
1363 local_formats.erase(name);
1369 bool FormPreferences::Formats::Input()
1371 string const name = fl_get_input(dialog_->input_format);
1372 int const sel = local_formats.getNumber(name);
1373 fl_freeze_form(dialog_->form);
1376 fl_set_object_label(dialog_->button_add,
1378 fl_set_button_shortcut(dialog_->button_add,
1379 scex(_("Add|#A")), 1);
1381 fl_deselect_browser(dialog_->browser_all);
1382 setEnabled(dialog_->button_delete, false);
1385 fl_set_object_label(dialog_->button_add,
1386 idex(_("Modify|#M")));
1387 fl_set_button_shortcut(dialog_->button_add,
1388 scex(_("Modify|#M")), 1);
1390 int const top = max(sel-5, 0);
1391 fl_set_browser_topline(dialog_->browser_all, top);
1392 fl_select_browser_line(dialog_->browser_all, sel+1);
1394 setEnabled(dialog_->button_add, true);
1395 setEnabled(dialog_->button_delete, true);
1398 string const prettyname = fl_get_input(dialog_->input_gui_name);
1399 bool const enable = !(name.empty() || prettyname.empty());
1400 setEnabled(dialog_->button_add, enable);
1402 fl_unfreeze_form(dialog_->form);
1407 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1412 FD_form_inputs_misc const * FormPreferences::InputsMisc::dialog()
1414 return dialog_.get();
1418 void FormPreferences::InputsMisc::apply() const
1420 lyxrc.date_insert_format =
1421 fl_get_input(dialog_->input_date_format);
1425 void FormPreferences::InputsMisc::build()
1427 dialog_.reset(parent_.build_inputs_misc());
1429 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1431 // set up the feedback mechanism
1432 setPrehandler(dialog_->input_date_format);
1437 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1441 if (ob == dialog_->input_date_format)
1442 str = lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1448 void FormPreferences::InputsMisc::update()
1450 fl_set_input(dialog_->input_date_format,
1451 lyxrc.date_insert_format.c_str());
1455 FormPreferences::Interface::Interface(FormPreferences & p)
1460 FD_form_interface const * FormPreferences::Interface::dialog()
1462 return dialog_.get();
1466 void FormPreferences::Interface::apply() const
1468 lyxrc.popup_normal_font =
1469 fl_get_input(dialog_->input_popup_normal_font);
1470 lyxrc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1471 lyxrc.popup_font_encoding =
1472 fl_get_input(dialog_->input_popup_font_encoding);
1473 lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
1474 lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
1475 lyxrc.override_x_deadkeys =
1476 fl_get_button(dialog_->check_override_x_dead_keys);
1480 void FormPreferences::Interface::build()
1482 dialog_.reset(parent_.build_interface());
1484 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1485 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1486 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1487 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1488 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1490 // set up the feedback mechanism
1491 setPrehandler(dialog_->input_popup_normal_font);
1492 setPrehandler(dialog_->input_popup_bold_font);
1493 setPrehandler(dialog_->input_popup_font_encoding);
1494 setPrehandler(dialog_->input_bind_file);
1495 setPrehandler(dialog_->button_bind_file_browse);
1496 setPrehandler(dialog_->input_ui_file);
1497 setPrehandler(dialog_->button_ui_file_browse);
1498 setPrehandler(dialog_->check_override_x_dead_keys);
1503 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1507 if (ob == dialog_->input_popup_normal_font)
1508 str = lyxrc.getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1509 else if (ob == dialog_->input_popup_bold_font)
1510 str = lyxrc.getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1511 else if (ob == dialog_->input_popup_font_encoding)
1512 str = lyxrc.getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1513 else if (ob == dialog_->input_bind_file)
1514 str = lyxrc.getDescription(LyXRC::RC_BINDFILE);
1515 else if (ob == dialog_->input_ui_file)
1516 str = lyxrc.getDescription(LyXRC::RC_UIFILE);
1517 else if (ob == dialog_->check_override_x_dead_keys)
1518 str = lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1524 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1526 if (ob == dialog_->button_bind_file_browse) {
1527 string dir = AddName(system_lyxdir, "bind");
1528 string name = N_("Sys Bind|#S#s");
1529 pair<string,string> dir1(name, dir);
1531 dir = AddName(user_lyxdir, "bind");
1532 name = N_("User Bind|#U#u");
1533 pair<string,string> dir2(name, dir);
1535 parent_.browse(dialog_->input_bind_file,
1536 N_("Bind file"), "*.bind", dir1, dir2);
1538 } else if (ob == dialog_->button_ui_file_browse) {
1539 string dir = AddName(system_lyxdir, "ui");
1540 string name = N_("Sys UI|#S#s");
1541 pair<string,string> dir1(name, dir);
1543 dir = AddName(user_lyxdir, "ui");
1544 name = N_("User UI|#U#u");
1545 pair<string,string> dir2(name, dir);
1547 parent_.browse(dialog_->input_ui_file,
1548 N_("UI file"), "*.ui", dir1, dir2);
1555 void FormPreferences::Interface::update()
1557 fl_set_input(dialog_->input_popup_normal_font,
1558 lyxrc.popup_normal_font.c_str());
1559 fl_set_input(dialog_->input_popup_bold_font,
1560 lyxrc.popup_bold_font.c_str());
1561 fl_set_input(dialog_->input_popup_font_encoding,
1562 lyxrc.popup_font_encoding.c_str());
1563 fl_set_input(dialog_->input_bind_file,
1564 lyxrc.bind_file.c_str());
1565 fl_set_input(dialog_->input_ui_file,
1566 lyxrc.ui_file.c_str());
1567 fl_set_button(dialog_->check_override_x_dead_keys,
1568 lyxrc.override_x_deadkeys);
1572 FormPreferences::Language::Language(FormPreferences & p)
1577 FD_form_language const * FormPreferences::Language::dialog()
1579 return dialog_.get();
1583 void FormPreferences::Language::apply()
1585 lyxrc.default_language = combo_default_lang->getline();
1587 int button = fl_get_button(dialog_->check_use_kbmap);
1588 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1589 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1591 button = !(name_1.empty() && name_2.empty());
1592 lyxrc.use_kbmap = static_cast<bool>(button);
1594 if (lyxrc.use_kbmap) {
1595 lyxrc.primary_kbmap = name_1;
1596 lyxrc.secondary_kbmap = name_2;
1599 button = fl_get_button(dialog_->check_rtl_support);
1600 lyxrc.rtl_support = static_cast<bool>(button);
1602 button = fl_get_button(dialog_->check_mark_foreign);
1603 lyxrc.mark_foreign_language = static_cast<bool>(button);
1605 button = fl_get_button(dialog_->check_auto_begin);
1606 lyxrc.language_auto_begin = static_cast<bool>(button);
1608 button = fl_get_button(dialog_->check_auto_end);
1609 lyxrc.language_auto_end = static_cast<bool>(button);
1611 button = fl_get_button(dialog_->check_use_babel);
1612 lyxrc.language_use_babel = static_cast<bool>(button);
1614 button = fl_get_button(dialog_->check_global_options);
1615 lyxrc.language_global_options = static_cast<bool>(button);
1617 lyxrc.language_package = fl_get_input(dialog_->input_package);
1618 lyxrc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1619 lyxrc.language_command_end = fl_get_input(dialog_->input_command_end);
1621 // Ensure that all is self-consistent.
1626 void FormPreferences::Language::build()
1628 dialog_.reset(parent_.build_language());
1630 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1631 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1632 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1634 // The default_language is a combo-box and has to be inserted manually
1635 fl_freeze_form(dialog_->form);
1636 fl_addto_form(dialog_->form);
1638 FL_OBJECT * obj = dialog_->choice_default_lang;
1639 fl_deactivate_object(dialog_->choice_default_lang);
1640 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1641 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
1642 parent_.lang_opts_tab_->tabfolder_inner,
1643 parent_.dialog_->tabfolder_prefs);
1644 combo_default_lang->shortcut("#L",1);
1645 combo_default_lang->setcallback(ComboCB, &parent_);
1647 for (Languages::const_iterator cit = languages.begin();
1648 cit != languages.end(); ++cit) {
1649 combo_default_lang->addto(cit->second.lang());
1653 fl_unfreeze_form(dialog_->form);
1655 // set up the feedback mechanism
1656 setPrehandler(dialog_->input_package);
1657 setPrehandler(dialog_->check_use_kbmap);
1659 // This is safe, as nothing is done to the pointer, other than
1660 // to use its address in a block-if statement.
1661 // No it's not! Leads to crash.
1663 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1664 // C_FormPreferencesFeedbackCB);
1666 setPrehandler(dialog_->input_kbmap1);
1667 setPrehandler(dialog_->input_kbmap2);
1668 setPrehandler(dialog_->check_rtl_support);
1669 setPrehandler(dialog_->check_mark_foreign);
1670 setPrehandler(dialog_->check_auto_begin);
1671 setPrehandler(dialog_->check_auto_end);
1672 setPrehandler(dialog_->check_use_babel);
1673 setPrehandler(dialog_->check_global_options);
1674 setPrehandler(dialog_->input_command_begin);
1675 setPrehandler(dialog_->input_command_end);
1677 // Activate/Deactivate the input fields dependent on the state of the
1684 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1688 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1689 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1690 else if (ob == dialog_->check_use_kbmap)
1691 str = lyxrc.getDescription(LyXRC::RC_KBMAP);
1692 else if (ob == dialog_->input_kbmap1)
1693 str = lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1694 else if (ob == dialog_->input_kbmap2)
1695 str = lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1696 else if (ob == dialog_->check_rtl_support)
1697 str = lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1698 else if (ob == dialog_->check_mark_foreign)
1699 str = lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1700 else if (ob == dialog_->check_auto_begin)
1701 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1702 else if (ob == dialog_->check_auto_end)
1703 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1704 else if (ob == dialog_->check_use_babel)
1705 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1706 else if (ob == dialog_->check_global_options)
1707 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1708 else if (ob == dialog_->input_package)
1709 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1710 else if (ob == dialog_->input_command_begin)
1711 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1712 else if (ob == dialog_->input_command_end)
1713 str = 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 = N_("Key maps|#K#k");
1737 pair<string, string> dir1(name, dir);
1739 parent_.browse(dialog_->input_kbmap1,
1740 N_("Keyboard map"), "*.kmap", dir1);
1741 } else if (ob == dialog_->button_kbmap2_browse) {
1742 string const dir = AddName(system_lyxdir, "kbd");
1743 string const name = N_("Key maps|#K#k");
1744 pair<string, string> dir1(name, dir);
1746 parent_.browse(dialog_->input_kbmap2,
1747 N_("Keyboard map"), "*.kmap", dir1);
1754 void FormPreferences::Language::update()
1756 fl_set_button(dialog_->check_use_kbmap,
1759 combo_default_lang->select(lyxrc.default_language);
1761 if (lyxrc.use_kbmap) {
1762 fl_set_input(dialog_->input_kbmap1,
1763 lyxrc.primary_kbmap.c_str());
1764 fl_set_input(dialog_->input_kbmap2,
1765 lyxrc.secondary_kbmap.c_str());
1767 fl_set_input(dialog_->input_kbmap1, "");
1768 fl_set_input(dialog_->input_kbmap2, "");
1771 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1772 fl_set_button(dialog_->check_mark_foreign,
1773 lyxrc.mark_foreign_language);
1774 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1775 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1776 fl_set_button(dialog_->check_use_babel, lyxrc.language_use_babel);
1777 fl_set_button(dialog_->check_global_options,
1778 lyxrc.language_global_options);
1780 fl_set_input(dialog_->input_package,
1781 lyxrc.language_package.c_str());
1782 fl_set_input(dialog_->input_command_begin,
1783 lyxrc.language_command_begin.c_str());
1784 fl_set_input(dialog_->input_command_end,
1785 lyxrc.language_command_end.c_str());
1787 // Activate/Deactivate the input fields dependent on the state of the
1793 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1795 FormPreferences * pre = static_cast<FormPreferences*>(v);
1796 // This is safe, as nothing is done to the pointer, other than
1797 // to use its address in a block-if statement.
1798 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1802 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1807 FD_form_lnf_misc const * FormPreferences::LnFmisc::dialog()
1809 return dialog_.get();
1813 void FormPreferences::LnFmisc::apply() const
1815 lyxrc.show_banner = fl_get_button(dialog_->check_banner);
1816 lyxrc.auto_region_delete =
1817 fl_get_button(dialog_->check_auto_region_delete);
1818 lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm);
1819 lyxrc.display_shortcuts =
1820 fl_get_button(dialog_->check_display_shrtcuts);
1821 lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
1822 lyxrc.cursor_follows_scrollbar =
1823 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1824 lyxrc.dialogs_iconify_with_main =
1825 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1826 lyxrc.autosave = static_cast<unsigned int>
1827 (fl_get_counter_value(dialog_->counter_autosave));
1828 lyxrc.wheel_jump = static_cast<unsigned int>
1829 (fl_get_counter_value(dialog_->counter_wm_jump));
1831 string const old_value = lyxrc.display_graphics;
1832 if (fl_get_button(dialog_->radio_display_monochrome)) {
1833 lyxrc.display_graphics = "mono";
1834 } else if (fl_get_button(dialog_->radio_display_grayscale)) {
1835 lyxrc.display_graphics = "gray";
1836 } else if (fl_get_button(dialog_->radio_display_color)) {
1837 lyxrc.display_graphics = "color";
1839 lyxrc.display_graphics = "no";
1841 if (old_value != lyxrc.display_graphics) {
1842 grfx::GCache & gc = grfx::GCache::get();
1848 void FormPreferences::LnFmisc::build()
1850 dialog_.reset(parent_.build_lnf_misc());
1852 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1853 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1855 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1856 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1858 // set up the feedback mechanism
1859 setPrehandler(dialog_->check_banner);
1860 setPrehandler(dialog_->check_auto_region_delete);
1861 setPrehandler(dialog_->check_exit_confirm);
1862 setPrehandler(dialog_->check_display_shrtcuts);
1863 setPrehandler(dialog_->counter_autosave);
1864 setPrehandler(dialog_->check_ask_new_file);
1865 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1866 setPrehandler(dialog_->check_dialogs_iconify_with_main);
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
1880 if (ob == dialog_->check_banner)
1881 str = lyxrc.getDescription(LyXRC::RC_SHOW_BANNER);
1882 else if (ob == dialog_->check_auto_region_delete)
1883 str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1884 else if (ob == dialog_->check_exit_confirm)
1885 str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION);
1886 else if (ob == dialog_->check_display_shrtcuts)
1887 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_SHORTCUTS);
1888 else if (ob == dialog_->check_ask_new_file)
1889 str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
1890 else if (ob == dialog_->check_cursor_follows_scrollbar)
1891 str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1892 else if (ob == dialog_->check_dialogs_iconify_with_main)
1893 str = lyxrc.getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1894 else if (ob == dialog_->counter_autosave)
1895 str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1896 else if (ob == dialog_->counter_wm_jump)
1897 str = lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1898 else if (ob == dialog_->radio_display_monochrome ||
1899 ob == dialog_->radio_display_grayscale ||
1900 ob == dialog_->radio_display_color ||
1901 ob == dialog_->radio_no_display)
1902 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1908 void FormPreferences::LnFmisc::update()
1910 fl_set_button(dialog_->check_banner, lyxrc.show_banner);
1911 fl_set_button(dialog_->check_auto_region_delete,
1912 lyxrc.auto_region_delete);
1913 fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
1914 fl_set_button(dialog_->check_display_shrtcuts, lyxrc.display_shortcuts);
1915 fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
1916 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1917 lyxrc.cursor_follows_scrollbar);
1918 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1919 lyxrc.dialogs_iconify_with_main);
1920 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1921 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1923 if (lyxrc.display_graphics == "mono") {
1924 fl_set_button(dialog_->radio_display_monochrome, 1);
1925 } else if (lyxrc.display_graphics == "gray") {
1926 fl_set_button(dialog_->radio_display_grayscale, 1);
1927 } else if (lyxrc.display_graphics == "color") {
1928 fl_set_button(dialog_->radio_display_color, 1);
1930 fl_set_button(dialog_->radio_no_display, 1);
1935 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1940 FD_form_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1942 return dialog_.get();
1946 void FormPreferences::OutputsMisc::apply() const
1948 lyxrc.ascii_linelen = static_cast<unsigned int>
1949 (fl_get_counter_value(dialog_->counter_line_len));
1950 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1953 fl_get_choice(dialog_->choice_default_papersize) - 1;
1954 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1956 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1957 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1958 lyxrc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1959 lyxrc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1963 void FormPreferences::OutputsMisc::build()
1965 dialog_.reset(parent_.build_outputs_misc());
1967 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1969 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1970 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1971 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1972 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1973 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1975 fl_addto_choice(dialog_->choice_default_papersize,
1976 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
1978 // set up the feedback mechanism
1979 setPrehandler(dialog_->counter_line_len);
1980 setPrehandler(dialog_->input_tex_encoding);
1981 setPrehandler(dialog_->choice_default_papersize);
1982 setPrehandler(dialog_->input_ascii_roff);
1983 setPrehandler(dialog_->input_checktex);
1984 setPrehandler(dialog_->input_paperoption);
1985 setPrehandler(dialog_->check_autoreset_classopt);
1990 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1994 if (ob == dialog_->counter_line_len)
1995 str = lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
1996 else if (ob == dialog_->input_tex_encoding)
1997 str = lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
1998 else if (ob == dialog_->input_ascii_roff)
1999 str = lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
2000 else if (ob == dialog_->input_checktex)
2001 str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
2002 else if (ob == dialog_->choice_default_papersize)
2003 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2004 else if (ob == dialog_->input_paperoption)
2005 str = lyxrc.getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
2006 else if (ob == dialog_->check_autoreset_classopt)
2007 str = lyxrc.getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2013 void FormPreferences::OutputsMisc::update()
2015 fl_set_counter_value(dialog_->counter_line_len,
2016 lyxrc.ascii_linelen);
2017 fl_set_input(dialog_->input_tex_encoding,
2018 lyxrc.fontenc.c_str());
2019 fl_set_choice(dialog_->choice_default_papersize,
2020 lyxrc.default_papersize+1);
2021 fl_set_input(dialog_->input_ascii_roff,
2022 lyxrc.ascii_roff_command.c_str());
2023 fl_set_input(dialog_->input_checktex,
2024 lyxrc.chktex_command.c_str());
2025 fl_set_input(dialog_->input_paperoption,
2026 lyxrc.view_dvi_paper_option.c_str());
2027 fl_set_button(dialog_->check_autoreset_classopt,
2028 lyxrc.auto_reset_options);
2033 FormPreferences::Paths::Paths(FormPreferences & p)
2038 FD_form_paths const * FormPreferences::Paths::dialog()
2040 return dialog_.get();
2044 void FormPreferences::Paths::apply()
2046 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2047 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2049 int button = fl_get_button(dialog_->check_use_temp_dir);
2050 string str = fl_get_input(dialog_->input_temp_dir);
2051 if (!button) str.erase();
2053 lyxrc.use_tempdir = button;
2054 lyxrc.tempdir_path = str;
2056 button = fl_get_button(dialog_->check_last_files);
2057 str = fl_get_input(dialog_->input_lastfiles);
2058 if (!button) str.erase();
2060 lyxrc.check_lastfiles = button;
2061 lyxrc.lastfiles = str;
2062 lyxrc.num_lastfiles = static_cast<unsigned int>
2063 (fl_get_counter_value(dialog_->counter_lastfiles));
2065 button = fl_get_button(dialog_->check_make_backups);
2066 str = fl_get_input(dialog_->input_backup_path);
2067 if (!button) str.erase();
2069 lyxrc.make_backup = button;
2070 lyxrc.backupdir_path = str;
2072 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2079 void FormPreferences::Paths::build()
2081 dialog_.reset(parent_.build_paths());
2083 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2084 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2085 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2086 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2087 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2088 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2089 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2091 // set up the feedback mechanism
2092 setPrehandler(dialog_->input_default_path);
2093 setPrehandler(dialog_->counter_lastfiles);
2094 setPrehandler(dialog_->input_template_path);
2095 setPrehandler(dialog_->check_last_files);
2096 setPrehandler(dialog_->input_lastfiles);
2097 setPrehandler(dialog_->check_make_backups);
2098 setPrehandler(dialog_->input_backup_path);
2099 setPrehandler(dialog_->input_serverpipe);
2100 setPrehandler(dialog_->input_temp_dir);
2101 setPrehandler(dialog_->check_use_temp_dir);
2106 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2110 if (ob == dialog_->input_default_path)
2111 str = lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2112 else if (ob == dialog_->input_template_path)
2113 str = lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2114 else if (ob == dialog_->check_use_temp_dir)
2115 str = lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2116 else if (ob == dialog_->input_temp_dir)
2117 str = lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2118 else if (ob == dialog_->check_last_files)
2119 str = lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2120 else if (ob == dialog_->input_lastfiles)
2121 str = lyxrc.getDescription(LyXRC::RC_LASTFILES);
2122 else if (ob == dialog_->counter_lastfiles)
2123 str = lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2124 else if (ob == dialog_->check_make_backups)
2125 str = lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2126 else if (ob == dialog_->input_backup_path)
2127 str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2128 else if (ob == dialog_->input_serverpipe) {
2129 str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2136 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2138 bool activate = true;
2140 // !ob if function is called from Paths::update() to de/activate
2142 // otherwise the function is called by an xforms CB via input().
2143 if (!ob || ob == dialog_->check_use_temp_dir) {
2144 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2145 setEnabled(dialog_->input_temp_dir, enable);
2148 if (!ob || ob == dialog_->check_last_files) {
2149 bool const enable = fl_get_button(dialog_->check_last_files);
2150 setEnabled(dialog_->input_lastfiles, enable);
2153 if (!ob || ob == dialog_->check_make_backups) {
2154 bool const enable = fl_get_button(dialog_->check_make_backups);
2155 setEnabled(dialog_->input_backup_path, enable);
2158 if (!ob || ob == dialog_->input_default_path) {
2159 string const name = fl_get_input(dialog_->input_default_path);
2160 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2161 parent_.postWarning(RWInfo::ErrorMessage());
2166 if (!ob || ob == dialog_->input_template_path) {
2167 string const name = fl_get_input(dialog_->input_template_path);
2168 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2169 parent_.postWarning(RWInfo::ErrorMessage());
2174 if (!ob || ob == dialog_->input_temp_dir) {
2175 string const name = fl_get_input(dialog_->input_temp_dir);
2176 if (fl_get_button(dialog_->check_make_backups)
2178 && !RWInfo::WriteableDir(name)) {
2179 parent_.postWarning(RWInfo::ErrorMessage());
2184 if (!ob || ob == dialog_->input_backup_path) {
2185 string const name = fl_get_input(dialog_->input_backup_path);
2186 if (fl_get_button(dialog_->check_make_backups)
2188 && !RWInfo::WriteableDir(name)) {
2189 parent_.postWarning(RWInfo::ErrorMessage());
2194 if (!ob || ob == dialog_->input_lastfiles) {
2195 string const name = fl_get_input(dialog_->input_lastfiles);
2196 if (fl_get_button(dialog_->check_last_files)
2198 && !RWInfo::WriteableFile(name)) {
2199 parent_.postWarning(RWInfo::ErrorMessage());
2204 if (!ob || ob == dialog_->input_serverpipe) {
2205 string const name = fl_get_input(dialog_->input_serverpipe);
2206 if (!name.empty()) {
2207 // strip off the extension
2208 string const str = ChangeExtension(name, "");
2209 if (!RWInfo::WriteableFile(str + ".in")) {
2210 parent_.postWarning(RWInfo::ErrorMessage());
2213 if (!RWInfo::WriteableFile(str + ".out")) {
2214 parent_.postWarning(RWInfo::ErrorMessage());
2220 if (ob == dialog_->button_default_path_browse) {
2221 parent_.browse(dialog_->input_default_path,
2222 N_("Default path"), string());
2223 } else if (ob == dialog_->button_template_path_browse) {
2224 parent_.browse(dialog_->input_template_path,
2225 N_("Template path"), string());
2226 } else if (ob == dialog_->button_temp_dir_browse) {
2227 parent_.browse(dialog_->input_temp_dir,
2228 N_("Temp dir"), string());
2229 } else if (ob == dialog_->button_lastfiles_browse) {
2230 pair<string, string> dir(_("User|#U#u"), user_lyxdir);
2232 parent_.browse(dialog_->input_lastfiles,
2233 N_("Lastfiles"), string(), dir);
2234 } else if (ob == dialog_->button_backup_path_browse) {
2235 parent_.browse(dialog_->input_backup_path,
2236 N_("Backup path"), string());
2237 } else if (ob == dialog_->button_serverpipe_browse) {
2238 parent_.browse(dialog_->input_serverpipe,
2239 N_("LyX Server pipes"), string());
2246 void FormPreferences::Paths::update()
2248 fl_set_input(dialog_->input_default_path,
2249 lyxrc.document_path.c_str());
2250 fl_set_input(dialog_->input_template_path,
2251 lyxrc.template_path.c_str());
2254 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
2256 fl_set_button(dialog_->check_make_backups,
2258 fl_set_input(dialog_->input_backup_path, str.c_str());
2261 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
2263 fl_set_button(dialog_->check_use_temp_dir,
2265 fl_set_input(dialog_->input_temp_dir, str.c_str());
2268 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
2270 fl_set_button(dialog_->check_last_files,
2271 lyxrc.check_lastfiles);
2272 fl_set_input(dialog_->input_lastfiles, str.c_str());
2273 fl_set_counter_value(dialog_->counter_lastfiles,
2274 lyxrc.num_lastfiles);
2276 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2278 // Activate/Deactivate the input fields dependent on the state of the
2284 FormPreferences::Printer::Printer(FormPreferences & p)
2289 FD_form_printer const * FormPreferences::Printer::dialog()
2291 return dialog_.get();
2295 void FormPreferences::Printer::apply() const
2297 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2298 lyxrc.print_command = fl_get_input(dialog_->input_command);
2299 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2300 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2301 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2302 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2303 lyxrc.print_file_extension =
2304 fl_get_input(dialog_->input_file_extension);
2305 lyxrc.print_spool_command =
2306 fl_get_input(dialog_->input_spool_command);
2307 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2308 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2309 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2310 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2311 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2312 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2313 lyxrc.print_extra_options =
2314 fl_get_input(dialog_->input_extra_options);
2315 lyxrc.print_spool_printerprefix =
2316 fl_get_input(dialog_->input_spool_prefix);
2317 lyxrc.print_paper_dimension_flag =
2318 fl_get_input(dialog_->input_paper_size);
2319 lyxrc.printer = fl_get_input(dialog_->input_name);
2324 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2328 if (ob == dialog_->input_command)
2329 str = lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2330 else if (ob == dialog_->check_adapt_output)
2331 str = lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2332 else if (ob == dialog_->input_to_printer)
2333 str = lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2334 else if (ob == dialog_->input_to_file)
2335 str = lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2336 else if (ob == dialog_->input_file_extension)
2337 str = lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2338 else if (ob == dialog_->input_extra_options)
2339 str = lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2340 else if (ob == dialog_->input_spool_command)
2341 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2342 else if (ob == dialog_->input_spool_prefix)
2343 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2344 else if (ob == dialog_->input_name)
2345 str = lyxrc.getDescription(LyXRC::RC_PRINTER);
2346 else if (ob == dialog_->input_even_pages)
2347 str = lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2348 else if (ob == dialog_->input_odd_pages)
2349 str = lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2350 else if (ob == dialog_->input_page_range)
2351 str = lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2352 else if (ob == dialog_->input_reverse)
2353 str = lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2354 else if (ob == dialog_->input_landscape)
2355 str = lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2356 else if (ob == dialog_->input_copies)
2357 str = lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2358 else if (ob == dialog_->input_collated)
2359 str = lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2360 else if (ob == dialog_->input_paper_type)
2361 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2362 else if (ob == dialog_->input_paper_size)
2363 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2369 void FormPreferences::Printer::build()
2371 dialog_.reset(parent_.build_printer());
2373 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2374 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2375 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2376 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2377 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2378 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2379 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2380 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2381 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2382 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2383 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2384 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2385 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2386 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2387 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2388 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2389 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2391 // set up the feedback mechanism
2392 setPrehandler(dialog_->input_command);
2393 setPrehandler(dialog_->input_page_range);
2394 setPrehandler(dialog_->input_copies);
2395 setPrehandler(dialog_->input_reverse);
2396 setPrehandler(dialog_->input_to_printer);
2397 setPrehandler(dialog_->input_file_extension);
2398 setPrehandler(dialog_->input_spool_command);
2399 setPrehandler(dialog_->input_paper_type);
2400 setPrehandler(dialog_->input_even_pages);
2401 setPrehandler(dialog_->input_odd_pages);
2402 setPrehandler(dialog_->input_collated);
2403 setPrehandler(dialog_->input_landscape);
2404 setPrehandler(dialog_->input_to_file);
2405 setPrehandler(dialog_->input_extra_options);
2406 setPrehandler(dialog_->input_spool_prefix);
2407 setPrehandler(dialog_->input_paper_size);
2408 setPrehandler(dialog_->input_name);
2409 setPrehandler(dialog_->check_adapt_output);
2413 void FormPreferences::Printer::update()
2415 fl_set_button(dialog_->check_adapt_output,
2416 lyxrc.print_adapt_output);
2417 fl_set_input(dialog_->input_command,
2418 lyxrc.print_command.c_str());
2419 fl_set_input(dialog_->input_page_range,
2420 lyxrc.print_pagerange_flag.c_str());
2421 fl_set_input(dialog_->input_copies,
2422 lyxrc.print_copies_flag.c_str());
2423 fl_set_input(dialog_->input_reverse,
2424 lyxrc.print_reverse_flag.c_str());
2425 fl_set_input(dialog_->input_to_printer,
2426 lyxrc.print_to_printer.c_str());
2427 fl_set_input(dialog_->input_file_extension,
2428 lyxrc.print_file_extension.c_str());
2429 fl_set_input(dialog_->input_spool_command,
2430 lyxrc.print_spool_command.c_str());
2431 fl_set_input(dialog_->input_paper_type,
2432 lyxrc.print_paper_flag.c_str());
2433 fl_set_input(dialog_->input_even_pages,
2434 lyxrc.print_evenpage_flag.c_str());
2435 fl_set_input(dialog_->input_odd_pages,
2436 lyxrc.print_oddpage_flag.c_str());
2437 fl_set_input(dialog_->input_collated,
2438 lyxrc.print_collcopies_flag.c_str());
2439 fl_set_input(dialog_->input_landscape,
2440 lyxrc.print_landscape_flag.c_str());
2441 fl_set_input(dialog_->input_to_file,
2442 lyxrc.print_to_file.c_str());
2443 fl_set_input(dialog_->input_extra_options,
2444 lyxrc.print_extra_options.c_str());
2445 fl_set_input(dialog_->input_spool_prefix,
2446 lyxrc.print_spool_printerprefix.c_str());
2447 fl_set_input(dialog_->input_paper_size,
2448 lyxrc.print_paper_dimension_flag.c_str());
2449 fl_set_input(dialog_->input_name,
2450 lyxrc.printer.c_str());
2454 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2459 FD_form_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2461 return dialog_.get();
2465 void FormPreferences::ScreenFonts::apply() const
2467 bool changed = false;
2469 string str = fl_get_input(dialog_->input_roman);
2470 if (lyxrc.roman_font_name != str) {
2472 lyxrc.roman_font_name = str;
2475 str = fl_get_input(dialog_->input_sans);
2476 if (lyxrc.sans_font_name != str) {
2478 lyxrc.sans_font_name = str;
2481 str = fl_get_input(dialog_->input_typewriter);
2482 if (lyxrc.typewriter_font_name != str) {
2484 lyxrc.typewriter_font_name = str;
2487 str = fl_get_input(dialog_->input_screen_encoding);
2488 if (lyxrc.font_norm != str) {
2490 lyxrc.font_norm = str;
2493 bool button = fl_get_button(dialog_->check_scalable);
2494 if (lyxrc.use_scalable_fonts != button) {
2496 lyxrc.use_scalable_fonts = button;
2499 unsigned int ivalue = static_cast<unsigned int>
2500 (fl_get_counter_value(dialog_->counter_zoom));
2501 if (lyxrc.zoom != ivalue) {
2503 lyxrc.zoom = ivalue;
2506 ivalue = static_cast<unsigned int>
2507 (fl_get_counter_value(dialog_->counter_dpi));
2508 if (lyxrc.dpi != ivalue) {
2513 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2514 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2516 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2519 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2520 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2522 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2525 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2526 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2528 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2531 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2532 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2534 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2537 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2538 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2540 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2543 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2544 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2546 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2549 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2550 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2552 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2555 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2556 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2558 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2561 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2562 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2564 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2567 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2568 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2570 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2574 // Now update the buffers
2575 // Can anything below here affect the redraw process?
2576 parent_.lv_->getLyXFunc()->dispatch(LFUN_SCREEN_FONT_UPDATE);
2581 void FormPreferences::ScreenFonts::build()
2583 dialog_.reset(parent_.build_screen_fonts());
2585 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2586 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2588 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2589 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2590 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2591 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2592 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2593 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2594 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2595 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2596 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2597 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2598 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2599 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2600 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2601 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2602 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2603 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2605 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2606 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2607 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2608 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2609 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2610 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2611 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2612 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2613 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2614 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2616 // set up the feedback mechanism
2617 setPrehandler(dialog_->input_roman);
2618 setPrehandler(dialog_->input_sans);
2619 setPrehandler(dialog_->input_typewriter);
2620 setPrehandler(dialog_->counter_zoom);
2621 setPrehandler(dialog_->counter_dpi);
2622 setPrehandler(dialog_->check_scalable);
2623 setPrehandler(dialog_->input_screen_encoding);
2624 setPrehandler(dialog_->input_tiny);
2625 setPrehandler(dialog_->input_script);
2626 setPrehandler(dialog_->input_footnote);
2627 setPrehandler(dialog_->input_small);
2628 setPrehandler(dialog_->input_large);
2629 setPrehandler(dialog_->input_larger);
2630 setPrehandler(dialog_->input_largest);
2631 setPrehandler(dialog_->input_normal);
2632 setPrehandler(dialog_->input_huge);
2633 setPrehandler(dialog_->input_huger);
2638 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2642 if (ob == dialog_->input_roman)
2643 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2644 else if (ob == dialog_->input_sans)
2645 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2646 else if (ob == dialog_->input_typewriter)
2647 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2648 else if (ob == dialog_->check_scalable)
2649 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2650 else if (ob == dialog_->input_screen_encoding)
2651 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2652 else if (ob == dialog_->counter_zoom)
2653 str = lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2654 else if (ob == dialog_->counter_dpi)
2655 str = lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2656 else if (ob == dialog_->input_tiny
2657 || ob == dialog_->input_script
2658 || ob == dialog_->input_footnote
2659 || ob == dialog_->input_small
2660 || ob == dialog_->input_large
2661 || ob == dialog_->input_larger
2662 || ob == dialog_->input_larger
2663 || ob == dialog_->input_largest
2664 || ob == dialog_->input_normal
2665 || ob == dialog_->input_huge
2666 || ob == dialog_->input_huger)
2667 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2673 bool FormPreferences::ScreenFonts::input()
2675 bool activate = true;
2678 // Make sure that all fonts all have positive entries
2679 // Also note that an empty entry is returned as 0.0 by strToDbl
2680 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2681 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2682 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2683 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2684 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2685 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2686 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2687 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2688 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2689 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2691 str = N_("Fonts must be positive!");
2693 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2694 // Fontsizes -- tiny < script < footnote etc.
2695 strToDbl(fl_get_input(dialog_->input_script)) ||
2696 strToDbl(fl_get_input(dialog_->input_script)) >
2697 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2698 strToDbl(fl_get_input(dialog_->input_footnote)) >
2699 strToDbl(fl_get_input(dialog_->input_small)) ||
2700 strToDbl(fl_get_input(dialog_->input_small)) >
2701 strToDbl(fl_get_input(dialog_->input_normal)) ||
2702 strToDbl(fl_get_input(dialog_->input_normal)) >
2703 strToDbl(fl_get_input(dialog_->input_large)) ||
2704 strToDbl(fl_get_input(dialog_->input_large)) >
2705 strToDbl(fl_get_input(dialog_->input_larger)) ||
2706 strToDbl(fl_get_input(dialog_->input_larger)) >
2707 strToDbl(fl_get_input(dialog_->input_largest)) ||
2708 strToDbl(fl_get_input(dialog_->input_largest)) >
2709 strToDbl(fl_get_input(dialog_->input_huge)) ||
2710 strToDbl(fl_get_input(dialog_->input_huge)) >
2711 strToDbl(fl_get_input(dialog_->input_huger))) {
2714 str = N_("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2718 parent_.postWarning(str);
2724 void FormPreferences::ScreenFonts::update()
2726 fl_set_input(dialog_->input_roman,
2727 lyxrc.roman_font_name.c_str());
2728 fl_set_input(dialog_->input_sans,
2729 lyxrc.sans_font_name.c_str());
2730 fl_set_input(dialog_->input_typewriter,
2731 lyxrc.typewriter_font_name.c_str());
2732 fl_set_input(dialog_->input_screen_encoding,
2733 lyxrc.font_norm.c_str());
2734 fl_set_button(dialog_->check_scalable,
2735 lyxrc.use_scalable_fonts);
2736 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2737 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2738 fl_set_input(dialog_->input_tiny,
2739 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2740 fl_set_input(dialog_->input_script,
2741 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2742 fl_set_input(dialog_->input_footnote,
2743 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2744 fl_set_input(dialog_->input_small,
2745 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2746 fl_set_input(dialog_->input_normal,
2747 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2748 fl_set_input(dialog_->input_large,
2749 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2750 fl_set_input(dialog_->input_larger,
2751 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2752 fl_set_input(dialog_->input_largest,
2753 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2754 fl_set_input(dialog_->input_huge,
2755 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2756 fl_set_input(dialog_->input_huger,
2757 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2762 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2767 FD_form_spelloptions const * FormPreferences::SpellOptions::dialog()
2769 return dialog_.get();
2773 void FormPreferences::SpellOptions::apply()
2776 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2777 choice = strip(frontStrip(choice));
2779 lyxrc.isp_command = choice;
2782 // If spell checker == "none", all other input set to off.
2783 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2784 lyxrc.isp_use_alt_lang = false;
2785 lyxrc.isp_alt_lang.erase();
2787 lyxrc.isp_use_esc_chars = false;
2788 lyxrc.isp_esc_chars.erase();
2790 lyxrc.isp_use_pers_dict = false;
2791 lyxrc.isp_pers_dict.erase();
2793 lyxrc.isp_accept_compound = false;
2794 lyxrc.isp_use_input_encoding = false;
2797 int button = fl_get_button(dialog_->check_alt_lang);
2798 choice = fl_get_input(dialog_->input_alt_lang);
2799 if (button && choice.empty()) button = 0;
2800 if (!button) choice.erase();
2802 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2803 lyxrc.isp_alt_lang = choice;
2805 button = fl_get_button(dialog_->check_escape_chars);
2806 choice = fl_get_input(dialog_->input_escape_chars);
2807 if (button && choice.empty()) button = 0;
2808 if (!button) choice.erase();
2810 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2811 lyxrc.isp_esc_chars = choice;
2813 button = fl_get_button(dialog_->check_personal_dict);
2814 choice = fl_get_input(dialog_->input_personal_dict);
2815 if (button && choice.empty()) button = 0;
2816 if (!button) choice.erase();
2818 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2819 lyxrc.isp_pers_dict = choice;
2821 button = fl_get_button(dialog_->check_compound_words);
2822 lyxrc.isp_accept_compound = static_cast<bool>(button);
2824 button = fl_get_button(dialog_->check_input_enc);
2825 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2836 void FormPreferences::SpellOptions::build()
2838 dialog_.reset(parent_.build_spelloptions());
2840 fl_addto_choice(dialog_->choice_spell_command,
2841 _(" ispell | aspell "));
2842 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2843 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2844 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2846 // set up the feedback mechanism
2847 setPrehandler(dialog_->choice_spell_command);
2848 setPrehandler(dialog_->check_alt_lang);
2849 setPrehandler(dialog_->input_alt_lang);
2850 setPrehandler(dialog_->check_escape_chars);
2851 setPrehandler(dialog_->input_escape_chars);
2852 setPrehandler(dialog_->check_personal_dict);
2853 setPrehandler(dialog_->input_personal_dict);
2854 setPrehandler(dialog_->button_personal_dict);
2855 setPrehandler(dialog_->check_compound_words);
2856 setPrehandler(dialog_->check_input_enc);
2861 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2865 if (ob == dialog_->choice_spell_command)
2866 str = lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2867 else if (ob == dialog_->check_alt_lang)
2868 str = lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2869 else if (ob == dialog_->input_alt_lang)
2870 str = lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2871 else if (ob == dialog_->check_escape_chars)
2872 str = lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2873 else if (ob == dialog_->input_escape_chars)
2874 str = lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2875 else if (ob == dialog_->check_personal_dict)
2876 str = lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2877 else if (ob == dialog_->input_personal_dict)
2878 str = lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2879 else if (ob == dialog_->check_compound_words)
2880 str = lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2881 else if (ob == dialog_->check_input_enc)
2882 str = lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2888 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2890 // !ob if function is called from updateSpellOptions() to de/activate
2892 // otherwise the function is called by an xforms CB via input().
2895 // If spell checker == "none", disable all input.
2896 if (!ob || ob == dialog_->choice_spell_command) {
2897 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2898 fl_deactivate_object(dialog_->check_alt_lang);
2899 fl_deactivate_object(dialog_->input_alt_lang);
2900 fl_deactivate_object(dialog_->check_escape_chars);
2901 fl_deactivate_object(dialog_->input_escape_chars);
2902 fl_deactivate_object(dialog_->check_personal_dict);
2903 fl_deactivate_object(dialog_->input_personal_dict);
2904 fl_deactivate_object(dialog_->check_compound_words);
2905 fl_deactivate_object(dialog_->check_input_enc);
2908 fl_activate_object(dialog_->check_alt_lang);
2909 fl_activate_object(dialog_->check_escape_chars);
2910 fl_activate_object(dialog_->check_personal_dict);
2911 fl_activate_object(dialog_->check_compound_words);
2912 fl_activate_object(dialog_->check_input_enc);
2917 if (!ob || ob == dialog_->check_alt_lang) {
2918 bool const enable = fl_get_button(dialog_->check_alt_lang);
2919 setEnabled(dialog_->input_alt_lang, enable);
2922 if (!ob || ob == dialog_->check_escape_chars) {
2923 bool const enable = fl_get_button(dialog_->check_escape_chars);
2924 setEnabled(dialog_->input_escape_chars, enable);
2927 if (!ob || ob == dialog_->check_personal_dict) {
2928 bool const enable = fl_get_button(dialog_->check_personal_dict);
2929 setEnabled(dialog_->input_personal_dict, enable);
2932 if (ob == dialog_->button_personal_dict) {
2933 parent_.browse(dialog_->input_personal_dict,
2934 N_("Personal dictionary"), "*.ispell");
2937 return true; // All input is valid!
2941 void FormPreferences::SpellOptions::update()
2945 if (lyxrc.isp_command == "none")
2947 else if (lyxrc.isp_command == "ispell")
2949 else if (lyxrc.isp_command == "aspell")
2952 if (lyxrc.isp_command == "ispell")
2954 else if (lyxrc.isp_command == "aspell")
2957 fl_set_choice(dialog_->choice_spell_command, choice);
2960 if (lyxrc.isp_use_alt_lang) str = lyxrc.isp_alt_lang;
2962 fl_set_button(dialog_->check_alt_lang,
2963 lyxrc.isp_use_alt_lang);
2964 fl_set_input(dialog_->input_alt_lang, str.c_str());
2967 if (lyxrc.isp_use_esc_chars) str = lyxrc.isp_esc_chars;
2969 fl_set_button(dialog_->check_escape_chars,
2970 lyxrc.isp_use_esc_chars);
2971 fl_set_input(dialog_->input_escape_chars, str.c_str());
2974 if (lyxrc.isp_use_pers_dict) str = lyxrc.isp_pers_dict;
2976 fl_set_button(dialog_->check_personal_dict,
2977 lyxrc.isp_use_pers_dict);
2978 fl_set_input(dialog_->input_personal_dict, str.c_str());
2980 fl_set_button(dialog_->check_compound_words,
2981 lyxrc.isp_accept_compound);
2982 fl_set_button(dialog_->check_input_enc,
2983 lyxrc.isp_use_input_encoding);
2985 // Activate/Deactivate the input fields dependent on the state of the
2991 void FormPreferences::browse(FL_OBJECT * inpt,
2992 string const & title,
2993 string const & pattern,
2994 pair<string,string> const & dir1,
2995 pair<string,string> const & dir2)
2997 // Get the filename from the dialog
2998 string const filename = fl_get_input(inpt);
3000 // Show the file browser dialog
3001 string const new_filename =
3002 browseFile(lv_, filename, title, pattern, dir1, dir2);
3004 // Save the filename to the dialog
3005 if (new_filename != filename && !new_filename.empty()) {
3006 fl_set_input(inpt, new_filename.c_str());