2 * \file FormPreferences.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS
14 #pragma implementation
17 #include "FormPreferences.h"
18 #include "forms/form_preferences.h"
22 #include "input_validators.h"
23 #include "forms_gettext.h"
24 #include "xforms_helpers.h"
25 #include "helper_funcs.h"
28 #include "converter.h"
31 #include "frnt_lang.h"
36 #include "funcrequest.h"
38 #include "frontends/LyXView.h"
39 #include "frontends/Dialogs.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"
47 #include "graphics/GraphicsTypes.h"
49 #include <boost/bind.hpp>
51 #include FORMS_H_LOCATION
65 extern string system_lyxdir;
66 extern string user_lyxdir;
70 // These should probably go inside the class definition...
71 Formats local_formats;
72 Converters local_converters;
77 FormPreferences::FormPreferences(LyXView & lv, Dialogs & d)
78 : FormBaseBI(lv, d, _("Preferences"), false),
79 colors_(*this), converters_(*this), inputs_misc_(*this),
80 formats_(*this), interface_(*this), language_(*this),
81 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
82 printer_(*this), screen_fonts_(*this), spelloptions_(*this)
84 // let the dialog be shown
85 // This is a permanent connection so we won't bother
86 // storing a copy because we won't be disconnecting.
90 void FormPreferences::redraw()
92 if (!(form() && form()->visible))
94 fl_redraw_form(form());
96 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
97 if (!(form2 && form2->visible))
99 fl_redraw_form(form2);
102 if (form2 == converters_tab_->form)
103 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
105 else if (form2 == look_n_feel_tab_->form)
106 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
108 else if (form2 == inputs_tab_->form)
109 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
111 else if (form2 == outputs_tab_->form)
112 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
114 else if (form2 == lang_opts_tab_->form)
115 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
117 if (form3 && form3->visible)
118 fl_redraw_form(form3);
122 FL_FORM * FormPreferences::form() const
124 return dialog_.get() ? dialog_->form : 0;
128 void FormPreferences::ok()
130 FormBaseDeprecated::ok();
132 if (colors_.modifiedXformsPrefs) {
133 string const filename =
134 AddName(user_lyxdir, "preferences.xform");
135 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
138 lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
142 void FormPreferences::hide()
144 // We need to hide the active tabfolder otherwise we get a
145 // BadDrawable error from X window and LyX crashes without saving.
146 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
147 if (inner_form && inner_form->visible)
148 fl_hide_form(inner_form);
149 FormBaseDeprecated::hide();
153 void FormPreferences::build()
155 dialog_.reset(build_preferences(this));
157 // Manage the restore, save, apply and cancel/close buttons
158 bc().setOK(dialog_->button_ok);
159 bc().setApply(dialog_->button_apply);
160 bc().setCancel(dialog_->button_close);
161 bc().setRestore(dialog_->button_restore);
163 // Allow the base class to control messages
164 setMessageWidget(dialog_->text_warning);
166 // build the tab folders
167 converters_tab_.reset(build_preferences_inner_tab(this));
168 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
169 inputs_tab_.reset(build_preferences_inner_tab(this));
170 outputs_tab_.reset(build_preferences_inner_tab(this));
171 lang_opts_tab_.reset(build_preferences_inner_tab(this));
173 // build actual tabfolder contents
174 // these will become nested tabfolders
178 inputs_misc_.build();
182 outputs_misc_.build();
185 screen_fonts_.build();
186 spelloptions_.build();
188 // Now add them to the tabfolder
189 fl_addto_tabfolder(dialog_->tabfolder_prefs,
191 look_n_feel_tab_->form);
192 fl_addto_tabfolder(dialog_->tabfolder_prefs,
194 lang_opts_tab_->form);
195 fl_addto_tabfolder(dialog_->tabfolder_prefs,
197 converters_tab_->form);
198 fl_addto_tabfolder(dialog_->tabfolder_prefs,
201 fl_addto_tabfolder(dialog_->tabfolder_prefs,
205 // now build the nested tabfolders
206 // Starting with look and feel
207 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
209 screen_fonts_.dialog()->form);
210 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
212 interface_.dialog()->form);
213 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
215 colors_.dialog()->form);
216 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
218 lnf_misc_.dialog()->form);
220 // then build converters
221 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
223 formats_.dialog()->form);
224 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
226 converters_.dialog()->form);
229 // Paths should probably go in a few inner_tab called Files
230 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
232 paths_.dialog()->form);
233 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
235 inputs_misc_.dialog()->form);
237 // then building outputs
238 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
240 printer_.dialog()->form);
241 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
243 outputs_misc_.dialog()->form);
245 // then building usage
246 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
248 spelloptions_.dialog()->form);
249 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
251 language_.dialog()->form);
253 // work-around xforms bug re update of folder->x, folder->y coords.
254 setPrehandler(look_n_feel_tab_->tabfolder_inner);
255 setPrehandler(converters_tab_->tabfolder_inner);
256 setPrehandler(inputs_tab_->tabfolder_inner);
257 setPrehandler(outputs_tab_->tabfolder_inner);
258 setPrehandler(lang_opts_tab_->tabfolder_inner);
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)
294 if (ob->form->fdui == colors_.dialog())
295 return colors_.feedback(ob);
296 if (ob->form->fdui == converters_.dialog())
297 return converters_.feedback(ob);
298 if (ob->form->fdui == formats_.dialog())
299 return formats_.feedback(ob);
300 if (ob->form->fdui == inputs_misc_.dialog())
301 return inputs_misc_.feedback(ob);
302 if (ob->form->fdui == interface_.dialog())
303 return interface_.feedback(ob);
304 if (ob->form->fdui == language_.dialog())
305 return language_.feedback(ob);
306 if (ob->form->fdui == lnf_misc_.dialog())
307 return lnf_misc_.feedback(ob);
308 if (ob->form->fdui == outputs_misc_.dialog())
309 return outputs_misc_.feedback(ob);
310 if (ob->form->fdui == paths_.dialog())
311 return paths_.feedback(ob);
312 if (ob->form->fdui == printer_.dialog())
313 return printer_.feedback(ob);
314 if (ob->form->fdui == screen_fonts_.dialog())
315 return screen_fonts_.feedback(ob);
316 if (ob->form->fdui == spelloptions_.dialog())
317 return spelloptions_.feedback(ob);
323 bool FormPreferences::input(FL_OBJECT * ob, long)
327 // whatever checks you need to ensure the user hasn't entered
328 // some totally ridiculous value somewhere. Change activate to suit.
329 // comments before each test describe what is _valid_
331 if (ob->form->fdui == colors_.dialog()) {
335 if (ob->form->fdui == converters_.dialog())
336 return converters_.input(ob);
337 if (ob->form->fdui == formats_.dialog())
338 return formats_.input(ob);
339 if (ob->form->fdui == interface_.dialog())
340 return interface_.input(ob);
341 if (ob->form->fdui == language_.dialog())
342 return language_.input(ob);
343 if (ob->form->fdui == paths_.dialog())
344 return paths_.input(ob);
345 if (ob->form->fdui == screen_fonts_.dialog())
346 return screen_fonts_.input();
347 if (ob->form->fdui == spelloptions_.dialog())
348 return spelloptions_.input(ob);
354 void FormPreferences::update()
356 if (!dialog_.get()) return;
358 // read lyxrc entries
360 formats_.update(); // Must be before converters_.update()
361 converters_.update();
362 inputs_misc_.update();
366 outputs_misc_.update();
369 screen_fonts_.update();
370 spelloptions_.update();
374 FormPreferences::Colors::Colors(FormPreferences & p)
375 : modifiedXformsPrefs(false), parent_(p)
379 FD_preferences_colors const * FormPreferences::Colors::dialog()
381 return dialog_.get();
385 void FormPreferences::Colors::apply()
387 bool modifiedText = false;
388 bool modifiedBackground = false;
390 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
391 cit != xformsColorDB.end(); ++cit) {
393 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
394 if (col != cit->color()) {
395 modifiedXformsPrefs = true;
396 if (cit->colorID == FL_BLACK)
398 if (cit->colorID == FL_COL1)
399 modifiedBackground = true;
403 if (modifiedXformsPrefs) {
404 for (vector<XformsColor>::const_iterator cit =
405 xformsColorDB.begin();
406 cit != xformsColorDB.end(); ++cit) {
407 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
409 if (modifiedText && cit->colorID == FL_BLACK) {
410 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
413 if (modifiedBackground && cit->colorID == FL_COL1) {
414 AdjustVal(FL_MCOL, FL_COL1, 0.1);
415 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
416 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
418 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
419 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
422 if (cit->colorID == GUI_COLOR_CURSOR) {
423 fl_mapcolor(GUI_COLOR_CURSOR,
424 cit->r, cit->g, cit->b);
425 setCursorColor(GUI_COLOR_CURSOR);
428 parent_.lv_.getDialogs().redrawGUI();
431 // Now do the same for the LyX LColors...
432 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
433 cit != lyxColorDB.end(); ++cit) {
434 LColor::color lc = lcolor.getFromGUIName(cit->getname());
435 if (lc == LColor::inherit) continue;
437 // Create a valid X11 name of the form "#rrggbb"
438 string const hexname = X11hexname(cit->color());
440 if (lcolor.getX11Name(lc) != hexname) {
442 << "FormPreferences::Colors::apply: "
443 << "resetting LColor " << lcolor.getGUIName(lc)
444 << " from \"" << lcolor.getX11Name(lc)
445 << "\" to \"" << hexname << "\"."
448 string const s = lcolor.getLyXName(lc) + string(" ") +
450 parent_.lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s));
456 void FormPreferences::Colors::build()
458 dialog_.reset(build_preferences_colors(&parent_));
460 fl_set_object_color(dialog_->button_color,
461 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
463 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
464 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
465 fl_set_dial_step(dialog_->dial_hue, 1.0);
466 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
468 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
469 fl_set_slider_step(dialog_->slider_saturation, 0.01);
470 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
472 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
473 fl_set_slider_step(dialog_->slider_value, 0.01);
474 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
476 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
477 fl_set_slider_step(dialog_->slider_red, 1.0);
478 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
480 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
481 fl_set_slider_step(dialog_->slider_green, 1.0);
482 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
484 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
485 fl_set_slider_step(dialog_->slider_blue, 1.0);
486 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
488 // set up the feedback mechanism
489 setPrehandler(dialog_->browser_lyx_objs);
490 setPrehandler(dialog_->button_color);
491 setPrehandler(dialog_->button_modify);
492 setPrehandler(dialog_->dial_hue);
493 setPrehandler(dialog_->slider_saturation);
494 setPrehandler(dialog_->slider_value);
495 setPrehandler(dialog_->slider_red);
496 setPrehandler(dialog_->slider_green);
497 setPrehandler(dialog_->slider_blue);
498 setPrehandler(dialog_->radio_rgb);
499 setPrehandler(dialog_->radio_hsv);
504 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
506 if (ob == dialog_->browser_lyx_objs)
507 return _("LyX objects that can be assigned a color.");
509 if (ob == dialog_->button_modify)
510 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
512 if (ob == dialog_->dial_hue ||
513 ob == dialog_->slider_saturation ||
514 ob == dialog_->slider_value ||
515 ob == dialog_->slider_red ||
516 ob == dialog_->slider_green ||
517 ob == dialog_->slider_blue)
518 return _("Find a new color.");
520 if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
521 return _("Toggle between RGB and HSV color spaces.");
527 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
529 if (ob == dialog_->browser_lyx_objs) {
532 } else if (ob == dialog_->dial_hue ||
533 ob == dialog_->slider_saturation ||
534 ob == dialog_->slider_value) {
537 } else if (ob == dialog_->slider_red ||
538 ob == dialog_->slider_green ||
539 ob == dialog_->slider_blue) {
542 } else if (ob == dialog_->radio_rgb ||
543 ob == dialog_->radio_hsv) {
546 } else if (ob == dialog_->button_modify) {
552 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
556 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
560 hsv.v = min(1.0, max(0.0, hsv.v));
563 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
567 void FormPreferences::Colors::InputBrowserLyX() const
569 vector<NamedColor>::size_type const selLyX =
570 fl_get_browser(dialog_->browser_lyx_objs);
571 if (selLyX < 1) return;
573 // Is the choice an Xforms color...
576 if (selLyX - 1 < xformsColorDB.size()) {
577 vector<XformsColor>::size_type const i = selLyX - 1;
578 col = xformsColorDB[i].color();
580 // or a LyX Logical color?
582 vector<NamedColor>::size_type const i = selLyX - 1 -
583 xformsColorDB.size();
584 col = lyxColorDB[i].color();
587 fl_freeze_form(dialog_->form);
589 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
590 fl_redraw_object(dialog_->button_color);
592 // Display either RGB or HSV but not both!
595 // Deactivate the modify button to begin with...
596 setEnabled(dialog_->button_modify, false);
598 fl_unfreeze_form(dialog_->form);
602 void FormPreferences::Colors::InputHSV()
604 double const hue = fl_get_dial_value(dialog_->dial_hue);
605 double const sat = fl_get_slider_value(dialog_->slider_saturation);
606 double const val = fl_get_slider_value(dialog_->slider_value);
608 int const h = int(hue);
609 int const s = int(100.0 * sat);
610 int const v = int(100.0 * val);
612 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
614 fl_set_object_label(dialog_->text_color_values, label.c_str());
616 RGBColor col = HSVColor(hue, sat, val);
618 fl_freeze_form(dialog_->form);
620 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
621 fl_redraw_object(dialog_->button_color);
623 col = HSVColor(hue, 1.0, 1.0);
624 col.r = max(col.r, 0);
625 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
626 fl_redraw_object(dialog_->dial_hue);
628 // Ascertain whether to activate the Modify button.
629 vector<NamedColor>::size_type const selLyX =
630 fl_get_browser(dialog_->browser_lyx_objs);
632 fl_unfreeze_form(dialog_->form);
633 if (selLyX < 1) return;
635 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
638 // Is the choice an Xforms color...
639 if (selLyX - 1 < xformsColorDB.size()) {
640 vector<XformsColor>::size_type const i = selLyX - 1;
641 modify = (xformsColorDB[i].color() != col);
643 // or a LyX Logical color?
645 vector<NamedColor>::size_type const i = selLyX - 1 -
646 xformsColorDB.size();
647 modify = (lyxColorDB[i].color() != col);
650 setEnabled(dialog_->button_modify, modify);
654 void FormPreferences::Colors::InputRGB()
656 int const red = int(fl_get_slider_value(dialog_->slider_red));
657 int const green = int(fl_get_slider_value(dialog_->slider_green));
658 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
660 string const label = tostr(red) + string(", ") + tostr(green) +
661 string(", ") + tostr(blue);
662 fl_set_object_label(dialog_->text_color_values, label.c_str());
664 fl_freeze_form(dialog_->form);
666 RGBColor col = RGBColor(red, green, blue);
667 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
668 fl_redraw_object(dialog_->button_color);
670 // Ascertain whether to activate the Modify button.
671 vector<NamedColor>::size_type const selLyX =
672 fl_get_browser(dialog_->browser_lyx_objs);
674 fl_unfreeze_form(dialog_->form);
675 if (selLyX < 1) return;
679 // Is the choice an Xforms color...
680 if (selLyX - 1 < xformsColorDB.size()) {
681 vector<XformsColor>::size_type const i = selLyX - 1;
682 modify = (xformsColorDB[i].color() != col);
684 // or a LyX Logical color?
686 vector<NamedColor>::size_type const i = selLyX - 1 -
687 xformsColorDB.size();
688 modify = (lyxColorDB[i].color() != col);
691 setEnabled(dialog_->button_modify, modify);
695 void FormPreferences::Colors::LoadBrowserLyX()
697 if (!dialog_->browser_lyx_objs->visible)
700 // First, define the modifiable xforms colors
701 xformsColorDB.clear();
704 xcol.name = _("GUI background");
705 xcol.colorID = FL_COL1;
706 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
708 xformsColorDB.push_back(xcol);
710 xcol.name = _("GUI text");
711 xcol.colorID = FL_BLACK;
712 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
714 xformsColorDB.push_back(xcol);
716 xcol.name = _("GUI selection");
717 xcol.colorID = FL_YELLOW;
718 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
720 xformsColorDB.push_back(xcol);
722 xcol.name = _("GUI pointer");
723 xcol.colorID = GUI_COLOR_CURSOR;
724 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
726 xformsColorDB.push_back(xcol);
728 // Now create the the LyX LColors database
730 for (int i=0; i<LColor::ignore; ++i) {
731 LColor::color lc = static_cast<LColor::color>(i);
732 if (lc == LColor::none
733 || lc == LColor::black
734 || lc == LColor::white
736 || lc == LColor::green
737 || lc == LColor::blue
738 || lc == LColor::cyan
739 || lc == LColor::magenta
740 || lc == LColor::yellow
741 || lc == LColor::inherit
742 || lc == LColor::ignore) continue;
744 string const name = lcolor.getX11Name(lc);
745 Display * display = fl_get_display();;
746 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
749 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
751 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
752 << "LColor " << lcolor.getLyXName(lc)
753 << ": X can't find color \"" << name
754 << "\". Set to \"black\"!" << endl;
756 string const arg = lcolor.getLyXName(lc) + " black";
757 parent_.lv_.dispatch(FuncRequest(LFUN_SET_COLOR, arg));
761 // X has found the color. Now find the "appropriate" X11 name
764 // Note that X stores the RGB values in the range 0 - 65535
765 // whilst we require them in the range 0 - 255.
767 col.r = xcol.red / 256;
768 col.g = xcol.green / 256;
769 col.b = xcol.blue / 256;
771 // Create a valid X11 name of the form "#rrggbb" and change the
772 // LColor X11name to this. Don't want to trigger a redraw,
773 // as we're just changing the name not the RGB values.
774 // Also reset the system_lcolor names, so that we don't output
775 // unnecessary changes.
776 string const hexname = X11hexname(col);
778 if (lcolor.getX11Name(lc) != hexname) {
779 lcolor.setColor(lc, hexname);
780 system_lcolor.setColor(lc, hexname);
783 // Finally, push the color onto the database
784 NamedColor ncol(lcolor.getGUIName(lc), col);
785 lyxColorDB.push_back(ncol);
788 // Now construct the browser
789 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
790 fl_freeze_form(dialog_->form);
791 fl_clear_browser(colbr);
792 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
793 cit != xformsColorDB.end(); ++cit) {
794 fl_addto_browser(colbr, cit->getname().c_str());
796 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
797 cit != lyxColorDB.end(); ++cit) {
798 fl_addto_browser(colbr, cit->getname().c_str());
801 // just to be safe...
802 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
803 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
804 fl_unfreeze_form(dialog_->form);
810 void FormPreferences::Colors::Modify()
812 vector<NamedColor>::size_type const selLyX =
813 fl_get_browser(dialog_->browser_lyx_objs);
818 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
820 // Is the choice an Xforms color...
821 if (selLyX - 1 < xformsColorDB.size()) {
822 vector<XformsColor>::size_type const i = selLyX - 1;
823 xformsColorDB[i].r = col.r;
824 xformsColorDB[i].g = col.g;
825 xformsColorDB[i].b = col.b;
827 // or a LyX Logical color?
829 vector<NamedColor>::size_type const i = selLyX - 1 -
830 xformsColorDB.size();
831 lyxColorDB[i].r = col.r;
832 lyxColorDB[i].g = col.g;
833 lyxColorDB[i].b = col.b;
836 fl_freeze_form(dialog_->form);
837 setEnabled(dialog_->button_modify, false);
838 fl_unfreeze_form(dialog_->form);
842 void FormPreferences::Colors::SwitchColorSpace() const
844 bool const hsv = fl_get_button(dialog_->radio_hsv);
847 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
849 fl_freeze_form(dialog_->form);
852 fl_hide_object(dialog_->slider_red);
853 fl_hide_object(dialog_->slider_blue);
854 fl_hide_object(dialog_->slider_green);
855 fl_show_object(dialog_->dial_hue);
856 fl_show_object(dialog_->slider_saturation);
857 fl_show_object(dialog_->slider_value);
859 HSVColor hsv = HSVColor(col);
860 hsv.h = max(hsv.h, 0.0);
862 fl_set_dial_value(dialog_->dial_hue, hsv.h);
863 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
864 fl_set_slider_value(dialog_->slider_value, hsv.v);
866 col = HSVColor(hsv.h, 1.0, 1.0);
867 col.r = max(col.r, 0);
868 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
869 fl_redraw_object(dialog_->dial_hue);
871 // Adjust the label a bit, but not the actual values.
872 // Means that toggling from one space to the other has no
873 // effect on the final color.
874 int const h = int(hsv.h);
875 int const s = int(100 * hsv.s);
876 int const v = int(100 * hsv.v);
877 string const label = tostr(h) + ", " + tostr(s) +
879 fl_set_object_label(dialog_->text_color_values, label.c_str());
882 fl_show_object(dialog_->slider_red);
883 fl_show_object(dialog_->slider_blue);
884 fl_show_object(dialog_->slider_green);
885 fl_hide_object(dialog_->dial_hue);
886 fl_hide_object(dialog_->slider_saturation);
887 fl_hide_object(dialog_->slider_value);
889 fl_set_slider_value(dialog_->slider_red, col.r);
890 fl_set_slider_value(dialog_->slider_green, col.g);
891 fl_set_slider_value(dialog_->slider_blue, col.b);
893 // Adjust the label a bit. Same reasoning as above.
894 int const r = int(col.r);
895 int const g = int(col.g);
896 int const b = int(col.b);
897 string const label = tostr(r) + ", " + tostr(g) +
899 fl_set_object_label(dialog_->text_color_values, label.c_str());
902 fl_unfreeze_form(dialog_->form);
905 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
909 ostr << "#" << std::setbase(16) << setfill('0')
914 return ostr.str().c_str();
918 FormPreferences::Converters::Converters(FormPreferences & p)
923 FD_preferences_converters const * FormPreferences::Converters::dialog()
925 return dialog_.get();
929 void FormPreferences::Converters::apply() const
931 converters = local_converters;
932 converters.update(formats);
933 converters.buildGraph();
937 void FormPreferences::Converters::build()
939 dialog_.reset(build_preferences_converters(&parent_));
941 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
942 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
944 // set up the feedback mechanism
945 setPrehandler(dialog_->browser_all);
946 setPrehandler(dialog_->button_delete);
947 setPrehandler(dialog_->button_add);
948 setPrehandler(dialog_->input_converter);
949 setPrehandler(dialog_->choice_from);
950 setPrehandler(dialog_->choice_to);
951 setPrehandler(dialog_->input_flags);
956 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
958 if (ob == dialog_->browser_all)
959 return _("All the currently defined converters known to LyX.");
961 if (ob == dialog_->choice_from)
962 return _("Convert \"from\" this format");
964 if (ob == dialog_->choice_to)
965 return _("Convert \"to\" this format");
967 if (ob == dialog_->input_converter)
968 return _("The conversion command. $$i is the input file name, "
969 "$$b is the file name without its extension and $$o is "
970 "the name of the output file. $$s can be used as path to "
971 "LyX's own collection of conversion scripts.");
973 if (ob == dialog_->input_flags)
974 return _("Extra information for the Converter class, whether and "
975 "how to parse the result, and various other things.");
977 if (ob == dialog_->button_delete)
978 return _("Remove the current converter from the list of available "
979 "converters. Note: you must then \"Apply\" the change.");
981 if (ob == dialog_->button_add) {
982 if (string(ob->label) == _("Add"))
983 return _("Add the current converter to the list of available "
984 "converters. Note: you must then \"Apply\" the change.");
986 return _("Modify the contents of the current converter. "
987 "Note: you must then \"Apply\" the change.");
994 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
996 if (ob == dialog_->browser_all)
999 if (ob == dialog_->choice_from
1000 || ob == dialog_->choice_to
1001 || ob == dialog_->input_converter
1002 || ob == dialog_->input_flags)
1005 if (ob == dialog_->button_add)
1008 if (ob == dialog_->button_delete)
1015 void FormPreferences::Converters::update()
1017 local_converters = converters;
1018 local_converters.update(local_formats);
1023 void FormPreferences::Converters::UpdateBrowser()
1025 local_converters.sort();
1027 fl_freeze_form(dialog_->form);
1028 fl_clear_browser(dialog_->browser_all);
1029 for (::Converters::const_iterator cit = local_converters.begin();
1030 cit != local_converters.end(); ++cit) {
1031 string const name = cit->From->prettyname() + " -> "
1032 + cit->To->prettyname();
1033 fl_addto_browser(dialog_->browser_all, name.c_str());
1036 fl_unfreeze_form(dialog_->form);
1040 bool FormPreferences::Converters::Add()
1042 string const from = GetFrom();
1043 string const to = GetTo();
1044 string const command = fl_get_input(dialog_->input_converter);
1045 string const flags = fl_get_input(dialog_->input_flags);
1047 Converter const * old = local_converters.getConverter(from, to);
1048 local_converters.add(from, to, command, flags);
1050 local_converters.updateLast(local_formats);
1053 setEnabled(dialog_->button_add, false);
1059 bool FormPreferences::Converters::Browser()
1061 int const i = fl_get_browser(dialog_->browser_all);
1062 if (i <= 0) return false;
1064 fl_freeze_form(dialog_->form);
1066 Converter const & c = local_converters.get(i - 1);
1067 int j = local_formats.getNumber(c.from);
1069 fl_set_choice(dialog_->choice_from, j + 1);
1071 j = local_formats.getNumber(c.to);
1073 fl_set_choice(dialog_->choice_to, j + 1);
1075 fl_set_input(dialog_->input_converter, c.command.c_str());
1076 fl_set_input(dialog_->input_flags, c.flags.c_str());
1078 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1079 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1081 setEnabled(dialog_->button_add, false);
1082 setEnabled(dialog_->button_delete, true);
1084 fl_unfreeze_form(dialog_->form);
1089 bool FormPreferences::Converters::erase()
1091 string const from = GetFrom();
1092 string const to = GetTo();
1094 local_converters.erase(from, to);
1100 bool FormPreferences::Converters::Input()
1102 string const from = GetFrom();
1103 string const to = GetTo();
1104 int const sel = local_converters.getNumber(from, to);
1106 fl_freeze_form(dialog_->form);
1109 fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
1110 fl_set_button_shortcut(dialog_->button_add,
1111 scex(_("Add|#A")), 1);
1113 fl_deselect_browser(dialog_->browser_all);
1114 setEnabled(dialog_->button_delete, false);
1117 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1118 fl_set_button_shortcut(dialog_->button_add,
1119 scex(_("Modify|#M")), 1);
1121 int top = max(sel-5, 0);
1122 fl_set_browser_topline(dialog_->browser_all, top);
1123 fl_select_browser_line(dialog_->browser_all, sel+1);
1124 setEnabled(dialog_->button_delete, true);
1127 string const command = rtrim(fl_get_input(dialog_->input_converter));
1128 bool const enable = !(command.empty() || from == to);
1129 setEnabled(dialog_->button_add, enable);
1131 fl_unfreeze_form(dialog_->form);
1136 string const FormPreferences::Converters::GetFrom() const
1138 ::Formats::FormatList::size_type const i =
1139 fl_get_choice(dialog_->choice_from);
1141 if (i > 0 && i <= local_formats.size())
1142 return local_formats.get(i - 1).name();
1144 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
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!" << endl;
1162 void FormPreferences::Converters::UpdateChoices() const
1165 for (::Formats::const_iterator cit = local_formats.begin();
1166 cit != local_formats.end(); ++cit) {
1167 if (!choice.empty())
1171 choice += cit->prettyname();
1175 fl_clear_choice(dialog_->choice_from);
1176 fl_addto_choice(dialog_->choice_from, choice.c_str());
1178 fl_clear_choice(dialog_->choice_to);
1179 fl_addto_choice(dialog_->choice_to, choice.c_str());
1183 FormPreferences::Formats::Formats(FormPreferences & p)
1188 FD_preferences_formats const * FormPreferences::Formats::dialog()
1190 return dialog_.get();
1194 void FormPreferences::Formats::apply() const
1196 formats = local_formats;
1200 void FormPreferences::Formats::build()
1202 dialog_.reset(build_preferences_formats(&parent_));
1204 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1205 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1206 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1207 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1208 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1210 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1212 // set up the feedback mechanism
1213 setPrehandler(dialog_->browser_all);
1214 setPrehandler(dialog_->input_format);
1215 setPrehandler(dialog_->input_gui_name);
1216 setPrehandler(dialog_->button_delete);
1217 setPrehandler(dialog_->button_add);
1218 setPrehandler(dialog_->input_extension);
1219 setPrehandler(dialog_->input_viewer);
1220 setPrehandler(dialog_->input_shrtcut);
1225 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1227 if (ob == dialog_->browser_all)
1228 return _("All the currently defined formats known to LyX.");
1230 if (ob == dialog_->input_format)
1231 return _("The format identifier.");
1233 if (ob == dialog_->input_gui_name)
1234 return _("The format name as it will appear in the menus.");
1236 if (ob == dialog_->input_shrtcut)
1237 return _("The keyboard accelerator. Use a letter in the GUI name. "
1240 if (ob == dialog_->input_extension)
1241 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1243 if (ob == dialog_->input_viewer)
1244 return _("The command used to launch the viewer application.");
1246 if (ob == dialog_->button_delete)
1247 return _("Remove the current format from the list of available "
1248 "formats. Note: you must then \"Apply\" the change.");
1250 if (ob == dialog_->button_add) {
1251 if (string(ob->label) == _("Add"))
1252 return _("Add the current format to the list of available "
1253 "formats. Note: you must then \"Apply\" the change.");
1255 return _("Modify the contents of the current format. Note: "
1256 "you must then \"Apply\" the change.");
1263 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1265 if (ob == dialog_->browser_all)
1268 if (ob == dialog_->input_format
1269 || ob == dialog_->input_gui_name
1270 || ob == dialog_->input_shrtcut
1271 || ob == dialog_->input_extension
1272 || ob == dialog_->input_viewer)
1275 if (ob == dialog_->button_add)
1278 if (ob == dialog_->button_delete)
1285 void FormPreferences::Formats::update()
1287 local_formats = formats;
1292 void FormPreferences::Formats::UpdateBrowser()
1294 local_formats.sort();
1296 fl_freeze_form(dialog_->form);
1297 fl_deselect_browser(dialog_->browser_all);
1298 fl_clear_browser(dialog_->browser_all);
1299 for (::Formats::const_iterator cit = local_formats.begin();
1300 cit != local_formats.end(); ++cit)
1301 fl_addto_browser(dialog_->browser_all,
1302 cit->prettyname().c_str());
1305 fl_unfreeze_form(dialog_->form);
1307 // Mustn't forget to update the Formats available to the converters_
1308 parent_.converters_.UpdateChoices();
1309 local_converters.update(local_formats);
1313 bool FormPreferences::Formats::Add()
1315 string const name = fl_get_input(dialog_->input_format);
1316 string const prettyname = fl_get_input(dialog_->input_gui_name);
1317 string const extension = fl_get_input(dialog_->input_extension);
1318 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1319 string const viewer = fl_get_input(dialog_->input_viewer);
1321 Format const * old = local_formats.getFormat(name);
1322 string const old_prettyname = old ? old->prettyname() : string();
1323 local_formats.add(name, extension, prettyname, shortcut);
1324 local_formats.setViewer(name, viewer);
1325 if (!old || prettyname != old_prettyname) {
1328 parent_.converters_.UpdateBrowser();
1330 setEnabled(dialog_->button_add, false);
1336 bool FormPreferences::Formats::Browser()
1338 int const i = fl_get_browser(dialog_->browser_all);
1342 fl_freeze_form(dialog_->form);
1344 Format const & f = local_formats.get(i - 1);
1346 fl_set_input(dialog_->input_format, f.name().c_str());
1347 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1348 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1349 fl_set_input(dialog_->input_extension, f.extension().c_str());
1350 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1352 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1353 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1355 setEnabled(dialog_->button_add, false);
1356 setEnabled(dialog_->button_delete, true);
1358 fl_unfreeze_form(dialog_->form);
1363 bool FormPreferences::Formats::erase()
1365 string const name = fl_get_input(dialog_->input_format);
1367 if (local_converters.formatIsUsed(name)) {
1368 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1369 "Remove the converter first."));
1370 setEnabled(dialog_->button_delete, false);
1374 local_formats.erase(name);
1380 bool FormPreferences::Formats::Input()
1382 string const name = fl_get_input(dialog_->input_format);
1383 int const sel = local_formats.getNumber(name);
1384 fl_freeze_form(dialog_->form);
1387 fl_set_object_label(dialog_->button_add,
1389 fl_set_button_shortcut(dialog_->button_add,
1390 scex(_("Add|#A")), 1);
1392 fl_deselect_browser(dialog_->browser_all);
1393 setEnabled(dialog_->button_delete, false);
1396 fl_set_object_label(dialog_->button_add,
1397 idex(_("Modify|#M")));
1398 fl_set_button_shortcut(dialog_->button_add,
1399 scex(_("Modify|#M")), 1);
1401 int const top = max(sel-5, 0);
1402 fl_set_browser_topline(dialog_->browser_all, top);
1403 fl_select_browser_line(dialog_->browser_all, sel+1);
1405 setEnabled(dialog_->button_add, true);
1406 setEnabled(dialog_->button_delete, true);
1409 string const prettyname = fl_get_input(dialog_->input_gui_name);
1410 bool const enable = !(name.empty() || prettyname.empty());
1411 setEnabled(dialog_->button_add, enable);
1413 fl_unfreeze_form(dialog_->form);
1418 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1423 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1425 return dialog_.get();
1429 void FormPreferences::InputsMisc::apply() const
1431 lyxrc.date_insert_format =
1432 fl_get_input(dialog_->input_date_format);
1436 void FormPreferences::InputsMisc::build()
1438 dialog_.reset(build_preferences_inputs_misc(&parent_));
1440 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1442 // set up the feedback mechanism
1443 setPrehandler(dialog_->input_date_format);
1448 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1450 if (ob == dialog_->input_date_format)
1451 return lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1456 void FormPreferences::InputsMisc::update()
1458 fl_set_input(dialog_->input_date_format,
1459 lyxrc.date_insert_format.c_str());
1463 FormPreferences::Interface::Interface(FormPreferences & p)
1468 FD_preferences_interface const * FormPreferences::Interface::dialog()
1470 return dialog_.get();
1474 void FormPreferences::Interface::apply() const
1476 lyxrc.popup_normal_font =
1477 fl_get_input(dialog_->input_popup_normal_font);
1478 lyxrc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1479 lyxrc.popup_font_encoding =
1480 fl_get_input(dialog_->input_popup_font_encoding);
1481 lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
1482 lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
1483 lyxrc.override_x_deadkeys =
1484 fl_get_button(dialog_->check_override_x_dead_keys);
1488 void FormPreferences::Interface::build()
1490 dialog_.reset(build_preferences_interface(&parent_));
1492 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1493 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1494 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1495 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1496 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1498 // set up the feedback mechanism
1499 setPrehandler(dialog_->input_popup_normal_font);
1500 setPrehandler(dialog_->input_popup_bold_font);
1501 setPrehandler(dialog_->input_popup_font_encoding);
1502 setPrehandler(dialog_->input_bind_file);
1503 setPrehandler(dialog_->button_bind_file_browse);
1504 setPrehandler(dialog_->input_ui_file);
1505 setPrehandler(dialog_->button_ui_file_browse);
1506 setPrehandler(dialog_->check_override_x_dead_keys);
1511 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1513 if (ob == dialog_->input_popup_normal_font)
1514 return lyxrc.getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1515 if (ob == dialog_->input_popup_bold_font)
1516 return lyxrc.getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1517 if (ob == dialog_->input_popup_font_encoding)
1518 return lyxrc.getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1519 if (ob == dialog_->input_bind_file)
1520 return lyxrc.getDescription(LyXRC::RC_BINDFILE);
1521 if (ob == dialog_->input_ui_file)
1522 return lyxrc.getDescription(LyXRC::RC_UIFILE);
1523 if (ob == dialog_->check_override_x_dead_keys)
1524 return lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1529 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1531 if (ob == dialog_->button_bind_file_browse) {
1532 string dir = AddName(system_lyxdir, "bind");
1533 string name = _("Sys Bind|#S#s");
1534 pair<string,string> dir1(name, dir);
1536 dir = AddName(user_lyxdir, "bind");
1537 name = _("User Bind|#U#u");
1538 pair<string,string> dir2(name, dir);
1540 parent_.browse(dialog_->input_bind_file,
1541 _("Bind file"), "*.bind", dir1, dir2);
1543 } else if (ob == dialog_->button_ui_file_browse) {
1544 string dir = AddName(system_lyxdir, "ui");
1545 string name = _("Sys UI|#S#s");
1546 pair<string,string> dir1(name, dir);
1548 dir = AddName(user_lyxdir, "ui");
1549 name = _("User UI|#U#u");
1550 pair<string,string> dir2(name, dir);
1552 parent_.browse(dialog_->input_ui_file,
1553 _("UI file"), "*.ui", dir1, dir2);
1560 void FormPreferences::Interface::update()
1562 fl_set_input(dialog_->input_popup_normal_font,
1563 lyxrc.popup_normal_font.c_str());
1564 fl_set_input(dialog_->input_popup_bold_font,
1565 lyxrc.popup_bold_font.c_str());
1566 fl_set_input(dialog_->input_popup_font_encoding,
1567 lyxrc.popup_font_encoding.c_str());
1568 fl_set_input(dialog_->input_bind_file,
1569 lyxrc.bind_file.c_str());
1570 fl_set_input(dialog_->input_ui_file,
1571 lyxrc.ui_file.c_str());
1572 fl_set_button(dialog_->check_override_x_dead_keys,
1573 lyxrc.override_x_deadkeys);
1577 FormPreferences::Language::Language(FormPreferences & p)
1582 FD_preferences_language const * FormPreferences::Language::dialog()
1584 return dialog_.get();
1588 void FormPreferences::Language::apply()
1590 int const pos = combo_default_lang->get();
1591 lyxrc.default_language = lang_[pos-1];
1593 int button = fl_get_button(dialog_->check_use_kbmap);
1594 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1595 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1597 button = !(name_1.empty() && name_2.empty());
1598 lyxrc.use_kbmap = static_cast<bool>(button);
1600 if (lyxrc.use_kbmap) {
1601 lyxrc.primary_kbmap = name_1;
1602 lyxrc.secondary_kbmap = name_2;
1605 button = fl_get_button(dialog_->check_rtl_support);
1606 lyxrc.rtl_support = static_cast<bool>(button);
1608 button = fl_get_button(dialog_->check_mark_foreign);
1609 lyxrc.mark_foreign_language = static_cast<bool>(button);
1611 button = fl_get_button(dialog_->check_auto_begin);
1612 lyxrc.language_auto_begin = static_cast<bool>(button);
1614 button = fl_get_button(dialog_->check_auto_end);
1615 lyxrc.language_auto_end = static_cast<bool>(button);
1617 button = fl_get_button(dialog_->check_use_babel);
1618 lyxrc.language_use_babel = static_cast<bool>(button);
1620 button = fl_get_button(dialog_->check_global_options);
1621 lyxrc.language_global_options = static_cast<bool>(button);
1623 lyxrc.language_package = fl_get_input(dialog_->input_package);
1624 lyxrc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1625 lyxrc.language_command_end = fl_get_input(dialog_->input_command_end);
1627 // Ensure that all is self-consistent.
1632 void FormPreferences::Language::build()
1634 dialog_.reset(build_preferences_language(&parent_));
1636 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1637 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1638 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1640 // Store the lang identifiers for later
1641 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1642 lang_ = getSecond(langs);
1644 // The default_language is a combo-box and has to be inserted manually
1645 fl_freeze_form(dialog_->form);
1646 fl_addto_form(dialog_->form);
1648 FL_OBJECT * obj = dialog_->choice_default_lang;
1649 fl_deactivate_object(dialog_->choice_default_lang);
1650 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1651 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
1652 combo_default_lang->shortcut("#L",1);
1653 combo_default_lang->setcallback(ComboCB, &parent_);
1655 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1656 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1657 for (; lit != lend; ++lit) {
1658 combo_default_lang->addto(lit->first);
1660 combo_default_lang->select(1);
1663 fl_unfreeze_form(dialog_->form);
1665 // set up the feedback mechanism
1666 setPrehandler(dialog_->input_package);
1667 setPrehandler(dialog_->check_use_kbmap);
1669 // This is safe, as nothing is done to the pointer, other than
1670 // to use its address in a block-if statement.
1671 // No it's not! Leads to crash.
1673 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1674 // C_FormPreferencesFeedbackCB);
1676 setPrehandler(dialog_->input_kbmap1);
1677 setPrehandler(dialog_->input_kbmap2);
1678 setPrehandler(dialog_->check_rtl_support);
1679 setPrehandler(dialog_->check_mark_foreign);
1680 setPrehandler(dialog_->check_auto_begin);
1681 setPrehandler(dialog_->check_auto_end);
1682 setPrehandler(dialog_->check_use_babel);
1683 setPrehandler(dialog_->check_global_options);
1684 setPrehandler(dialog_->input_command_begin);
1685 setPrehandler(dialog_->input_command_end);
1687 // Activate/Deactivate the input fields dependent on the state of the
1694 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1696 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1697 return lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1698 if (ob == dialog_->check_use_kbmap)
1699 return lyxrc.getDescription(LyXRC::RC_KBMAP);
1700 if (ob == dialog_->input_kbmap1)
1701 return lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1702 if (ob == dialog_->input_kbmap2)
1703 return lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1704 if (ob == dialog_->check_rtl_support)
1705 return lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1706 if (ob == dialog_->check_mark_foreign)
1707 return lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1708 if (ob == dialog_->check_auto_begin)
1709 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1710 if (ob == dialog_->check_auto_end)
1711 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1712 if (ob == dialog_->check_use_babel)
1713 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1714 if (ob == dialog_->check_global_options)
1715 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1716 if (ob == dialog_->input_package)
1717 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1718 if (ob == dialog_->input_command_begin)
1719 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1720 if (ob == dialog_->input_command_end)
1721 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1726 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1728 bool activate = true;
1730 // !ob if function is called from Language::build() to de/activate
1732 // otherwise the function is called by an xforms CB via input().
1733 if (!ob || ob == dialog_->check_use_kbmap) {
1734 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1735 setEnabled(dialog_->button_kbmap1_browse, enable);
1736 setEnabled(dialog_->button_kbmap2_browse, enable);
1737 setEnabled(dialog_->input_kbmap1, enable);
1738 setEnabled(dialog_->input_kbmap2, enable);
1741 if (ob == dialog_->button_kbmap1_browse) {
1742 string const dir = AddName(system_lyxdir, "kbd");
1743 string const name = _("Key maps|#K#k");
1744 pair<string, string> dir1(name, dir);
1746 parent_.browse(dialog_->input_kbmap1,
1747 _("Keyboard map"), "*.kmap", dir1);
1748 } else if (ob == dialog_->button_kbmap2_browse) {
1749 string const dir = AddName(system_lyxdir, "kbd");
1750 string const name = _("Key maps|#K#k");
1751 pair<string, string> dir1(name, dir);
1753 parent_.browse(dialog_->input_kbmap2,
1754 _("Keyboard map"), "*.kmap", dir1);
1761 void FormPreferences::Language::update()
1763 fl_set_button(dialog_->check_use_kbmap,
1766 int const pos = int(findPos(lang_, lyxrc.default_language));
1767 combo_default_lang->select(pos + 1);
1769 if (lyxrc.use_kbmap) {
1770 fl_set_input(dialog_->input_kbmap1,
1771 lyxrc.primary_kbmap.c_str());
1772 fl_set_input(dialog_->input_kbmap2,
1773 lyxrc.secondary_kbmap.c_str());
1775 fl_set_input(dialog_->input_kbmap1, "");
1776 fl_set_input(dialog_->input_kbmap2, "");
1779 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1780 fl_set_button(dialog_->check_mark_foreign,
1781 lyxrc.mark_foreign_language);
1782 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1783 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1784 fl_set_button(dialog_->check_use_babel, lyxrc.language_use_babel);
1785 fl_set_button(dialog_->check_global_options,
1786 lyxrc.language_global_options);
1788 fl_set_input(dialog_->input_package,
1789 lyxrc.language_package.c_str());
1790 fl_set_input(dialog_->input_command_begin,
1791 lyxrc.language_command_begin.c_str());
1792 fl_set_input(dialog_->input_command_end,
1793 lyxrc.language_command_end.c_str());
1795 // Activate/Deactivate the input fields dependent on the state of the
1801 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1803 FormPreferences * pre = static_cast<FormPreferences*>(v);
1804 // This is safe, as nothing is done to the pointer, other than
1805 // to use its address in a block-if statement.
1806 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1810 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1815 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1817 return dialog_.get();
1821 void FormPreferences::LnFmisc::apply() const
1823 lyxrc.auto_region_delete =
1824 fl_get_button(dialog_->check_auto_region_delete);
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.preview = fl_get_button(dialog_->check_preview_latex);
1830 lyxrc.autosave = static_cast<unsigned int>
1831 (fl_get_counter_value(dialog_->counter_autosave));
1832 lyxrc.wheel_jump = static_cast<unsigned int>
1833 (fl_get_counter_value(dialog_->counter_wm_jump));
1836 // grfx::DisplayType old_value = lyxrc.display_graphics;
1837 switch (fl_get_choice(dialog_->choice_display)) {
1838 case 4: lyxrc.display_graphics = grfx::NoDisplay; break;
1839 case 3: lyxrc.display_graphics = grfx::ColorDisplay; break;
1840 case 2: lyxrc.display_graphics = grfx::GrayscaleDisplay; break;
1841 case 1: lyxrc.display_graphics = grfx::MonochromeDisplay; break;
1842 default: lyxrc.display_graphics = grfx::ColorDisplay; break;
1845 #ifdef WITH_WARNINGS
1846 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1849 if (old_value != lyxrc.display_graphics) {
1850 grfx::GCache & gc = grfx::GCache::get();
1857 void FormPreferences::LnFmisc::build()
1859 dialog_.reset(build_preferences_lnf_misc(&parent_));
1861 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1862 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1864 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1865 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1867 // set up the feedback mechanism
1868 setPrehandler(dialog_->check_auto_region_delete);
1869 setPrehandler(dialog_->counter_autosave);
1870 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1871 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1872 setPrehandler(dialog_->check_preview_latex);
1873 setPrehandler(dialog_->counter_wm_jump);
1875 fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
1880 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1882 if (ob == dialog_->check_auto_region_delete)
1883 return lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1884 if (ob == dialog_->check_cursor_follows_scrollbar)
1885 return lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1886 if (ob == dialog_->check_dialogs_iconify_with_main)
1887 return lyxrc.getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1888 if (ob == dialog_->check_preview_latex)
1889 return lyxrc.getDescription(LyXRC::RC_PREVIEW);
1890 if (ob == dialog_->counter_autosave)
1891 return lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1892 if (ob == dialog_->counter_wm_jump)
1893 return lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1894 if (ob == dialog_->choice_display)
1895 return lyxrc.getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1900 void FormPreferences::LnFmisc::update()
1902 fl_set_button(dialog_->check_auto_region_delete,
1903 lyxrc.auto_region_delete);
1904 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1905 lyxrc.cursor_follows_scrollbar);
1906 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1907 lyxrc.dialogs_iconify_with_main);
1908 fl_set_button(dialog_->check_preview_latex,
1910 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1911 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1913 switch (lyxrc.display_graphics) {
1914 case grfx::NoDisplay: fl_set_choice(dialog_->choice_display, 4); break;
1915 case grfx::ColorDisplay: fl_set_choice(dialog_->choice_display, 3); break;
1916 case grfx::GrayscaleDisplay: fl_set_choice(dialog_->choice_display, 2); break;
1917 case grfx::MonochromeDisplay: fl_set_choice(dialog_->choice_display, 1); break;
1918 default: fl_set_choice(dialog_->choice_display, 3); break;
1923 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1928 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1930 return dialog_.get();
1934 void FormPreferences::OutputsMisc::apply() const
1936 lyxrc.ascii_linelen = static_cast<unsigned int>
1937 (fl_get_counter_value(dialog_->counter_line_len));
1938 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1941 fl_get_choice(dialog_->choice_default_papersize) - 1;
1942 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1944 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1945 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1946 lyxrc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1947 lyxrc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1951 void FormPreferences::OutputsMisc::build()
1953 dialog_.reset(build_preferences_outputs_misc(&parent_));
1955 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1957 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1958 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1959 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1960 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1961 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1963 fl_addto_choice(dialog_->choice_default_papersize,
1964 _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1966 // set up the feedback mechanism
1967 setPrehandler(dialog_->counter_line_len);
1968 setPrehandler(dialog_->input_tex_encoding);
1969 setPrehandler(dialog_->choice_default_papersize);
1970 setPrehandler(dialog_->input_ascii_roff);
1971 setPrehandler(dialog_->input_checktex);
1972 setPrehandler(dialog_->input_paperoption);
1973 setPrehandler(dialog_->check_autoreset_classopt);
1978 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1980 if (ob == dialog_->counter_line_len)
1981 return lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
1982 if (ob == dialog_->input_tex_encoding)
1983 return lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
1984 if (ob == dialog_->input_ascii_roff)
1985 return lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1986 if (ob == dialog_->input_checktex)
1987 return lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
1988 if (ob == dialog_->choice_default_papersize)
1989 return lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1990 if (ob == dialog_->input_paperoption)
1991 return lyxrc.getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
1992 if (ob == dialog_->check_autoreset_classopt)
1993 return lyxrc.getDescription(LyXRC::RC_AUTORESET_OPTIONS);
1998 void FormPreferences::OutputsMisc::update()
2000 fl_set_counter_value(dialog_->counter_line_len,
2001 lyxrc.ascii_linelen);
2002 fl_set_input(dialog_->input_tex_encoding,
2003 lyxrc.fontenc.c_str());
2004 fl_set_choice(dialog_->choice_default_papersize,
2005 lyxrc.default_papersize+1);
2006 fl_set_input(dialog_->input_ascii_roff,
2007 lyxrc.ascii_roff_command.c_str());
2008 fl_set_input(dialog_->input_checktex,
2009 lyxrc.chktex_command.c_str());
2010 fl_set_input(dialog_->input_paperoption,
2011 lyxrc.view_dvi_paper_option.c_str());
2012 fl_set_button(dialog_->check_autoreset_classopt,
2013 lyxrc.auto_reset_options);
2018 FormPreferences::Paths::Paths(FormPreferences & p)
2023 FD_preferences_paths const * FormPreferences::Paths::dialog()
2025 return dialog_.get();
2029 void FormPreferences::Paths::apply()
2031 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2032 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2034 int button = fl_get_button(dialog_->check_use_temp_dir);
2035 string str = fl_get_input(dialog_->input_temp_dir);
2039 lyxrc.use_tempdir = button;
2040 lyxrc.tempdir_path = str;
2042 button = fl_get_button(dialog_->check_last_files);
2043 str = fl_get_input(dialog_->input_lastfiles);
2044 if (!button) str.erase();
2046 lyxrc.check_lastfiles = button;
2047 lyxrc.lastfiles = str;
2048 lyxrc.num_lastfiles = static_cast<unsigned int>
2049 (fl_get_counter_value(dialog_->counter_lastfiles));
2051 button = fl_get_button(dialog_->check_make_backups);
2052 str = fl_get_input(dialog_->input_backup_path);
2056 lyxrc.make_backup = button;
2057 lyxrc.backupdir_path = str;
2059 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2066 void FormPreferences::Paths::build()
2068 dialog_.reset(build_preferences_paths(&parent_));
2070 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2071 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2072 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2073 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2074 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2075 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2076 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2078 // set up the feedback mechanism
2079 setPrehandler(dialog_->input_default_path);
2080 setPrehandler(dialog_->counter_lastfiles);
2081 setPrehandler(dialog_->input_template_path);
2082 setPrehandler(dialog_->check_last_files);
2083 setPrehandler(dialog_->input_lastfiles);
2084 setPrehandler(dialog_->check_make_backups);
2085 setPrehandler(dialog_->input_backup_path);
2086 setPrehandler(dialog_->input_serverpipe);
2087 setPrehandler(dialog_->input_temp_dir);
2088 setPrehandler(dialog_->check_use_temp_dir);
2093 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2095 if (ob == dialog_->input_default_path)
2096 return lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2097 if (ob == dialog_->input_template_path)
2098 return lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2099 if (ob == dialog_->check_use_temp_dir)
2100 return lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2101 if (ob == dialog_->input_temp_dir)
2102 return lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2103 if (ob == dialog_->check_last_files)
2104 return lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2105 if (ob == dialog_->input_lastfiles)
2106 return lyxrc.getDescription(LyXRC::RC_LASTFILES);
2107 if (ob == dialog_->counter_lastfiles)
2108 return lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2109 if (ob == dialog_->check_make_backups)
2110 return lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2111 if (ob == dialog_->input_backup_path)
2112 return lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2113 if (ob == dialog_->input_serverpipe)
2114 return lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2119 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2121 bool activate = true;
2123 // !ob if function is called from Paths::update() to de/activate
2125 // otherwise the function is called by an xforms CB via input().
2126 if (!ob || ob == dialog_->check_use_temp_dir) {
2127 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2128 setEnabled(dialog_->input_temp_dir, enable);
2131 if (!ob || ob == dialog_->check_last_files) {
2132 bool const enable = fl_get_button(dialog_->check_last_files);
2133 setEnabled(dialog_->input_lastfiles, enable);
2136 if (!ob || ob == dialog_->check_make_backups) {
2137 bool const enable = fl_get_button(dialog_->check_make_backups);
2138 setEnabled(dialog_->input_backup_path, enable);
2141 if (!ob || ob == dialog_->input_default_path) {
2142 string const name = fl_get_input(dialog_->input_default_path);
2143 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2144 parent_.postWarning(RWInfo::ErrorMessage());
2149 if (!ob || ob == dialog_->input_template_path) {
2150 string const name = fl_get_input(dialog_->input_template_path);
2151 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2152 parent_.postWarning(RWInfo::ErrorMessage());
2157 if (!ob || ob == dialog_->input_temp_dir) {
2158 string const name = fl_get_input(dialog_->input_temp_dir);
2159 if (fl_get_button(dialog_->check_make_backups)
2161 && !RWInfo::WriteableDir(name)) {
2162 parent_.postWarning(RWInfo::ErrorMessage());
2167 if (!ob || ob == dialog_->input_backup_path) {
2168 string const name = fl_get_input(dialog_->input_backup_path);
2169 if (fl_get_button(dialog_->check_make_backups)
2171 && !RWInfo::WriteableDir(name)) {
2172 parent_.postWarning(RWInfo::ErrorMessage());
2177 if (!ob || ob == dialog_->input_lastfiles) {
2178 string const name = fl_get_input(dialog_->input_lastfiles);
2179 if (fl_get_button(dialog_->check_last_files)
2181 && !RWInfo::WriteableFile(name)) {
2182 parent_.postWarning(RWInfo::ErrorMessage());
2187 if (!ob || ob == dialog_->input_serverpipe) {
2188 string const name = fl_get_input(dialog_->input_serverpipe);
2189 if (!name.empty()) {
2190 // strip off the extension
2191 string const str = ChangeExtension(name, "");
2192 if (!RWInfo::WriteableFile(str + ".in")) {
2193 parent_.postWarning(RWInfo::ErrorMessage());
2196 if (!RWInfo::WriteableFile(str + ".out")) {
2197 parent_.postWarning(RWInfo::ErrorMessage());
2203 if (ob == dialog_->button_default_path_browse) {
2204 parent_.browse(dialog_->input_default_path,
2205 _("Default path"), string());
2206 } else if (ob == dialog_->button_template_path_browse) {
2207 parent_.browse(dialog_->input_template_path,
2208 _("Template path"), string());
2209 } else if (ob == dialog_->button_temp_dir_browse) {
2210 parent_.browse(dialog_->input_temp_dir,
2211 _("Temp dir"), string());
2212 } else if (ob == dialog_->button_lastfiles_browse) {
2213 pair<string, string> dir(_("User|#U#u"), user_lyxdir);
2215 parent_.browse(dialog_->input_lastfiles,
2216 _("Lastfiles"), string(), dir);
2217 } else if (ob == dialog_->button_backup_path_browse) {
2218 parent_.browse(dialog_->input_backup_path,
2219 _("Backup path"), string());
2220 } else if (ob == dialog_->button_serverpipe_browse) {
2221 parent_.browse(dialog_->input_serverpipe,
2222 _("LyX Server pipes"), string());
2229 void FormPreferences::Paths::update()
2231 fl_set_input(dialog_->input_default_path,
2232 lyxrc.document_path.c_str());
2233 fl_set_input(dialog_->input_template_path,
2234 lyxrc.template_path.c_str());
2237 if (lyxrc.make_backup)
2238 str = lyxrc.backupdir_path;
2240 fl_set_button(dialog_->check_make_backups,
2242 fl_set_input(dialog_->input_backup_path, str.c_str());
2245 if (lyxrc.use_tempdir)
2246 str = lyxrc.tempdir_path;
2248 fl_set_button(dialog_->check_use_temp_dir,
2250 fl_set_input(dialog_->input_temp_dir, str.c_str());
2253 if (lyxrc.check_lastfiles)
2254 str = lyxrc.lastfiles;
2256 fl_set_button(dialog_->check_last_files,
2257 lyxrc.check_lastfiles);
2258 fl_set_input(dialog_->input_lastfiles, str.c_str());
2259 fl_set_counter_value(dialog_->counter_lastfiles,
2260 lyxrc.num_lastfiles);
2262 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2264 // Activate/Deactivate the input fields dependent on the state of the
2270 FormPreferences::Printer::Printer(FormPreferences & p)
2275 FD_preferences_printer const * FormPreferences::Printer::dialog()
2277 return dialog_.get();
2281 void FormPreferences::Printer::apply() const
2283 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2284 lyxrc.print_command = fl_get_input(dialog_->input_command);
2285 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2286 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2287 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2288 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2289 lyxrc.print_file_extension =
2290 fl_get_input(dialog_->input_file_extension);
2291 lyxrc.print_spool_command =
2292 fl_get_input(dialog_->input_spool_command);
2293 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2294 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2295 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2296 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2297 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2298 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2299 lyxrc.print_extra_options =
2300 fl_get_input(dialog_->input_extra_options);
2301 lyxrc.print_spool_printerprefix =
2302 fl_get_input(dialog_->input_spool_prefix);
2303 lyxrc.print_paper_dimension_flag =
2304 fl_get_input(dialog_->input_paper_size);
2305 lyxrc.printer = fl_get_input(dialog_->input_name);
2310 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2312 if (ob == dialog_->input_command)
2313 return lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2314 if (ob == dialog_->check_adapt_output)
2315 return lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2316 if (ob == dialog_->input_to_printer)
2317 return lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2318 if (ob == dialog_->input_to_file)
2319 return lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2320 if (ob == dialog_->input_file_extension)
2321 return lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2322 if (ob == dialog_->input_extra_options)
2323 return lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2324 if (ob == dialog_->input_spool_command)
2325 return lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2326 if (ob == dialog_->input_spool_prefix)
2327 return lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2328 if (ob == dialog_->input_name)
2329 return lyxrc.getDescription(LyXRC::RC_PRINTER);
2330 if (ob == dialog_->input_even_pages)
2331 return lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2332 if (ob == dialog_->input_odd_pages)
2333 return lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2334 if (ob == dialog_->input_page_range)
2335 return lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2336 if (ob == dialog_->input_reverse)
2337 return lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2338 if (ob == dialog_->input_landscape)
2339 return lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2340 if (ob == dialog_->input_copies)
2341 return lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2342 if (ob == dialog_->input_collated)
2343 return lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2344 if (ob == dialog_->input_paper_type)
2345 return lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2346 if (ob == dialog_->input_paper_size)
2347 return lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2352 void FormPreferences::Printer::build()
2354 dialog_.reset(build_preferences_printer(&parent_));
2356 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2357 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2358 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2359 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2360 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2361 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2362 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2363 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2364 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2365 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2366 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2367 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2368 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2369 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2370 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2371 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2372 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2374 // set up the feedback mechanism
2375 setPrehandler(dialog_->input_command);
2376 setPrehandler(dialog_->input_page_range);
2377 setPrehandler(dialog_->input_copies);
2378 setPrehandler(dialog_->input_reverse);
2379 setPrehandler(dialog_->input_to_printer);
2380 setPrehandler(dialog_->input_file_extension);
2381 setPrehandler(dialog_->input_spool_command);
2382 setPrehandler(dialog_->input_paper_type);
2383 setPrehandler(dialog_->input_even_pages);
2384 setPrehandler(dialog_->input_odd_pages);
2385 setPrehandler(dialog_->input_collated);
2386 setPrehandler(dialog_->input_landscape);
2387 setPrehandler(dialog_->input_to_file);
2388 setPrehandler(dialog_->input_extra_options);
2389 setPrehandler(dialog_->input_spool_prefix);
2390 setPrehandler(dialog_->input_paper_size);
2391 setPrehandler(dialog_->input_name);
2392 setPrehandler(dialog_->check_adapt_output);
2396 void FormPreferences::Printer::update()
2398 fl_set_button(dialog_->check_adapt_output,
2399 lyxrc.print_adapt_output);
2400 fl_set_input(dialog_->input_command,
2401 lyxrc.print_command.c_str());
2402 fl_set_input(dialog_->input_page_range,
2403 lyxrc.print_pagerange_flag.c_str());
2404 fl_set_input(dialog_->input_copies,
2405 lyxrc.print_copies_flag.c_str());
2406 fl_set_input(dialog_->input_reverse,
2407 lyxrc.print_reverse_flag.c_str());
2408 fl_set_input(dialog_->input_to_printer,
2409 lyxrc.print_to_printer.c_str());
2410 fl_set_input(dialog_->input_file_extension,
2411 lyxrc.print_file_extension.c_str());
2412 fl_set_input(dialog_->input_spool_command,
2413 lyxrc.print_spool_command.c_str());
2414 fl_set_input(dialog_->input_paper_type,
2415 lyxrc.print_paper_flag.c_str());
2416 fl_set_input(dialog_->input_even_pages,
2417 lyxrc.print_evenpage_flag.c_str());
2418 fl_set_input(dialog_->input_odd_pages,
2419 lyxrc.print_oddpage_flag.c_str());
2420 fl_set_input(dialog_->input_collated,
2421 lyxrc.print_collcopies_flag.c_str());
2422 fl_set_input(dialog_->input_landscape,
2423 lyxrc.print_landscape_flag.c_str());
2424 fl_set_input(dialog_->input_to_file,
2425 lyxrc.print_to_file.c_str());
2426 fl_set_input(dialog_->input_extra_options,
2427 lyxrc.print_extra_options.c_str());
2428 fl_set_input(dialog_->input_spool_prefix,
2429 lyxrc.print_spool_printerprefix.c_str());
2430 fl_set_input(dialog_->input_paper_size,
2431 lyxrc.print_paper_dimension_flag.c_str());
2432 fl_set_input(dialog_->input_name,
2433 lyxrc.printer.c_str());
2437 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2442 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2444 return dialog_.get();
2448 void FormPreferences::ScreenFonts::apply() const
2450 bool changed = false;
2452 string str = fl_get_input(dialog_->input_roman);
2453 if (lyxrc.roman_font_name != str) {
2455 lyxrc.roman_font_name = str;
2458 str = fl_get_input(dialog_->input_sans);
2459 if (lyxrc.sans_font_name != str) {
2461 lyxrc.sans_font_name = str;
2464 str = fl_get_input(dialog_->input_typewriter);
2465 if (lyxrc.typewriter_font_name != str) {
2467 lyxrc.typewriter_font_name = str;
2470 str = fl_get_input(dialog_->input_screen_encoding);
2471 if (lyxrc.font_norm != str) {
2473 lyxrc.font_norm = str;
2476 bool button = fl_get_button(dialog_->check_scalable);
2477 if (lyxrc.use_scalable_fonts != button) {
2479 lyxrc.use_scalable_fonts = button;
2482 unsigned int ivalue = static_cast<unsigned int>
2483 (fl_get_counter_value(dialog_->counter_zoom));
2484 if (lyxrc.zoom != ivalue) {
2486 lyxrc.zoom = ivalue;
2489 ivalue = static_cast<unsigned int>
2490 (fl_get_counter_value(dialog_->counter_dpi));
2491 if (lyxrc.dpi != ivalue) {
2496 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2497 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2499 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2502 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2503 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2505 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2508 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2509 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2511 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2514 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2515 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2517 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2520 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2521 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2523 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2526 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2527 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2529 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2532 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2533 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2535 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2538 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2539 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2541 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2544 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2545 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2547 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2550 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2551 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2553 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2557 // Now update the buffers
2558 // Can anything below here affect the redraw process?
2559 parent_.lv_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
2564 void FormPreferences::ScreenFonts::build()
2566 dialog_.reset(build_preferences_screen_fonts(&parent_));
2568 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2569 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2571 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2572 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2573 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2574 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2575 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2576 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2577 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2578 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2579 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2580 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2581 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2582 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2583 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2584 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2585 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2586 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2588 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2589 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2590 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2591 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2592 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2593 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2594 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2595 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2596 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2597 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2599 // set up the feedback mechanism
2600 setPrehandler(dialog_->input_roman);
2601 setPrehandler(dialog_->input_sans);
2602 setPrehandler(dialog_->input_typewriter);
2603 setPrehandler(dialog_->counter_zoom);
2604 setPrehandler(dialog_->counter_dpi);
2605 setPrehandler(dialog_->check_scalable);
2606 setPrehandler(dialog_->input_screen_encoding);
2607 setPrehandler(dialog_->input_tiny);
2608 setPrehandler(dialog_->input_script);
2609 setPrehandler(dialog_->input_footnote);
2610 setPrehandler(dialog_->input_small);
2611 setPrehandler(dialog_->input_large);
2612 setPrehandler(dialog_->input_larger);
2613 setPrehandler(dialog_->input_largest);
2614 setPrehandler(dialog_->input_normal);
2615 setPrehandler(dialog_->input_huge);
2616 setPrehandler(dialog_->input_huger);
2621 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2623 if (ob == dialog_->input_roman)
2624 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2625 if (ob == dialog_->input_sans)
2626 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2627 if (ob == dialog_->input_typewriter)
2628 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2629 if (ob == dialog_->check_scalable)
2630 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2631 if (ob == dialog_->input_screen_encoding)
2632 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2633 if (ob == dialog_->counter_zoom)
2634 return lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2635 if (ob == dialog_->counter_dpi)
2636 return lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2637 if (ob == dialog_->input_tiny
2638 || ob == dialog_->input_script
2639 || ob == dialog_->input_footnote
2640 || ob == dialog_->input_small
2641 || ob == dialog_->input_large
2642 || ob == dialog_->input_larger
2643 || ob == dialog_->input_larger
2644 || ob == dialog_->input_largest
2645 || ob == dialog_->input_normal
2646 || ob == dialog_->input_huge
2647 || ob == dialog_->input_huger)
2648 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2653 bool FormPreferences::ScreenFonts::input()
2655 bool activate = true;
2658 // Make sure that all fonts all have positive entries
2659 // Also note that an empty entry is returned as 0.0 by strToDbl
2660 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2661 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2662 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2663 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2664 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2665 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2666 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2667 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2668 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2669 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2671 str = _("Fonts must be positive!");
2673 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2674 // Fontsizes -- tiny < script < footnote etc.
2675 strToDbl(fl_get_input(dialog_->input_script)) ||
2676 strToDbl(fl_get_input(dialog_->input_script)) >
2677 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2678 strToDbl(fl_get_input(dialog_->input_footnote)) >
2679 strToDbl(fl_get_input(dialog_->input_small)) ||
2680 strToDbl(fl_get_input(dialog_->input_small)) >
2681 strToDbl(fl_get_input(dialog_->input_normal)) ||
2682 strToDbl(fl_get_input(dialog_->input_normal)) >
2683 strToDbl(fl_get_input(dialog_->input_large)) ||
2684 strToDbl(fl_get_input(dialog_->input_large)) >
2685 strToDbl(fl_get_input(dialog_->input_larger)) ||
2686 strToDbl(fl_get_input(dialog_->input_larger)) >
2687 strToDbl(fl_get_input(dialog_->input_largest)) ||
2688 strToDbl(fl_get_input(dialog_->input_largest)) >
2689 strToDbl(fl_get_input(dialog_->input_huge)) ||
2690 strToDbl(fl_get_input(dialog_->input_huge)) >
2691 strToDbl(fl_get_input(dialog_->input_huger))) {
2694 str = _("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2698 parent_.postWarning(str);
2704 void FormPreferences::ScreenFonts::update()
2706 fl_set_input(dialog_->input_roman,
2707 lyxrc.roman_font_name.c_str());
2708 fl_set_input(dialog_->input_sans,
2709 lyxrc.sans_font_name.c_str());
2710 fl_set_input(dialog_->input_typewriter,
2711 lyxrc.typewriter_font_name.c_str());
2712 fl_set_input(dialog_->input_screen_encoding,
2713 lyxrc.font_norm.c_str());
2714 fl_set_button(dialog_->check_scalable,
2715 lyxrc.use_scalable_fonts);
2716 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2717 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2718 fl_set_input(dialog_->input_tiny,
2719 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2720 fl_set_input(dialog_->input_script,
2721 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2722 fl_set_input(dialog_->input_footnote,
2723 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2724 fl_set_input(dialog_->input_small,
2725 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2726 fl_set_input(dialog_->input_normal,
2727 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2728 fl_set_input(dialog_->input_large,
2729 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2730 fl_set_input(dialog_->input_larger,
2731 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2732 fl_set_input(dialog_->input_largest,
2733 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2734 fl_set_input(dialog_->input_huge,
2735 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2736 fl_set_input(dialog_->input_huger,
2737 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2742 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2747 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2749 return dialog_.get();
2753 void FormPreferences::SpellOptions::apply()
2756 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2757 choice = trim(choice);
2759 lyxrc.isp_command = choice;
2762 // If spell checker == "none", all other input set to off.
2763 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2764 lyxrc.isp_use_alt_lang = false;
2765 lyxrc.isp_alt_lang.erase();
2767 lyxrc.isp_use_esc_chars = false;
2768 lyxrc.isp_esc_chars.erase();
2770 lyxrc.isp_use_pers_dict = false;
2771 lyxrc.isp_pers_dict.erase();
2773 lyxrc.isp_accept_compound = false;
2774 lyxrc.isp_use_input_encoding = false;
2777 int button = fl_get_button(dialog_->check_alt_lang);
2778 choice = fl_get_input(dialog_->input_alt_lang);
2779 if (button && choice.empty()) button = 0;
2780 if (!button) choice.erase();
2782 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2783 lyxrc.isp_alt_lang = choice;
2785 button = fl_get_button(dialog_->check_escape_chars);
2786 choice = fl_get_input(dialog_->input_escape_chars);
2787 if (button && choice.empty()) button = 0;
2788 if (!button) choice.erase();
2790 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2791 lyxrc.isp_esc_chars = choice;
2793 button = fl_get_button(dialog_->check_personal_dict);
2794 choice = fl_get_input(dialog_->input_personal_dict);
2795 if (button && choice.empty()) button = 0;
2796 if (!button) choice.erase();
2798 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2799 lyxrc.isp_pers_dict = choice;
2801 button = fl_get_button(dialog_->check_compound_words);
2802 lyxrc.isp_accept_compound = static_cast<bool>(button);
2804 button = fl_get_button(dialog_->check_input_enc);
2805 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2816 void FormPreferences::SpellOptions::build()
2818 dialog_.reset(build_preferences_spelloptions(&parent_));
2820 fl_addto_choice(dialog_->choice_spell_command,
2821 _(" ispell | aspell "));
2822 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2823 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2824 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2826 // set up the feedback mechanism
2827 setPrehandler(dialog_->choice_spell_command);
2828 setPrehandler(dialog_->check_alt_lang);
2829 setPrehandler(dialog_->input_alt_lang);
2830 setPrehandler(dialog_->check_escape_chars);
2831 setPrehandler(dialog_->input_escape_chars);
2832 setPrehandler(dialog_->check_personal_dict);
2833 setPrehandler(dialog_->input_personal_dict);
2834 setPrehandler(dialog_->button_personal_dict);
2835 setPrehandler(dialog_->check_compound_words);
2836 setPrehandler(dialog_->check_input_enc);
2841 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2843 if (ob == dialog_->choice_spell_command)
2844 return lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2845 if (ob == dialog_->check_alt_lang)
2846 return lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2847 if (ob == dialog_->input_alt_lang)
2848 return lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2849 if (ob == dialog_->check_escape_chars)
2850 return lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2851 if (ob == dialog_->input_escape_chars)
2852 return lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2853 if (ob == dialog_->check_personal_dict)
2854 return lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2855 if (ob == dialog_->input_personal_dict)
2856 return lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2857 if (ob == dialog_->check_compound_words)
2858 return lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2859 if (ob == dialog_->check_input_enc)
2860 return lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2865 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2867 // !ob if function is called from updateSpellOptions() to de/activate
2869 // otherwise the function is called by an xforms CB via input().
2872 // If spell checker == "none", disable all input.
2873 if (!ob || ob == dialog_->choice_spell_command) {
2874 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2875 fl_deactivate_object(dialog_->check_alt_lang);
2876 fl_deactivate_object(dialog_->input_alt_lang);
2877 fl_deactivate_object(dialog_->check_escape_chars);
2878 fl_deactivate_object(dialog_->input_escape_chars);
2879 fl_deactivate_object(dialog_->check_personal_dict);
2880 fl_deactivate_object(dialog_->input_personal_dict);
2881 fl_deactivate_object(dialog_->check_compound_words);
2882 fl_deactivate_object(dialog_->check_input_enc);
2885 fl_activate_object(dialog_->check_alt_lang);
2886 fl_activate_object(dialog_->check_escape_chars);
2887 fl_activate_object(dialog_->check_personal_dict);
2888 fl_activate_object(dialog_->check_compound_words);
2889 fl_activate_object(dialog_->check_input_enc);
2894 if (!ob || ob == dialog_->check_alt_lang) {
2895 bool const enable = fl_get_button(dialog_->check_alt_lang);
2896 setEnabled(dialog_->input_alt_lang, enable);
2899 if (!ob || ob == dialog_->check_escape_chars) {
2900 bool const enable = fl_get_button(dialog_->check_escape_chars);
2901 setEnabled(dialog_->input_escape_chars, enable);
2904 if (!ob || ob == dialog_->check_personal_dict) {
2905 bool const enable = fl_get_button(dialog_->check_personal_dict);
2906 setEnabled(dialog_->input_personal_dict, enable);
2909 if (ob == dialog_->button_personal_dict) {
2910 parent_.browse(dialog_->input_personal_dict,
2911 _("Personal dictionary"), "*.ispell");
2914 return true; // All input is valid!
2918 void FormPreferences::SpellOptions::update()
2922 if (lyxrc.isp_command == "none")
2924 else if (lyxrc.isp_command == "ispell")
2926 else if (lyxrc.isp_command == "aspell")
2929 if (lyxrc.isp_command == "ispell")
2931 else if (lyxrc.isp_command == "aspell")
2934 fl_set_choice(dialog_->choice_spell_command, choice);
2937 if (lyxrc.isp_use_alt_lang)
2938 str = lyxrc.isp_alt_lang;
2940 fl_set_button(dialog_->check_alt_lang,
2941 lyxrc.isp_use_alt_lang);
2942 fl_set_input(dialog_->input_alt_lang, str.c_str());
2945 if (lyxrc.isp_use_esc_chars)
2946 str = lyxrc.isp_esc_chars;
2948 fl_set_button(dialog_->check_escape_chars,
2949 lyxrc.isp_use_esc_chars);
2950 fl_set_input(dialog_->input_escape_chars, str.c_str());
2953 if (lyxrc.isp_use_pers_dict)
2954 str = lyxrc.isp_pers_dict;
2956 fl_set_button(dialog_->check_personal_dict,
2957 lyxrc.isp_use_pers_dict);
2958 fl_set_input(dialog_->input_personal_dict, str.c_str());
2960 fl_set_button(dialog_->check_compound_words,
2961 lyxrc.isp_accept_compound);
2962 fl_set_button(dialog_->check_input_enc,
2963 lyxrc.isp_use_input_encoding);
2965 // Activate/Deactivate the input fields dependent on the state of the
2971 void FormPreferences::browse(FL_OBJECT * inpt,
2972 string const & title,
2973 string const & pattern,
2974 pair<string,string> const & dir1,
2975 pair<string,string> const & dir2)
2977 // Get the filename from the dialog
2978 string const filename = fl_get_input(inpt);
2980 // Show the file browser dialog
2981 string const new_filename =
2982 browseFile(&lv_, filename, title, pattern, dir1, dir2);
2984 // Save the filename to the dialog
2985 if (new_filename != filename && !new_filename.empty()) {
2986 fl_set_input(inpt, new_filename.c_str());