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
15 #include FORMS_H_LOCATION
18 #pragma implementation
24 #include "FormPreferences.h"
25 #include "form_preferences.h"
26 #include "ButtonController.tmpl"
27 #include "input_validators.h"
36 #include "input_validators.h"
37 #include "xforms_helpers.h"
38 #include "helper_funcs.h"
39 #include "converter.h"
41 #include "support/lyxfunctional.h"
42 #include "support/lyxmanip.h"
43 #include "support/filetools.h"
44 #include "support/LAssert.h"
46 #include "graphics/GraphicsCache.h"
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_cancel);
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 fl_set_cursor_color(FL_DEFAULT_CURSOR,
429 GUI_COLOR_CURSOR, FL_WHITE);
430 fl_set_cursor_color(XC_question_arrow,
431 GUI_COLOR_CURSOR, FL_WHITE);
434 Dialogs::redrawGUI();
437 // Now do the same for the LyX LColors...
438 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
439 cit != lyxColorDB.end(); ++cit) {
440 LColor::color lc = lcolor.getFromGUIName(cit->getname());
441 if (lc == LColor::inherit) continue;
443 // Create a valid X11 name of the form "#rrggbb"
444 string const hexname = X11hexname(cit->color());
446 if (lcolor.getX11Name(lc) != hexname) {
448 << "FormPreferences::Colors::apply: "
449 << "resetting LColor " << lcolor.getGUIName(lc)
450 << " from \"" << lcolor.getX11Name(lc)
451 << "\" to \"" << hexname << "\"."
454 string const s = lcolor.getLyXName(lc) + string(" ") +
456 parent_.lv_->getLyXFunc()->dispatch(LFUN_SET_COLOR, s);
462 void FormPreferences::Colors::build()
464 dialog_.reset(parent_.build_colors());
466 fl_set_object_color(dialog_->button_color,
467 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
469 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
470 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
471 fl_set_dial_step(dialog_->dial_hue, 1.0);
472 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
474 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
475 fl_set_slider_step(dialog_->slider_saturation, 0.01);
476 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
478 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
479 fl_set_slider_step(dialog_->slider_value, 0.01);
480 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
482 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
483 fl_set_slider_step(dialog_->slider_red, 1.0);
484 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
486 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
487 fl_set_slider_step(dialog_->slider_green, 1.0);
488 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
490 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
491 fl_set_slider_step(dialog_->slider_blue, 1.0);
492 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
494 // set up the feedback mechanism
495 setPrehandler(dialog_->browser_lyx_objs);
496 setPrehandler(dialog_->button_color);
497 setPrehandler(dialog_->button_modify);
498 setPrehandler(dialog_->dial_hue);
499 setPrehandler(dialog_->slider_saturation);
500 setPrehandler(dialog_->slider_value);
501 setPrehandler(dialog_->slider_red);
502 setPrehandler(dialog_->slider_green);
503 setPrehandler(dialog_->slider_blue);
504 setPrehandler(dialog_->radio_rgb);
505 setPrehandler(dialog_->radio_hsv);
509 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
513 if (ob == dialog_->browser_lyx_objs) {
514 str = N_("LyX objects that can be assigned a color.");
516 } else if (ob == dialog_->button_modify) {
517 str = N_("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
519 } else if (ob == dialog_->dial_hue ||
520 ob == dialog_->slider_saturation ||
521 ob == dialog_->slider_value ||
522 ob == dialog_->slider_red ||
523 ob == dialog_->slider_green ||
524 ob == dialog_->slider_blue) {
525 str = N_("Find a new color.");
527 } else if (ob == dialog_->radio_rgb ||
528 ob == dialog_->radio_hsv) {
529 str = N_("Toggle between RGB and HSV color spaces.");
536 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
538 if (ob == dialog_->browser_lyx_objs) {
541 } else if (ob == dialog_->dial_hue ||
542 ob == dialog_->slider_saturation ||
543 ob == dialog_->slider_value) {
546 } else if (ob == dialog_->slider_red ||
547 ob == dialog_->slider_green ||
548 ob == dialog_->slider_blue) {
551 } else if (ob == dialog_->radio_rgb ||
552 ob == dialog_->radio_hsv) {
555 } else if (ob == dialog_->button_modify) {
561 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
565 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
569 hsv.v = min(1.0, max(0.0, hsv.v));
572 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
576 void FormPreferences::Colors::InputBrowserLyX() const
578 vector<NamedColor>::size_type const selLyX =
579 fl_get_browser(dialog_->browser_lyx_objs);
580 if (selLyX < 1) return;
582 // Is the choice an Xforms color...
585 if (selLyX - 1 < xformsColorDB.size()) {
586 vector<XformsColor>::size_type const i = selLyX - 1;
587 col = xformsColorDB[i].color();
589 // or a LyX Logical color?
591 vector<NamedColor>::size_type const i = selLyX - 1 -
592 xformsColorDB.size();
593 col = lyxColorDB[i].color();
596 fl_freeze_form(dialog_->form);
598 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
599 fl_redraw_object(dialog_->button_color);
601 // Display either RGB or HSV but not both!
604 // Deactivate the modify button to begin with...
605 setEnabled(dialog_->button_modify, false);
607 fl_unfreeze_form(dialog_->form);
611 void FormPreferences::Colors::InputHSV()
613 double const hue = fl_get_dial_value(dialog_->dial_hue);
614 double const sat = fl_get_slider_value(dialog_->slider_saturation);
615 double const val = fl_get_slider_value(dialog_->slider_value);
617 int const h = int(hue);
618 int const s = int(100.0 * sat);
619 int const v = int(100.0 * val);
621 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
623 fl_set_object_label(dialog_->text_color_values, label.c_str());
625 RGBColor col = HSVColor(hue, sat, val);
627 fl_freeze_form(dialog_->form);
629 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
630 fl_redraw_object(dialog_->button_color);
632 col = HSVColor(hue, 1.0, 1.0);
633 col.r = max(col.r, 0);
634 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
635 fl_redraw_object(dialog_->dial_hue);
637 // Ascertain whether to activate the Modify button.
638 vector<NamedColor>::size_type const selLyX =
639 fl_get_browser(dialog_->browser_lyx_objs);
641 fl_unfreeze_form(dialog_->form);
642 if (selLyX < 1) return;
644 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
647 // Is the choice an Xforms color...
648 if (selLyX - 1 < xformsColorDB.size()) {
649 vector<XformsColor>::size_type const i = selLyX - 1;
650 modify = (xformsColorDB[i].color() != col);
652 // or a LyX Logical color?
654 vector<NamedColor>::size_type const i = selLyX - 1 -
655 xformsColorDB.size();
656 modify = (lyxColorDB[i].color() != col);
659 setEnabled(dialog_->button_modify, modify);
663 void FormPreferences::Colors::InputRGB()
665 int const red = int(fl_get_slider_value(dialog_->slider_red));
666 int const green = int(fl_get_slider_value(dialog_->slider_green));
667 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
669 string const label = tostr(red) + string(", ") + tostr(green) +
670 string(", ") + tostr(blue);
671 fl_set_object_label(dialog_->text_color_values, label.c_str());
673 fl_freeze_form(dialog_->form);
675 RGBColor col = RGBColor(red, green, blue);
676 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
677 fl_redraw_object(dialog_->button_color);
679 // Ascertain whether to activate the Modify button.
680 vector<NamedColor>::size_type const selLyX =
681 fl_get_browser(dialog_->browser_lyx_objs);
683 fl_unfreeze_form(dialog_->form);
684 if (selLyX < 1) return;
688 // Is the choice an Xforms color...
689 if (selLyX - 1 < xformsColorDB.size()) {
690 vector<XformsColor>::size_type const i = selLyX - 1;
691 modify = (xformsColorDB[i].color() != col);
693 // or a LyX Logical color?
695 vector<NamedColor>::size_type const i = selLyX - 1 -
696 xformsColorDB.size();
697 modify = (lyxColorDB[i].color() != col);
700 setEnabled(dialog_->button_modify, modify);
704 void FormPreferences::Colors::LoadBrowserLyX()
706 if (!dialog_->browser_lyx_objs->visible) return;
708 // First, define the modifiable xforms colors
709 xformsColorDB.clear();
712 xcol.name = _("GUI background");
713 xcol.colorID = FL_COL1;
714 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
716 xformsColorDB.push_back(xcol);
718 xcol.name = _("GUI text");
719 xcol.colorID = FL_BLACK;
720 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
722 xformsColorDB.push_back(xcol);
724 xcol.name = _("GUI selection");
725 xcol.colorID = FL_YELLOW;
726 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
728 xformsColorDB.push_back(xcol);
730 xcol.name = _("GUI pointer");
731 xcol.colorID = GUI_COLOR_CURSOR;
732 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
734 xformsColorDB.push_back(xcol);
736 // Now create the the LyX LColors database
738 for (int i=0; i<LColor::ignore; ++i) {
739 LColor::color lc = static_cast<LColor::color>(i);
740 if (lc == LColor::none
741 || lc == LColor::black
742 || lc == LColor::white
744 || lc == LColor::green
745 || lc == LColor::blue
746 || lc == LColor::cyan
747 || lc == LColor::magenta
748 || lc == LColor::yellow
749 || lc == LColor::inherit
750 || lc == LColor::ignore) continue;
752 string const name = lcolor.getX11Name(lc);
753 Display * display = fl_get_display();;
754 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
757 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
759 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
760 << "LColor " << lcolor.getLyXName(lc)
761 << ": X can't find color \"" << name
762 << "\". Set to \"black\"!" << endl;
764 string const arg = lcolor.getLyXName(lc) + " black";
765 parent_.lv_->getLyXFunc()->
766 dispatch(LFUN_SET_COLOR, arg);
770 // X has found the color. Now find the "appropriate" X11 name
773 // Note that X stores the RGB values in the range 0 - 65535
774 // whilst we require them in the range 0 - 255.
776 col.r = xcol.red / 256;
777 col.g = xcol.green / 256;
778 col.b = xcol.blue / 256;
780 // Create a valid X11 name of the form "#rrggbb" and change the
781 // LColor X11name to this. Don't want to trigger a redraw,
782 // as we're just changing the name not the RGB values.
783 // Also reset the system_lcolor names, so that we don't output
784 // unnecessary changes.
785 string const hexname = X11hexname(col);
787 if (lcolor.getX11Name(lc) != hexname) {
788 lcolor.setColor(lc, hexname);
789 system_lcolor.setColor(lc, hexname);
792 // Finally, push the color onto the database
793 NamedColor ncol(lcolor.getGUIName(lc), col);
794 lyxColorDB.push_back(ncol);
797 // Now construct the browser
798 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
799 fl_freeze_form(dialog_->form);
800 fl_clear_browser(colbr);
801 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
802 cit != xformsColorDB.end(); ++cit) {
803 fl_addto_browser(colbr, cit->getname().c_str());
805 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
806 cit != lyxColorDB.end(); ++cit) {
807 fl_addto_browser(colbr, cit->getname().c_str());
810 // just to be safe...
811 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
812 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
813 fl_unfreeze_form(dialog_->form);
819 void FormPreferences::Colors::Modify()
821 vector<NamedColor>::size_type const selLyX =
822 fl_get_browser(dialog_->browser_lyx_objs);
823 if (selLyX < 1) return;
826 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
828 // Is the choice an Xforms color...
829 if (selLyX - 1 < xformsColorDB.size()) {
830 vector<XformsColor>::size_type const i = selLyX - 1;
831 xformsColorDB[i].r = col.r;
832 xformsColorDB[i].g = col.g;
833 xformsColorDB[i].b = col.b;
835 // or a LyX Logical color?
837 vector<NamedColor>::size_type const i = selLyX - 1 -
838 xformsColorDB.size();
839 lyxColorDB[i].r = col.r;
840 lyxColorDB[i].g = col.g;
841 lyxColorDB[i].b = col.b;
844 fl_freeze_form(dialog_->form);
845 setEnabled(dialog_->button_modify, false);
846 fl_unfreeze_form(dialog_->form);
850 void FormPreferences::Colors::SwitchColorSpace() const
852 bool const hsv = fl_get_button(dialog_->radio_hsv);
855 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
857 fl_freeze_form(dialog_->form);
860 fl_hide_object(dialog_->slider_red);
861 fl_hide_object(dialog_->slider_blue);
862 fl_hide_object(dialog_->slider_green);
863 fl_show_object(dialog_->dial_hue);
864 fl_show_object(dialog_->slider_saturation);
865 fl_show_object(dialog_->slider_value);
867 HSVColor hsv = HSVColor(col);
868 hsv.h = max(hsv.h, 0.0);
870 fl_set_dial_value(dialog_->dial_hue, hsv.h);
871 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
872 fl_set_slider_value(dialog_->slider_value, hsv.v);
874 col = HSVColor(hsv.h, 1.0, 1.0);
875 col.r = max(col.r,0);
876 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
877 fl_redraw_object(dialog_->dial_hue);
879 // Adjust the label a bit, but not the actual values.
880 // Means that toggling from one space to the other has no
881 // effect on the final color.
882 int const h = int(hsv.h);
883 int const s = int(100*hsv.s);
884 int const v = int(100*hsv.v);
885 string const label = tostr(h) + string(", ") + tostr(s) +
886 string(", ") + tostr(v);
887 fl_set_object_label(dialog_->text_color_values, label.c_str());
890 fl_show_object(dialog_->slider_red);
891 fl_show_object(dialog_->slider_blue);
892 fl_show_object(dialog_->slider_green);
893 fl_hide_object(dialog_->dial_hue);
894 fl_hide_object(dialog_->slider_saturation);
895 fl_hide_object(dialog_->slider_value);
897 fl_set_slider_value(dialog_->slider_red, col.r);
898 fl_set_slider_value(dialog_->slider_green, col.g);
899 fl_set_slider_value(dialog_->slider_blue, col.b);
901 // Adjust the label a bit. Same reasoning as above.
902 int const r = int(col.r);
903 int const g = int(col.g);
904 int const b = int(col.b);
905 string const label = tostr(r) + string(", ") + tostr(g) +
906 string(", ") + tostr(b);
907 fl_set_object_label(dialog_->text_color_values, label.c_str());
910 fl_unfreeze_form(dialog_->form);
913 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
917 ostr << "#" << std::setbase(16) << setfill('0')
922 return ostr.str().c_str();
926 FormPreferences::Converters::Converters(FormPreferences & p)
931 FD_form_converters const * FormPreferences::Converters::dialog()
933 return dialog_.get();
937 void FormPreferences::Converters::apply() const
939 converters = local_converters;
940 converters.update(formats);
941 converters.buildGraph();
945 void FormPreferences::Converters::build()
947 dialog_.reset(parent_.build_converters());
949 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
950 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
952 // set up the feedback mechanism
953 setPrehandler(dialog_->browser_all);
954 setPrehandler(dialog_->button_delete);
955 setPrehandler(dialog_->button_add);
956 setPrehandler(dialog_->input_converter);
957 setPrehandler(dialog_->choice_from);
958 setPrehandler(dialog_->choice_to);
959 setPrehandler(dialog_->input_flags);
964 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
968 if (ob == dialog_->browser_all) {
969 str = N_("All the currently defined converters known to LyX.");
970 } else if (ob == dialog_->choice_from) {
971 str = N_("Convert \"from\" this format");
972 } else if (ob == dialog_->choice_to) {
973 str = N_("Convert \"to\" this format");
974 } else if (ob == dialog_->input_converter) {
975 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.");
976 } else if (ob == dialog_->input_flags) {
977 str = N_("Flags that control the converter behavior");
978 } else if (ob == dialog_->button_delete) {
979 str = N_("Remove the current converter from the list of available converters. Note: you must then \"Apply\" the change.");
980 } else if (ob == dialog_->button_add) {
981 if (string(ob->label) == _("Add"))
982 str = N_("Add the current converter to the list of available converters. Note: you must then \"Apply\" the change.");
984 str = N_("Modify the contents of the current converter. Note: you must then \"Apply\" the change.");
991 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
993 if (ob == dialog_->browser_all) {
996 } else if (ob == dialog_->choice_from
997 || ob == dialog_->choice_to
998 || ob == dialog_->input_converter
999 || ob == dialog_->input_flags) {
1002 } else if (ob == dialog_->button_add) {
1005 } else if (ob == dialog_->button_delete) {
1013 void FormPreferences::Converters::update()
1015 local_converters = converters;
1016 local_converters.update(local_formats);
1021 void FormPreferences::Converters::UpdateBrowser()
1023 local_converters.sort();
1025 fl_freeze_form(dialog_->form);
1026 fl_clear_browser(dialog_->browser_all);
1027 for (::Converters::const_iterator cit = local_converters.begin();
1028 cit != local_converters.end(); ++cit) {
1029 string const name = cit->From->prettyname() + " -> "
1030 + cit->To->prettyname();
1031 fl_addto_browser(dialog_->browser_all, name.c_str());
1034 fl_unfreeze_form(dialog_->form);
1038 bool FormPreferences::Converters::Add()
1040 string const from = GetFrom();
1041 string const to = GetTo();
1042 string const command = fl_get_input(dialog_->input_converter);
1043 string const flags = fl_get_input(dialog_->input_flags);
1045 Converter const * old = local_converters.getConverter(from, to);
1046 local_converters.add(from, to, command, flags);
1048 local_converters.updateLast(local_formats);
1051 setEnabled(dialog_->button_add, false);
1057 bool FormPreferences::Converters::Browser()
1059 int const i = fl_get_browser(dialog_->browser_all);
1060 if (i <= 0) return false;
1062 fl_freeze_form(dialog_->form);
1064 Converter const & c = local_converters.get(i - 1);
1065 int j = local_formats.getNumber(c.from);
1067 fl_set_choice(dialog_->choice_from, j + 1);
1069 j = local_formats.getNumber(c.to);
1071 fl_set_choice(dialog_->choice_to, j + 1);
1073 fl_set_input(dialog_->input_converter, c.command.c_str());
1074 fl_set_input(dialog_->input_flags, c.flags.c_str());
1076 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1077 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1079 setEnabled(dialog_->button_add, false);
1080 setEnabled(dialog_->button_delete, true);
1082 fl_unfreeze_form(dialog_->form);
1087 bool FormPreferences::Converters::erase()
1089 string const from = GetFrom();
1090 string const to = GetTo();
1092 local_converters.erase(from, to);
1098 bool FormPreferences::Converters::Input()
1100 string const from = GetFrom();
1101 string const to = GetTo();
1102 int const sel = local_converters.getNumber(from, to);
1104 fl_freeze_form(dialog_->form);
1107 fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
1108 fl_set_button_shortcut(dialog_->button_add,
1109 scex(_("Add|#A")), 1);
1111 fl_deselect_browser(dialog_->browser_all);
1112 setEnabled(dialog_->button_delete, false);
1115 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1116 fl_set_button_shortcut(dialog_->button_add,
1117 scex(_("Modify|#M")), 1);
1119 int top = max(sel-5, 0);
1120 fl_set_browser_topline(dialog_->browser_all, top);
1121 fl_select_browser_line(dialog_->browser_all, sel+1);
1122 setEnabled(dialog_->button_delete, true);
1125 string const command = strip(fl_get_input(dialog_->input_converter));
1126 bool const enable = !(command.empty() || from == to);
1127 setEnabled(dialog_->button_add, enable);
1129 fl_unfreeze_form(dialog_->form);
1134 string const FormPreferences::Converters::GetFrom() const
1136 ::Formats::FormatList::size_type const i =
1137 fl_get_choice(dialog_->choice_from);
1139 if (i > 0 && i <= local_formats.size())
1140 return local_formats.get(i - 1).name();
1142 lyxerr << "FormPreferences::Converters::GetFrom: No choice!"
1149 string const FormPreferences::Converters::GetTo() const
1151 ::Formats::FormatList::size_type const i =
1152 fl_get_choice(dialog_->choice_to);
1154 if (i > 0 && i <= local_formats.size())
1155 return local_formats.get(i - 1).name();
1157 lyxerr << "FormPreferences::Converters::GetTo: No choice!"
1164 void FormPreferences::Converters::UpdateChoices() const
1167 for (::Formats::const_iterator cit = local_formats.begin();
1168 cit != local_formats.end(); ++cit) {
1169 if (!choice.empty())
1173 choice += cit->prettyname();
1177 fl_clear_choice(dialog_->choice_from);
1178 fl_addto_choice(dialog_->choice_from, choice.c_str());
1180 fl_clear_choice(dialog_->choice_to);
1181 fl_addto_choice(dialog_->choice_to, choice.c_str());
1185 FormPreferences::Formats::Formats(FormPreferences & p)
1190 FD_form_formats const * FormPreferences::Formats::dialog()
1192 return dialog_.get();
1196 void FormPreferences::Formats::apply() const
1198 formats = local_formats;
1202 void FormPreferences::Formats::build()
1204 dialog_.reset(parent_.build_formats());
1206 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1207 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1208 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1209 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1210 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1212 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1214 // set up the feedback mechanism
1215 setPrehandler(dialog_->browser_all);
1216 setPrehandler(dialog_->input_format);
1217 setPrehandler(dialog_->input_gui_name);
1218 setPrehandler(dialog_->button_delete);
1219 setPrehandler(dialog_->button_add);
1220 setPrehandler(dialog_->input_extension);
1221 setPrehandler(dialog_->input_viewer);
1222 setPrehandler(dialog_->input_shrtcut);
1227 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1231 if (ob == dialog_->browser_all) {
1232 str = N_("All the currently defined formats known to LyX.");
1233 } else if (ob == dialog_->input_format) {
1234 str = N_("The format identifier.");
1235 } else if (ob == dialog_->input_gui_name) {
1236 str = N_("The format name as it will appear in the menus.");
1237 } else if (ob == dialog_->input_shrtcut) {
1238 str = N_("The keyboard accelerator. Use a letter in the GUI name. Case sensitive.");
1239 } else if (ob == dialog_->input_extension) {
1240 str = N_("Used to recognize the file. E.g., ps, pdf, tex.");
1241 } else if (ob == dialog_->input_viewer) {
1242 str = N_("The command used to launch the viewer application.");
1243 } else if (ob == dialog_->button_delete) {
1244 str = N_("Remove the current format from the list of available formats. Note: you must then \"Apply\" the change.");
1245 } else if (ob == dialog_->button_add) {
1246 if (string(ob->label) == _("Add"))
1247 str = N_("Add the current format to the list of available formats. Note: you must then \"Apply\" the change.");
1249 str = N_("Modify the contents of the current format. Note: you must then \"Apply\" the change.");
1256 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1258 if (ob == dialog_->browser_all) {
1261 } else if (ob == dialog_->input_format
1262 || ob == dialog_->input_gui_name
1263 || ob == dialog_->input_shrtcut
1264 || ob == dialog_->input_extension
1265 || ob == dialog_->input_viewer) {
1268 } else if (ob == dialog_->button_add) {
1271 } else if (ob == dialog_->button_delete) {
1279 void FormPreferences::Formats::update()
1281 local_formats = formats;
1286 void FormPreferences::Formats::UpdateBrowser()
1288 local_formats.sort();
1290 fl_freeze_form(dialog_->form);
1291 fl_deselect_browser(dialog_->browser_all);
1292 fl_clear_browser(dialog_->browser_all);
1293 for (::Formats::const_iterator cit = local_formats.begin();
1294 cit != local_formats.end(); ++cit)
1295 fl_addto_browser(dialog_->browser_all,
1296 cit->prettyname().c_str());
1299 fl_unfreeze_form(dialog_->form);
1301 // Mustn't forget to update the Formats available to the converters_
1302 parent_.converters_.UpdateChoices();
1303 local_converters.update(local_formats);
1307 bool FormPreferences::Formats::Add()
1309 string const name = fl_get_input(dialog_->input_format);
1310 string const prettyname = fl_get_input(dialog_->input_gui_name);
1311 string const extension = fl_get_input(dialog_->input_extension);
1312 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1313 string const viewer = fl_get_input(dialog_->input_viewer);
1315 Format const * old = local_formats.getFormat(name);
1316 string const old_prettyname = old ? old->prettyname() : string();
1317 local_formats.add(name, extension, prettyname, shortcut);
1318 local_formats.setViewer(name, viewer);
1319 if (!old || prettyname != old_prettyname) {
1322 parent_.converters_.UpdateBrowser();
1324 setEnabled(dialog_->button_add, false);
1330 bool FormPreferences::Formats::Browser()
1332 int const i = fl_get_browser(dialog_->browser_all);
1333 if (i <= 0) return false;
1335 fl_freeze_form(dialog_->form);
1337 Format const & f = local_formats.get(i - 1);
1339 fl_set_input(dialog_->input_format, f.name().c_str());
1340 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1341 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1342 fl_set_input(dialog_->input_extension, f.extension().c_str());
1343 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1345 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1346 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1348 setEnabled(dialog_->button_add, false);
1349 setEnabled(dialog_->button_delete, true);
1351 fl_unfreeze_form(dialog_->form);
1356 bool FormPreferences::Formats::erase()
1358 string const name = fl_get_input(dialog_->input_format);
1360 if (local_converters.formatIsUsed(name)) {
1361 parent_.postWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
1362 setEnabled(dialog_->button_delete, false);
1366 local_formats.erase(name);
1372 bool FormPreferences::Formats::Input()
1374 string const name = fl_get_input(dialog_->input_format);
1375 int const sel = local_formats.getNumber(name);
1376 fl_freeze_form(dialog_->form);
1379 fl_set_object_label(dialog_->button_add,
1381 fl_set_button_shortcut(dialog_->button_add,
1382 scex(_("Add|#A")), 1);
1384 fl_deselect_browser(dialog_->browser_all);
1385 setEnabled(dialog_->button_delete, false);
1388 fl_set_object_label(dialog_->button_add,
1389 idex(_("Modify|#M")));
1390 fl_set_button_shortcut(dialog_->button_add,
1391 scex(_("Modify|#M")), 1);
1393 int const top = max(sel-5, 0);
1394 fl_set_browser_topline(dialog_->browser_all, top);
1395 fl_select_browser_line(dialog_->browser_all, sel+1);
1397 setEnabled(dialog_->button_add, true);
1398 setEnabled(dialog_->button_delete, true);
1401 string const prettyname = fl_get_input(dialog_->input_gui_name);
1402 bool const enable = !(name.empty() || prettyname.empty());
1403 setEnabled(dialog_->button_add, enable);
1405 fl_unfreeze_form(dialog_->form);
1410 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1415 FD_form_inputs_misc const * FormPreferences::InputsMisc::dialog()
1417 return dialog_.get();
1421 void FormPreferences::InputsMisc::apply() const
1423 lyxrc.date_insert_format =
1424 fl_get_input(dialog_->input_date_format);
1428 void FormPreferences::InputsMisc::build()
1430 dialog_.reset(parent_.build_inputs_misc());
1432 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1434 // set up the feedback mechanism
1435 setPrehandler(dialog_->input_date_format);
1440 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1444 if (ob == dialog_->input_date_format)
1445 str = lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1451 void FormPreferences::InputsMisc::update()
1453 fl_set_input(dialog_->input_date_format,
1454 lyxrc.date_insert_format.c_str());
1458 FormPreferences::Interface::Interface(FormPreferences & p)
1463 FD_form_interface const * FormPreferences::Interface::dialog()
1465 return dialog_.get();
1469 void FormPreferences::Interface::apply() const
1471 lyxrc.popup_normal_font =
1472 fl_get_input(dialog_->input_popup_normal_font);
1473 lyxrc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1474 lyxrc.popup_font_encoding =
1475 fl_get_input(dialog_->input_popup_font_encoding);
1476 lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
1477 lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
1478 lyxrc.override_x_deadkeys =
1479 fl_get_button(dialog_->check_override_x_dead_keys);
1483 void FormPreferences::Interface::build()
1485 dialog_.reset(parent_.build_interface());
1487 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1488 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1489 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1490 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1491 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1493 // set up the feedback mechanism
1494 setPrehandler(dialog_->input_popup_normal_font);
1495 setPrehandler(dialog_->input_popup_bold_font);
1496 setPrehandler(dialog_->input_popup_font_encoding);
1497 setPrehandler(dialog_->input_bind_file);
1498 setPrehandler(dialog_->button_bind_file_browse);
1499 setPrehandler(dialog_->input_ui_file);
1500 setPrehandler(dialog_->button_ui_file_browse);
1501 setPrehandler(dialog_->check_override_x_dead_keys);
1506 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1510 if (ob == dialog_->input_popup_normal_font)
1511 str = lyxrc.getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1512 else if (ob == dialog_->input_popup_bold_font)
1513 str = lyxrc.getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1514 else if (ob == dialog_->input_popup_font_encoding)
1515 str = lyxrc.getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1516 else if (ob == dialog_->input_bind_file)
1517 str = lyxrc.getDescription(LyXRC::RC_BINDFILE);
1518 else if (ob == dialog_->input_ui_file)
1519 str = lyxrc.getDescription(LyXRC::RC_UIFILE);
1520 else if (ob == dialog_->check_override_x_dead_keys)
1521 str = lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1527 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1529 if (ob == dialog_->button_bind_file_browse) {
1530 string dir = AddName(system_lyxdir, "bind");
1531 string name = N_("Sys Bind|#S#s");
1532 pair<string,string> dir1(name, dir);
1534 dir = AddName(user_lyxdir, "bind");
1535 name = N_("User Bind|#U#u");
1536 pair<string,string> dir2(name, dir);
1538 parent_.browse(dialog_->input_bind_file,
1539 N_("Bind file"), "*.bind", dir1, dir2);
1541 } else if (ob == dialog_->button_ui_file_browse) {
1542 string dir = AddName(system_lyxdir, "ui");
1543 string name = N_("Sys UI|#S#s");
1544 pair<string,string> dir1(name, dir);
1546 dir = AddName(user_lyxdir, "ui");
1547 name = N_("User UI|#U#u");
1548 pair<string,string> dir2(name, dir);
1550 parent_.browse(dialog_->input_ui_file,
1551 N_("UI file"), "*.ui", dir1, dir2);
1558 void FormPreferences::Interface::update()
1560 fl_set_input(dialog_->input_popup_normal_font,
1561 lyxrc.popup_normal_font.c_str());
1562 fl_set_input(dialog_->input_popup_bold_font,
1563 lyxrc.popup_bold_font.c_str());
1564 fl_set_input(dialog_->input_popup_font_encoding,
1565 lyxrc.popup_font_encoding.c_str());
1566 fl_set_input(dialog_->input_bind_file,
1567 lyxrc.bind_file.c_str());
1568 fl_set_input(dialog_->input_ui_file,
1569 lyxrc.ui_file.c_str());
1570 fl_set_button(dialog_->check_override_x_dead_keys,
1571 lyxrc.override_x_deadkeys);
1575 FormPreferences::Language::Language(FormPreferences & p)
1580 FD_form_language const * FormPreferences::Language::dialog()
1582 return dialog_.get();
1586 void FormPreferences::Language::apply()
1588 lyxrc.default_language = combo_default_lang->getline();
1590 int button = fl_get_button(dialog_->check_use_kbmap);
1591 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1592 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1594 button = !(name_1.empty() && name_2.empty());
1595 lyxrc.use_kbmap = static_cast<bool>(button);
1597 if (lyxrc.use_kbmap) {
1598 lyxrc.primary_kbmap = name_1;
1599 lyxrc.secondary_kbmap = name_2;
1602 button = fl_get_button(dialog_->check_rtl_support);
1603 lyxrc.rtl_support = static_cast<bool>(button);
1605 button = fl_get_button(dialog_->check_mark_foreign);
1606 lyxrc.mark_foreign_language = static_cast<bool>(button);
1608 button = fl_get_button(dialog_->check_auto_begin);
1609 lyxrc.language_auto_begin = static_cast<bool>(button);
1611 button = fl_get_button(dialog_->check_auto_end);
1612 lyxrc.language_auto_end = static_cast<bool>(button);
1614 button = fl_get_button(dialog_->check_use_babel);
1615 lyxrc.language_use_babel = static_cast<bool>(button);
1617 button = fl_get_button(dialog_->check_global_options);
1618 lyxrc.language_global_options = static_cast<bool>(button);
1620 lyxrc.language_package = fl_get_input(dialog_->input_package);
1621 lyxrc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1622 lyxrc.language_command_end = fl_get_input(dialog_->input_command_end);
1624 // Ensure that all is self-consistent.
1629 void FormPreferences::Language::build()
1631 dialog_.reset(parent_.build_language());
1633 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1634 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1635 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1637 // The default_language is a combo-box and has to be inserted manually
1638 fl_freeze_form(dialog_->form);
1639 fl_addto_form(dialog_->form);
1641 FL_OBJECT * obj = dialog_->choice_default_lang;
1642 fl_deactivate_object(dialog_->choice_default_lang);
1643 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1644 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
1645 parent_.lang_opts_tab_->tabfolder_inner,
1646 parent_.dialog_->tabfolder_prefs);
1647 combo_default_lang->shortcut("#L",1);
1648 combo_default_lang->setcallback(ComboCB, &parent_);
1650 for (Languages::const_iterator cit = languages.begin();
1651 cit != languages.end(); ++cit) {
1652 combo_default_lang->addto(cit->second.lang());
1656 fl_unfreeze_form(dialog_->form);
1658 // set up the feedback mechanism
1659 setPrehandler(dialog_->input_package);
1660 setPrehandler(dialog_->check_use_kbmap);
1662 // This is safe, as nothing is done to the pointer, other than
1663 // to use its address in a block-if statement.
1664 // No it's not! Leads to crash.
1666 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1667 // C_FormPreferencesFeedbackCB);
1669 setPrehandler(dialog_->input_kbmap1);
1670 setPrehandler(dialog_->input_kbmap2);
1671 setPrehandler(dialog_->check_rtl_support);
1672 setPrehandler(dialog_->check_mark_foreign);
1673 setPrehandler(dialog_->check_auto_begin);
1674 setPrehandler(dialog_->check_auto_end);
1675 setPrehandler(dialog_->check_use_babel);
1676 setPrehandler(dialog_->check_global_options);
1677 setPrehandler(dialog_->input_command_begin);
1678 setPrehandler(dialog_->input_command_end);
1680 // Activate/Deactivate the input fields dependent on the state of the
1687 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1691 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1692 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1693 else if (ob == dialog_->check_use_kbmap)
1694 str = lyxrc.getDescription(LyXRC::RC_KBMAP);
1695 else if (ob == dialog_->input_kbmap1)
1696 str = lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1697 else if (ob == dialog_->input_kbmap2)
1698 str = lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1699 else if (ob == dialog_->check_rtl_support)
1700 str = lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1701 else if (ob == dialog_->check_mark_foreign)
1702 str = lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1703 else if (ob == dialog_->check_auto_begin)
1704 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1705 else if (ob == dialog_->check_auto_end)
1706 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1707 else if (ob == dialog_->check_use_babel)
1708 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1709 else if (ob == dialog_->check_global_options)
1710 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1711 else if (ob == dialog_->input_package)
1712 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1713 else if (ob == dialog_->input_command_begin)
1714 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1715 else if (ob == dialog_->input_command_end)
1716 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1722 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1724 bool activate = true;
1726 // !ob if function is called from Language::build() to de/activate
1728 // otherwise the function is called by an xforms CB via input().
1729 if (!ob || ob == dialog_->check_use_kbmap) {
1730 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1731 setEnabled(dialog_->button_kbmap1_browse, enable);
1732 setEnabled(dialog_->button_kbmap2_browse, enable);
1733 setEnabled(dialog_->input_kbmap1, enable);
1734 setEnabled(dialog_->input_kbmap2, enable);
1737 if (ob == dialog_->button_kbmap1_browse) {
1738 string const dir = AddName(system_lyxdir, "kbd");
1739 string const name = N_("Key maps|#K#k");
1740 pair<string, string> dir1(name, dir);
1742 parent_.browse(dialog_->input_kbmap1,
1743 N_("Keyboard map"), "*.kmap", dir1);
1744 } else if (ob == dialog_->button_kbmap2_browse) {
1745 string const dir = AddName(system_lyxdir, "kbd");
1746 string const name = N_("Key maps|#K#k");
1747 pair<string, string> dir1(name, dir);
1749 parent_.browse(dialog_->input_kbmap2,
1750 N_("Keyboard map"), "*.kmap", dir1);
1757 void FormPreferences::Language::update()
1759 fl_set_button(dialog_->check_use_kbmap,
1762 combo_default_lang->select(lyxrc.default_language);
1764 if (lyxrc.use_kbmap) {
1765 fl_set_input(dialog_->input_kbmap1,
1766 lyxrc.primary_kbmap.c_str());
1767 fl_set_input(dialog_->input_kbmap2,
1768 lyxrc.secondary_kbmap.c_str());
1770 fl_set_input(dialog_->input_kbmap1, "");
1771 fl_set_input(dialog_->input_kbmap2, "");
1774 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1775 fl_set_button(dialog_->check_mark_foreign,
1776 lyxrc.mark_foreign_language);
1777 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1778 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1779 fl_set_button(dialog_->check_use_babel, lyxrc.language_use_babel);
1780 fl_set_button(dialog_->check_global_options,
1781 lyxrc.language_global_options);
1783 fl_set_input(dialog_->input_package,
1784 lyxrc.language_package.c_str());
1785 fl_set_input(dialog_->input_command_begin,
1786 lyxrc.language_command_begin.c_str());
1787 fl_set_input(dialog_->input_command_end,
1788 lyxrc.language_command_end.c_str());
1790 // Activate/Deactivate the input fields dependent on the state of the
1796 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1798 FormPreferences * pre = static_cast<FormPreferences*>(v);
1799 // This is safe, as nothing is done to the pointer, other than
1800 // to use its address in a block-if statement.
1801 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1805 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1810 FD_form_lnf_misc const * FormPreferences::LnFmisc::dialog()
1812 return dialog_.get();
1816 void FormPreferences::LnFmisc::apply() const
1818 lyxrc.show_banner = fl_get_button(dialog_->check_banner);
1819 lyxrc.auto_region_delete =
1820 fl_get_button(dialog_->check_auto_region_delete);
1821 lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm);
1822 lyxrc.display_shortcuts =
1823 fl_get_button(dialog_->check_display_shrtcuts);
1824 lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
1825 lyxrc.cursor_follows_scrollbar =
1826 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1827 lyxrc.dialogs_iconify_with_main =
1828 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1829 lyxrc.autosave = static_cast<unsigned int>
1830 (fl_get_counter_value(dialog_->counter_autosave));
1831 lyxrc.wheel_jump = static_cast<unsigned int>
1832 (fl_get_counter_value(dialog_->counter_wm_jump));
1834 string const old_value = lyxrc.display_graphics;
1835 if (fl_get_button(dialog_->radio_display_monochrome)) {
1836 lyxrc.display_graphics = "mono";
1837 } else if (fl_get_button(dialog_->radio_display_grayscale)) {
1838 lyxrc.display_graphics = "gray";
1839 } else if (fl_get_button(dialog_->radio_display_color)) {
1840 lyxrc.display_graphics = "color";
1842 lyxrc.display_graphics = "no";
1844 if (old_value != lyxrc.display_graphics) {
1845 grfx::GCache & gc = grfx::GCache::get();
1851 void FormPreferences::LnFmisc::build()
1853 dialog_.reset(parent_.build_lnf_misc());
1855 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1856 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1858 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1859 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1861 // set up the feedback mechanism
1862 setPrehandler(dialog_->check_banner);
1863 setPrehandler(dialog_->check_auto_region_delete);
1864 setPrehandler(dialog_->check_exit_confirm);
1865 setPrehandler(dialog_->check_display_shrtcuts);
1866 setPrehandler(dialog_->counter_autosave);
1867 setPrehandler(dialog_->check_ask_new_file);
1868 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1869 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1870 setPrehandler(dialog_->counter_wm_jump);
1871 setPrehandler(dialog_->radio_display_monochrome);
1872 setPrehandler(dialog_->radio_display_grayscale);
1873 setPrehandler(dialog_->radio_display_color);
1874 setPrehandler(dialog_->radio_no_display);
1879 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1883 if (ob == dialog_->check_banner)
1884 str = lyxrc.getDescription(LyXRC::RC_SHOW_BANNER);
1885 else if (ob == dialog_->check_auto_region_delete)
1886 str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1887 else if (ob == dialog_->check_exit_confirm)
1888 str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION);
1889 else if (ob == dialog_->check_display_shrtcuts)
1890 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_SHORTCUTS);
1891 else if (ob == dialog_->check_ask_new_file)
1892 str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
1893 else if (ob == dialog_->check_cursor_follows_scrollbar)
1894 str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1895 else if (ob == dialog_->check_dialogs_iconify_with_main)
1896 str = lyxrc.getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1897 else if (ob == dialog_->counter_autosave)
1898 str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1899 else if (ob == dialog_->counter_wm_jump)
1900 str = lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1901 else if (ob == dialog_->radio_display_monochrome ||
1902 ob == dialog_->radio_display_grayscale ||
1903 ob == dialog_->radio_display_color ||
1904 ob == dialog_->radio_no_display)
1905 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1911 void FormPreferences::LnFmisc::update()
1913 fl_set_button(dialog_->check_banner, lyxrc.show_banner);
1914 fl_set_button(dialog_->check_auto_region_delete,
1915 lyxrc.auto_region_delete);
1916 fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
1917 fl_set_button(dialog_->check_display_shrtcuts, lyxrc.display_shortcuts);
1918 fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
1919 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1920 lyxrc.cursor_follows_scrollbar);
1921 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1922 lyxrc.dialogs_iconify_with_main);
1923 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1924 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1926 if (lyxrc.display_graphics == "mono") {
1927 fl_set_button(dialog_->radio_display_monochrome, 1);
1928 } else if (lyxrc.display_graphics == "gray") {
1929 fl_set_button(dialog_->radio_display_grayscale, 1);
1930 } else if (lyxrc.display_graphics == "color") {
1931 fl_set_button(dialog_->radio_display_color, 1);
1933 fl_set_button(dialog_->radio_no_display, 1);
1938 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1943 FD_form_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1945 return dialog_.get();
1949 void FormPreferences::OutputsMisc::apply() const
1951 lyxrc.ascii_linelen = static_cast<unsigned int>
1952 (fl_get_counter_value(dialog_->counter_line_len));
1953 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1956 fl_get_choice(dialog_->choice_default_papersize) - 1;
1957 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1959 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1960 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1961 lyxrc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1962 lyxrc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1966 void FormPreferences::OutputsMisc::build()
1968 dialog_.reset(parent_.build_outputs_misc());
1970 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1972 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1973 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1974 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1975 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1976 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1978 fl_addto_choice(dialog_->choice_default_papersize,
1979 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
1981 // set up the feedback mechanism
1982 setPrehandler(dialog_->counter_line_len);
1983 setPrehandler(dialog_->input_tex_encoding);
1984 setPrehandler(dialog_->choice_default_papersize);
1985 setPrehandler(dialog_->input_ascii_roff);
1986 setPrehandler(dialog_->input_checktex);
1987 setPrehandler(dialog_->input_paperoption);
1988 setPrehandler(dialog_->check_autoreset_classopt);
1993 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1997 if (ob == dialog_->counter_line_len)
1998 str = lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
1999 else if (ob == dialog_->input_tex_encoding)
2000 str = lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
2001 else if (ob == dialog_->input_ascii_roff)
2002 str = lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
2003 else if (ob == dialog_->input_checktex)
2004 str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
2005 else if (ob == dialog_->choice_default_papersize)
2006 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2007 else if (ob == dialog_->input_paperoption)
2008 str = lyxrc.getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
2009 else if (ob == dialog_->check_autoreset_classopt)
2010 str = lyxrc.getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2016 void FormPreferences::OutputsMisc::update()
2018 fl_set_counter_value(dialog_->counter_line_len,
2019 lyxrc.ascii_linelen);
2020 fl_set_input(dialog_->input_tex_encoding,
2021 lyxrc.fontenc.c_str());
2022 fl_set_choice(dialog_->choice_default_papersize,
2023 lyxrc.default_papersize+1);
2024 fl_set_input(dialog_->input_ascii_roff,
2025 lyxrc.ascii_roff_command.c_str());
2026 fl_set_input(dialog_->input_checktex,
2027 lyxrc.chktex_command.c_str());
2028 fl_set_input(dialog_->input_paperoption,
2029 lyxrc.view_dvi_paper_option.c_str());
2030 fl_set_button(dialog_->check_autoreset_classopt,
2031 lyxrc.auto_reset_options);
2036 FormPreferences::Paths::Paths(FormPreferences & p)
2041 FD_form_paths const * FormPreferences::Paths::dialog()
2043 return dialog_.get();
2047 void FormPreferences::Paths::apply()
2049 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2050 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2052 int button = fl_get_button(dialog_->check_use_temp_dir);
2053 string str = fl_get_input(dialog_->input_temp_dir);
2054 if (!button) str.erase();
2056 lyxrc.use_tempdir = button;
2057 lyxrc.tempdir_path = str;
2059 button = fl_get_button(dialog_->check_last_files);
2060 str = fl_get_input(dialog_->input_lastfiles);
2061 if (!button) str.erase();
2063 lyxrc.check_lastfiles = button;
2064 lyxrc.lastfiles = str;
2065 lyxrc.num_lastfiles = static_cast<unsigned int>
2066 (fl_get_counter_value(dialog_->counter_lastfiles));
2068 button = fl_get_button(dialog_->check_make_backups);
2069 str = fl_get_input(dialog_->input_backup_path);
2070 if (!button) str.erase();
2072 lyxrc.make_backup = button;
2073 lyxrc.backupdir_path = str;
2075 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2082 void FormPreferences::Paths::build()
2084 dialog_.reset(parent_.build_paths());
2086 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2087 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2088 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2089 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2090 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2091 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2092 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2094 // set up the feedback mechanism
2095 setPrehandler(dialog_->input_default_path);
2096 setPrehandler(dialog_->counter_lastfiles);
2097 setPrehandler(dialog_->input_template_path);
2098 setPrehandler(dialog_->check_last_files);
2099 setPrehandler(dialog_->input_lastfiles);
2100 setPrehandler(dialog_->check_make_backups);
2101 setPrehandler(dialog_->input_backup_path);
2102 setPrehandler(dialog_->input_serverpipe);
2103 setPrehandler(dialog_->input_temp_dir);
2104 setPrehandler(dialog_->check_use_temp_dir);
2109 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2113 if (ob == dialog_->input_default_path)
2114 str = lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2115 else if (ob == dialog_->input_template_path)
2116 str = lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2117 else if (ob == dialog_->check_use_temp_dir)
2118 str = lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2119 else if (ob == dialog_->input_temp_dir)
2120 str = lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2121 else if (ob == dialog_->check_last_files)
2122 str = lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2123 else if (ob == dialog_->input_lastfiles)
2124 str = lyxrc.getDescription(LyXRC::RC_LASTFILES);
2125 else if (ob == dialog_->counter_lastfiles)
2126 str = lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2127 else if (ob == dialog_->check_make_backups)
2128 str = lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2129 else if (ob == dialog_->input_backup_path)
2130 str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2131 else if (ob == dialog_->input_serverpipe) {
2132 str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2139 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2141 bool activate = true;
2143 // !ob if function is called from Paths::update() to de/activate
2145 // otherwise the function is called by an xforms CB via input().
2146 if (!ob || ob == dialog_->check_use_temp_dir) {
2147 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2148 setEnabled(dialog_->input_temp_dir, enable);
2151 if (!ob || ob == dialog_->check_last_files) {
2152 bool const enable = fl_get_button(dialog_->check_last_files);
2153 setEnabled(dialog_->input_lastfiles, enable);
2156 if (!ob || ob == dialog_->check_make_backups) {
2157 bool const enable = fl_get_button(dialog_->check_make_backups);
2158 setEnabled(dialog_->input_backup_path, enable);
2161 if (!ob || ob == dialog_->input_default_path) {
2162 string const name = fl_get_input(dialog_->input_default_path);
2163 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2164 parent_.postWarning(RWInfo::ErrorMessage());
2169 if (!ob || ob == dialog_->input_template_path) {
2170 string const name = fl_get_input(dialog_->input_template_path);
2171 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2172 parent_.postWarning(RWInfo::ErrorMessage());
2177 if (!ob || ob == dialog_->input_temp_dir) {
2178 string const name = fl_get_input(dialog_->input_temp_dir);
2179 if (fl_get_button(dialog_->check_make_backups)
2181 && !RWInfo::WriteableDir(name)) {
2182 parent_.postWarning(RWInfo::ErrorMessage());
2187 if (!ob || ob == dialog_->input_backup_path) {
2188 string const name = fl_get_input(dialog_->input_backup_path);
2189 if (fl_get_button(dialog_->check_make_backups)
2191 && !RWInfo::WriteableDir(name)) {
2192 parent_.postWarning(RWInfo::ErrorMessage());
2197 if (!ob || ob == dialog_->input_lastfiles) {
2198 string const name = fl_get_input(dialog_->input_lastfiles);
2199 if (fl_get_button(dialog_->check_last_files)
2201 && !RWInfo::WriteableFile(name)) {
2202 parent_.postWarning(RWInfo::ErrorMessage());
2207 if (!ob || ob == dialog_->input_serverpipe) {
2208 string const name = fl_get_input(dialog_->input_serverpipe);
2209 if (!name.empty()) {
2210 // strip off the extension
2211 string const str = ChangeExtension(name, "");
2212 if (!RWInfo::WriteableFile(str + ".in")) {
2213 parent_.postWarning(RWInfo::ErrorMessage());
2216 if (!RWInfo::WriteableFile(str + ".out")) {
2217 parent_.postWarning(RWInfo::ErrorMessage());
2223 if (ob == dialog_->button_default_path_browse) {
2224 parent_.browse(dialog_->input_default_path,
2225 N_("Default path"), string());
2226 } else if (ob == dialog_->button_template_path_browse) {
2227 parent_.browse(dialog_->input_template_path,
2228 N_("Template path"), string());
2229 } else if (ob == dialog_->button_temp_dir_browse) {
2230 parent_.browse(dialog_->input_temp_dir,
2231 N_("Temp dir"), string());
2232 } else if (ob == dialog_->button_lastfiles_browse) {
2233 pair<string, string> dir(_("User|#U#u"), user_lyxdir);
2235 parent_.browse(dialog_->input_lastfiles,
2236 N_("Lastfiles"), string(), dir);
2237 } else if (ob == dialog_->button_backup_path_browse) {
2238 parent_.browse(dialog_->input_backup_path,
2239 N_("Backup path"), string());
2240 } else if (ob == dialog_->button_serverpipe_browse) {
2241 parent_.browse(dialog_->input_serverpipe,
2242 N_("LyX Server pipes"), string());
2249 void FormPreferences::Paths::update()
2251 fl_set_input(dialog_->input_default_path,
2252 lyxrc.document_path.c_str());
2253 fl_set_input(dialog_->input_template_path,
2254 lyxrc.template_path.c_str());
2257 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
2259 fl_set_button(dialog_->check_make_backups,
2261 fl_set_input(dialog_->input_backup_path, str.c_str());
2264 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
2266 fl_set_button(dialog_->check_use_temp_dir,
2268 fl_set_input(dialog_->input_temp_dir, str.c_str());
2271 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
2273 fl_set_button(dialog_->check_last_files,
2274 lyxrc.check_lastfiles);
2275 fl_set_input(dialog_->input_lastfiles, str.c_str());
2276 fl_set_counter_value(dialog_->counter_lastfiles,
2277 lyxrc.num_lastfiles);
2279 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2281 // Activate/Deactivate the input fields dependent on the state of the
2287 FormPreferences::Printer::Printer(FormPreferences & p)
2292 FD_form_printer const * FormPreferences::Printer::dialog()
2294 return dialog_.get();
2298 void FormPreferences::Printer::apply() const
2300 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2301 lyxrc.print_command = fl_get_input(dialog_->input_command);
2302 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2303 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2304 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2305 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2306 lyxrc.print_file_extension =
2307 fl_get_input(dialog_->input_file_extension);
2308 lyxrc.print_spool_command =
2309 fl_get_input(dialog_->input_spool_command);
2310 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2311 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2312 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2313 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2314 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2315 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2316 lyxrc.print_extra_options =
2317 fl_get_input(dialog_->input_extra_options);
2318 lyxrc.print_spool_printerprefix =
2319 fl_get_input(dialog_->input_spool_prefix);
2320 lyxrc.print_paper_dimension_flag =
2321 fl_get_input(dialog_->input_paper_size);
2322 lyxrc.printer = fl_get_input(dialog_->input_name);
2327 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2331 if (ob == dialog_->input_command)
2332 str = lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2333 else if (ob == dialog_->check_adapt_output)
2334 str = lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2335 else if (ob == dialog_->input_to_printer)
2336 str = lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2337 else if (ob == dialog_->input_to_file)
2338 str = lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2339 else if (ob == dialog_->input_file_extension)
2340 str = lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2341 else if (ob == dialog_->input_extra_options)
2342 str = lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2343 else if (ob == dialog_->input_spool_command)
2344 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2345 else if (ob == dialog_->input_spool_prefix)
2346 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2347 else if (ob == dialog_->input_name)
2348 str = lyxrc.getDescription(LyXRC::RC_PRINTER);
2349 else if (ob == dialog_->input_even_pages)
2350 str = lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2351 else if (ob == dialog_->input_odd_pages)
2352 str = lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2353 else if (ob == dialog_->input_page_range)
2354 str = lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2355 else if (ob == dialog_->input_reverse)
2356 str = lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2357 else if (ob == dialog_->input_landscape)
2358 str = lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2359 else if (ob == dialog_->input_copies)
2360 str = lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2361 else if (ob == dialog_->input_collated)
2362 str = lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2363 else if (ob == dialog_->input_paper_type)
2364 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2365 else if (ob == dialog_->input_paper_size)
2366 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2372 void FormPreferences::Printer::build()
2374 dialog_.reset(parent_.build_printer());
2376 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2377 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2378 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2379 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2380 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2381 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2382 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2383 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2384 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2385 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2386 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2387 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2388 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2389 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2390 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2391 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2392 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2394 // set up the feedback mechanism
2395 setPrehandler(dialog_->input_command);
2396 setPrehandler(dialog_->input_page_range);
2397 setPrehandler(dialog_->input_copies);
2398 setPrehandler(dialog_->input_reverse);
2399 setPrehandler(dialog_->input_to_printer);
2400 setPrehandler(dialog_->input_file_extension);
2401 setPrehandler(dialog_->input_spool_command);
2402 setPrehandler(dialog_->input_paper_type);
2403 setPrehandler(dialog_->input_even_pages);
2404 setPrehandler(dialog_->input_odd_pages);
2405 setPrehandler(dialog_->input_collated);
2406 setPrehandler(dialog_->input_landscape);
2407 setPrehandler(dialog_->input_to_file);
2408 setPrehandler(dialog_->input_extra_options);
2409 setPrehandler(dialog_->input_spool_prefix);
2410 setPrehandler(dialog_->input_paper_size);
2411 setPrehandler(dialog_->input_name);
2412 setPrehandler(dialog_->check_adapt_output);
2416 void FormPreferences::Printer::update()
2418 fl_set_button(dialog_->check_adapt_output,
2419 lyxrc.print_adapt_output);
2420 fl_set_input(dialog_->input_command,
2421 lyxrc.print_command.c_str());
2422 fl_set_input(dialog_->input_page_range,
2423 lyxrc.print_pagerange_flag.c_str());
2424 fl_set_input(dialog_->input_copies,
2425 lyxrc.print_copies_flag.c_str());
2426 fl_set_input(dialog_->input_reverse,
2427 lyxrc.print_reverse_flag.c_str());
2428 fl_set_input(dialog_->input_to_printer,
2429 lyxrc.print_to_printer.c_str());
2430 fl_set_input(dialog_->input_file_extension,
2431 lyxrc.print_file_extension.c_str());
2432 fl_set_input(dialog_->input_spool_command,
2433 lyxrc.print_spool_command.c_str());
2434 fl_set_input(dialog_->input_paper_type,
2435 lyxrc.print_paper_flag.c_str());
2436 fl_set_input(dialog_->input_even_pages,
2437 lyxrc.print_evenpage_flag.c_str());
2438 fl_set_input(dialog_->input_odd_pages,
2439 lyxrc.print_oddpage_flag.c_str());
2440 fl_set_input(dialog_->input_collated,
2441 lyxrc.print_collcopies_flag.c_str());
2442 fl_set_input(dialog_->input_landscape,
2443 lyxrc.print_landscape_flag.c_str());
2444 fl_set_input(dialog_->input_to_file,
2445 lyxrc.print_to_file.c_str());
2446 fl_set_input(dialog_->input_extra_options,
2447 lyxrc.print_extra_options.c_str());
2448 fl_set_input(dialog_->input_spool_prefix,
2449 lyxrc.print_spool_printerprefix.c_str());
2450 fl_set_input(dialog_->input_paper_size,
2451 lyxrc.print_paper_dimension_flag.c_str());
2452 fl_set_input(dialog_->input_name,
2453 lyxrc.printer.c_str());
2457 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2462 FD_form_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2464 return dialog_.get();
2468 void FormPreferences::ScreenFonts::apply() const
2470 bool changed = false;
2472 string str = fl_get_input(dialog_->input_roman);
2473 if (lyxrc.roman_font_name != str) {
2475 lyxrc.roman_font_name = str;
2478 str = fl_get_input(dialog_->input_sans);
2479 if (lyxrc.sans_font_name != str) {
2481 lyxrc.sans_font_name = str;
2484 str = fl_get_input(dialog_->input_typewriter);
2485 if (lyxrc.typewriter_font_name != str) {
2487 lyxrc.typewriter_font_name = str;
2490 str = fl_get_input(dialog_->input_screen_encoding);
2491 if (lyxrc.font_norm != str) {
2493 lyxrc.font_norm = str;
2496 bool button = fl_get_button(dialog_->check_scalable);
2497 if (lyxrc.use_scalable_fonts != button) {
2499 lyxrc.use_scalable_fonts = button;
2502 unsigned int ivalue = static_cast<unsigned int>
2503 (fl_get_counter_value(dialog_->counter_zoom));
2504 if (lyxrc.zoom != ivalue) {
2506 lyxrc.zoom = ivalue;
2509 ivalue = static_cast<unsigned int>
2510 (fl_get_counter_value(dialog_->counter_dpi));
2511 if (lyxrc.dpi != ivalue) {
2516 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2517 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2519 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2522 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2523 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2525 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2528 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2529 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2531 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2534 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2535 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2537 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2540 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2541 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2543 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2546 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2547 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2549 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2552 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2553 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2555 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2558 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2559 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2561 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2564 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2565 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2567 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2570 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2571 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2573 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2577 // Now update the buffers
2578 // Can anything below here affect the redraw process?
2579 parent_.lv_->getLyXFunc()->dispatch(LFUN_SCREEN_FONT_UPDATE);
2584 void FormPreferences::ScreenFonts::build()
2586 dialog_.reset(parent_.build_screen_fonts());
2588 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2589 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2591 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2592 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2593 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2594 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2595 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2596 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2597 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2598 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2599 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2600 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2601 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2602 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2603 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2604 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2605 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2606 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2608 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2609 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2610 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2611 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2612 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2613 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2614 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2615 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2616 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2617 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2619 // set up the feedback mechanism
2620 setPrehandler(dialog_->input_roman);
2621 setPrehandler(dialog_->input_sans);
2622 setPrehandler(dialog_->input_typewriter);
2623 setPrehandler(dialog_->counter_zoom);
2624 setPrehandler(dialog_->counter_dpi);
2625 setPrehandler(dialog_->check_scalable);
2626 setPrehandler(dialog_->input_screen_encoding);
2627 setPrehandler(dialog_->input_tiny);
2628 setPrehandler(dialog_->input_script);
2629 setPrehandler(dialog_->input_footnote);
2630 setPrehandler(dialog_->input_small);
2631 setPrehandler(dialog_->input_large);
2632 setPrehandler(dialog_->input_larger);
2633 setPrehandler(dialog_->input_largest);
2634 setPrehandler(dialog_->input_normal);
2635 setPrehandler(dialog_->input_huge);
2636 setPrehandler(dialog_->input_huger);
2641 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2645 if (ob == dialog_->input_roman)
2646 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2647 else if (ob == dialog_->input_sans)
2648 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2649 else if (ob == dialog_->input_typewriter)
2650 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2651 else if (ob == dialog_->check_scalable)
2652 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2653 else if (ob == dialog_->input_screen_encoding)
2654 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2655 else if (ob == dialog_->counter_zoom)
2656 str = lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2657 else if (ob == dialog_->counter_dpi)
2658 str = lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2659 else if (ob == dialog_->input_tiny
2660 || ob == dialog_->input_script
2661 || ob == dialog_->input_footnote
2662 || ob == dialog_->input_small
2663 || ob == dialog_->input_large
2664 || ob == dialog_->input_larger
2665 || ob == dialog_->input_larger
2666 || ob == dialog_->input_largest
2667 || ob == dialog_->input_normal
2668 || ob == dialog_->input_huge
2669 || ob == dialog_->input_huger)
2670 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2676 bool FormPreferences::ScreenFonts::input()
2678 bool activate = true;
2681 // Make sure that all fonts all have positive entries
2682 // Also note that an empty entry is returned as 0.0 by strToDbl
2683 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2684 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2685 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2686 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2687 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2688 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2689 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2690 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2691 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2692 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2694 str = N_("Fonts must be positive!");
2696 // Fontsizes -- tiny < script < footnote etc.
2697 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2698 strToDbl(fl_get_input(dialog_->input_script)) ||
2699 strToDbl(fl_get_input(dialog_->input_script)) >
2700 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2701 strToDbl(fl_get_input(dialog_->input_footnote)) >
2702 strToDbl(fl_get_input(dialog_->input_small)) ||
2703 strToDbl(fl_get_input(dialog_->input_small)) >
2704 strToDbl(fl_get_input(dialog_->input_normal)) ||
2705 strToDbl(fl_get_input(dialog_->input_normal)) >
2706 strToDbl(fl_get_input(dialog_->input_large)) ||
2707 strToDbl(fl_get_input(dialog_->input_large)) >
2708 strToDbl(fl_get_input(dialog_->input_larger)) ||
2709 strToDbl(fl_get_input(dialog_->input_larger)) >
2710 strToDbl(fl_get_input(dialog_->input_largest)) ||
2711 strToDbl(fl_get_input(dialog_->input_largest)) >
2712 strToDbl(fl_get_input(dialog_->input_huge)) ||
2713 strToDbl(fl_get_input(dialog_->input_huge)) >
2714 strToDbl(fl_get_input(dialog_->input_huger))) {
2717 str = N_("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2721 parent_.postWarning(str);
2727 void FormPreferences::ScreenFonts::update()
2729 fl_set_input(dialog_->input_roman,
2730 lyxrc.roman_font_name.c_str());
2731 fl_set_input(dialog_->input_sans,
2732 lyxrc.sans_font_name.c_str());
2733 fl_set_input(dialog_->input_typewriter,
2734 lyxrc.typewriter_font_name.c_str());
2735 fl_set_input(dialog_->input_screen_encoding,
2736 lyxrc.font_norm.c_str());
2737 fl_set_button(dialog_->check_scalable,
2738 lyxrc.use_scalable_fonts);
2739 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2740 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2741 fl_set_input(dialog_->input_tiny,
2742 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2743 fl_set_input(dialog_->input_script,
2744 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2745 fl_set_input(dialog_->input_footnote,
2746 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2747 fl_set_input(dialog_->input_small,
2748 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2749 fl_set_input(dialog_->input_normal,
2750 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2751 fl_set_input(dialog_->input_large,
2752 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2753 fl_set_input(dialog_->input_larger,
2754 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2755 fl_set_input(dialog_->input_largest,
2756 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2757 fl_set_input(dialog_->input_huge,
2758 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2759 fl_set_input(dialog_->input_huger,
2760 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2765 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2770 FD_form_spelloptions const * FormPreferences::SpellOptions::dialog()
2772 return dialog_.get();
2776 void FormPreferences::SpellOptions::apply()
2779 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2780 choice = strip(frontStrip(choice));
2782 lyxrc.isp_command = choice;
2785 // If spell checker == "none", all other input set to off.
2786 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2787 lyxrc.isp_use_alt_lang = false;
2788 lyxrc.isp_alt_lang.erase();
2790 lyxrc.isp_use_esc_chars = false;
2791 lyxrc.isp_esc_chars.erase();
2793 lyxrc.isp_use_pers_dict = false;
2794 lyxrc.isp_pers_dict.erase();
2796 lyxrc.isp_accept_compound = false;
2797 lyxrc.isp_use_input_encoding = false;
2800 int button = fl_get_button(dialog_->check_alt_lang);
2801 choice = fl_get_input(dialog_->input_alt_lang);
2802 if (button && choice.empty()) button = 0;
2803 if (!button) choice.erase();
2805 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2806 lyxrc.isp_alt_lang = choice;
2808 button = fl_get_button(dialog_->check_escape_chars);
2809 choice = fl_get_input(dialog_->input_escape_chars);
2810 if (button && choice.empty()) button = 0;
2811 if (!button) choice.erase();
2813 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2814 lyxrc.isp_esc_chars = choice;
2816 button = fl_get_button(dialog_->check_personal_dict);
2817 choice = fl_get_input(dialog_->input_personal_dict);
2818 if (button && choice.empty()) button = 0;
2819 if (!button) choice.erase();
2821 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2822 lyxrc.isp_pers_dict = choice;
2824 button = fl_get_button(dialog_->check_compound_words);
2825 lyxrc.isp_accept_compound = static_cast<bool>(button);
2827 button = fl_get_button(dialog_->check_input_enc);
2828 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2839 void FormPreferences::SpellOptions::build()
2841 dialog_.reset(parent_.build_spelloptions());
2843 fl_addto_choice(dialog_->choice_spell_command,
2845 _(" none | ispell | aspell "));
2847 _(" ispell | aspell "));
2849 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2850 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2851 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2853 // set up the feedback mechanism
2854 setPrehandler(dialog_->choice_spell_command);
2855 setPrehandler(dialog_->check_alt_lang);
2856 setPrehandler(dialog_->input_alt_lang);
2857 setPrehandler(dialog_->check_escape_chars);
2858 setPrehandler(dialog_->input_escape_chars);
2859 setPrehandler(dialog_->check_personal_dict);
2860 setPrehandler(dialog_->input_personal_dict);
2861 setPrehandler(dialog_->button_personal_dict);
2862 setPrehandler(dialog_->check_compound_words);
2863 setPrehandler(dialog_->check_input_enc);
2868 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2872 if (ob == dialog_->choice_spell_command)
2873 str = lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2874 else if (ob == dialog_->check_alt_lang)
2875 str = lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2876 else if (ob == dialog_->input_alt_lang)
2877 str = lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2878 else if (ob == dialog_->check_escape_chars)
2879 str = lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2880 else if (ob == dialog_->input_escape_chars)
2881 str = lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2882 else if (ob == dialog_->check_personal_dict)
2883 str = lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2884 else if (ob == dialog_->input_personal_dict)
2885 str = lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2886 else if (ob == dialog_->check_compound_words)
2887 str = lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2888 else if (ob == dialog_->check_input_enc)
2889 str = lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2895 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2897 // !ob if function is called from updateSpellOptions() to de/activate
2899 // otherwise the function is called by an xforms CB via input().
2902 // If spell checker == "none", disable all input.
2903 if (!ob || ob == dialog_->choice_spell_command) {
2904 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2905 fl_deactivate_object(dialog_->check_alt_lang);
2906 fl_deactivate_object(dialog_->input_alt_lang);
2907 fl_deactivate_object(dialog_->check_escape_chars);
2908 fl_deactivate_object(dialog_->input_escape_chars);
2909 fl_deactivate_object(dialog_->check_personal_dict);
2910 fl_deactivate_object(dialog_->input_personal_dict);
2911 fl_deactivate_object(dialog_->check_compound_words);
2912 fl_deactivate_object(dialog_->check_input_enc);
2915 fl_activate_object(dialog_->check_alt_lang);
2916 fl_activate_object(dialog_->check_escape_chars);
2917 fl_activate_object(dialog_->check_personal_dict);
2918 fl_activate_object(dialog_->check_compound_words);
2919 fl_activate_object(dialog_->check_input_enc);
2924 if (!ob || ob == dialog_->check_alt_lang) {
2925 bool const enable = fl_get_button(dialog_->check_alt_lang);
2926 setEnabled(dialog_->input_alt_lang, enable);
2929 if (!ob || ob == dialog_->check_escape_chars) {
2930 bool const enable = fl_get_button(dialog_->check_escape_chars);
2931 setEnabled(dialog_->input_escape_chars, enable);
2934 if (!ob || ob == dialog_->check_personal_dict) {
2935 bool const enable = fl_get_button(dialog_->check_personal_dict);
2936 setEnabled(dialog_->input_personal_dict, enable);
2939 if (ob == dialog_->button_personal_dict) {
2940 parent_.browse(dialog_->input_personal_dict,
2941 N_("Personal dictionary"), "*.ispell");
2944 return true; // All input is valid!
2948 void FormPreferences::SpellOptions::update()
2952 if (lyxrc.isp_command == "none")
2954 else if (lyxrc.isp_command == "ispell")
2956 else if (lyxrc.isp_command == "aspell")
2959 if (lyxrc.isp_command == "ispell")
2961 else if (lyxrc.isp_command == "aspell")
2964 fl_set_choice(dialog_->choice_spell_command, choice);
2967 if (lyxrc.isp_use_alt_lang) str = lyxrc.isp_alt_lang;
2969 fl_set_button(dialog_->check_alt_lang,
2970 lyxrc.isp_use_alt_lang);
2971 fl_set_input(dialog_->input_alt_lang, str.c_str());
2974 if (lyxrc.isp_use_esc_chars) str = lyxrc.isp_esc_chars;
2976 fl_set_button(dialog_->check_escape_chars,
2977 lyxrc.isp_use_esc_chars);
2978 fl_set_input(dialog_->input_escape_chars, str.c_str());
2981 if (lyxrc.isp_use_pers_dict) str = lyxrc.isp_pers_dict;
2983 fl_set_button(dialog_->check_personal_dict,
2984 lyxrc.isp_use_pers_dict);
2985 fl_set_input(dialog_->input_personal_dict, str.c_str());
2987 fl_set_button(dialog_->check_compound_words,
2988 lyxrc.isp_accept_compound);
2989 fl_set_button(dialog_->check_input_enc,
2990 lyxrc.isp_use_input_encoding);
2992 // Activate/Deactivate the input fields dependent on the state of the
2998 void FormPreferences::browse(FL_OBJECT * inpt,
2999 string const & title,
3000 string const & pattern,
3001 pair<string,string> const & dir1,
3002 pair<string,string> const & dir2)
3004 // Get the filename from the dialog
3005 string const filename = fl_get_input(inpt);
3007 // Show the file browser dialog
3008 string const new_filename =
3009 browseFile(lv_, filename, title, pattern, dir1, dir2);
3011 // Save the filename to the dialog
3012 if (new_filename != filename && !new_filename.empty()) {
3013 fl_set_input(inpt, new_filename.c_str());