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"
33 #include "input_validators.h"
34 #include "forms_gettext.h"
35 #include "xforms_helpers.h"
36 #include "helper_funcs.h"
38 #include "support/lyxfunctional.h"
39 #include "support/lyxmanip.h"
40 #include "support/filetools.h"
41 #include "support/LAssert.h"
43 #include "graphics/GraphicsCache.h"
45 #include <boost/bind.hpp>
47 #include FORMS_H_LOCATION
61 extern string system_lyxdir;
62 extern string user_lyxdir;
66 // These should probably go inside the class definition...
67 Formats local_formats;
68 Converters local_converters;
73 FormPreferences::FormPreferences(LyXView & lv, Dialogs & d)
74 : FormBaseBI(&lv, &d, _("Preferences"), false),
75 colors_(*this), converters_(*this), inputs_misc_(*this),
76 formats_(*this), interface_(*this), language_(*this),
77 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
78 printer_(*this), screen_fonts_(*this), spelloptions_(*this)
80 // let the dialog be shown
81 // This is a permanent connection so we won't bother
82 // storing a copy because we won't be disconnecting.
86 void FormPreferences::redraw()
88 if (!(form() && form()->visible))
90 fl_redraw_form(form());
92 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
93 if (!(form2 && form2->visible))
95 fl_redraw_form(form2);
98 if (form2 == converters_tab_->form)
99 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
101 else if (form2 == look_n_feel_tab_->form)
102 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
104 else if (form2 == inputs_tab_->form)
105 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
107 else if (form2 == outputs_tab_->form)
108 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
110 else if (form2 == lang_opts_tab_->form)
111 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
113 if (form3 && form3->visible)
114 fl_redraw_form(form3);
118 FL_FORM * FormPreferences::form() const
120 if (dialog_.get()) return dialog_->form;
125 void FormPreferences::showSpellPref()
128 fl_set_folder(dialog_->tabfolder_prefs, lang_opts_tab_->form);
129 fl_set_folder(lang_opts_tab_->tabfolder_inner, spelloptions_.dialog()->form);
133 void FormPreferences::ok()
135 FormBaseDeprecated::ok();
137 if (colors_.modifiedXformsPrefs) {
138 string const filename =
139 AddName(user_lyxdir, "preferences.xform");
140 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
143 lv_->getLyXFunc()->dispatch(LFUN_SAVEPREFERENCES);
147 void FormPreferences::hide()
149 // We need to hide the active tabfolder otherwise we get a
150 // BadDrawable error from X window and LyX crashes without saving.
151 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
153 && inner_form->visible) {
154 fl_hide_form(inner_form);
156 FormBaseDeprecated::hide();
160 void FormPreferences::build()
162 dialog_.reset(build_preferences(this));
164 // Manage the restore, save, apply and cancel/close buttons
165 bc().setOK(dialog_->button_ok);
166 bc().setApply(dialog_->button_apply);
167 bc().setCancel(dialog_->button_close);
168 bc().setRestore(dialog_->button_restore);
170 // Allow the base class to control messages
171 setMessageWidget(dialog_->text_warning);
173 // build the tab folders
174 converters_tab_.reset(build_preferences_inner_tab(this));
175 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
176 inputs_tab_.reset(build_preferences_inner_tab(this));
177 outputs_tab_.reset(build_preferences_inner_tab(this));
178 lang_opts_tab_.reset(build_preferences_inner_tab(this));
180 // build actual tabfolder contents
181 // these will become nested tabfolders
185 inputs_misc_.build();
189 outputs_misc_.build();
192 screen_fonts_.build();
193 spelloptions_.build();
195 // Now add them to the tabfolder
196 fl_addto_tabfolder(dialog_->tabfolder_prefs,
198 look_n_feel_tab_->form);
199 fl_addto_tabfolder(dialog_->tabfolder_prefs,
201 lang_opts_tab_->form);
202 fl_addto_tabfolder(dialog_->tabfolder_prefs,
204 converters_tab_->form);
205 fl_addto_tabfolder(dialog_->tabfolder_prefs,
208 fl_addto_tabfolder(dialog_->tabfolder_prefs,
212 // now build the nested tabfolders
213 // Starting with look and feel
214 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
216 screen_fonts_.dialog()->form);
217 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
219 interface_.dialog()->form);
220 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
222 colors_.dialog()->form);
223 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
225 lnf_misc_.dialog()->form);
227 // then build converters
228 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
230 formats_.dialog()->form);
231 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
233 converters_.dialog()->form);
236 // Paths should probably go in a few inner_tab called Files
237 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
239 paths_.dialog()->form);
240 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
242 inputs_misc_.dialog()->form);
244 // then building outputs
245 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
247 printer_.dialog()->form);
248 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
250 outputs_misc_.dialog()->form);
252 // then building usage
253 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
255 spelloptions_.dialog()->form);
256 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
258 language_.dialog()->form);
262 void FormPreferences::apply()
264 // set the new lyxrc entries
265 // many of these need to trigger other functions when the assignment
266 // is made. For example, screen zoom and font types. These could be
267 // handled either by signals/slots in lyxrc or just directly call the
268 // associated functions here.
269 // There are other problems with this scheme. We really should check
270 // what we copy to make sure that it really is necessary to do things
271 // like update the screen fonts because that flushes the textcache
272 // and other stuff which may cost us a lot on slower/high-load
276 formats_.apply(); // Must be before converters_.apply()
278 inputs_misc_.apply();
282 outputs_misc_.apply();
285 screen_fonts_.apply();
286 spelloptions_.apply();
290 string const FormPreferences::getFeedback(FL_OBJECT * ob)
296 if (ob->form->fdui == colors_.dialog()) {
297 str = colors_.feedback(ob);
298 } else if (ob->form->fdui == converters_.dialog()) {
299 str = converters_.feedback(ob);
300 } else if (ob->form->fdui == formats_.dialog()) {
301 str = formats_.feedback(ob);
302 } else if (ob->form->fdui == inputs_misc_.dialog()) {
303 str = inputs_misc_.feedback(ob);
304 } else if (ob->form->fdui == interface_.dialog()) {
305 str = interface_.feedback(ob);
306 } else if (ob->form->fdui == language_.dialog()) {
307 str = language_.feedback(ob);
308 } else if (ob->form->fdui == lnf_misc_.dialog()) {
309 str = lnf_misc_.feedback(ob);
310 } else if (ob->form->fdui == outputs_misc_.dialog()) {
311 str = outputs_misc_.feedback(ob);
312 } else if (ob->form->fdui == paths_.dialog()) {
313 str = paths_.feedback(ob);
314 } else if (ob->form->fdui == printer_.dialog()) {
315 str = printer_.feedback(ob);
316 } else if (ob->form->fdui == screen_fonts_.dialog()) {
317 str = screen_fonts_.feedback(ob);
318 } else if (ob->form->fdui == spelloptions_.dialog()) {
319 str = spelloptions_.feedback(ob);
326 bool FormPreferences::input(FL_OBJECT * ob, long)
330 // whatever checks you need to ensure the user hasn't entered
331 // some totally ridiculous value somewhere. Change activate to suit.
332 // comments before each test describe what is _valid_
334 if (ob->form->fdui == colors_.dialog()) {
337 } else if (ob->form->fdui == converters_.dialog())
338 return converters_.input(ob);
339 else if (ob->form->fdui == formats_.dialog())
340 return formats_.input(ob);
341 else if (ob->form->fdui == interface_.dialog())
342 return interface_.input(ob);
343 else if (ob->form->fdui == language_.dialog())
344 return language_.input(ob);
345 else if (ob->form->fdui == paths_.dialog())
346 return paths_.input(ob);
347 else if (ob->form->fdui == screen_fonts_.dialog())
348 return screen_fonts_.input();
349 else if (ob->form->fdui == spelloptions_.dialog())
350 return spelloptions_.input(ob);
356 void FormPreferences::update()
358 if (!dialog_.get()) return;
360 // read lyxrc entries
362 formats_.update(); // Must be before converters_.update()
363 converters_.update();
364 inputs_misc_.update();
368 outputs_misc_.update();
371 screen_fonts_.update();
372 spelloptions_.update();
376 FormPreferences::Colors::Colors(FormPreferences & p)
377 : modifiedXformsPrefs(false), parent_(p)
381 FD_preferences_colors const * FormPreferences::Colors::dialog()
383 return dialog_.get();
387 void FormPreferences::Colors::apply()
389 bool modifiedText = false;
390 bool modifiedBackground = false;
392 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
393 cit != xformsColorDB.end(); ++cit) {
395 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
396 if (col != cit->color()) {
397 modifiedXformsPrefs = true;
398 if (cit->colorID == FL_BLACK)
400 if (cit->colorID == FL_COL1)
401 modifiedBackground = true;
405 if (modifiedXformsPrefs) {
406 for (vector<XformsColor>::const_iterator cit =
407 xformsColorDB.begin();
408 cit != xformsColorDB.end(); ++cit) {
409 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
411 if (modifiedText && cit->colorID == FL_BLACK) {
412 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
415 if (modifiedBackground && cit->colorID == FL_COL1) {
416 AdjustVal(FL_MCOL, FL_COL1, 0.1);
417 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
418 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
420 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
421 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
424 if (cit->colorID == GUI_COLOR_CURSOR) {
425 fl_mapcolor(GUI_COLOR_CURSOR,
426 cit->r, cit->g, cit->b);
427 setCursorColor(GUI_COLOR_CURSOR);
430 Dialogs::redrawGUI();
433 // Now do the same for the LyX LColors...
434 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
435 cit != lyxColorDB.end(); ++cit) {
436 LColor::color lc = lcolor.getFromGUIName(cit->getname());
437 if (lc == LColor::inherit) continue;
439 // Create a valid X11 name of the form "#rrggbb"
440 string const hexname = X11hexname(cit->color());
442 if (lcolor.getX11Name(lc) != hexname) {
444 << "FormPreferences::Colors::apply: "
445 << "resetting LColor " << lcolor.getGUIName(lc)
446 << " from \"" << lcolor.getX11Name(lc)
447 << "\" to \"" << hexname << "\"."
450 string const s = lcolor.getLyXName(lc) + string(" ") +
452 parent_.lv_->getLyXFunc()->dispatch(LFUN_SET_COLOR, s);
458 void FormPreferences::Colors::build()
460 dialog_.reset(build_preferences_colors(&parent_));
462 fl_set_object_color(dialog_->button_color,
463 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
465 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
466 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
467 fl_set_dial_step(dialog_->dial_hue, 1.0);
468 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
470 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
471 fl_set_slider_step(dialog_->slider_saturation, 0.01);
472 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
474 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
475 fl_set_slider_step(dialog_->slider_value, 0.01);
476 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
478 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
479 fl_set_slider_step(dialog_->slider_red, 1.0);
480 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
482 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
483 fl_set_slider_step(dialog_->slider_green, 1.0);
484 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
486 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
487 fl_set_slider_step(dialog_->slider_blue, 1.0);
488 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
490 // set up the feedback mechanism
491 setPrehandler(dialog_->browser_lyx_objs);
492 setPrehandler(dialog_->button_color);
493 setPrehandler(dialog_->button_modify);
494 setPrehandler(dialog_->dial_hue);
495 setPrehandler(dialog_->slider_saturation);
496 setPrehandler(dialog_->slider_value);
497 setPrehandler(dialog_->slider_red);
498 setPrehandler(dialog_->slider_green);
499 setPrehandler(dialog_->slider_blue);
500 setPrehandler(dialog_->radio_rgb);
501 setPrehandler(dialog_->radio_hsv);
505 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
509 if (ob == dialog_->browser_lyx_objs) {
510 str = _("LyX objects that can be assigned a color.");
512 } else if (ob == dialog_->button_modify) {
513 str = _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
515 } else if (ob == dialog_->dial_hue ||
516 ob == dialog_->slider_saturation ||
517 ob == dialog_->slider_value ||
518 ob == dialog_->slider_red ||
519 ob == dialog_->slider_green ||
520 ob == dialog_->slider_blue) {
521 str = _("Find a new color.");
523 } else if (ob == dialog_->radio_rgb ||
524 ob == dialog_->radio_hsv) {
525 str = _("Toggle between RGB and HSV color spaces.");
532 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
534 if (ob == dialog_->browser_lyx_objs) {
537 } else if (ob == dialog_->dial_hue ||
538 ob == dialog_->slider_saturation ||
539 ob == dialog_->slider_value) {
542 } else if (ob == dialog_->slider_red ||
543 ob == dialog_->slider_green ||
544 ob == dialog_->slider_blue) {
547 } else if (ob == dialog_->radio_rgb ||
548 ob == dialog_->radio_hsv) {
551 } else if (ob == dialog_->button_modify) {
557 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
561 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
565 hsv.v = min(1.0, max(0.0, hsv.v));
568 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
572 void FormPreferences::Colors::InputBrowserLyX() const
574 vector<NamedColor>::size_type const selLyX =
575 fl_get_browser(dialog_->browser_lyx_objs);
576 if (selLyX < 1) return;
578 // Is the choice an Xforms color...
581 if (selLyX - 1 < xformsColorDB.size()) {
582 vector<XformsColor>::size_type const i = selLyX - 1;
583 col = xformsColorDB[i].color();
585 // or a LyX Logical color?
587 vector<NamedColor>::size_type const i = selLyX - 1 -
588 xformsColorDB.size();
589 col = lyxColorDB[i].color();
592 fl_freeze_form(dialog_->form);
594 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
595 fl_redraw_object(dialog_->button_color);
597 // Display either RGB or HSV but not both!
600 // Deactivate the modify button to begin with...
601 setEnabled(dialog_->button_modify, false);
603 fl_unfreeze_form(dialog_->form);
607 void FormPreferences::Colors::InputHSV()
609 double const hue = fl_get_dial_value(dialog_->dial_hue);
610 double const sat = fl_get_slider_value(dialog_->slider_saturation);
611 double const val = fl_get_slider_value(dialog_->slider_value);
613 int const h = int(hue);
614 int const s = int(100.0 * sat);
615 int const v = int(100.0 * val);
617 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
619 fl_set_object_label(dialog_->text_color_values, label.c_str());
621 RGBColor col = HSVColor(hue, sat, val);
623 fl_freeze_form(dialog_->form);
625 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
626 fl_redraw_object(dialog_->button_color);
628 col = HSVColor(hue, 1.0, 1.0);
629 col.r = max(col.r, 0);
630 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
631 fl_redraw_object(dialog_->dial_hue);
633 // Ascertain whether to activate the Modify button.
634 vector<NamedColor>::size_type const selLyX =
635 fl_get_browser(dialog_->browser_lyx_objs);
637 fl_unfreeze_form(dialog_->form);
638 if (selLyX < 1) return;
640 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
643 // Is the choice an Xforms color...
644 if (selLyX - 1 < xformsColorDB.size()) {
645 vector<XformsColor>::size_type const i = selLyX - 1;
646 modify = (xformsColorDB[i].color() != col);
648 // or a LyX Logical color?
650 vector<NamedColor>::size_type const i = selLyX - 1 -
651 xformsColorDB.size();
652 modify = (lyxColorDB[i].color() != col);
655 setEnabled(dialog_->button_modify, modify);
659 void FormPreferences::Colors::InputRGB()
661 int const red = int(fl_get_slider_value(dialog_->slider_red));
662 int const green = int(fl_get_slider_value(dialog_->slider_green));
663 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
665 string const label = tostr(red) + string(", ") + tostr(green) +
666 string(", ") + tostr(blue);
667 fl_set_object_label(dialog_->text_color_values, label.c_str());
669 fl_freeze_form(dialog_->form);
671 RGBColor col = RGBColor(red, green, blue);
672 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
673 fl_redraw_object(dialog_->button_color);
675 // Ascertain whether to activate the Modify button.
676 vector<NamedColor>::size_type const selLyX =
677 fl_get_browser(dialog_->browser_lyx_objs);
679 fl_unfreeze_form(dialog_->form);
680 if (selLyX < 1) return;
684 // Is the choice an Xforms color...
685 if (selLyX - 1 < xformsColorDB.size()) {
686 vector<XformsColor>::size_type const i = selLyX - 1;
687 modify = (xformsColorDB[i].color() != col);
689 // or a LyX Logical color?
691 vector<NamedColor>::size_type const i = selLyX - 1 -
692 xformsColorDB.size();
693 modify = (lyxColorDB[i].color() != col);
696 setEnabled(dialog_->button_modify, modify);
700 void FormPreferences::Colors::LoadBrowserLyX()
702 if (!dialog_->browser_lyx_objs->visible) return;
704 // First, define the modifiable xforms colors
705 xformsColorDB.clear();
708 xcol.name = _("GUI background");
709 xcol.colorID = FL_COL1;
710 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
712 xformsColorDB.push_back(xcol);
714 xcol.name = _("GUI text");
715 xcol.colorID = FL_BLACK;
716 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
718 xformsColorDB.push_back(xcol);
720 xcol.name = _("GUI selection");
721 xcol.colorID = FL_YELLOW;
722 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
724 xformsColorDB.push_back(xcol);
726 xcol.name = _("GUI pointer");
727 xcol.colorID = GUI_COLOR_CURSOR;
728 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
730 xformsColorDB.push_back(xcol);
732 // Now create the the LyX LColors database
734 for (int i=0; i<LColor::ignore; ++i) {
735 LColor::color lc = static_cast<LColor::color>(i);
736 if (lc == LColor::none
737 || lc == LColor::black
738 || lc == LColor::white
740 || lc == LColor::green
741 || lc == LColor::blue
742 || lc == LColor::cyan
743 || lc == LColor::magenta
744 || lc == LColor::yellow
745 || lc == LColor::inherit
746 || lc == LColor::ignore) continue;
748 string const name = lcolor.getX11Name(lc);
749 Display * display = fl_get_display();;
750 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
753 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
755 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
756 << "LColor " << lcolor.getLyXName(lc)
757 << ": X can't find color \"" << name
758 << "\". Set to \"black\"!" << endl;
760 string const arg = lcolor.getLyXName(lc) + " black";
761 parent_.lv_->getLyXFunc()->
762 dispatch(LFUN_SET_COLOR, arg);
766 // X has found the color. Now find the "appropriate" X11 name
769 // Note that X stores the RGB values in the range 0 - 65535
770 // whilst we require them in the range 0 - 255.
772 col.r = xcol.red / 256;
773 col.g = xcol.green / 256;
774 col.b = xcol.blue / 256;
776 // Create a valid X11 name of the form "#rrggbb" and change the
777 // LColor X11name to this. Don't want to trigger a redraw,
778 // as we're just changing the name not the RGB values.
779 // Also reset the system_lcolor names, so that we don't output
780 // unnecessary changes.
781 string const hexname = X11hexname(col);
783 if (lcolor.getX11Name(lc) != hexname) {
784 lcolor.setColor(lc, hexname);
785 system_lcolor.setColor(lc, hexname);
788 // Finally, push the color onto the database
789 NamedColor ncol(lcolor.getGUIName(lc), col);
790 lyxColorDB.push_back(ncol);
793 // Now construct the browser
794 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
795 fl_freeze_form(dialog_->form);
796 fl_clear_browser(colbr);
797 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
798 cit != xformsColorDB.end(); ++cit) {
799 fl_addto_browser(colbr, cit->getname().c_str());
801 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
802 cit != lyxColorDB.end(); ++cit) {
803 fl_addto_browser(colbr, cit->getname().c_str());
806 // just to be safe...
807 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
808 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
809 fl_unfreeze_form(dialog_->form);
815 void FormPreferences::Colors::Modify()
817 vector<NamedColor>::size_type const selLyX =
818 fl_get_browser(dialog_->browser_lyx_objs);
819 if (selLyX < 1) return;
822 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
824 // Is the choice an Xforms color...
825 if (selLyX - 1 < xformsColorDB.size()) {
826 vector<XformsColor>::size_type const i = selLyX - 1;
827 xformsColorDB[i].r = col.r;
828 xformsColorDB[i].g = col.g;
829 xformsColorDB[i].b = col.b;
831 // or a LyX Logical color?
833 vector<NamedColor>::size_type const i = selLyX - 1 -
834 xformsColorDB.size();
835 lyxColorDB[i].r = col.r;
836 lyxColorDB[i].g = col.g;
837 lyxColorDB[i].b = col.b;
840 fl_freeze_form(dialog_->form);
841 setEnabled(dialog_->button_modify, false);
842 fl_unfreeze_form(dialog_->form);
846 void FormPreferences::Colors::SwitchColorSpace() const
848 bool const hsv = fl_get_button(dialog_->radio_hsv);
851 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
853 fl_freeze_form(dialog_->form);
856 fl_hide_object(dialog_->slider_red);
857 fl_hide_object(dialog_->slider_blue);
858 fl_hide_object(dialog_->slider_green);
859 fl_show_object(dialog_->dial_hue);
860 fl_show_object(dialog_->slider_saturation);
861 fl_show_object(dialog_->slider_value);
863 HSVColor hsv = HSVColor(col);
864 hsv.h = max(hsv.h, 0.0);
866 fl_set_dial_value(dialog_->dial_hue, hsv.h);
867 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
868 fl_set_slider_value(dialog_->slider_value, hsv.v);
870 col = HSVColor(hsv.h, 1.0, 1.0);
871 col.r = max(col.r,0);
872 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
873 fl_redraw_object(dialog_->dial_hue);
875 // Adjust the label a bit, but not the actual values.
876 // Means that toggling from one space to the other has no
877 // effect on the final color.
878 int const h = int(hsv.h);
879 int const s = int(100*hsv.s);
880 int const v = int(100*hsv.v);
881 string const label = tostr(h) + string(", ") + tostr(s) +
882 string(", ") + tostr(v);
883 fl_set_object_label(dialog_->text_color_values, label.c_str());
886 fl_show_object(dialog_->slider_red);
887 fl_show_object(dialog_->slider_blue);
888 fl_show_object(dialog_->slider_green);
889 fl_hide_object(dialog_->dial_hue);
890 fl_hide_object(dialog_->slider_saturation);
891 fl_hide_object(dialog_->slider_value);
893 fl_set_slider_value(dialog_->slider_red, col.r);
894 fl_set_slider_value(dialog_->slider_green, col.g);
895 fl_set_slider_value(dialog_->slider_blue, col.b);
897 // Adjust the label a bit. Same reasoning as above.
898 int const r = int(col.r);
899 int const g = int(col.g);
900 int const b = int(col.b);
901 string const label = tostr(r) + string(", ") + tostr(g) +
902 string(", ") + tostr(b);
903 fl_set_object_label(dialog_->text_color_values, label.c_str());
906 fl_unfreeze_form(dialog_->form);
909 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
913 ostr << "#" << std::setbase(16) << setfill('0')
918 return ostr.str().c_str();
922 FormPreferences::Converters::Converters(FormPreferences & p)
927 FD_preferences_converters const * FormPreferences::Converters::dialog()
929 return dialog_.get();
933 void FormPreferences::Converters::apply() const
935 converters = local_converters;
936 converters.update(formats);
937 converters.buildGraph();
941 void FormPreferences::Converters::build()
943 dialog_.reset(build_preferences_converters(&parent_));
945 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
946 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
948 // set up the feedback mechanism
949 setPrehandler(dialog_->browser_all);
950 setPrehandler(dialog_->button_delete);
951 setPrehandler(dialog_->button_add);
952 setPrehandler(dialog_->input_converter);
953 setPrehandler(dialog_->choice_from);
954 setPrehandler(dialog_->choice_to);
955 setPrehandler(dialog_->input_flags);
960 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
964 if (ob == dialog_->browser_all) {
965 str = _("All the currently defined converters known to LyX.");
966 } else if (ob == dialog_->choice_from) {
967 str = _("Convert \"from\" this format");
968 } else if (ob == dialog_->choice_to) {
969 str = _("Convert \"to\" this format");
970 } else if (ob == dialog_->input_converter) {
971 str = _("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.");
972 } else if (ob == dialog_->input_flags) {
973 str = _("Extra information for the Converter class, whether and how to parse the result, and various other things.");
974 } else if (ob == dialog_->button_delete) {
975 str = _("Remove the current converter from the list of available converters. Note: you must then \"Apply\" the change.");
976 } else if (ob == dialog_->button_add) {
977 if (string(ob->label) == _("Add"))
978 str = _("Add the current converter to the list of available converters. Note: you must then \"Apply\" the change.");
980 str = _("Modify the contents of the current converter. Note: you must then \"Apply\" the change.");
987 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
989 if (ob == dialog_->browser_all) {
992 } else if (ob == dialog_->choice_from
993 || ob == dialog_->choice_to
994 || ob == dialog_->input_converter
995 || ob == dialog_->input_flags) {
998 } else if (ob == dialog_->button_add) {
1001 } else if (ob == dialog_->button_delete) {
1009 void FormPreferences::Converters::update()
1011 local_converters = converters;
1012 local_converters.update(local_formats);
1017 void FormPreferences::Converters::UpdateBrowser()
1019 local_converters.sort();
1021 fl_freeze_form(dialog_->form);
1022 fl_clear_browser(dialog_->browser_all);
1023 for (::Converters::const_iterator cit = local_converters.begin();
1024 cit != local_converters.end(); ++cit) {
1025 string const name = cit->From->prettyname() + " -> "
1026 + cit->To->prettyname();
1027 fl_addto_browser(dialog_->browser_all, name.c_str());
1030 fl_unfreeze_form(dialog_->form);
1034 bool FormPreferences::Converters::Add()
1036 string const from = GetFrom();
1037 string const to = GetTo();
1038 string const command = fl_get_input(dialog_->input_converter);
1039 string const flags = fl_get_input(dialog_->input_flags);
1041 Converter const * old = local_converters.getConverter(from, to);
1042 local_converters.add(from, to, command, flags);
1044 local_converters.updateLast(local_formats);
1047 setEnabled(dialog_->button_add, false);
1053 bool FormPreferences::Converters::Browser()
1055 int const i = fl_get_browser(dialog_->browser_all);
1056 if (i <= 0) return false;
1058 fl_freeze_form(dialog_->form);
1060 Converter const & c = local_converters.get(i - 1);
1061 int j = local_formats.getNumber(c.from);
1063 fl_set_choice(dialog_->choice_from, j + 1);
1065 j = local_formats.getNumber(c.to);
1067 fl_set_choice(dialog_->choice_to, j + 1);
1069 fl_set_input(dialog_->input_converter, c.command.c_str());
1070 fl_set_input(dialog_->input_flags, c.flags.c_str());
1072 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1073 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1075 setEnabled(dialog_->button_add, false);
1076 setEnabled(dialog_->button_delete, true);
1078 fl_unfreeze_form(dialog_->form);
1083 bool FormPreferences::Converters::erase()
1085 string const from = GetFrom();
1086 string const to = GetTo();
1088 local_converters.erase(from, to);
1094 bool FormPreferences::Converters::Input()
1096 string const from = GetFrom();
1097 string const to = GetTo();
1098 int const sel = local_converters.getNumber(from, to);
1100 fl_freeze_form(dialog_->form);
1103 fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
1104 fl_set_button_shortcut(dialog_->button_add,
1105 scex(_("Add|#A")), 1);
1107 fl_deselect_browser(dialog_->browser_all);
1108 setEnabled(dialog_->button_delete, false);
1111 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1112 fl_set_button_shortcut(dialog_->button_add,
1113 scex(_("Modify|#M")), 1);
1115 int top = max(sel-5, 0);
1116 fl_set_browser_topline(dialog_->browser_all, top);
1117 fl_select_browser_line(dialog_->browser_all, sel+1);
1118 setEnabled(dialog_->button_delete, true);
1121 string const command = strip(fl_get_input(dialog_->input_converter));
1122 bool const enable = !(command.empty() || from == to);
1123 setEnabled(dialog_->button_add, enable);
1125 fl_unfreeze_form(dialog_->form);
1130 string const FormPreferences::Converters::GetFrom() const
1132 ::Formats::FormatList::size_type const i =
1133 fl_get_choice(dialog_->choice_from);
1135 if (i > 0 && i <= local_formats.size())
1136 return local_formats.get(i - 1).name();
1138 lyxerr << "FormPreferences::Converters::GetFrom: No choice!"
1145 string const FormPreferences::Converters::GetTo() const
1147 ::Formats::FormatList::size_type const i =
1148 fl_get_choice(dialog_->choice_to);
1150 if (i > 0 && i <= local_formats.size())
1151 return local_formats.get(i - 1).name();
1153 lyxerr << "FormPreferences::Converters::GetTo: No choice!"
1160 void FormPreferences::Converters::UpdateChoices() const
1163 for (::Formats::const_iterator cit = local_formats.begin();
1164 cit != local_formats.end(); ++cit) {
1165 if (!choice.empty())
1169 choice += cit->prettyname();
1173 fl_clear_choice(dialog_->choice_from);
1174 fl_addto_choice(dialog_->choice_from, choice.c_str());
1176 fl_clear_choice(dialog_->choice_to);
1177 fl_addto_choice(dialog_->choice_to, choice.c_str());
1181 FormPreferences::Formats::Formats(FormPreferences & p)
1186 FD_preferences_formats const * FormPreferences::Formats::dialog()
1188 return dialog_.get();
1192 void FormPreferences::Formats::apply() const
1194 formats = local_formats;
1198 void FormPreferences::Formats::build()
1200 dialog_.reset(build_preferences_formats(&parent_));
1202 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1203 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1204 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1205 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1206 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1208 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1210 // set up the feedback mechanism
1211 setPrehandler(dialog_->browser_all);
1212 setPrehandler(dialog_->input_format);
1213 setPrehandler(dialog_->input_gui_name);
1214 setPrehandler(dialog_->button_delete);
1215 setPrehandler(dialog_->button_add);
1216 setPrehandler(dialog_->input_extension);
1217 setPrehandler(dialog_->input_viewer);
1218 setPrehandler(dialog_->input_shrtcut);
1223 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1227 if (ob == dialog_->browser_all) {
1228 str = _("All the currently defined formats known to LyX.");
1229 } else if (ob == dialog_->input_format) {
1230 str = _("The format identifier.");
1231 } else if (ob == dialog_->input_gui_name) {
1232 str = _("The format name as it will appear in the menus.");
1233 } else if (ob == dialog_->input_shrtcut) {
1234 str = _("The keyboard accelerator. Use a letter in the GUI name. Case sensitive.");
1235 } else if (ob == dialog_->input_extension) {
1236 str = _("Used to recognize the file. E.g., ps, pdf, tex.");
1237 } else if (ob == dialog_->input_viewer) {
1238 str = _("The command used to launch the viewer application.");
1239 } else if (ob == dialog_->button_delete) {
1240 str = _("Remove the current format from the list of available formats. Note: you must then \"Apply\" the change.");
1241 } else if (ob == dialog_->button_add) {
1242 if (string(ob->label) == _("Add"))
1243 str = _("Add the current format to the list of available formats. Note: you must then \"Apply\" the change.");
1245 str = _("Modify the contents of the current format. Note: you must then \"Apply\" the change.");
1252 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1254 if (ob == dialog_->browser_all) {
1257 } else if (ob == dialog_->input_format
1258 || ob == dialog_->input_gui_name
1259 || ob == dialog_->input_shrtcut
1260 || ob == dialog_->input_extension
1261 || ob == dialog_->input_viewer) {
1264 } else if (ob == dialog_->button_add) {
1267 } else if (ob == dialog_->button_delete) {
1275 void FormPreferences::Formats::update()
1277 local_formats = formats;
1282 void FormPreferences::Formats::UpdateBrowser()
1284 local_formats.sort();
1286 fl_freeze_form(dialog_->form);
1287 fl_deselect_browser(dialog_->browser_all);
1288 fl_clear_browser(dialog_->browser_all);
1289 for (::Formats::const_iterator cit = local_formats.begin();
1290 cit != local_formats.end(); ++cit)
1291 fl_addto_browser(dialog_->browser_all,
1292 cit->prettyname().c_str());
1295 fl_unfreeze_form(dialog_->form);
1297 // Mustn't forget to update the Formats available to the converters_
1298 parent_.converters_.UpdateChoices();
1299 local_converters.update(local_formats);
1303 bool FormPreferences::Formats::Add()
1305 string const name = fl_get_input(dialog_->input_format);
1306 string const prettyname = fl_get_input(dialog_->input_gui_name);
1307 string const extension = fl_get_input(dialog_->input_extension);
1308 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1309 string const viewer = fl_get_input(dialog_->input_viewer);
1311 Format const * old = local_formats.getFormat(name);
1312 string const old_prettyname = old ? old->prettyname() : string();
1313 local_formats.add(name, extension, prettyname, shortcut);
1314 local_formats.setViewer(name, viewer);
1315 if (!old || prettyname != old_prettyname) {
1318 parent_.converters_.UpdateBrowser();
1320 setEnabled(dialog_->button_add, false);
1326 bool FormPreferences::Formats::Browser()
1328 int const i = fl_get_browser(dialog_->browser_all);
1329 if (i <= 0) return false;
1331 fl_freeze_form(dialog_->form);
1333 Format const & f = local_formats.get(i - 1);
1335 fl_set_input(dialog_->input_format, f.name().c_str());
1336 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1337 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1338 fl_set_input(dialog_->input_extension, f.extension().c_str());
1339 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1341 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1342 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1344 setEnabled(dialog_->button_add, false);
1345 setEnabled(dialog_->button_delete, true);
1347 fl_unfreeze_form(dialog_->form);
1352 bool FormPreferences::Formats::erase()
1354 string const name = fl_get_input(dialog_->input_format);
1356 if (local_converters.formatIsUsed(name)) {
1357 parent_.postWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
1358 setEnabled(dialog_->button_delete, false);
1362 local_formats.erase(name);
1368 bool FormPreferences::Formats::Input()
1370 string const name = fl_get_input(dialog_->input_format);
1371 int const sel = local_formats.getNumber(name);
1372 fl_freeze_form(dialog_->form);
1375 fl_set_object_label(dialog_->button_add,
1377 fl_set_button_shortcut(dialog_->button_add,
1378 scex(_("Add|#A")), 1);
1380 fl_deselect_browser(dialog_->browser_all);
1381 setEnabled(dialog_->button_delete, false);
1384 fl_set_object_label(dialog_->button_add,
1385 idex(_("Modify|#M")));
1386 fl_set_button_shortcut(dialog_->button_add,
1387 scex(_("Modify|#M")), 1);
1389 int const top = max(sel-5, 0);
1390 fl_set_browser_topline(dialog_->browser_all, top);
1391 fl_select_browser_line(dialog_->browser_all, sel+1);
1393 setEnabled(dialog_->button_add, true);
1394 setEnabled(dialog_->button_delete, true);
1397 string const prettyname = fl_get_input(dialog_->input_gui_name);
1398 bool const enable = !(name.empty() || prettyname.empty());
1399 setEnabled(dialog_->button_add, enable);
1401 fl_unfreeze_form(dialog_->form);
1406 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1411 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1413 return dialog_.get();
1417 void FormPreferences::InputsMisc::apply() const
1419 lyxrc.date_insert_format =
1420 fl_get_input(dialog_->input_date_format);
1424 void FormPreferences::InputsMisc::build()
1426 dialog_.reset(build_preferences_inputs_misc(&parent_));
1428 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1430 // set up the feedback mechanism
1431 setPrehandler(dialog_->input_date_format);
1436 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1440 if (ob == dialog_->input_date_format)
1441 str = 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
1506 if (ob == dialog_->input_popup_normal_font)
1507 str = lyxrc.getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1508 else if (ob == dialog_->input_popup_bold_font)
1509 str = lyxrc.getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1510 else if (ob == dialog_->input_popup_font_encoding)
1511 str = lyxrc.getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1512 else if (ob == dialog_->input_bind_file)
1513 str = lyxrc.getDescription(LyXRC::RC_BINDFILE);
1514 else if (ob == dialog_->input_ui_file)
1515 str = lyxrc.getDescription(LyXRC::RC_UIFILE);
1516 else if (ob == dialog_->check_override_x_dead_keys)
1517 str = lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1523 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1525 if (ob == dialog_->button_bind_file_browse) {
1526 string dir = AddName(system_lyxdir, "bind");
1527 string name = _("Sys Bind|#S#s");
1528 pair<string,string> dir1(name, dir);
1530 dir = AddName(user_lyxdir, "bind");
1531 name = _("User Bind|#U#u");
1532 pair<string,string> dir2(name, dir);
1534 parent_.browse(dialog_->input_bind_file,
1535 _("Bind file"), "*.bind", dir1, dir2);
1537 } else if (ob == dialog_->button_ui_file_browse) {
1538 string dir = AddName(system_lyxdir, "ui");
1539 string name = _("Sys UI|#S#s");
1540 pair<string,string> dir1(name, dir);
1542 dir = AddName(user_lyxdir, "ui");
1543 name = _("User UI|#U#u");
1544 pair<string,string> dir2(name, dir);
1546 parent_.browse(dialog_->input_ui_file,
1547 _("UI file"), "*.ui", dir1, dir2);
1554 void FormPreferences::Interface::update()
1556 fl_set_input(dialog_->input_popup_normal_font,
1557 lyxrc.popup_normal_font.c_str());
1558 fl_set_input(dialog_->input_popup_bold_font,
1559 lyxrc.popup_bold_font.c_str());
1560 fl_set_input(dialog_->input_popup_font_encoding,
1561 lyxrc.popup_font_encoding.c_str());
1562 fl_set_input(dialog_->input_bind_file,
1563 lyxrc.bind_file.c_str());
1564 fl_set_input(dialog_->input_ui_file,
1565 lyxrc.ui_file.c_str());
1566 fl_set_button(dialog_->check_override_x_dead_keys,
1567 lyxrc.override_x_deadkeys);
1571 FormPreferences::Language::Language(FormPreferences & p)
1576 FD_preferences_language const * FormPreferences::Language::dialog()
1578 return dialog_.get();
1582 void FormPreferences::Language::apply()
1584 int const pos = combo_default_lang->get();
1585 lyxrc.default_language = lang_[pos-1];
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(build_preferences_language(&parent_));
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 // Store the lang identifiers for later
1635 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1636 lang_ = getSecond(langs);
1638 // The default_language is a combo-box and has to be inserted manually
1639 fl_freeze_form(dialog_->form);
1640 fl_addto_form(dialog_->form);
1642 FL_OBJECT * obj = dialog_->choice_default_lang;
1643 fl_deactivate_object(dialog_->choice_default_lang);
1644 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1645 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
1646 parent_.lang_opts_tab_->tabfolder_inner,
1647 parent_.dialog_->tabfolder_prefs);
1648 combo_default_lang->shortcut("#L",1);
1649 combo_default_lang->setcallback(ComboCB, &parent_);
1651 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1652 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1653 for (; lit != lend; ++lit) {
1654 combo_default_lang->addto(lit->first);
1656 combo_default_lang->select(1);
1659 fl_unfreeze_form(dialog_->form);
1661 // set up the feedback mechanism
1662 setPrehandler(dialog_->input_package);
1663 setPrehandler(dialog_->check_use_kbmap);
1665 // This is safe, as nothing is done to the pointer, other than
1666 // to use its address in a block-if statement.
1667 // No it's not! Leads to crash.
1669 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1670 // C_FormPreferencesFeedbackCB);
1672 setPrehandler(dialog_->input_kbmap1);
1673 setPrehandler(dialog_->input_kbmap2);
1674 setPrehandler(dialog_->check_rtl_support);
1675 setPrehandler(dialog_->check_mark_foreign);
1676 setPrehandler(dialog_->check_auto_begin);
1677 setPrehandler(dialog_->check_auto_end);
1678 setPrehandler(dialog_->check_use_babel);
1679 setPrehandler(dialog_->check_global_options);
1680 setPrehandler(dialog_->input_command_begin);
1681 setPrehandler(dialog_->input_command_end);
1683 // Activate/Deactivate the input fields dependent on the state of the
1690 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1694 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1695 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1696 else if (ob == dialog_->check_use_kbmap)
1697 str = lyxrc.getDescription(LyXRC::RC_KBMAP);
1698 else if (ob == dialog_->input_kbmap1)
1699 str = lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1700 else if (ob == dialog_->input_kbmap2)
1701 str = lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1702 else if (ob == dialog_->check_rtl_support)
1703 str = lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1704 else if (ob == dialog_->check_mark_foreign)
1705 str = lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1706 else if (ob == dialog_->check_auto_begin)
1707 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1708 else if (ob == dialog_->check_auto_end)
1709 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1710 else if (ob == dialog_->check_use_babel)
1711 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1712 else if (ob == dialog_->check_global_options)
1713 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1714 else if (ob == dialog_->input_package)
1715 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1716 else if (ob == dialog_->input_command_begin)
1717 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1718 else if (ob == dialog_->input_command_end)
1719 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1725 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1727 bool activate = true;
1729 // !ob if function is called from Language::build() to de/activate
1731 // otherwise the function is called by an xforms CB via input().
1732 if (!ob || ob == dialog_->check_use_kbmap) {
1733 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1734 setEnabled(dialog_->button_kbmap1_browse, enable);
1735 setEnabled(dialog_->button_kbmap2_browse, enable);
1736 setEnabled(dialog_->input_kbmap1, enable);
1737 setEnabled(dialog_->input_kbmap2, enable);
1740 if (ob == dialog_->button_kbmap1_browse) {
1741 string const dir = AddName(system_lyxdir, "kbd");
1742 string const name = _("Key maps|#K#k");
1743 pair<string, string> dir1(name, dir);
1745 parent_.browse(dialog_->input_kbmap1,
1746 _("Keyboard map"), "*.kmap", dir1);
1747 } else if (ob == dialog_->button_kbmap2_browse) {
1748 string const dir = AddName(system_lyxdir, "kbd");
1749 string const name = _("Key maps|#K#k");
1750 pair<string, string> dir1(name, dir);
1752 parent_.browse(dialog_->input_kbmap2,
1753 _("Keyboard map"), "*.kmap", dir1);
1760 void FormPreferences::Language::update()
1762 fl_set_button(dialog_->check_use_kbmap,
1765 int const pos = int(findPos(lang_, lyxrc.default_language));
1766 combo_default_lang->select(pos+1);
1768 if (lyxrc.use_kbmap) {
1769 fl_set_input(dialog_->input_kbmap1,
1770 lyxrc.primary_kbmap.c_str());
1771 fl_set_input(dialog_->input_kbmap2,
1772 lyxrc.secondary_kbmap.c_str());
1774 fl_set_input(dialog_->input_kbmap1, "");
1775 fl_set_input(dialog_->input_kbmap2, "");
1778 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1779 fl_set_button(dialog_->check_mark_foreign,
1780 lyxrc.mark_foreign_language);
1781 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1782 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1783 fl_set_button(dialog_->check_use_babel, lyxrc.language_use_babel);
1784 fl_set_button(dialog_->check_global_options,
1785 lyxrc.language_global_options);
1787 fl_set_input(dialog_->input_package,
1788 lyxrc.language_package.c_str());
1789 fl_set_input(dialog_->input_command_begin,
1790 lyxrc.language_command_begin.c_str());
1791 fl_set_input(dialog_->input_command_end,
1792 lyxrc.language_command_end.c_str());
1794 // Activate/Deactivate the input fields dependent on the state of the
1800 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1802 FormPreferences * pre = static_cast<FormPreferences*>(v);
1803 // This is safe, as nothing is done to the pointer, other than
1804 // to use its address in a block-if statement.
1805 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1809 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1814 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1816 return dialog_.get();
1820 void FormPreferences::LnFmisc::apply() const
1822 lyxrc.auto_region_delete =
1823 fl_get_button(dialog_->check_auto_region_delete);
1824 lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm);
1825 lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
1826 lyxrc.cursor_follows_scrollbar =
1827 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1828 lyxrc.dialogs_iconify_with_main =
1829 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1830 lyxrc.autosave = static_cast<unsigned int>
1831 (fl_get_counter_value(dialog_->counter_autosave));
1832 lyxrc.wheel_jump = static_cast<unsigned int>
1833 (fl_get_counter_value(dialog_->counter_wm_jump));
1835 string const old_value = lyxrc.display_graphics;
1836 if (fl_get_button(dialog_->radio_display_monochrome)) {
1837 lyxrc.display_graphics = "mono";
1838 } else if (fl_get_button(dialog_->radio_display_grayscale)) {
1839 lyxrc.display_graphics = "gray";
1840 } else if (fl_get_button(dialog_->radio_display_color)) {
1841 lyxrc.display_graphics = "color";
1843 lyxrc.display_graphics = "no";
1845 if (old_value != lyxrc.display_graphics) {
1846 grfx::GCache & gc = grfx::GCache::get();
1852 void FormPreferences::LnFmisc::build()
1854 dialog_.reset(build_preferences_lnf_misc(&parent_));
1856 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1857 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1859 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1860 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1862 // set up the feedback mechanism
1863 setPrehandler(dialog_->check_auto_region_delete);
1864 setPrehandler(dialog_->check_exit_confirm);
1865 setPrehandler(dialog_->counter_autosave);
1866 setPrehandler(dialog_->check_ask_new_file);
1867 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1868 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1869 setPrehandler(dialog_->counter_wm_jump);
1870 setPrehandler(dialog_->radio_display_monochrome);
1871 setPrehandler(dialog_->radio_display_grayscale);
1872 setPrehandler(dialog_->radio_display_color);
1873 setPrehandler(dialog_->radio_no_display);
1878 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1882 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_ask_new_file)
1887 str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
1888 else if (ob == dialog_->check_cursor_follows_scrollbar)
1889 str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1890 else if (ob == dialog_->check_dialogs_iconify_with_main)
1891 str = lyxrc.getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1892 else if (ob == dialog_->counter_autosave)
1893 str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1894 else if (ob == dialog_->counter_wm_jump)
1895 str = lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1896 else if (ob == dialog_->radio_display_monochrome ||
1897 ob == dialog_->radio_display_grayscale ||
1898 ob == dialog_->radio_display_color ||
1899 ob == dialog_->radio_no_display)
1900 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1906 void FormPreferences::LnFmisc::update()
1908 fl_set_button(dialog_->check_auto_region_delete,
1909 lyxrc.auto_region_delete);
1910 fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
1911 fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
1912 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1913 lyxrc.cursor_follows_scrollbar);
1914 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1915 lyxrc.dialogs_iconify_with_main);
1916 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1917 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1919 if (lyxrc.display_graphics == "mono") {
1920 fl_set_button(dialog_->radio_display_monochrome, 1);
1921 } else if (lyxrc.display_graphics == "gray") {
1922 fl_set_button(dialog_->radio_display_grayscale, 1);
1923 } else if (lyxrc.display_graphics == "color") {
1924 fl_set_button(dialog_->radio_display_color, 1);
1926 fl_set_button(dialog_->radio_no_display, 1);
1931 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1936 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1938 return dialog_.get();
1942 void FormPreferences::OutputsMisc::apply() const
1944 lyxrc.ascii_linelen = static_cast<unsigned int>
1945 (fl_get_counter_value(dialog_->counter_line_len));
1946 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1949 fl_get_choice(dialog_->choice_default_papersize) - 1;
1950 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1952 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1953 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1954 lyxrc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1955 lyxrc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1959 void FormPreferences::OutputsMisc::build()
1961 dialog_.reset(build_preferences_outputs_misc(&parent_));
1963 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1965 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1966 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1967 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1968 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1969 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1971 fl_addto_choice(dialog_->choice_default_papersize,
1972 _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1974 // set up the feedback mechanism
1975 setPrehandler(dialog_->counter_line_len);
1976 setPrehandler(dialog_->input_tex_encoding);
1977 setPrehandler(dialog_->choice_default_papersize);
1978 setPrehandler(dialog_->input_ascii_roff);
1979 setPrehandler(dialog_->input_checktex);
1980 setPrehandler(dialog_->input_paperoption);
1981 setPrehandler(dialog_->check_autoreset_classopt);
1986 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1990 if (ob == dialog_->counter_line_len)
1991 str = lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
1992 else if (ob == dialog_->input_tex_encoding)
1993 str = lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
1994 else if (ob == dialog_->input_ascii_roff)
1995 str = lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1996 else if (ob == dialog_->input_checktex)
1997 str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
1998 else if (ob == dialog_->choice_default_papersize)
1999 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2000 else if (ob == dialog_->input_paperoption)
2001 str = lyxrc.getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
2002 else if (ob == dialog_->check_autoreset_classopt)
2003 str = lyxrc.getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2009 void FormPreferences::OutputsMisc::update()
2011 fl_set_counter_value(dialog_->counter_line_len,
2012 lyxrc.ascii_linelen);
2013 fl_set_input(dialog_->input_tex_encoding,
2014 lyxrc.fontenc.c_str());
2015 fl_set_choice(dialog_->choice_default_papersize,
2016 lyxrc.default_papersize+1);
2017 fl_set_input(dialog_->input_ascii_roff,
2018 lyxrc.ascii_roff_command.c_str());
2019 fl_set_input(dialog_->input_checktex,
2020 lyxrc.chktex_command.c_str());
2021 fl_set_input(dialog_->input_paperoption,
2022 lyxrc.view_dvi_paper_option.c_str());
2023 fl_set_button(dialog_->check_autoreset_classopt,
2024 lyxrc.auto_reset_options);
2029 FormPreferences::Paths::Paths(FormPreferences & p)
2034 FD_preferences_paths const * FormPreferences::Paths::dialog()
2036 return dialog_.get();
2040 void FormPreferences::Paths::apply()
2042 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2043 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2045 int button = fl_get_button(dialog_->check_use_temp_dir);
2046 string str = fl_get_input(dialog_->input_temp_dir);
2047 if (!button) str.erase();
2049 lyxrc.use_tempdir = button;
2050 lyxrc.tempdir_path = str;
2052 button = fl_get_button(dialog_->check_last_files);
2053 str = fl_get_input(dialog_->input_lastfiles);
2054 if (!button) str.erase();
2056 lyxrc.check_lastfiles = button;
2057 lyxrc.lastfiles = str;
2058 lyxrc.num_lastfiles = static_cast<unsigned int>
2059 (fl_get_counter_value(dialog_->counter_lastfiles));
2061 button = fl_get_button(dialog_->check_make_backups);
2062 str = fl_get_input(dialog_->input_backup_path);
2063 if (!button) str.erase();
2065 lyxrc.make_backup = button;
2066 lyxrc.backupdir_path = str;
2068 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2075 void FormPreferences::Paths::build()
2077 dialog_.reset(build_preferences_paths(&parent_));
2079 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2080 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2081 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2082 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2083 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2084 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2085 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2087 // set up the feedback mechanism
2088 setPrehandler(dialog_->input_default_path);
2089 setPrehandler(dialog_->counter_lastfiles);
2090 setPrehandler(dialog_->input_template_path);
2091 setPrehandler(dialog_->check_last_files);
2092 setPrehandler(dialog_->input_lastfiles);
2093 setPrehandler(dialog_->check_make_backups);
2094 setPrehandler(dialog_->input_backup_path);
2095 setPrehandler(dialog_->input_serverpipe);
2096 setPrehandler(dialog_->input_temp_dir);
2097 setPrehandler(dialog_->check_use_temp_dir);
2102 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2106 if (ob == dialog_->input_default_path)
2107 str = lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2108 else if (ob == dialog_->input_template_path)
2109 str = lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2110 else if (ob == dialog_->check_use_temp_dir)
2111 str = lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2112 else if (ob == dialog_->input_temp_dir)
2113 str = lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2114 else if (ob == dialog_->check_last_files)
2115 str = lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2116 else if (ob == dialog_->input_lastfiles)
2117 str = lyxrc.getDescription(LyXRC::RC_LASTFILES);
2118 else if (ob == dialog_->counter_lastfiles)
2119 str = lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2120 else if (ob == dialog_->check_make_backups)
2121 str = lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2122 else if (ob == dialog_->input_backup_path)
2123 str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2124 else if (ob == dialog_->input_serverpipe) {
2125 str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2132 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2134 bool activate = true;
2136 // !ob if function is called from Paths::update() to de/activate
2138 // otherwise the function is called by an xforms CB via input().
2139 if (!ob || ob == dialog_->check_use_temp_dir) {
2140 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2141 setEnabled(dialog_->input_temp_dir, enable);
2144 if (!ob || ob == dialog_->check_last_files) {
2145 bool const enable = fl_get_button(dialog_->check_last_files);
2146 setEnabled(dialog_->input_lastfiles, enable);
2149 if (!ob || ob == dialog_->check_make_backups) {
2150 bool const enable = fl_get_button(dialog_->check_make_backups);
2151 setEnabled(dialog_->input_backup_path, enable);
2154 if (!ob || ob == dialog_->input_default_path) {
2155 string const name = fl_get_input(dialog_->input_default_path);
2156 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2157 parent_.postWarning(RWInfo::ErrorMessage());
2162 if (!ob || ob == dialog_->input_template_path) {
2163 string const name = fl_get_input(dialog_->input_template_path);
2164 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2165 parent_.postWarning(RWInfo::ErrorMessage());
2170 if (!ob || ob == dialog_->input_temp_dir) {
2171 string const name = fl_get_input(dialog_->input_temp_dir);
2172 if (fl_get_button(dialog_->check_make_backups)
2174 && !RWInfo::WriteableDir(name)) {
2175 parent_.postWarning(RWInfo::ErrorMessage());
2180 if (!ob || ob == dialog_->input_backup_path) {
2181 string const name = fl_get_input(dialog_->input_backup_path);
2182 if (fl_get_button(dialog_->check_make_backups)
2184 && !RWInfo::WriteableDir(name)) {
2185 parent_.postWarning(RWInfo::ErrorMessage());
2190 if (!ob || ob == dialog_->input_lastfiles) {
2191 string const name = fl_get_input(dialog_->input_lastfiles);
2192 if (fl_get_button(dialog_->check_last_files)
2194 && !RWInfo::WriteableFile(name)) {
2195 parent_.postWarning(RWInfo::ErrorMessage());
2200 if (!ob || ob == dialog_->input_serverpipe) {
2201 string const name = fl_get_input(dialog_->input_serverpipe);
2202 if (!name.empty()) {
2203 // strip off the extension
2204 string const str = ChangeExtension(name, "");
2205 if (!RWInfo::WriteableFile(str + ".in")) {
2206 parent_.postWarning(RWInfo::ErrorMessage());
2209 if (!RWInfo::WriteableFile(str + ".out")) {
2210 parent_.postWarning(RWInfo::ErrorMessage());
2216 if (ob == dialog_->button_default_path_browse) {
2217 parent_.browse(dialog_->input_default_path,
2218 _("Default path"), string());
2219 } else if (ob == dialog_->button_template_path_browse) {
2220 parent_.browse(dialog_->input_template_path,
2221 _("Template path"), string());
2222 } else if (ob == dialog_->button_temp_dir_browse) {
2223 parent_.browse(dialog_->input_temp_dir,
2224 _("Temp dir"), string());
2225 } else if (ob == dialog_->button_lastfiles_browse) {
2226 pair<string, string> dir(_("User|#U#u"), user_lyxdir);
2228 parent_.browse(dialog_->input_lastfiles,
2229 _("Lastfiles"), string(), dir);
2230 } else if (ob == dialog_->button_backup_path_browse) {
2231 parent_.browse(dialog_->input_backup_path,
2232 _("Backup path"), string());
2233 } else if (ob == dialog_->button_serverpipe_browse) {
2234 parent_.browse(dialog_->input_serverpipe,
2235 _("LyX Server pipes"), string());
2242 void FormPreferences::Paths::update()
2244 fl_set_input(dialog_->input_default_path,
2245 lyxrc.document_path.c_str());
2246 fl_set_input(dialog_->input_template_path,
2247 lyxrc.template_path.c_str());
2250 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
2252 fl_set_button(dialog_->check_make_backups,
2254 fl_set_input(dialog_->input_backup_path, str.c_str());
2257 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
2259 fl_set_button(dialog_->check_use_temp_dir,
2261 fl_set_input(dialog_->input_temp_dir, str.c_str());
2264 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
2266 fl_set_button(dialog_->check_last_files,
2267 lyxrc.check_lastfiles);
2268 fl_set_input(dialog_->input_lastfiles, str.c_str());
2269 fl_set_counter_value(dialog_->counter_lastfiles,
2270 lyxrc.num_lastfiles);
2272 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2274 // Activate/Deactivate the input fields dependent on the state of the
2280 FormPreferences::Printer::Printer(FormPreferences & p)
2285 FD_preferences_printer const * FormPreferences::Printer::dialog()
2287 return dialog_.get();
2291 void FormPreferences::Printer::apply() const
2293 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2294 lyxrc.print_command = fl_get_input(dialog_->input_command);
2295 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2296 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2297 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2298 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2299 lyxrc.print_file_extension =
2300 fl_get_input(dialog_->input_file_extension);
2301 lyxrc.print_spool_command =
2302 fl_get_input(dialog_->input_spool_command);
2303 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2304 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2305 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2306 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2307 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2308 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2309 lyxrc.print_extra_options =
2310 fl_get_input(dialog_->input_extra_options);
2311 lyxrc.print_spool_printerprefix =
2312 fl_get_input(dialog_->input_spool_prefix);
2313 lyxrc.print_paper_dimension_flag =
2314 fl_get_input(dialog_->input_paper_size);
2315 lyxrc.printer = fl_get_input(dialog_->input_name);
2320 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2324 if (ob == dialog_->input_command)
2325 str = lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2326 else if (ob == dialog_->check_adapt_output)
2327 str = lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2328 else if (ob == dialog_->input_to_printer)
2329 str = lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2330 else if (ob == dialog_->input_to_file)
2331 str = lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2332 else if (ob == dialog_->input_file_extension)
2333 str = lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2334 else if (ob == dialog_->input_extra_options)
2335 str = lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2336 else if (ob == dialog_->input_spool_command)
2337 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2338 else if (ob == dialog_->input_spool_prefix)
2339 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2340 else if (ob == dialog_->input_name)
2341 str = lyxrc.getDescription(LyXRC::RC_PRINTER);
2342 else if (ob == dialog_->input_even_pages)
2343 str = lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2344 else if (ob == dialog_->input_odd_pages)
2345 str = lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2346 else if (ob == dialog_->input_page_range)
2347 str = lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2348 else if (ob == dialog_->input_reverse)
2349 str = lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2350 else if (ob == dialog_->input_landscape)
2351 str = lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2352 else if (ob == dialog_->input_copies)
2353 str = lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2354 else if (ob == dialog_->input_collated)
2355 str = lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2356 else if (ob == dialog_->input_paper_type)
2357 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2358 else if (ob == dialog_->input_paper_size)
2359 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2365 void FormPreferences::Printer::build()
2367 dialog_.reset(build_preferences_printer(&parent_));
2369 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2370 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2371 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2372 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2373 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2374 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2375 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2376 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2377 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2378 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2379 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2380 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2381 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2382 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2383 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2384 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2385 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2387 // set up the feedback mechanism
2388 setPrehandler(dialog_->input_command);
2389 setPrehandler(dialog_->input_page_range);
2390 setPrehandler(dialog_->input_copies);
2391 setPrehandler(dialog_->input_reverse);
2392 setPrehandler(dialog_->input_to_printer);
2393 setPrehandler(dialog_->input_file_extension);
2394 setPrehandler(dialog_->input_spool_command);
2395 setPrehandler(dialog_->input_paper_type);
2396 setPrehandler(dialog_->input_even_pages);
2397 setPrehandler(dialog_->input_odd_pages);
2398 setPrehandler(dialog_->input_collated);
2399 setPrehandler(dialog_->input_landscape);
2400 setPrehandler(dialog_->input_to_file);
2401 setPrehandler(dialog_->input_extra_options);
2402 setPrehandler(dialog_->input_spool_prefix);
2403 setPrehandler(dialog_->input_paper_size);
2404 setPrehandler(dialog_->input_name);
2405 setPrehandler(dialog_->check_adapt_output);
2409 void FormPreferences::Printer::update()
2411 fl_set_button(dialog_->check_adapt_output,
2412 lyxrc.print_adapt_output);
2413 fl_set_input(dialog_->input_command,
2414 lyxrc.print_command.c_str());
2415 fl_set_input(dialog_->input_page_range,
2416 lyxrc.print_pagerange_flag.c_str());
2417 fl_set_input(dialog_->input_copies,
2418 lyxrc.print_copies_flag.c_str());
2419 fl_set_input(dialog_->input_reverse,
2420 lyxrc.print_reverse_flag.c_str());
2421 fl_set_input(dialog_->input_to_printer,
2422 lyxrc.print_to_printer.c_str());
2423 fl_set_input(dialog_->input_file_extension,
2424 lyxrc.print_file_extension.c_str());
2425 fl_set_input(dialog_->input_spool_command,
2426 lyxrc.print_spool_command.c_str());
2427 fl_set_input(dialog_->input_paper_type,
2428 lyxrc.print_paper_flag.c_str());
2429 fl_set_input(dialog_->input_even_pages,
2430 lyxrc.print_evenpage_flag.c_str());
2431 fl_set_input(dialog_->input_odd_pages,
2432 lyxrc.print_oddpage_flag.c_str());
2433 fl_set_input(dialog_->input_collated,
2434 lyxrc.print_collcopies_flag.c_str());
2435 fl_set_input(dialog_->input_landscape,
2436 lyxrc.print_landscape_flag.c_str());
2437 fl_set_input(dialog_->input_to_file,
2438 lyxrc.print_to_file.c_str());
2439 fl_set_input(dialog_->input_extra_options,
2440 lyxrc.print_extra_options.c_str());
2441 fl_set_input(dialog_->input_spool_prefix,
2442 lyxrc.print_spool_printerprefix.c_str());
2443 fl_set_input(dialog_->input_paper_size,
2444 lyxrc.print_paper_dimension_flag.c_str());
2445 fl_set_input(dialog_->input_name,
2446 lyxrc.printer.c_str());
2450 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2455 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2457 return dialog_.get();
2461 void FormPreferences::ScreenFonts::apply() const
2463 bool changed = false;
2465 string str = fl_get_input(dialog_->input_roman);
2466 if (lyxrc.roman_font_name != str) {
2468 lyxrc.roman_font_name = str;
2471 str = fl_get_input(dialog_->input_sans);
2472 if (lyxrc.sans_font_name != str) {
2474 lyxrc.sans_font_name = str;
2477 str = fl_get_input(dialog_->input_typewriter);
2478 if (lyxrc.typewriter_font_name != str) {
2480 lyxrc.typewriter_font_name = str;
2483 str = fl_get_input(dialog_->input_screen_encoding);
2484 if (lyxrc.font_norm != str) {
2486 lyxrc.font_norm = str;
2489 bool button = fl_get_button(dialog_->check_scalable);
2490 if (lyxrc.use_scalable_fonts != button) {
2492 lyxrc.use_scalable_fonts = button;
2495 unsigned int ivalue = static_cast<unsigned int>
2496 (fl_get_counter_value(dialog_->counter_zoom));
2497 if (lyxrc.zoom != ivalue) {
2499 lyxrc.zoom = ivalue;
2502 ivalue = static_cast<unsigned int>
2503 (fl_get_counter_value(dialog_->counter_dpi));
2504 if (lyxrc.dpi != ivalue) {
2509 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2510 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2512 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2515 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2516 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2518 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2521 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2522 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2524 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2527 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2528 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2530 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2533 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2534 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2536 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2539 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2540 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2542 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2545 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2546 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2548 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2551 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2552 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2554 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2557 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2558 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2560 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2563 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2564 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2566 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2570 // Now update the buffers
2571 // Can anything below here affect the redraw process?
2572 parent_.lv_->getLyXFunc()->dispatch(LFUN_SCREEN_FONT_UPDATE);
2577 void FormPreferences::ScreenFonts::build()
2579 dialog_.reset(build_preferences_screen_fonts(&parent_));
2581 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2582 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2584 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2585 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2586 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2587 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2588 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2589 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2590 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2591 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2592 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2593 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2594 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2595 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2596 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2597 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2598 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2599 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2601 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2602 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2603 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2604 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2605 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2606 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2607 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2608 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2609 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2610 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2612 // set up the feedback mechanism
2613 setPrehandler(dialog_->input_roman);
2614 setPrehandler(dialog_->input_sans);
2615 setPrehandler(dialog_->input_typewriter);
2616 setPrehandler(dialog_->counter_zoom);
2617 setPrehandler(dialog_->counter_dpi);
2618 setPrehandler(dialog_->check_scalable);
2619 setPrehandler(dialog_->input_screen_encoding);
2620 setPrehandler(dialog_->input_tiny);
2621 setPrehandler(dialog_->input_script);
2622 setPrehandler(dialog_->input_footnote);
2623 setPrehandler(dialog_->input_small);
2624 setPrehandler(dialog_->input_large);
2625 setPrehandler(dialog_->input_larger);
2626 setPrehandler(dialog_->input_largest);
2627 setPrehandler(dialog_->input_normal);
2628 setPrehandler(dialog_->input_huge);
2629 setPrehandler(dialog_->input_huger);
2634 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2638 if (ob == dialog_->input_roman)
2639 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2640 else if (ob == dialog_->input_sans)
2641 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2642 else if (ob == dialog_->input_typewriter)
2643 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2644 else if (ob == dialog_->check_scalable)
2645 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2646 else if (ob == dialog_->input_screen_encoding)
2647 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2648 else if (ob == dialog_->counter_zoom)
2649 str = lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2650 else if (ob == dialog_->counter_dpi)
2651 str = lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2652 else if (ob == dialog_->input_tiny
2653 || ob == dialog_->input_script
2654 || ob == dialog_->input_footnote
2655 || ob == dialog_->input_small
2656 || ob == dialog_->input_large
2657 || ob == dialog_->input_larger
2658 || ob == dialog_->input_larger
2659 || ob == dialog_->input_largest
2660 || ob == dialog_->input_normal
2661 || ob == dialog_->input_huge
2662 || ob == dialog_->input_huger)
2663 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2669 bool FormPreferences::ScreenFonts::input()
2671 bool activate = true;
2674 // Make sure that all fonts all have positive entries
2675 // Also note that an empty entry is returned as 0.0 by strToDbl
2676 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2677 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2678 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2679 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2680 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2681 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2682 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2683 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2684 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2685 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2687 str = _("Fonts must be positive!");
2689 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2690 // Fontsizes -- tiny < script < footnote etc.
2691 strToDbl(fl_get_input(dialog_->input_script)) ||
2692 strToDbl(fl_get_input(dialog_->input_script)) >
2693 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2694 strToDbl(fl_get_input(dialog_->input_footnote)) >
2695 strToDbl(fl_get_input(dialog_->input_small)) ||
2696 strToDbl(fl_get_input(dialog_->input_small)) >
2697 strToDbl(fl_get_input(dialog_->input_normal)) ||
2698 strToDbl(fl_get_input(dialog_->input_normal)) >
2699 strToDbl(fl_get_input(dialog_->input_large)) ||
2700 strToDbl(fl_get_input(dialog_->input_large)) >
2701 strToDbl(fl_get_input(dialog_->input_larger)) ||
2702 strToDbl(fl_get_input(dialog_->input_larger)) >
2703 strToDbl(fl_get_input(dialog_->input_largest)) ||
2704 strToDbl(fl_get_input(dialog_->input_largest)) >
2705 strToDbl(fl_get_input(dialog_->input_huge)) ||
2706 strToDbl(fl_get_input(dialog_->input_huge)) >
2707 strToDbl(fl_get_input(dialog_->input_huger))) {
2710 str = _("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2714 parent_.postWarning(str);
2720 void FormPreferences::ScreenFonts::update()
2722 fl_set_input(dialog_->input_roman,
2723 lyxrc.roman_font_name.c_str());
2724 fl_set_input(dialog_->input_sans,
2725 lyxrc.sans_font_name.c_str());
2726 fl_set_input(dialog_->input_typewriter,
2727 lyxrc.typewriter_font_name.c_str());
2728 fl_set_input(dialog_->input_screen_encoding,
2729 lyxrc.font_norm.c_str());
2730 fl_set_button(dialog_->check_scalable,
2731 lyxrc.use_scalable_fonts);
2732 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2733 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2734 fl_set_input(dialog_->input_tiny,
2735 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2736 fl_set_input(dialog_->input_script,
2737 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2738 fl_set_input(dialog_->input_footnote,
2739 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2740 fl_set_input(dialog_->input_small,
2741 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2742 fl_set_input(dialog_->input_normal,
2743 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2744 fl_set_input(dialog_->input_large,
2745 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2746 fl_set_input(dialog_->input_larger,
2747 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2748 fl_set_input(dialog_->input_largest,
2749 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2750 fl_set_input(dialog_->input_huge,
2751 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2752 fl_set_input(dialog_->input_huger,
2753 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2758 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2763 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2765 return dialog_.get();
2769 void FormPreferences::SpellOptions::apply()
2772 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2773 choice = strip(frontStrip(choice));
2775 lyxrc.isp_command = choice;
2778 // If spell checker == "none", all other input set to off.
2779 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2780 lyxrc.isp_use_alt_lang = false;
2781 lyxrc.isp_alt_lang.erase();
2783 lyxrc.isp_use_esc_chars = false;
2784 lyxrc.isp_esc_chars.erase();
2786 lyxrc.isp_use_pers_dict = false;
2787 lyxrc.isp_pers_dict.erase();
2789 lyxrc.isp_accept_compound = false;
2790 lyxrc.isp_use_input_encoding = false;
2793 int button = fl_get_button(dialog_->check_alt_lang);
2794 choice = fl_get_input(dialog_->input_alt_lang);
2795 if (button && choice.empty()) button = 0;
2796 if (!button) choice.erase();
2798 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2799 lyxrc.isp_alt_lang = choice;
2801 button = fl_get_button(dialog_->check_escape_chars);
2802 choice = fl_get_input(dialog_->input_escape_chars);
2803 if (button && choice.empty()) button = 0;
2804 if (!button) choice.erase();
2806 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2807 lyxrc.isp_esc_chars = choice;
2809 button = fl_get_button(dialog_->check_personal_dict);
2810 choice = fl_get_input(dialog_->input_personal_dict);
2811 if (button && choice.empty()) button = 0;
2812 if (!button) choice.erase();
2814 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2815 lyxrc.isp_pers_dict = choice;
2817 button = fl_get_button(dialog_->check_compound_words);
2818 lyxrc.isp_accept_compound = static_cast<bool>(button);
2820 button = fl_get_button(dialog_->check_input_enc);
2821 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2832 void FormPreferences::SpellOptions::build()
2834 dialog_.reset(build_preferences_spelloptions(&parent_));
2836 fl_addto_choice(dialog_->choice_spell_command,
2837 _(" ispell | aspell "));
2838 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2839 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2840 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2842 // set up the feedback mechanism
2843 setPrehandler(dialog_->choice_spell_command);
2844 setPrehandler(dialog_->check_alt_lang);
2845 setPrehandler(dialog_->input_alt_lang);
2846 setPrehandler(dialog_->check_escape_chars);
2847 setPrehandler(dialog_->input_escape_chars);
2848 setPrehandler(dialog_->check_personal_dict);
2849 setPrehandler(dialog_->input_personal_dict);
2850 setPrehandler(dialog_->button_personal_dict);
2851 setPrehandler(dialog_->check_compound_words);
2852 setPrehandler(dialog_->check_input_enc);
2857 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2861 if (ob == dialog_->choice_spell_command)
2862 str = lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2863 else if (ob == dialog_->check_alt_lang)
2864 str = lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2865 else if (ob == dialog_->input_alt_lang)
2866 str = lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2867 else if (ob == dialog_->check_escape_chars)
2868 str = lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2869 else if (ob == dialog_->input_escape_chars)
2870 str = lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2871 else if (ob == dialog_->check_personal_dict)
2872 str = lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2873 else if (ob == dialog_->input_personal_dict)
2874 str = lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2875 else if (ob == dialog_->check_compound_words)
2876 str = lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2877 else if (ob == dialog_->check_input_enc)
2878 str = lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2884 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2886 // !ob if function is called from updateSpellOptions() to de/activate
2888 // otherwise the function is called by an xforms CB via input().
2891 // If spell checker == "none", disable all input.
2892 if (!ob || ob == dialog_->choice_spell_command) {
2893 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2894 fl_deactivate_object(dialog_->check_alt_lang);
2895 fl_deactivate_object(dialog_->input_alt_lang);
2896 fl_deactivate_object(dialog_->check_escape_chars);
2897 fl_deactivate_object(dialog_->input_escape_chars);
2898 fl_deactivate_object(dialog_->check_personal_dict);
2899 fl_deactivate_object(dialog_->input_personal_dict);
2900 fl_deactivate_object(dialog_->check_compound_words);
2901 fl_deactivate_object(dialog_->check_input_enc);
2904 fl_activate_object(dialog_->check_alt_lang);
2905 fl_activate_object(dialog_->check_escape_chars);
2906 fl_activate_object(dialog_->check_personal_dict);
2907 fl_activate_object(dialog_->check_compound_words);
2908 fl_activate_object(dialog_->check_input_enc);
2913 if (!ob || ob == dialog_->check_alt_lang) {
2914 bool const enable = fl_get_button(dialog_->check_alt_lang);
2915 setEnabled(dialog_->input_alt_lang, enable);
2918 if (!ob || ob == dialog_->check_escape_chars) {
2919 bool const enable = fl_get_button(dialog_->check_escape_chars);
2920 setEnabled(dialog_->input_escape_chars, enable);
2923 if (!ob || ob == dialog_->check_personal_dict) {
2924 bool const enable = fl_get_button(dialog_->check_personal_dict);
2925 setEnabled(dialog_->input_personal_dict, enable);
2928 if (ob == dialog_->button_personal_dict) {
2929 parent_.browse(dialog_->input_personal_dict,
2930 _("Personal dictionary"), "*.ispell");
2933 return true; // All input is valid!
2937 void FormPreferences::SpellOptions::update()
2941 if (lyxrc.isp_command == "none")
2943 else if (lyxrc.isp_command == "ispell")
2945 else if (lyxrc.isp_command == "aspell")
2948 if (lyxrc.isp_command == "ispell")
2950 else if (lyxrc.isp_command == "aspell")
2953 fl_set_choice(dialog_->choice_spell_command, choice);
2956 if (lyxrc.isp_use_alt_lang) str = lyxrc.isp_alt_lang;
2958 fl_set_button(dialog_->check_alt_lang,
2959 lyxrc.isp_use_alt_lang);
2960 fl_set_input(dialog_->input_alt_lang, str.c_str());
2963 if (lyxrc.isp_use_esc_chars) str = lyxrc.isp_esc_chars;
2965 fl_set_button(dialog_->check_escape_chars,
2966 lyxrc.isp_use_esc_chars);
2967 fl_set_input(dialog_->input_escape_chars, str.c_str());
2970 if (lyxrc.isp_use_pers_dict) str = lyxrc.isp_pers_dict;
2972 fl_set_button(dialog_->check_personal_dict,
2973 lyxrc.isp_use_pers_dict);
2974 fl_set_input(dialog_->input_personal_dict, str.c_str());
2976 fl_set_button(dialog_->check_compound_words,
2977 lyxrc.isp_accept_compound);
2978 fl_set_button(dialog_->check_input_enc,
2979 lyxrc.isp_use_input_encoding);
2981 // Activate/Deactivate the input fields dependent on the state of the
2987 void FormPreferences::browse(FL_OBJECT * inpt,
2988 string const & title,
2989 string const & pattern,
2990 pair<string,string> const & dir1,
2991 pair<string,string> const & dir2)
2993 // Get the filename from the dialog
2994 string const filename = fl_get_input(inpt);
2996 // Show the file browser dialog
2997 string const new_filename =
2998 browseFile(lv_, filename, title, pattern, dir1, dir2);
3000 // Save the filename to the dialog
3001 if (new_filename != filename && !new_filename.empty()) {
3002 fl_set_input(inpt, new_filename.c_str());