2 * \file FormPreferences.C
3 * Copyright 2000-2001 The LyX Team.
4 * See the file COPYING.
6 * \author Angus Leeming, a.leeming@ic.ac.uk
12 #pragma implementation
15 #include "FormPreferences.h"
16 #include "form_preferences.h"
20 #include "converter.h"
22 #include "frontends/LyXView.h"
24 #include "frnt_lang.h"
33 #include "input_validators.h"
34 #include "xforms_helpers.h"
35 #include "helper_funcs.h"
37 #include "support/lyxfunctional.h"
38 #include "support/lyxmanip.h"
39 #include "support/filetools.h"
40 #include "support/LAssert.h"
42 #include "graphics/GraphicsCache.h"
44 #include <boost/bind.hpp>
59 extern string system_lyxdir;
60 extern string user_lyxdir;
64 // These should probably go inside the class definition...
65 Formats local_formats;
66 Converters local_converters;
71 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
72 : FormBaseBI(lv, d, _("Preferences"), false),
73 colors_(*this), converters_(*this), inputs_misc_(*this),
74 formats_(*this), interface_(*this), language_(*this),
75 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
76 printer_(*this), screen_fonts_(*this), spelloptions_(*this)
78 // let the dialog be shown
79 // This is a permanent connection so we won't bother
80 // storing a copy because we won't be disconnecting.
81 d->showPreferences = boost::bind(&FormPreferences::show, this);
82 d->showSpellcheckerPreferences = boost::bind(&FormPreferences::showSpellPref, this);
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());
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_inner_tab());
175 look_n_feel_tab_.reset(build_inner_tab());
176 inputs_tab_.reset(build_inner_tab());
177 outputs_tab_.reset(build_inner_tab());
178 lang_opts_tab_.reset(build_inner_tab());
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_form_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(parent_.build_colors());
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_form_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(parent_.build_converters());
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_form_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(parent_.build_formats());
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_form_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(parent_.build_inputs_misc());
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_form_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(parent_.build_interface());
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_form_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(parent_.build_language());
1630 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1631 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1632 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1634 // 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_form_lnf_misc const * FormPreferences::LnFmisc::dialog()
1816 return dialog_.get();
1820 void FormPreferences::LnFmisc::apply() const
1822 lyxrc.show_banner = fl_get_button(dialog_->check_banner);
1823 lyxrc.auto_region_delete =
1824 fl_get_button(dialog_->check_auto_region_delete);
1825 lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm);
1826 lyxrc.display_shortcuts =
1827 fl_get_button(dialog_->check_display_shrtcuts);
1828 lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
1829 lyxrc.cursor_follows_scrollbar =
1830 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1831 lyxrc.dialogs_iconify_with_main =
1832 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1833 lyxrc.autosave = static_cast<unsigned int>
1834 (fl_get_counter_value(dialog_->counter_autosave));
1835 lyxrc.wheel_jump = static_cast<unsigned int>
1836 (fl_get_counter_value(dialog_->counter_wm_jump));
1838 string const old_value = lyxrc.display_graphics;
1839 if (fl_get_button(dialog_->radio_display_monochrome)) {
1840 lyxrc.display_graphics = "mono";
1841 } else if (fl_get_button(dialog_->radio_display_grayscale)) {
1842 lyxrc.display_graphics = "gray";
1843 } else if (fl_get_button(dialog_->radio_display_color)) {
1844 lyxrc.display_graphics = "color";
1846 lyxrc.display_graphics = "no";
1848 if (old_value != lyxrc.display_graphics) {
1849 grfx::GCache & gc = grfx::GCache::get();
1855 void FormPreferences::LnFmisc::build()
1857 dialog_.reset(parent_.build_lnf_misc());
1859 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1860 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1862 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1863 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1865 // set up the feedback mechanism
1866 setPrehandler(dialog_->check_banner);
1867 setPrehandler(dialog_->check_auto_region_delete);
1868 setPrehandler(dialog_->check_exit_confirm);
1869 setPrehandler(dialog_->check_display_shrtcuts);
1870 setPrehandler(dialog_->counter_autosave);
1871 setPrehandler(dialog_->check_ask_new_file);
1872 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1873 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1874 setPrehandler(dialog_->counter_wm_jump);
1875 setPrehandler(dialog_->radio_display_monochrome);
1876 setPrehandler(dialog_->radio_display_grayscale);
1877 setPrehandler(dialog_->radio_display_color);
1878 setPrehandler(dialog_->radio_no_display);
1883 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1887 if (ob == dialog_->check_banner)
1888 str = lyxrc.getDescription(LyXRC::RC_SHOW_BANNER);
1889 else if (ob == dialog_->check_auto_region_delete)
1890 str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1891 else if (ob == dialog_->check_exit_confirm)
1892 str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION);
1893 else if (ob == dialog_->check_display_shrtcuts)
1894 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_SHORTCUTS);
1895 else if (ob == dialog_->check_ask_new_file)
1896 str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
1897 else if (ob == dialog_->check_cursor_follows_scrollbar)
1898 str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1899 else if (ob == dialog_->check_dialogs_iconify_with_main)
1900 str = lyxrc.getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1901 else if (ob == dialog_->counter_autosave)
1902 str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1903 else if (ob == dialog_->counter_wm_jump)
1904 str = lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1905 else if (ob == dialog_->radio_display_monochrome ||
1906 ob == dialog_->radio_display_grayscale ||
1907 ob == dialog_->radio_display_color ||
1908 ob == dialog_->radio_no_display)
1909 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1915 void FormPreferences::LnFmisc::update()
1917 fl_set_button(dialog_->check_banner, lyxrc.show_banner);
1918 fl_set_button(dialog_->check_auto_region_delete,
1919 lyxrc.auto_region_delete);
1920 fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
1921 fl_set_button(dialog_->check_display_shrtcuts, lyxrc.display_shortcuts);
1922 fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
1923 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1924 lyxrc.cursor_follows_scrollbar);
1925 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1926 lyxrc.dialogs_iconify_with_main);
1927 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1928 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1930 if (lyxrc.display_graphics == "mono") {
1931 fl_set_button(dialog_->radio_display_monochrome, 1);
1932 } else if (lyxrc.display_graphics == "gray") {
1933 fl_set_button(dialog_->radio_display_grayscale, 1);
1934 } else if (lyxrc.display_graphics == "color") {
1935 fl_set_button(dialog_->radio_display_color, 1);
1937 fl_set_button(dialog_->radio_no_display, 1);
1942 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1947 FD_form_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1949 return dialog_.get();
1953 void FormPreferences::OutputsMisc::apply() const
1955 lyxrc.ascii_linelen = static_cast<unsigned int>
1956 (fl_get_counter_value(dialog_->counter_line_len));
1957 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1960 fl_get_choice(dialog_->choice_default_papersize) - 1;
1961 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1963 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1964 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1965 lyxrc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1966 lyxrc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1970 void FormPreferences::OutputsMisc::build()
1972 dialog_.reset(parent_.build_outputs_misc());
1974 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1976 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1977 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1978 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1979 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1980 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1982 fl_addto_choice(dialog_->choice_default_papersize,
1983 _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1985 // set up the feedback mechanism
1986 setPrehandler(dialog_->counter_line_len);
1987 setPrehandler(dialog_->input_tex_encoding);
1988 setPrehandler(dialog_->choice_default_papersize);
1989 setPrehandler(dialog_->input_ascii_roff);
1990 setPrehandler(dialog_->input_checktex);
1991 setPrehandler(dialog_->input_paperoption);
1992 setPrehandler(dialog_->check_autoreset_classopt);
1997 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
2001 if (ob == dialog_->counter_line_len)
2002 str = lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
2003 else if (ob == dialog_->input_tex_encoding)
2004 str = lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
2005 else if (ob == dialog_->input_ascii_roff)
2006 str = lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
2007 else if (ob == dialog_->input_checktex)
2008 str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
2009 else if (ob == dialog_->choice_default_papersize)
2010 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2011 else if (ob == dialog_->input_paperoption)
2012 str = lyxrc.getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
2013 else if (ob == dialog_->check_autoreset_classopt)
2014 str = lyxrc.getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2020 void FormPreferences::OutputsMisc::update()
2022 fl_set_counter_value(dialog_->counter_line_len,
2023 lyxrc.ascii_linelen);
2024 fl_set_input(dialog_->input_tex_encoding,
2025 lyxrc.fontenc.c_str());
2026 fl_set_choice(dialog_->choice_default_papersize,
2027 lyxrc.default_papersize+1);
2028 fl_set_input(dialog_->input_ascii_roff,
2029 lyxrc.ascii_roff_command.c_str());
2030 fl_set_input(dialog_->input_checktex,
2031 lyxrc.chktex_command.c_str());
2032 fl_set_input(dialog_->input_paperoption,
2033 lyxrc.view_dvi_paper_option.c_str());
2034 fl_set_button(dialog_->check_autoreset_classopt,
2035 lyxrc.auto_reset_options);
2040 FormPreferences::Paths::Paths(FormPreferences & p)
2045 FD_form_paths const * FormPreferences::Paths::dialog()
2047 return dialog_.get();
2051 void FormPreferences::Paths::apply()
2053 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2054 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2056 int button = fl_get_button(dialog_->check_use_temp_dir);
2057 string str = fl_get_input(dialog_->input_temp_dir);
2058 if (!button) str.erase();
2060 lyxrc.use_tempdir = button;
2061 lyxrc.tempdir_path = str;
2063 button = fl_get_button(dialog_->check_last_files);
2064 str = fl_get_input(dialog_->input_lastfiles);
2065 if (!button) str.erase();
2067 lyxrc.check_lastfiles = button;
2068 lyxrc.lastfiles = str;
2069 lyxrc.num_lastfiles = static_cast<unsigned int>
2070 (fl_get_counter_value(dialog_->counter_lastfiles));
2072 button = fl_get_button(dialog_->check_make_backups);
2073 str = fl_get_input(dialog_->input_backup_path);
2074 if (!button) str.erase();
2076 lyxrc.make_backup = button;
2077 lyxrc.backupdir_path = str;
2079 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2086 void FormPreferences::Paths::build()
2088 dialog_.reset(parent_.build_paths());
2090 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2091 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2092 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2093 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2094 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2095 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2096 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2098 // set up the feedback mechanism
2099 setPrehandler(dialog_->input_default_path);
2100 setPrehandler(dialog_->counter_lastfiles);
2101 setPrehandler(dialog_->input_template_path);
2102 setPrehandler(dialog_->check_last_files);
2103 setPrehandler(dialog_->input_lastfiles);
2104 setPrehandler(dialog_->check_make_backups);
2105 setPrehandler(dialog_->input_backup_path);
2106 setPrehandler(dialog_->input_serverpipe);
2107 setPrehandler(dialog_->input_temp_dir);
2108 setPrehandler(dialog_->check_use_temp_dir);
2113 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2117 if (ob == dialog_->input_default_path)
2118 str = lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2119 else if (ob == dialog_->input_template_path)
2120 str = lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2121 else if (ob == dialog_->check_use_temp_dir)
2122 str = lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2123 else if (ob == dialog_->input_temp_dir)
2124 str = lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2125 else if (ob == dialog_->check_last_files)
2126 str = lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2127 else if (ob == dialog_->input_lastfiles)
2128 str = lyxrc.getDescription(LyXRC::RC_LASTFILES);
2129 else if (ob == dialog_->counter_lastfiles)
2130 str = lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2131 else if (ob == dialog_->check_make_backups)
2132 str = lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2133 else if (ob == dialog_->input_backup_path)
2134 str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2135 else if (ob == dialog_->input_serverpipe) {
2136 str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2143 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2145 bool activate = true;
2147 // !ob if function is called from Paths::update() to de/activate
2149 // otherwise the function is called by an xforms CB via input().
2150 if (!ob || ob == dialog_->check_use_temp_dir) {
2151 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2152 setEnabled(dialog_->input_temp_dir, enable);
2155 if (!ob || ob == dialog_->check_last_files) {
2156 bool const enable = fl_get_button(dialog_->check_last_files);
2157 setEnabled(dialog_->input_lastfiles, enable);
2160 if (!ob || ob == dialog_->check_make_backups) {
2161 bool const enable = fl_get_button(dialog_->check_make_backups);
2162 setEnabled(dialog_->input_backup_path, enable);
2165 if (!ob || ob == dialog_->input_default_path) {
2166 string const name = fl_get_input(dialog_->input_default_path);
2167 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2168 parent_.postWarning(RWInfo::ErrorMessage());
2173 if (!ob || ob == dialog_->input_template_path) {
2174 string const name = fl_get_input(dialog_->input_template_path);
2175 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2176 parent_.postWarning(RWInfo::ErrorMessage());
2181 if (!ob || ob == dialog_->input_temp_dir) {
2182 string const name = fl_get_input(dialog_->input_temp_dir);
2183 if (fl_get_button(dialog_->check_make_backups)
2185 && !RWInfo::WriteableDir(name)) {
2186 parent_.postWarning(RWInfo::ErrorMessage());
2191 if (!ob || ob == dialog_->input_backup_path) {
2192 string const name = fl_get_input(dialog_->input_backup_path);
2193 if (fl_get_button(dialog_->check_make_backups)
2195 && !RWInfo::WriteableDir(name)) {
2196 parent_.postWarning(RWInfo::ErrorMessage());
2201 if (!ob || ob == dialog_->input_lastfiles) {
2202 string const name = fl_get_input(dialog_->input_lastfiles);
2203 if (fl_get_button(dialog_->check_last_files)
2205 && !RWInfo::WriteableFile(name)) {
2206 parent_.postWarning(RWInfo::ErrorMessage());
2211 if (!ob || ob == dialog_->input_serverpipe) {
2212 string const name = fl_get_input(dialog_->input_serverpipe);
2213 if (!name.empty()) {
2214 // strip off the extension
2215 string const str = ChangeExtension(name, "");
2216 if (!RWInfo::WriteableFile(str + ".in")) {
2217 parent_.postWarning(RWInfo::ErrorMessage());
2220 if (!RWInfo::WriteableFile(str + ".out")) {
2221 parent_.postWarning(RWInfo::ErrorMessage());
2227 if (ob == dialog_->button_default_path_browse) {
2228 parent_.browse(dialog_->input_default_path,
2229 _("Default path"), string());
2230 } else if (ob == dialog_->button_template_path_browse) {
2231 parent_.browse(dialog_->input_template_path,
2232 _("Template path"), string());
2233 } else if (ob == dialog_->button_temp_dir_browse) {
2234 parent_.browse(dialog_->input_temp_dir,
2235 _("Temp dir"), string());
2236 } else if (ob == dialog_->button_lastfiles_browse) {
2237 pair<string, string> dir(_("User|#U#u"), user_lyxdir);
2239 parent_.browse(dialog_->input_lastfiles,
2240 _("Lastfiles"), string(), dir);
2241 } else if (ob == dialog_->button_backup_path_browse) {
2242 parent_.browse(dialog_->input_backup_path,
2243 _("Backup path"), string());
2244 } else if (ob == dialog_->button_serverpipe_browse) {
2245 parent_.browse(dialog_->input_serverpipe,
2246 _("LyX Server pipes"), string());
2253 void FormPreferences::Paths::update()
2255 fl_set_input(dialog_->input_default_path,
2256 lyxrc.document_path.c_str());
2257 fl_set_input(dialog_->input_template_path,
2258 lyxrc.template_path.c_str());
2261 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
2263 fl_set_button(dialog_->check_make_backups,
2265 fl_set_input(dialog_->input_backup_path, str.c_str());
2268 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
2270 fl_set_button(dialog_->check_use_temp_dir,
2272 fl_set_input(dialog_->input_temp_dir, str.c_str());
2275 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
2277 fl_set_button(dialog_->check_last_files,
2278 lyxrc.check_lastfiles);
2279 fl_set_input(dialog_->input_lastfiles, str.c_str());
2280 fl_set_counter_value(dialog_->counter_lastfiles,
2281 lyxrc.num_lastfiles);
2283 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2285 // Activate/Deactivate the input fields dependent on the state of the
2291 FormPreferences::Printer::Printer(FormPreferences & p)
2296 FD_form_printer const * FormPreferences::Printer::dialog()
2298 return dialog_.get();
2302 void FormPreferences::Printer::apply() const
2304 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2305 lyxrc.print_command = fl_get_input(dialog_->input_command);
2306 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2307 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2308 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2309 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2310 lyxrc.print_file_extension =
2311 fl_get_input(dialog_->input_file_extension);
2312 lyxrc.print_spool_command =
2313 fl_get_input(dialog_->input_spool_command);
2314 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2315 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2316 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2317 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2318 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2319 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2320 lyxrc.print_extra_options =
2321 fl_get_input(dialog_->input_extra_options);
2322 lyxrc.print_spool_printerprefix =
2323 fl_get_input(dialog_->input_spool_prefix);
2324 lyxrc.print_paper_dimension_flag =
2325 fl_get_input(dialog_->input_paper_size);
2326 lyxrc.printer = fl_get_input(dialog_->input_name);
2331 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2335 if (ob == dialog_->input_command)
2336 str = lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2337 else if (ob == dialog_->check_adapt_output)
2338 str = lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2339 else if (ob == dialog_->input_to_printer)
2340 str = lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2341 else if (ob == dialog_->input_to_file)
2342 str = lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2343 else if (ob == dialog_->input_file_extension)
2344 str = lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2345 else if (ob == dialog_->input_extra_options)
2346 str = lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2347 else if (ob == dialog_->input_spool_command)
2348 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2349 else if (ob == dialog_->input_spool_prefix)
2350 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2351 else if (ob == dialog_->input_name)
2352 str = lyxrc.getDescription(LyXRC::RC_PRINTER);
2353 else if (ob == dialog_->input_even_pages)
2354 str = lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2355 else if (ob == dialog_->input_odd_pages)
2356 str = lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2357 else if (ob == dialog_->input_page_range)
2358 str = lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2359 else if (ob == dialog_->input_reverse)
2360 str = lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2361 else if (ob == dialog_->input_landscape)
2362 str = lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2363 else if (ob == dialog_->input_copies)
2364 str = lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2365 else if (ob == dialog_->input_collated)
2366 str = lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2367 else if (ob == dialog_->input_paper_type)
2368 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2369 else if (ob == dialog_->input_paper_size)
2370 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2376 void FormPreferences::Printer::build()
2378 dialog_.reset(parent_.build_printer());
2380 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2381 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2382 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2383 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2384 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2385 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2386 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2387 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2388 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2389 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2390 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2391 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2392 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2393 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2394 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2395 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2396 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2398 // set up the feedback mechanism
2399 setPrehandler(dialog_->input_command);
2400 setPrehandler(dialog_->input_page_range);
2401 setPrehandler(dialog_->input_copies);
2402 setPrehandler(dialog_->input_reverse);
2403 setPrehandler(dialog_->input_to_printer);
2404 setPrehandler(dialog_->input_file_extension);
2405 setPrehandler(dialog_->input_spool_command);
2406 setPrehandler(dialog_->input_paper_type);
2407 setPrehandler(dialog_->input_even_pages);
2408 setPrehandler(dialog_->input_odd_pages);
2409 setPrehandler(dialog_->input_collated);
2410 setPrehandler(dialog_->input_landscape);
2411 setPrehandler(dialog_->input_to_file);
2412 setPrehandler(dialog_->input_extra_options);
2413 setPrehandler(dialog_->input_spool_prefix);
2414 setPrehandler(dialog_->input_paper_size);
2415 setPrehandler(dialog_->input_name);
2416 setPrehandler(dialog_->check_adapt_output);
2420 void FormPreferences::Printer::update()
2422 fl_set_button(dialog_->check_adapt_output,
2423 lyxrc.print_adapt_output);
2424 fl_set_input(dialog_->input_command,
2425 lyxrc.print_command.c_str());
2426 fl_set_input(dialog_->input_page_range,
2427 lyxrc.print_pagerange_flag.c_str());
2428 fl_set_input(dialog_->input_copies,
2429 lyxrc.print_copies_flag.c_str());
2430 fl_set_input(dialog_->input_reverse,
2431 lyxrc.print_reverse_flag.c_str());
2432 fl_set_input(dialog_->input_to_printer,
2433 lyxrc.print_to_printer.c_str());
2434 fl_set_input(dialog_->input_file_extension,
2435 lyxrc.print_file_extension.c_str());
2436 fl_set_input(dialog_->input_spool_command,
2437 lyxrc.print_spool_command.c_str());
2438 fl_set_input(dialog_->input_paper_type,
2439 lyxrc.print_paper_flag.c_str());
2440 fl_set_input(dialog_->input_even_pages,
2441 lyxrc.print_evenpage_flag.c_str());
2442 fl_set_input(dialog_->input_odd_pages,
2443 lyxrc.print_oddpage_flag.c_str());
2444 fl_set_input(dialog_->input_collated,
2445 lyxrc.print_collcopies_flag.c_str());
2446 fl_set_input(dialog_->input_landscape,
2447 lyxrc.print_landscape_flag.c_str());
2448 fl_set_input(dialog_->input_to_file,
2449 lyxrc.print_to_file.c_str());
2450 fl_set_input(dialog_->input_extra_options,
2451 lyxrc.print_extra_options.c_str());
2452 fl_set_input(dialog_->input_spool_prefix,
2453 lyxrc.print_spool_printerprefix.c_str());
2454 fl_set_input(dialog_->input_paper_size,
2455 lyxrc.print_paper_dimension_flag.c_str());
2456 fl_set_input(dialog_->input_name,
2457 lyxrc.printer.c_str());
2461 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2466 FD_form_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2468 return dialog_.get();
2472 void FormPreferences::ScreenFonts::apply() const
2474 bool changed = false;
2476 string str = fl_get_input(dialog_->input_roman);
2477 if (lyxrc.roman_font_name != str) {
2479 lyxrc.roman_font_name = str;
2482 str = fl_get_input(dialog_->input_sans);
2483 if (lyxrc.sans_font_name != str) {
2485 lyxrc.sans_font_name = str;
2488 str = fl_get_input(dialog_->input_typewriter);
2489 if (lyxrc.typewriter_font_name != str) {
2491 lyxrc.typewriter_font_name = str;
2494 str = fl_get_input(dialog_->input_screen_encoding);
2495 if (lyxrc.font_norm != str) {
2497 lyxrc.font_norm = str;
2500 bool button = fl_get_button(dialog_->check_scalable);
2501 if (lyxrc.use_scalable_fonts != button) {
2503 lyxrc.use_scalable_fonts = button;
2506 unsigned int ivalue = static_cast<unsigned int>
2507 (fl_get_counter_value(dialog_->counter_zoom));
2508 if (lyxrc.zoom != ivalue) {
2510 lyxrc.zoom = ivalue;
2513 ivalue = static_cast<unsigned int>
2514 (fl_get_counter_value(dialog_->counter_dpi));
2515 if (lyxrc.dpi != ivalue) {
2520 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2521 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2523 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2526 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2527 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2529 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2532 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2533 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2535 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2538 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2539 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2541 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2544 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2545 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2547 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2550 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2551 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2553 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2556 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2557 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2559 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2562 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2563 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2565 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2568 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2569 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2571 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2574 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2575 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2577 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2581 // Now update the buffers
2582 // Can anything below here affect the redraw process?
2583 parent_.lv_->getLyXFunc()->dispatch(LFUN_SCREEN_FONT_UPDATE);
2588 void FormPreferences::ScreenFonts::build()
2590 dialog_.reset(parent_.build_screen_fonts());
2592 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2593 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2595 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2596 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2597 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2598 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2599 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2600 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2601 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2602 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2603 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2604 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2605 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2606 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2607 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2608 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2609 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2610 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2612 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2613 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2614 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2615 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2616 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2617 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2618 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2619 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2620 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2621 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2623 // set up the feedback mechanism
2624 setPrehandler(dialog_->input_roman);
2625 setPrehandler(dialog_->input_sans);
2626 setPrehandler(dialog_->input_typewriter);
2627 setPrehandler(dialog_->counter_zoom);
2628 setPrehandler(dialog_->counter_dpi);
2629 setPrehandler(dialog_->check_scalable);
2630 setPrehandler(dialog_->input_screen_encoding);
2631 setPrehandler(dialog_->input_tiny);
2632 setPrehandler(dialog_->input_script);
2633 setPrehandler(dialog_->input_footnote);
2634 setPrehandler(dialog_->input_small);
2635 setPrehandler(dialog_->input_large);
2636 setPrehandler(dialog_->input_larger);
2637 setPrehandler(dialog_->input_largest);
2638 setPrehandler(dialog_->input_normal);
2639 setPrehandler(dialog_->input_huge);
2640 setPrehandler(dialog_->input_huger);
2645 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2649 if (ob == dialog_->input_roman)
2650 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2651 else if (ob == dialog_->input_sans)
2652 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2653 else if (ob == dialog_->input_typewriter)
2654 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2655 else if (ob == dialog_->check_scalable)
2656 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2657 else if (ob == dialog_->input_screen_encoding)
2658 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2659 else if (ob == dialog_->counter_zoom)
2660 str = lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2661 else if (ob == dialog_->counter_dpi)
2662 str = lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2663 else if (ob == dialog_->input_tiny
2664 || ob == dialog_->input_script
2665 || ob == dialog_->input_footnote
2666 || ob == dialog_->input_small
2667 || ob == dialog_->input_large
2668 || ob == dialog_->input_larger
2669 || ob == dialog_->input_larger
2670 || ob == dialog_->input_largest
2671 || ob == dialog_->input_normal
2672 || ob == dialog_->input_huge
2673 || ob == dialog_->input_huger)
2674 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2680 bool FormPreferences::ScreenFonts::input()
2682 bool activate = true;
2685 // Make sure that all fonts all have positive entries
2686 // Also note that an empty entry is returned as 0.0 by strToDbl
2687 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2688 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2689 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2690 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2691 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2692 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2693 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2694 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2695 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2696 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2698 str = _("Fonts must be positive!");
2700 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2701 // Fontsizes -- tiny < script < footnote etc.
2702 strToDbl(fl_get_input(dialog_->input_script)) ||
2703 strToDbl(fl_get_input(dialog_->input_script)) >
2704 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2705 strToDbl(fl_get_input(dialog_->input_footnote)) >
2706 strToDbl(fl_get_input(dialog_->input_small)) ||
2707 strToDbl(fl_get_input(dialog_->input_small)) >
2708 strToDbl(fl_get_input(dialog_->input_normal)) ||
2709 strToDbl(fl_get_input(dialog_->input_normal)) >
2710 strToDbl(fl_get_input(dialog_->input_large)) ||
2711 strToDbl(fl_get_input(dialog_->input_large)) >
2712 strToDbl(fl_get_input(dialog_->input_larger)) ||
2713 strToDbl(fl_get_input(dialog_->input_larger)) >
2714 strToDbl(fl_get_input(dialog_->input_largest)) ||
2715 strToDbl(fl_get_input(dialog_->input_largest)) >
2716 strToDbl(fl_get_input(dialog_->input_huge)) ||
2717 strToDbl(fl_get_input(dialog_->input_huge)) >
2718 strToDbl(fl_get_input(dialog_->input_huger))) {
2721 str = _("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2725 parent_.postWarning(str);
2731 void FormPreferences::ScreenFonts::update()
2733 fl_set_input(dialog_->input_roman,
2734 lyxrc.roman_font_name.c_str());
2735 fl_set_input(dialog_->input_sans,
2736 lyxrc.sans_font_name.c_str());
2737 fl_set_input(dialog_->input_typewriter,
2738 lyxrc.typewriter_font_name.c_str());
2739 fl_set_input(dialog_->input_screen_encoding,
2740 lyxrc.font_norm.c_str());
2741 fl_set_button(dialog_->check_scalable,
2742 lyxrc.use_scalable_fonts);
2743 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2744 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2745 fl_set_input(dialog_->input_tiny,
2746 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2747 fl_set_input(dialog_->input_script,
2748 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2749 fl_set_input(dialog_->input_footnote,
2750 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2751 fl_set_input(dialog_->input_small,
2752 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2753 fl_set_input(dialog_->input_normal,
2754 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2755 fl_set_input(dialog_->input_large,
2756 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2757 fl_set_input(dialog_->input_larger,
2758 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2759 fl_set_input(dialog_->input_largest,
2760 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2761 fl_set_input(dialog_->input_huge,
2762 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2763 fl_set_input(dialog_->input_huger,
2764 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2769 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2774 FD_form_spelloptions const * FormPreferences::SpellOptions::dialog()
2776 return dialog_.get();
2780 void FormPreferences::SpellOptions::apply()
2783 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2784 choice = strip(frontStrip(choice));
2786 lyxrc.isp_command = choice;
2789 // If spell checker == "none", all other input set to off.
2790 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2791 lyxrc.isp_use_alt_lang = false;
2792 lyxrc.isp_alt_lang.erase();
2794 lyxrc.isp_use_esc_chars = false;
2795 lyxrc.isp_esc_chars.erase();
2797 lyxrc.isp_use_pers_dict = false;
2798 lyxrc.isp_pers_dict.erase();
2800 lyxrc.isp_accept_compound = false;
2801 lyxrc.isp_use_input_encoding = false;
2804 int button = fl_get_button(dialog_->check_alt_lang);
2805 choice = fl_get_input(dialog_->input_alt_lang);
2806 if (button && choice.empty()) button = 0;
2807 if (!button) choice.erase();
2809 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2810 lyxrc.isp_alt_lang = choice;
2812 button = fl_get_button(dialog_->check_escape_chars);
2813 choice = fl_get_input(dialog_->input_escape_chars);
2814 if (button && choice.empty()) button = 0;
2815 if (!button) choice.erase();
2817 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2818 lyxrc.isp_esc_chars = choice;
2820 button = fl_get_button(dialog_->check_personal_dict);
2821 choice = fl_get_input(dialog_->input_personal_dict);
2822 if (button && choice.empty()) button = 0;
2823 if (!button) choice.erase();
2825 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2826 lyxrc.isp_pers_dict = choice;
2828 button = fl_get_button(dialog_->check_compound_words);
2829 lyxrc.isp_accept_compound = static_cast<bool>(button);
2831 button = fl_get_button(dialog_->check_input_enc);
2832 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2843 void FormPreferences::SpellOptions::build()
2845 dialog_.reset(parent_.build_spelloptions());
2847 fl_addto_choice(dialog_->choice_spell_command,
2848 _(" 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 _("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());