2 * \file FormPreferences.C
3 * Copyright 2000-2001 The LyX Team.
4 * See the file COPYING.
6 * \author Angus Leeming <leeming@lyx.org>
12 #pragma implementation
15 #include "FormPreferences.h"
16 #include "forms/form_preferences.h"
20 #include "input_validators.h"
21 #include "forms_gettext.h"
22 #include "xforms_helpers.h"
23 #include "helper_funcs.h"
26 #include "converter.h"
29 #include "frnt_lang.h"
34 #include "funcrequest.h"
36 #include "frontends/LyXView.h"
37 #include "frontends/Dialogs.h"
39 #include "support/lyxfunctional.h"
40 #include "support/lyxmanip.h"
41 #include "support/filetools.h"
42 #include "support/LAssert.h"
44 #include "graphics/GraphicsCache.h"
45 #include "graphics/GraphicsTypes.h"
47 #include <boost/bind.hpp>
49 #include FORMS_H_LOCATION
63 extern string system_lyxdir;
64 extern string user_lyxdir;
68 // These should probably go inside the class definition...
69 Formats local_formats;
70 Converters local_converters;
75 FormPreferences::FormPreferences(LyXView & lv, Dialogs & d)
76 : FormBaseBI(lv, d, _("Preferences"), false),
77 colors_(*this), converters_(*this), inputs_misc_(*this),
78 formats_(*this), interface_(*this), language_(*this),
79 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
80 printer_(*this), screen_fonts_(*this), spelloptions_(*this)
82 // let the dialog be shown
83 // This is a permanent connection so we won't bother
84 // storing a copy because we won't be disconnecting.
88 void FormPreferences::redraw()
90 if (!(form() && form()->visible))
92 fl_redraw_form(form());
94 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
95 if (!(form2 && form2->visible))
97 fl_redraw_form(form2);
100 if (form2 == converters_tab_->form)
101 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
103 else if (form2 == look_n_feel_tab_->form)
104 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
106 else if (form2 == inputs_tab_->form)
107 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
109 else if (form2 == outputs_tab_->form)
110 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
112 else if (form2 == lang_opts_tab_->form)
113 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
115 if (form3 && form3->visible)
116 fl_redraw_form(form3);
120 FL_FORM * FormPreferences::form() const
122 return dialog_.get() ? dialog_->form : 0;
126 void FormPreferences::ok()
128 FormBaseDeprecated::ok();
130 if (colors_.modifiedXformsPrefs) {
131 string const filename =
132 AddName(user_lyxdir, "preferences.xform");
133 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
136 lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
140 void FormPreferences::hide()
142 // We need to hide the active tabfolder otherwise we get a
143 // BadDrawable error from X window and LyX crashes without saving.
144 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
145 if (inner_form && inner_form->visible)
146 fl_hide_form(inner_form);
147 FormBaseDeprecated::hide();
151 void FormPreferences::build()
153 dialog_.reset(build_preferences(this));
155 // Manage the restore, save, apply and cancel/close buttons
156 bc().setOK(dialog_->button_ok);
157 bc().setApply(dialog_->button_apply);
158 bc().setCancel(dialog_->button_close);
159 bc().setRestore(dialog_->button_restore);
161 // Allow the base class to control messages
162 setMessageWidget(dialog_->text_warning);
164 // build the tab folders
165 converters_tab_.reset(build_preferences_inner_tab(this));
166 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
167 inputs_tab_.reset(build_preferences_inner_tab(this));
168 outputs_tab_.reset(build_preferences_inner_tab(this));
169 lang_opts_tab_.reset(build_preferences_inner_tab(this));
171 // build actual tabfolder contents
172 // these will become nested tabfolders
176 inputs_misc_.build();
180 outputs_misc_.build();
183 screen_fonts_.build();
184 spelloptions_.build();
186 // Now add them to the tabfolder
187 fl_addto_tabfolder(dialog_->tabfolder_prefs,
189 look_n_feel_tab_->form);
190 fl_addto_tabfolder(dialog_->tabfolder_prefs,
192 lang_opts_tab_->form);
193 fl_addto_tabfolder(dialog_->tabfolder_prefs,
195 converters_tab_->form);
196 fl_addto_tabfolder(dialog_->tabfolder_prefs,
199 fl_addto_tabfolder(dialog_->tabfolder_prefs,
203 // now build the nested tabfolders
204 // Starting with look and feel
205 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
207 screen_fonts_.dialog()->form);
208 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
210 interface_.dialog()->form);
211 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
213 colors_.dialog()->form);
214 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
216 lnf_misc_.dialog()->form);
218 // then build converters
219 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
221 formats_.dialog()->form);
222 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
224 converters_.dialog()->form);
227 // Paths should probably go in a few inner_tab called Files
228 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
230 paths_.dialog()->form);
231 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
233 inputs_misc_.dialog()->form);
235 // then building outputs
236 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
238 printer_.dialog()->form);
239 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
241 outputs_misc_.dialog()->form);
243 // then building usage
244 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
246 spelloptions_.dialog()->form);
247 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
249 language_.dialog()->form);
253 void FormPreferences::apply()
255 // set the new lyxrc entries
256 // many of these need to trigger other functions when the assignment
257 // is made. For example, screen zoom and font types. These could be
258 // handled either by signals/slots in lyxrc or just directly call the
259 // associated functions here.
260 // There are other problems with this scheme. We really should check
261 // what we copy to make sure that it really is necessary to do things
262 // like update the screen fonts because that flushes the textcache
263 // and other stuff which may cost us a lot on slower/high-load
267 formats_.apply(); // Must be before converters_.apply()
269 inputs_misc_.apply();
273 outputs_misc_.apply();
276 screen_fonts_.apply();
277 spelloptions_.apply();
281 string const FormPreferences::getFeedback(FL_OBJECT * ob)
285 if (ob->form->fdui == colors_.dialog())
286 return colors_.feedback(ob);
287 if (ob->form->fdui == converters_.dialog())
288 return converters_.feedback(ob);
289 if (ob->form->fdui == formats_.dialog())
290 return formats_.feedback(ob);
291 if (ob->form->fdui == inputs_misc_.dialog())
292 return inputs_misc_.feedback(ob);
293 if (ob->form->fdui == interface_.dialog())
294 return interface_.feedback(ob);
295 if (ob->form->fdui == language_.dialog())
296 return language_.feedback(ob);
297 if (ob->form->fdui == lnf_misc_.dialog())
298 return lnf_misc_.feedback(ob);
299 if (ob->form->fdui == outputs_misc_.dialog())
300 return outputs_misc_.feedback(ob);
301 if (ob->form->fdui == paths_.dialog())
302 return paths_.feedback(ob);
303 if (ob->form->fdui == printer_.dialog())
304 return printer_.feedback(ob);
305 if (ob->form->fdui == screen_fonts_.dialog())
306 return screen_fonts_.feedback(ob);
307 if (ob->form->fdui == spelloptions_.dialog())
308 return spelloptions_.feedback(ob);
314 bool FormPreferences::input(FL_OBJECT * ob, long)
318 // whatever checks you need to ensure the user hasn't entered
319 // some totally ridiculous value somewhere. Change activate to suit.
320 // comments before each test describe what is _valid_
322 if (ob->form->fdui == colors_.dialog()) {
326 if (ob->form->fdui == converters_.dialog())
327 return converters_.input(ob);
328 if (ob->form->fdui == formats_.dialog())
329 return formats_.input(ob);
330 if (ob->form->fdui == interface_.dialog())
331 return interface_.input(ob);
332 if (ob->form->fdui == language_.dialog())
333 return language_.input(ob);
334 if (ob->form->fdui == paths_.dialog())
335 return paths_.input(ob);
336 if (ob->form->fdui == screen_fonts_.dialog())
337 return screen_fonts_.input();
338 if (ob->form->fdui == spelloptions_.dialog())
339 return spelloptions_.input(ob);
345 void FormPreferences::update()
347 if (!dialog_.get()) return;
349 // read lyxrc entries
351 formats_.update(); // Must be before converters_.update()
352 converters_.update();
353 inputs_misc_.update();
357 outputs_misc_.update();
360 screen_fonts_.update();
361 spelloptions_.update();
365 FormPreferences::Colors::Colors(FormPreferences & p)
366 : modifiedXformsPrefs(false), parent_(p)
370 FD_preferences_colors const * FormPreferences::Colors::dialog()
372 return dialog_.get();
376 void FormPreferences::Colors::apply()
378 bool modifiedText = false;
379 bool modifiedBackground = false;
381 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
382 cit != xformsColorDB.end(); ++cit) {
384 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
385 if (col != cit->color()) {
386 modifiedXformsPrefs = true;
387 if (cit->colorID == FL_BLACK)
389 if (cit->colorID == FL_COL1)
390 modifiedBackground = true;
394 if (modifiedXformsPrefs) {
395 for (vector<XformsColor>::const_iterator cit =
396 xformsColorDB.begin();
397 cit != xformsColorDB.end(); ++cit) {
398 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
400 if (modifiedText && cit->colorID == FL_BLACK) {
401 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
404 if (modifiedBackground && cit->colorID == FL_COL1) {
405 AdjustVal(FL_MCOL, FL_COL1, 0.1);
406 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
407 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
409 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
410 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
413 if (cit->colorID == GUI_COLOR_CURSOR) {
414 fl_mapcolor(GUI_COLOR_CURSOR,
415 cit->r, cit->g, cit->b);
416 setCursorColor(GUI_COLOR_CURSOR);
419 parent_.lv_.getDialogs().redrawGUI();
422 // Now do the same for the LyX LColors...
423 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
424 cit != lyxColorDB.end(); ++cit) {
425 LColor::color lc = lcolor.getFromGUIName(cit->getname());
426 if (lc == LColor::inherit) continue;
428 // Create a valid X11 name of the form "#rrggbb"
429 string const hexname = X11hexname(cit->color());
431 if (lcolor.getX11Name(lc) != hexname) {
433 << "FormPreferences::Colors::apply: "
434 << "resetting LColor " << lcolor.getGUIName(lc)
435 << " from \"" << lcolor.getX11Name(lc)
436 << "\" to \"" << hexname << "\"."
439 string const s = lcolor.getLyXName(lc) + string(" ") +
441 parent_.lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s));
447 void FormPreferences::Colors::build()
449 dialog_.reset(build_preferences_colors(&parent_));
451 fl_set_object_color(dialog_->button_color,
452 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
454 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
455 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
456 fl_set_dial_step(dialog_->dial_hue, 1.0);
457 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
459 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
460 fl_set_slider_step(dialog_->slider_saturation, 0.01);
461 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
463 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
464 fl_set_slider_step(dialog_->slider_value, 0.01);
465 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
467 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
468 fl_set_slider_step(dialog_->slider_red, 1.0);
469 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
471 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
472 fl_set_slider_step(dialog_->slider_green, 1.0);
473 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
475 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
476 fl_set_slider_step(dialog_->slider_blue, 1.0);
477 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
479 // set up the feedback mechanism
480 setPrehandler(dialog_->browser_lyx_objs);
481 setPrehandler(dialog_->button_color);
482 setPrehandler(dialog_->button_modify);
483 setPrehandler(dialog_->dial_hue);
484 setPrehandler(dialog_->slider_saturation);
485 setPrehandler(dialog_->slider_value);
486 setPrehandler(dialog_->slider_red);
487 setPrehandler(dialog_->slider_green);
488 setPrehandler(dialog_->slider_blue);
489 setPrehandler(dialog_->radio_rgb);
490 setPrehandler(dialog_->radio_hsv);
495 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
497 if (ob == dialog_->browser_lyx_objs)
498 return _("LyX objects that can be assigned a color.");
500 if (ob == dialog_->button_modify)
501 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
503 if (ob == dialog_->dial_hue ||
504 ob == dialog_->slider_saturation ||
505 ob == dialog_->slider_value ||
506 ob == dialog_->slider_red ||
507 ob == dialog_->slider_green ||
508 ob == dialog_->slider_blue)
509 return _("Find a new color.");
511 if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
512 return _("Toggle between RGB and HSV color spaces.");
518 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
520 if (ob == dialog_->browser_lyx_objs) {
523 } else if (ob == dialog_->dial_hue ||
524 ob == dialog_->slider_saturation ||
525 ob == dialog_->slider_value) {
528 } else if (ob == dialog_->slider_red ||
529 ob == dialog_->slider_green ||
530 ob == dialog_->slider_blue) {
533 } else if (ob == dialog_->radio_rgb ||
534 ob == dialog_->radio_hsv) {
537 } else if (ob == dialog_->button_modify) {
543 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
547 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
551 hsv.v = min(1.0, max(0.0, hsv.v));
554 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
558 void FormPreferences::Colors::InputBrowserLyX() const
560 vector<NamedColor>::size_type const selLyX =
561 fl_get_browser(dialog_->browser_lyx_objs);
562 if (selLyX < 1) return;
564 // Is the choice an Xforms color...
567 if (selLyX - 1 < xformsColorDB.size()) {
568 vector<XformsColor>::size_type const i = selLyX - 1;
569 col = xformsColorDB[i].color();
571 // or a LyX Logical color?
573 vector<NamedColor>::size_type const i = selLyX - 1 -
574 xformsColorDB.size();
575 col = lyxColorDB[i].color();
578 fl_freeze_form(dialog_->form);
580 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
581 fl_redraw_object(dialog_->button_color);
583 // Display either RGB or HSV but not both!
586 // Deactivate the modify button to begin with...
587 setEnabled(dialog_->button_modify, false);
589 fl_unfreeze_form(dialog_->form);
593 void FormPreferences::Colors::InputHSV()
595 double const hue = fl_get_dial_value(dialog_->dial_hue);
596 double const sat = fl_get_slider_value(dialog_->slider_saturation);
597 double const val = fl_get_slider_value(dialog_->slider_value);
599 int const h = int(hue);
600 int const s = int(100.0 * sat);
601 int const v = int(100.0 * val);
603 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
605 fl_set_object_label(dialog_->text_color_values, label.c_str());
607 RGBColor col = HSVColor(hue, sat, val);
609 fl_freeze_form(dialog_->form);
611 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
612 fl_redraw_object(dialog_->button_color);
614 col = HSVColor(hue, 1.0, 1.0);
615 col.r = max(col.r, 0);
616 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
617 fl_redraw_object(dialog_->dial_hue);
619 // Ascertain whether to activate the Modify button.
620 vector<NamedColor>::size_type const selLyX =
621 fl_get_browser(dialog_->browser_lyx_objs);
623 fl_unfreeze_form(dialog_->form);
624 if (selLyX < 1) return;
626 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
629 // Is the choice an Xforms color...
630 if (selLyX - 1 < xformsColorDB.size()) {
631 vector<XformsColor>::size_type const i = selLyX - 1;
632 modify = (xformsColorDB[i].color() != col);
634 // or a LyX Logical color?
636 vector<NamedColor>::size_type const i = selLyX - 1 -
637 xformsColorDB.size();
638 modify = (lyxColorDB[i].color() != col);
641 setEnabled(dialog_->button_modify, modify);
645 void FormPreferences::Colors::InputRGB()
647 int const red = int(fl_get_slider_value(dialog_->slider_red));
648 int const green = int(fl_get_slider_value(dialog_->slider_green));
649 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
651 string const label = tostr(red) + string(", ") + tostr(green) +
652 string(", ") + tostr(blue);
653 fl_set_object_label(dialog_->text_color_values, label.c_str());
655 fl_freeze_form(dialog_->form);
657 RGBColor col = RGBColor(red, green, blue);
658 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
659 fl_redraw_object(dialog_->button_color);
661 // Ascertain whether to activate the Modify button.
662 vector<NamedColor>::size_type const selLyX =
663 fl_get_browser(dialog_->browser_lyx_objs);
665 fl_unfreeze_form(dialog_->form);
666 if (selLyX < 1) return;
670 // Is the choice an Xforms color...
671 if (selLyX - 1 < xformsColorDB.size()) {
672 vector<XformsColor>::size_type const i = selLyX - 1;
673 modify = (xformsColorDB[i].color() != col);
675 // or a LyX Logical color?
677 vector<NamedColor>::size_type const i = selLyX - 1 -
678 xformsColorDB.size();
679 modify = (lyxColorDB[i].color() != col);
682 setEnabled(dialog_->button_modify, modify);
686 void FormPreferences::Colors::LoadBrowserLyX()
688 if (!dialog_->browser_lyx_objs->visible)
691 // First, define the modifiable xforms colors
692 xformsColorDB.clear();
695 xcol.name = _("GUI background");
696 xcol.colorID = FL_COL1;
697 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
699 xformsColorDB.push_back(xcol);
701 xcol.name = _("GUI text");
702 xcol.colorID = FL_BLACK;
703 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
705 xformsColorDB.push_back(xcol);
707 xcol.name = _("GUI selection");
708 xcol.colorID = FL_YELLOW;
709 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
711 xformsColorDB.push_back(xcol);
713 xcol.name = _("GUI pointer");
714 xcol.colorID = GUI_COLOR_CURSOR;
715 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
717 xformsColorDB.push_back(xcol);
719 // Now create the the LyX LColors database
721 for (int i=0; i<LColor::ignore; ++i) {
722 LColor::color lc = static_cast<LColor::color>(i);
723 if (lc == LColor::none
724 || lc == LColor::black
725 || lc == LColor::white
727 || lc == LColor::green
728 || lc == LColor::blue
729 || lc == LColor::cyan
730 || lc == LColor::magenta
731 || lc == LColor::yellow
732 || lc == LColor::inherit
733 || lc == LColor::ignore) continue;
735 string const name = lcolor.getX11Name(lc);
736 Display * display = fl_get_display();;
737 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
740 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
742 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
743 << "LColor " << lcolor.getLyXName(lc)
744 << ": X can't find color \"" << name
745 << "\". Set to \"black\"!" << endl;
747 string const arg = lcolor.getLyXName(lc) + " black";
748 parent_.lv_.dispatch(FuncRequest(LFUN_SET_COLOR, arg));
752 // X has found the color. Now find the "appropriate" X11 name
755 // Note that X stores the RGB values in the range 0 - 65535
756 // whilst we require them in the range 0 - 255.
758 col.r = xcol.red / 256;
759 col.g = xcol.green / 256;
760 col.b = xcol.blue / 256;
762 // Create a valid X11 name of the form "#rrggbb" and change the
763 // LColor X11name to this. Don't want to trigger a redraw,
764 // as we're just changing the name not the RGB values.
765 // Also reset the system_lcolor names, so that we don't output
766 // unnecessary changes.
767 string const hexname = X11hexname(col);
769 if (lcolor.getX11Name(lc) != hexname) {
770 lcolor.setColor(lc, hexname);
771 system_lcolor.setColor(lc, hexname);
774 // Finally, push the color onto the database
775 NamedColor ncol(lcolor.getGUIName(lc), col);
776 lyxColorDB.push_back(ncol);
779 // Now construct the browser
780 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
781 fl_freeze_form(dialog_->form);
782 fl_clear_browser(colbr);
783 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
784 cit != xformsColorDB.end(); ++cit) {
785 fl_addto_browser(colbr, cit->getname().c_str());
787 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
788 cit != lyxColorDB.end(); ++cit) {
789 fl_addto_browser(colbr, cit->getname().c_str());
792 // just to be safe...
793 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
794 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
795 fl_unfreeze_form(dialog_->form);
801 void FormPreferences::Colors::Modify()
803 vector<NamedColor>::size_type const selLyX =
804 fl_get_browser(dialog_->browser_lyx_objs);
809 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
811 // Is the choice an Xforms color...
812 if (selLyX - 1 < xformsColorDB.size()) {
813 vector<XformsColor>::size_type const i = selLyX - 1;
814 xformsColorDB[i].r = col.r;
815 xformsColorDB[i].g = col.g;
816 xformsColorDB[i].b = col.b;
818 // or a LyX Logical color?
820 vector<NamedColor>::size_type const i = selLyX - 1 -
821 xformsColorDB.size();
822 lyxColorDB[i].r = col.r;
823 lyxColorDB[i].g = col.g;
824 lyxColorDB[i].b = col.b;
827 fl_freeze_form(dialog_->form);
828 setEnabled(dialog_->button_modify, false);
829 fl_unfreeze_form(dialog_->form);
833 void FormPreferences::Colors::SwitchColorSpace() const
835 bool const hsv = fl_get_button(dialog_->radio_hsv);
838 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
840 fl_freeze_form(dialog_->form);
843 fl_hide_object(dialog_->slider_red);
844 fl_hide_object(dialog_->slider_blue);
845 fl_hide_object(dialog_->slider_green);
846 fl_show_object(dialog_->dial_hue);
847 fl_show_object(dialog_->slider_saturation);
848 fl_show_object(dialog_->slider_value);
850 HSVColor hsv = HSVColor(col);
851 hsv.h = max(hsv.h, 0.0);
853 fl_set_dial_value(dialog_->dial_hue, hsv.h);
854 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
855 fl_set_slider_value(dialog_->slider_value, hsv.v);
857 col = HSVColor(hsv.h, 1.0, 1.0);
858 col.r = max(col.r, 0);
859 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
860 fl_redraw_object(dialog_->dial_hue);
862 // Adjust the label a bit, but not the actual values.
863 // Means that toggling from one space to the other has no
864 // effect on the final color.
865 int const h = int(hsv.h);
866 int const s = int(100 * hsv.s);
867 int const v = int(100 * hsv.v);
868 string const label = tostr(h) + ", " + tostr(s) +
870 fl_set_object_label(dialog_->text_color_values, label.c_str());
873 fl_show_object(dialog_->slider_red);
874 fl_show_object(dialog_->slider_blue);
875 fl_show_object(dialog_->slider_green);
876 fl_hide_object(dialog_->dial_hue);
877 fl_hide_object(dialog_->slider_saturation);
878 fl_hide_object(dialog_->slider_value);
880 fl_set_slider_value(dialog_->slider_red, col.r);
881 fl_set_slider_value(dialog_->slider_green, col.g);
882 fl_set_slider_value(dialog_->slider_blue, col.b);
884 // Adjust the label a bit. Same reasoning as above.
885 int const r = int(col.r);
886 int const g = int(col.g);
887 int const b = int(col.b);
888 string const label = tostr(r) + ", " + tostr(g) +
890 fl_set_object_label(dialog_->text_color_values, label.c_str());
893 fl_unfreeze_form(dialog_->form);
896 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
900 ostr << "#" << std::setbase(16) << setfill('0')
905 return ostr.str().c_str();
909 FormPreferences::Converters::Converters(FormPreferences & p)
914 FD_preferences_converters const * FormPreferences::Converters::dialog()
916 return dialog_.get();
920 void FormPreferences::Converters::apply() const
922 converters = local_converters;
923 converters.update(formats);
924 converters.buildGraph();
928 void FormPreferences::Converters::build()
930 dialog_.reset(build_preferences_converters(&parent_));
932 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
933 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
935 // set up the feedback mechanism
936 setPrehandler(dialog_->browser_all);
937 setPrehandler(dialog_->button_delete);
938 setPrehandler(dialog_->button_add);
939 setPrehandler(dialog_->input_converter);
940 setPrehandler(dialog_->choice_from);
941 setPrehandler(dialog_->choice_to);
942 setPrehandler(dialog_->input_flags);
947 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
949 if (ob == dialog_->browser_all)
950 return _("All the currently defined converters known to LyX.");
952 if (ob == dialog_->choice_from)
953 return _("Convert \"from\" this format");
955 if (ob == dialog_->choice_to)
956 return _("Convert \"to\" this format");
958 if (ob == dialog_->input_converter)
959 return _("The conversion command. $$i is the input file name, "
960 "$$b is the file name without its extension and $$o is "
961 "the name of the output file. $$s can be used as path to "
962 "LyX's own collection of conversion scripts.");
964 if (ob == dialog_->input_flags)
965 return _("Extra information for the Converter class, whether and "
966 "how to parse the result, and various other things.");
968 if (ob == dialog_->button_delete)
969 return _("Remove the current converter from the list of available "
970 "converters. Note: you must then \"Apply\" the change.");
972 if (ob == dialog_->button_add) {
973 if (string(ob->label) == _("Add"))
974 return _("Add the current converter to the list of available "
975 "converters. Note: you must then \"Apply\" the change.");
977 return _("Modify the contents of the current converter. "
978 "Note: you must then \"Apply\" the change.");
985 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
987 if (ob == dialog_->browser_all)
990 if (ob == dialog_->choice_from
991 || ob == dialog_->choice_to
992 || ob == dialog_->input_converter
993 || ob == dialog_->input_flags)
996 if (ob == dialog_->button_add)
999 if (ob == dialog_->button_delete)
1006 void FormPreferences::Converters::update()
1008 local_converters = converters;
1009 local_converters.update(local_formats);
1014 void FormPreferences::Converters::UpdateBrowser()
1016 local_converters.sort();
1018 fl_freeze_form(dialog_->form);
1019 fl_clear_browser(dialog_->browser_all);
1020 for (::Converters::const_iterator cit = local_converters.begin();
1021 cit != local_converters.end(); ++cit) {
1022 string const name = cit->From->prettyname() + " -> "
1023 + cit->To->prettyname();
1024 fl_addto_browser(dialog_->browser_all, name.c_str());
1027 fl_unfreeze_form(dialog_->form);
1031 bool FormPreferences::Converters::Add()
1033 string const from = GetFrom();
1034 string const to = GetTo();
1035 string const command = fl_get_input(dialog_->input_converter);
1036 string const flags = fl_get_input(dialog_->input_flags);
1038 Converter const * old = local_converters.getConverter(from, to);
1039 local_converters.add(from, to, command, flags);
1041 local_converters.updateLast(local_formats);
1044 setEnabled(dialog_->button_add, false);
1050 bool FormPreferences::Converters::Browser()
1052 int const i = fl_get_browser(dialog_->browser_all);
1053 if (i <= 0) return false;
1055 fl_freeze_form(dialog_->form);
1057 Converter const & c = local_converters.get(i - 1);
1058 int j = local_formats.getNumber(c.from);
1060 fl_set_choice(dialog_->choice_from, j + 1);
1062 j = local_formats.getNumber(c.to);
1064 fl_set_choice(dialog_->choice_to, j + 1);
1066 fl_set_input(dialog_->input_converter, c.command.c_str());
1067 fl_set_input(dialog_->input_flags, c.flags.c_str());
1069 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1070 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1072 setEnabled(dialog_->button_add, false);
1073 setEnabled(dialog_->button_delete, true);
1075 fl_unfreeze_form(dialog_->form);
1080 bool FormPreferences::Converters::erase()
1082 string const from = GetFrom();
1083 string const to = GetTo();
1085 local_converters.erase(from, to);
1091 bool FormPreferences::Converters::Input()
1093 string const from = GetFrom();
1094 string const to = GetTo();
1095 int const sel = local_converters.getNumber(from, to);
1097 fl_freeze_form(dialog_->form);
1100 fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
1101 fl_set_button_shortcut(dialog_->button_add,
1102 scex(_("Add|#A")), 1);
1104 fl_deselect_browser(dialog_->browser_all);
1105 setEnabled(dialog_->button_delete, false);
1108 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1109 fl_set_button_shortcut(dialog_->button_add,
1110 scex(_("Modify|#M")), 1);
1112 int top = max(sel-5, 0);
1113 fl_set_browser_topline(dialog_->browser_all, top);
1114 fl_select_browser_line(dialog_->browser_all, sel+1);
1115 setEnabled(dialog_->button_delete, true);
1118 string const command = rtrim(fl_get_input(dialog_->input_converter));
1119 bool const enable = !(command.empty() || from == to);
1120 setEnabled(dialog_->button_add, enable);
1122 fl_unfreeze_form(dialog_->form);
1127 string const FormPreferences::Converters::GetFrom() const
1129 ::Formats::FormatList::size_type const i =
1130 fl_get_choice(dialog_->choice_from);
1132 if (i > 0 && i <= local_formats.size())
1133 return local_formats.get(i - 1).name();
1135 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1140 string const FormPreferences::Converters::GetTo() const
1142 ::Formats::FormatList::size_type const i =
1143 fl_get_choice(dialog_->choice_to);
1145 if (i > 0 && i <= local_formats.size())
1146 return local_formats.get(i - 1).name();
1148 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1153 void FormPreferences::Converters::UpdateChoices() const
1156 for (::Formats::const_iterator cit = local_formats.begin();
1157 cit != local_formats.end(); ++cit) {
1158 if (!choice.empty())
1162 choice += cit->prettyname();
1166 fl_clear_choice(dialog_->choice_from);
1167 fl_addto_choice(dialog_->choice_from, choice.c_str());
1169 fl_clear_choice(dialog_->choice_to);
1170 fl_addto_choice(dialog_->choice_to, choice.c_str());
1174 FormPreferences::Formats::Formats(FormPreferences & p)
1179 FD_preferences_formats const * FormPreferences::Formats::dialog()
1181 return dialog_.get();
1185 void FormPreferences::Formats::apply() const
1187 formats = local_formats;
1191 void FormPreferences::Formats::build()
1193 dialog_.reset(build_preferences_formats(&parent_));
1195 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1196 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1197 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1198 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1199 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1201 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1203 // set up the feedback mechanism
1204 setPrehandler(dialog_->browser_all);
1205 setPrehandler(dialog_->input_format);
1206 setPrehandler(dialog_->input_gui_name);
1207 setPrehandler(dialog_->button_delete);
1208 setPrehandler(dialog_->button_add);
1209 setPrehandler(dialog_->input_extension);
1210 setPrehandler(dialog_->input_viewer);
1211 setPrehandler(dialog_->input_shrtcut);
1216 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1218 if (ob == dialog_->browser_all)
1219 return _("All the currently defined formats known to LyX.");
1221 if (ob == dialog_->input_format)
1222 return _("The format identifier.");
1224 if (ob == dialog_->input_gui_name)
1225 return _("The format name as it will appear in the menus.");
1227 if (ob == dialog_->input_shrtcut)
1228 return _("The keyboard accelerator. Use a letter in the GUI name. "
1231 if (ob == dialog_->input_extension)
1232 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1234 if (ob == dialog_->input_viewer)
1235 return _("The command used to launch the viewer application.");
1237 if (ob == dialog_->button_delete)
1238 return _("Remove the current format from the list of available "
1239 "formats. Note: you must then \"Apply\" the change.");
1241 if (ob == dialog_->button_add) {
1242 if (string(ob->label) == _("Add"))
1243 return _("Add the current format to the list of available "
1244 "formats. Note: you must then \"Apply\" the change.");
1246 return _("Modify the contents of the current format. Note: "
1247 "you must then \"Apply\" the change.");
1254 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1256 if (ob == dialog_->browser_all)
1259 if (ob == dialog_->input_format
1260 || ob == dialog_->input_gui_name
1261 || ob == dialog_->input_shrtcut
1262 || ob == dialog_->input_extension
1263 || ob == dialog_->input_viewer)
1266 if (ob == dialog_->button_add)
1269 if (ob == dialog_->button_delete)
1276 void FormPreferences::Formats::update()
1278 local_formats = formats;
1283 void FormPreferences::Formats::UpdateBrowser()
1285 local_formats.sort();
1287 fl_freeze_form(dialog_->form);
1288 fl_deselect_browser(dialog_->browser_all);
1289 fl_clear_browser(dialog_->browser_all);
1290 for (::Formats::const_iterator cit = local_formats.begin();
1291 cit != local_formats.end(); ++cit)
1292 fl_addto_browser(dialog_->browser_all,
1293 cit->prettyname().c_str());
1296 fl_unfreeze_form(dialog_->form);
1298 // Mustn't forget to update the Formats available to the converters_
1299 parent_.converters_.UpdateChoices();
1300 local_converters.update(local_formats);
1304 bool FormPreferences::Formats::Add()
1306 string const name = fl_get_input(dialog_->input_format);
1307 string const prettyname = fl_get_input(dialog_->input_gui_name);
1308 string const extension = fl_get_input(dialog_->input_extension);
1309 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1310 string const viewer = fl_get_input(dialog_->input_viewer);
1312 Format const * old = local_formats.getFormat(name);
1313 string const old_prettyname = old ? old->prettyname() : string();
1314 local_formats.add(name, extension, prettyname, shortcut);
1315 local_formats.setViewer(name, viewer);
1316 if (!old || prettyname != old_prettyname) {
1319 parent_.converters_.UpdateBrowser();
1321 setEnabled(dialog_->button_add, false);
1327 bool FormPreferences::Formats::Browser()
1329 int const i = fl_get_browser(dialog_->browser_all);
1333 fl_freeze_form(dialog_->form);
1335 Format const & f = local_formats.get(i - 1);
1337 fl_set_input(dialog_->input_format, f.name().c_str());
1338 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1339 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1340 fl_set_input(dialog_->input_extension, f.extension().c_str());
1341 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1343 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1344 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1346 setEnabled(dialog_->button_add, false);
1347 setEnabled(dialog_->button_delete, true);
1349 fl_unfreeze_form(dialog_->form);
1354 bool FormPreferences::Formats::erase()
1356 string const name = fl_get_input(dialog_->input_format);
1358 if (local_converters.formatIsUsed(name)) {
1359 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1360 "Remove the converter first."));
1361 setEnabled(dialog_->button_delete, false);
1365 local_formats.erase(name);
1371 bool FormPreferences::Formats::Input()
1373 string const name = fl_get_input(dialog_->input_format);
1374 int const sel = local_formats.getNumber(name);
1375 fl_freeze_form(dialog_->form);
1378 fl_set_object_label(dialog_->button_add,
1380 fl_set_button_shortcut(dialog_->button_add,
1381 scex(_("Add|#A")), 1);
1383 fl_deselect_browser(dialog_->browser_all);
1384 setEnabled(dialog_->button_delete, false);
1387 fl_set_object_label(dialog_->button_add,
1388 idex(_("Modify|#M")));
1389 fl_set_button_shortcut(dialog_->button_add,
1390 scex(_("Modify|#M")), 1);
1392 int const top = max(sel-5, 0);
1393 fl_set_browser_topline(dialog_->browser_all, top);
1394 fl_select_browser_line(dialog_->browser_all, sel+1);
1396 setEnabled(dialog_->button_add, true);
1397 setEnabled(dialog_->button_delete, true);
1400 string const prettyname = fl_get_input(dialog_->input_gui_name);
1401 bool const enable = !(name.empty() || prettyname.empty());
1402 setEnabled(dialog_->button_add, enable);
1404 fl_unfreeze_form(dialog_->form);
1409 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1414 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1416 return dialog_.get();
1420 void FormPreferences::InputsMisc::apply() const
1422 lyxrc.date_insert_format =
1423 fl_get_input(dialog_->input_date_format);
1427 void FormPreferences::InputsMisc::build()
1429 dialog_.reset(build_preferences_inputs_misc(&parent_));
1431 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1433 // set up the feedback mechanism
1434 setPrehandler(dialog_->input_date_format);
1439 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1441 if (ob == dialog_->input_date_format)
1442 return lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1447 void FormPreferences::InputsMisc::update()
1449 fl_set_input(dialog_->input_date_format,
1450 lyxrc.date_insert_format.c_str());
1454 FormPreferences::Interface::Interface(FormPreferences & p)
1459 FD_preferences_interface const * FormPreferences::Interface::dialog()
1461 return dialog_.get();
1465 void FormPreferences::Interface::apply() const
1467 lyxrc.popup_normal_font =
1468 fl_get_input(dialog_->input_popup_normal_font);
1469 lyxrc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1470 lyxrc.popup_font_encoding =
1471 fl_get_input(dialog_->input_popup_font_encoding);
1472 lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
1473 lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
1474 lyxrc.override_x_deadkeys =
1475 fl_get_button(dialog_->check_override_x_dead_keys);
1479 void FormPreferences::Interface::build()
1481 dialog_.reset(build_preferences_interface(&parent_));
1483 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1484 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1485 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1486 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1487 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1489 // set up the feedback mechanism
1490 setPrehandler(dialog_->input_popup_normal_font);
1491 setPrehandler(dialog_->input_popup_bold_font);
1492 setPrehandler(dialog_->input_popup_font_encoding);
1493 setPrehandler(dialog_->input_bind_file);
1494 setPrehandler(dialog_->button_bind_file_browse);
1495 setPrehandler(dialog_->input_ui_file);
1496 setPrehandler(dialog_->button_ui_file_browse);
1497 setPrehandler(dialog_->check_override_x_dead_keys);
1502 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1504 if (ob == dialog_->input_popup_normal_font)
1505 return lyxrc.getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1506 if (ob == dialog_->input_popup_bold_font)
1507 return lyxrc.getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1508 if (ob == dialog_->input_popup_font_encoding)
1509 return lyxrc.getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1510 if (ob == dialog_->input_bind_file)
1511 return lyxrc.getDescription(LyXRC::RC_BINDFILE);
1512 if (ob == dialog_->input_ui_file)
1513 return lyxrc.getDescription(LyXRC::RC_UIFILE);
1514 if (ob == dialog_->check_override_x_dead_keys)
1515 return lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1520 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1522 if (ob == dialog_->button_bind_file_browse) {
1523 string dir = AddName(system_lyxdir, "bind");
1524 string name = _("Sys Bind|#S#s");
1525 pair<string,string> dir1(name, dir);
1527 dir = AddName(user_lyxdir, "bind");
1528 name = _("User Bind|#U#u");
1529 pair<string,string> dir2(name, dir);
1531 parent_.browse(dialog_->input_bind_file,
1532 _("Bind file"), "*.bind", dir1, dir2);
1534 } else if (ob == dialog_->button_ui_file_browse) {
1535 string dir = AddName(system_lyxdir, "ui");
1536 string name = _("Sys UI|#S#s");
1537 pair<string,string> dir1(name, dir);
1539 dir = AddName(user_lyxdir, "ui");
1540 name = _("User UI|#U#u");
1541 pair<string,string> dir2(name, dir);
1543 parent_.browse(dialog_->input_ui_file,
1544 _("UI file"), "*.ui", dir1, dir2);
1551 void FormPreferences::Interface::update()
1553 fl_set_input(dialog_->input_popup_normal_font,
1554 lyxrc.popup_normal_font.c_str());
1555 fl_set_input(dialog_->input_popup_bold_font,
1556 lyxrc.popup_bold_font.c_str());
1557 fl_set_input(dialog_->input_popup_font_encoding,
1558 lyxrc.popup_font_encoding.c_str());
1559 fl_set_input(dialog_->input_bind_file,
1560 lyxrc.bind_file.c_str());
1561 fl_set_input(dialog_->input_ui_file,
1562 lyxrc.ui_file.c_str());
1563 fl_set_button(dialog_->check_override_x_dead_keys,
1564 lyxrc.override_x_deadkeys);
1568 FormPreferences::Language::Language(FormPreferences & p)
1573 FD_preferences_language const * FormPreferences::Language::dialog()
1575 return dialog_.get();
1579 void FormPreferences::Language::apply()
1581 int const pos = combo_default_lang->get();
1582 lyxrc.default_language = lang_[pos-1];
1584 int button = fl_get_button(dialog_->check_use_kbmap);
1585 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1586 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1588 button = !(name_1.empty() && name_2.empty());
1589 lyxrc.use_kbmap = static_cast<bool>(button);
1591 if (lyxrc.use_kbmap) {
1592 lyxrc.primary_kbmap = name_1;
1593 lyxrc.secondary_kbmap = name_2;
1596 button = fl_get_button(dialog_->check_rtl_support);
1597 lyxrc.rtl_support = static_cast<bool>(button);
1599 button = fl_get_button(dialog_->check_mark_foreign);
1600 lyxrc.mark_foreign_language = static_cast<bool>(button);
1602 button = fl_get_button(dialog_->check_auto_begin);
1603 lyxrc.language_auto_begin = static_cast<bool>(button);
1605 button = fl_get_button(dialog_->check_auto_end);
1606 lyxrc.language_auto_end = static_cast<bool>(button);
1608 button = fl_get_button(dialog_->check_use_babel);
1609 lyxrc.language_use_babel = static_cast<bool>(button);
1611 button = fl_get_button(dialog_->check_global_options);
1612 lyxrc.language_global_options = static_cast<bool>(button);
1614 lyxrc.language_package = fl_get_input(dialog_->input_package);
1615 lyxrc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1616 lyxrc.language_command_end = fl_get_input(dialog_->input_command_end);
1618 // Ensure that all is self-consistent.
1623 void FormPreferences::Language::build()
1625 dialog_.reset(build_preferences_language(&parent_));
1627 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1628 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1629 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1631 // Store the lang identifiers for later
1632 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1633 lang_ = getSecond(langs);
1635 // The default_language is a combo-box and has to be inserted manually
1636 fl_freeze_form(dialog_->form);
1637 fl_addto_form(dialog_->form);
1639 FL_OBJECT * obj = dialog_->choice_default_lang;
1640 fl_deactivate_object(dialog_->choice_default_lang);
1641 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1642 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
1643 parent_.lang_opts_tab_->tabfolder_inner,
1644 parent_.dialog_->tabfolder_prefs);
1645 combo_default_lang->shortcut("#L",1);
1646 combo_default_lang->setcallback(ComboCB, &parent_);
1648 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1649 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1650 for (; lit != lend; ++lit) {
1651 combo_default_lang->addto(lit->first);
1653 combo_default_lang->select(1);
1656 fl_unfreeze_form(dialog_->form);
1658 // set up the feedback mechanism
1659 setPrehandler(dialog_->input_package);
1660 setPrehandler(dialog_->check_use_kbmap);
1662 // This is safe, as nothing is done to the pointer, other than
1663 // to use its address in a block-if statement.
1664 // No it's not! Leads to crash.
1666 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1667 // C_FormPreferencesFeedbackCB);
1669 setPrehandler(dialog_->input_kbmap1);
1670 setPrehandler(dialog_->input_kbmap2);
1671 setPrehandler(dialog_->check_rtl_support);
1672 setPrehandler(dialog_->check_mark_foreign);
1673 setPrehandler(dialog_->check_auto_begin);
1674 setPrehandler(dialog_->check_auto_end);
1675 setPrehandler(dialog_->check_use_babel);
1676 setPrehandler(dialog_->check_global_options);
1677 setPrehandler(dialog_->input_command_begin);
1678 setPrehandler(dialog_->input_command_end);
1680 // Activate/Deactivate the input fields dependent on the state of the
1687 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1689 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1690 return lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1691 if (ob == dialog_->check_use_kbmap)
1692 return lyxrc.getDescription(LyXRC::RC_KBMAP);
1693 if (ob == dialog_->input_kbmap1)
1694 return lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1695 if (ob == dialog_->input_kbmap2)
1696 return lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1697 if (ob == dialog_->check_rtl_support)
1698 return lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1699 if (ob == dialog_->check_mark_foreign)
1700 return lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1701 if (ob == dialog_->check_auto_begin)
1702 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1703 if (ob == dialog_->check_auto_end)
1704 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1705 if (ob == dialog_->check_use_babel)
1706 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1707 if (ob == dialog_->check_global_options)
1708 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1709 if (ob == dialog_->input_package)
1710 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1711 if (ob == dialog_->input_command_begin)
1712 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1713 if (ob == dialog_->input_command_end)
1714 return lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1719 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1721 bool activate = true;
1723 // !ob if function is called from Language::build() to de/activate
1725 // otherwise the function is called by an xforms CB via input().
1726 if (!ob || ob == dialog_->check_use_kbmap) {
1727 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1728 setEnabled(dialog_->button_kbmap1_browse, enable);
1729 setEnabled(dialog_->button_kbmap2_browse, enable);
1730 setEnabled(dialog_->input_kbmap1, enable);
1731 setEnabled(dialog_->input_kbmap2, enable);
1734 if (ob == dialog_->button_kbmap1_browse) {
1735 string const dir = AddName(system_lyxdir, "kbd");
1736 string const name = _("Key maps|#K#k");
1737 pair<string, string> dir1(name, dir);
1739 parent_.browse(dialog_->input_kbmap1,
1740 _("Keyboard map"), "*.kmap", dir1);
1741 } else if (ob == dialog_->button_kbmap2_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_kbmap2,
1747 _("Keyboard map"), "*.kmap", dir1);
1754 void FormPreferences::Language::update()
1756 fl_set_button(dialog_->check_use_kbmap,
1759 int const pos = int(findPos(lang_, lyxrc.default_language));
1760 combo_default_lang->select(pos + 1);
1762 if (lyxrc.use_kbmap) {
1763 fl_set_input(dialog_->input_kbmap1,
1764 lyxrc.primary_kbmap.c_str());
1765 fl_set_input(dialog_->input_kbmap2,
1766 lyxrc.secondary_kbmap.c_str());
1768 fl_set_input(dialog_->input_kbmap1, "");
1769 fl_set_input(dialog_->input_kbmap2, "");
1772 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1773 fl_set_button(dialog_->check_mark_foreign,
1774 lyxrc.mark_foreign_language);
1775 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1776 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1777 fl_set_button(dialog_->check_use_babel, lyxrc.language_use_babel);
1778 fl_set_button(dialog_->check_global_options,
1779 lyxrc.language_global_options);
1781 fl_set_input(dialog_->input_package,
1782 lyxrc.language_package.c_str());
1783 fl_set_input(dialog_->input_command_begin,
1784 lyxrc.language_command_begin.c_str());
1785 fl_set_input(dialog_->input_command_end,
1786 lyxrc.language_command_end.c_str());
1788 // Activate/Deactivate the input fields dependent on the state of the
1794 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1796 FormPreferences * pre = static_cast<FormPreferences*>(v);
1797 // This is safe, as nothing is done to the pointer, other than
1798 // to use its address in a block-if statement.
1799 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1803 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1808 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1810 return dialog_.get();
1814 void FormPreferences::LnFmisc::apply() const
1816 lyxrc.auto_region_delete =
1817 fl_get_button(dialog_->check_auto_region_delete);
1818 lyxrc.cursor_follows_scrollbar =
1819 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1820 lyxrc.dialogs_iconify_with_main =
1821 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1822 lyxrc.preview = fl_get_button(dialog_->check_preview_latex);
1823 lyxrc.autosave = static_cast<unsigned int>
1824 (fl_get_counter_value(dialog_->counter_autosave));
1825 lyxrc.wheel_jump = static_cast<unsigned int>
1826 (fl_get_counter_value(dialog_->counter_wm_jump));
1829 // grfx::DisplayType old_value = lyxrc.display_graphics;
1830 switch (fl_get_choice(dialog_->choice_display)) {
1831 case 4: lyxrc.display_graphics = grfx::NoDisplay; break;
1832 case 3: lyxrc.display_graphics = grfx::ColorDisplay; break;
1833 case 2: lyxrc.display_graphics = grfx::GrayscaleDisplay; break;
1834 case 1: lyxrc.display_graphics = grfx::MonochromeDisplay; break;
1835 default: lyxrc.display_graphics = grfx::ColorDisplay; break;
1838 #ifdef WITH_WARNINGS
1839 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1842 if (old_value != lyxrc.display_graphics) {
1843 grfx::GCache & gc = grfx::GCache::get();
1850 void FormPreferences::LnFmisc::build()
1852 dialog_.reset(build_preferences_lnf_misc(&parent_));
1854 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1855 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1857 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1858 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1860 // set up the feedback mechanism
1861 setPrehandler(dialog_->check_auto_region_delete);
1862 setPrehandler(dialog_->counter_autosave);
1863 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1864 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1865 setPrehandler(dialog_->check_preview_latex);
1866 setPrehandler(dialog_->counter_wm_jump);
1868 fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
1873 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1875 if (ob == dialog_->check_auto_region_delete)
1876 return lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1877 if (ob == dialog_->check_cursor_follows_scrollbar)
1878 return lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1879 if (ob == dialog_->check_dialogs_iconify_with_main)
1880 return lyxrc.getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1881 if (ob == dialog_->check_preview_latex)
1882 return lyxrc.getDescription(LyXRC::RC_PREVIEW);
1883 if (ob == dialog_->counter_autosave)
1884 return lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1885 if (ob == dialog_->counter_wm_jump)
1886 return lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1887 if (ob == dialog_->choice_display)
1888 return lyxrc.getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1893 void FormPreferences::LnFmisc::update()
1895 fl_set_button(dialog_->check_auto_region_delete,
1896 lyxrc.auto_region_delete);
1897 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1898 lyxrc.cursor_follows_scrollbar);
1899 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1900 lyxrc.dialogs_iconify_with_main);
1901 fl_set_button(dialog_->check_preview_latex,
1903 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1904 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1906 switch (lyxrc.display_graphics) {
1907 case grfx::NoDisplay: fl_set_choice(dialog_->choice_display, 4); break;
1908 case grfx::ColorDisplay: fl_set_choice(dialog_->choice_display, 3); break;
1909 case grfx::GrayscaleDisplay: fl_set_choice(dialog_->choice_display, 2); break;
1910 case grfx::MonochromeDisplay: fl_set_choice(dialog_->choice_display, 1); break;
1911 default: fl_set_choice(dialog_->choice_display, 3); break;
1916 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1921 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1923 return dialog_.get();
1927 void FormPreferences::OutputsMisc::apply() const
1929 lyxrc.ascii_linelen = static_cast<unsigned int>
1930 (fl_get_counter_value(dialog_->counter_line_len));
1931 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1934 fl_get_choice(dialog_->choice_default_papersize) - 1;
1935 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1937 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1938 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1939 lyxrc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1940 lyxrc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1944 void FormPreferences::OutputsMisc::build()
1946 dialog_.reset(build_preferences_outputs_misc(&parent_));
1948 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1950 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1951 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1952 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1953 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1954 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1956 fl_addto_choice(dialog_->choice_default_papersize,
1957 _(" default | US letter | US legal | US executive | A3 | A4 | A5 | B5 "));
1959 // set up the feedback mechanism
1960 setPrehandler(dialog_->counter_line_len);
1961 setPrehandler(dialog_->input_tex_encoding);
1962 setPrehandler(dialog_->choice_default_papersize);
1963 setPrehandler(dialog_->input_ascii_roff);
1964 setPrehandler(dialog_->input_checktex);
1965 setPrehandler(dialog_->input_paperoption);
1966 setPrehandler(dialog_->check_autoreset_classopt);
1971 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1973 if (ob == dialog_->counter_line_len)
1974 return lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
1975 if (ob == dialog_->input_tex_encoding)
1976 return lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
1977 if (ob == dialog_->input_ascii_roff)
1978 return lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1979 if (ob == dialog_->input_checktex)
1980 return lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
1981 if (ob == dialog_->choice_default_papersize)
1982 return lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1983 if (ob == dialog_->input_paperoption)
1984 return lyxrc.getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
1985 if (ob == dialog_->check_autoreset_classopt)
1986 return lyxrc.getDescription(LyXRC::RC_AUTORESET_OPTIONS);
1991 void FormPreferences::OutputsMisc::update()
1993 fl_set_counter_value(dialog_->counter_line_len,
1994 lyxrc.ascii_linelen);
1995 fl_set_input(dialog_->input_tex_encoding,
1996 lyxrc.fontenc.c_str());
1997 fl_set_choice(dialog_->choice_default_papersize,
1998 lyxrc.default_papersize+1);
1999 fl_set_input(dialog_->input_ascii_roff,
2000 lyxrc.ascii_roff_command.c_str());
2001 fl_set_input(dialog_->input_checktex,
2002 lyxrc.chktex_command.c_str());
2003 fl_set_input(dialog_->input_paperoption,
2004 lyxrc.view_dvi_paper_option.c_str());
2005 fl_set_button(dialog_->check_autoreset_classopt,
2006 lyxrc.auto_reset_options);
2011 FormPreferences::Paths::Paths(FormPreferences & p)
2016 FD_preferences_paths const * FormPreferences::Paths::dialog()
2018 return dialog_.get();
2022 void FormPreferences::Paths::apply()
2024 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2025 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2027 int button = fl_get_button(dialog_->check_use_temp_dir);
2028 string str = fl_get_input(dialog_->input_temp_dir);
2032 lyxrc.use_tempdir = button;
2033 lyxrc.tempdir_path = str;
2035 button = fl_get_button(dialog_->check_last_files);
2036 str = fl_get_input(dialog_->input_lastfiles);
2037 if (!button) str.erase();
2039 lyxrc.check_lastfiles = button;
2040 lyxrc.lastfiles = str;
2041 lyxrc.num_lastfiles = static_cast<unsigned int>
2042 (fl_get_counter_value(dialog_->counter_lastfiles));
2044 button = fl_get_button(dialog_->check_make_backups);
2045 str = fl_get_input(dialog_->input_backup_path);
2049 lyxrc.make_backup = button;
2050 lyxrc.backupdir_path = str;
2052 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2059 void FormPreferences::Paths::build()
2061 dialog_.reset(build_preferences_paths(&parent_));
2063 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2064 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2065 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2066 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2067 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2068 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2069 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2071 // set up the feedback mechanism
2072 setPrehandler(dialog_->input_default_path);
2073 setPrehandler(dialog_->counter_lastfiles);
2074 setPrehandler(dialog_->input_template_path);
2075 setPrehandler(dialog_->check_last_files);
2076 setPrehandler(dialog_->input_lastfiles);
2077 setPrehandler(dialog_->check_make_backups);
2078 setPrehandler(dialog_->input_backup_path);
2079 setPrehandler(dialog_->input_serverpipe);
2080 setPrehandler(dialog_->input_temp_dir);
2081 setPrehandler(dialog_->check_use_temp_dir);
2086 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2088 if (ob == dialog_->input_default_path)
2089 return lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2090 if (ob == dialog_->input_template_path)
2091 return lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2092 if (ob == dialog_->check_use_temp_dir)
2093 return lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2094 if (ob == dialog_->input_temp_dir)
2095 return lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2096 if (ob == dialog_->check_last_files)
2097 return lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2098 if (ob == dialog_->input_lastfiles)
2099 return lyxrc.getDescription(LyXRC::RC_LASTFILES);
2100 if (ob == dialog_->counter_lastfiles)
2101 return lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2102 if (ob == dialog_->check_make_backups)
2103 return lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2104 if (ob == dialog_->input_backup_path)
2105 return lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2106 if (ob == dialog_->input_serverpipe)
2107 return lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2112 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2114 bool activate = true;
2116 // !ob if function is called from Paths::update() to de/activate
2118 // otherwise the function is called by an xforms CB via input().
2119 if (!ob || ob == dialog_->check_use_temp_dir) {
2120 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2121 setEnabled(dialog_->input_temp_dir, enable);
2124 if (!ob || ob == dialog_->check_last_files) {
2125 bool const enable = fl_get_button(dialog_->check_last_files);
2126 setEnabled(dialog_->input_lastfiles, enable);
2129 if (!ob || ob == dialog_->check_make_backups) {
2130 bool const enable = fl_get_button(dialog_->check_make_backups);
2131 setEnabled(dialog_->input_backup_path, enable);
2134 if (!ob || ob == dialog_->input_default_path) {
2135 string const name = fl_get_input(dialog_->input_default_path);
2136 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2137 parent_.postWarning(RWInfo::ErrorMessage());
2142 if (!ob || ob == dialog_->input_template_path) {
2143 string const name = fl_get_input(dialog_->input_template_path);
2144 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2145 parent_.postWarning(RWInfo::ErrorMessage());
2150 if (!ob || ob == dialog_->input_temp_dir) {
2151 string const name = fl_get_input(dialog_->input_temp_dir);
2152 if (fl_get_button(dialog_->check_make_backups)
2154 && !RWInfo::WriteableDir(name)) {
2155 parent_.postWarning(RWInfo::ErrorMessage());
2160 if (!ob || ob == dialog_->input_backup_path) {
2161 string const name = fl_get_input(dialog_->input_backup_path);
2162 if (fl_get_button(dialog_->check_make_backups)
2164 && !RWInfo::WriteableDir(name)) {
2165 parent_.postWarning(RWInfo::ErrorMessage());
2170 if (!ob || ob == dialog_->input_lastfiles) {
2171 string const name = fl_get_input(dialog_->input_lastfiles);
2172 if (fl_get_button(dialog_->check_last_files)
2174 && !RWInfo::WriteableFile(name)) {
2175 parent_.postWarning(RWInfo::ErrorMessage());
2180 if (!ob || ob == dialog_->input_serverpipe) {
2181 string const name = fl_get_input(dialog_->input_serverpipe);
2182 if (!name.empty()) {
2183 // strip off the extension
2184 string const str = ChangeExtension(name, "");
2185 if (!RWInfo::WriteableFile(str + ".in")) {
2186 parent_.postWarning(RWInfo::ErrorMessage());
2189 if (!RWInfo::WriteableFile(str + ".out")) {
2190 parent_.postWarning(RWInfo::ErrorMessage());
2196 if (ob == dialog_->button_default_path_browse) {
2197 parent_.browse(dialog_->input_default_path,
2198 _("Default path"), string());
2199 } else if (ob == dialog_->button_template_path_browse) {
2200 parent_.browse(dialog_->input_template_path,
2201 _("Template path"), string());
2202 } else if (ob == dialog_->button_temp_dir_browse) {
2203 parent_.browse(dialog_->input_temp_dir,
2204 _("Temp dir"), string());
2205 } else if (ob == dialog_->button_lastfiles_browse) {
2206 pair<string, string> dir(_("User|#U#u"), user_lyxdir);
2208 parent_.browse(dialog_->input_lastfiles,
2209 _("Lastfiles"), string(), dir);
2210 } else if (ob == dialog_->button_backup_path_browse) {
2211 parent_.browse(dialog_->input_backup_path,
2212 _("Backup path"), string());
2213 } else if (ob == dialog_->button_serverpipe_browse) {
2214 parent_.browse(dialog_->input_serverpipe,
2215 _("LyX Server pipes"), string());
2222 void FormPreferences::Paths::update()
2224 fl_set_input(dialog_->input_default_path,
2225 lyxrc.document_path.c_str());
2226 fl_set_input(dialog_->input_template_path,
2227 lyxrc.template_path.c_str());
2230 if (lyxrc.make_backup)
2231 str = lyxrc.backupdir_path;
2233 fl_set_button(dialog_->check_make_backups,
2235 fl_set_input(dialog_->input_backup_path, str.c_str());
2238 if (lyxrc.use_tempdir)
2239 str = lyxrc.tempdir_path;
2241 fl_set_button(dialog_->check_use_temp_dir,
2243 fl_set_input(dialog_->input_temp_dir, str.c_str());
2246 if (lyxrc.check_lastfiles)
2247 str = lyxrc.lastfiles;
2249 fl_set_button(dialog_->check_last_files,
2250 lyxrc.check_lastfiles);
2251 fl_set_input(dialog_->input_lastfiles, str.c_str());
2252 fl_set_counter_value(dialog_->counter_lastfiles,
2253 lyxrc.num_lastfiles);
2255 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2257 // Activate/Deactivate the input fields dependent on the state of the
2263 FormPreferences::Printer::Printer(FormPreferences & p)
2268 FD_preferences_printer const * FormPreferences::Printer::dialog()
2270 return dialog_.get();
2274 void FormPreferences::Printer::apply() const
2276 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2277 lyxrc.print_command = fl_get_input(dialog_->input_command);
2278 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2279 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2280 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2281 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2282 lyxrc.print_file_extension =
2283 fl_get_input(dialog_->input_file_extension);
2284 lyxrc.print_spool_command =
2285 fl_get_input(dialog_->input_spool_command);
2286 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2287 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2288 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2289 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2290 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2291 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2292 lyxrc.print_extra_options =
2293 fl_get_input(dialog_->input_extra_options);
2294 lyxrc.print_spool_printerprefix =
2295 fl_get_input(dialog_->input_spool_prefix);
2296 lyxrc.print_paper_dimension_flag =
2297 fl_get_input(dialog_->input_paper_size);
2298 lyxrc.printer = fl_get_input(dialog_->input_name);
2303 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2305 if (ob == dialog_->input_command)
2306 return lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2307 if (ob == dialog_->check_adapt_output)
2308 return lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2309 if (ob == dialog_->input_to_printer)
2310 return lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2311 if (ob == dialog_->input_to_file)
2312 return lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2313 if (ob == dialog_->input_file_extension)
2314 return lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2315 if (ob == dialog_->input_extra_options)
2316 return lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2317 if (ob == dialog_->input_spool_command)
2318 return lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2319 if (ob == dialog_->input_spool_prefix)
2320 return lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2321 if (ob == dialog_->input_name)
2322 return lyxrc.getDescription(LyXRC::RC_PRINTER);
2323 if (ob == dialog_->input_even_pages)
2324 return lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2325 if (ob == dialog_->input_odd_pages)
2326 return lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2327 if (ob == dialog_->input_page_range)
2328 return lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2329 if (ob == dialog_->input_reverse)
2330 return lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2331 if (ob == dialog_->input_landscape)
2332 return lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2333 if (ob == dialog_->input_copies)
2334 return lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2335 if (ob == dialog_->input_collated)
2336 return lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2337 if (ob == dialog_->input_paper_type)
2338 return lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2339 if (ob == dialog_->input_paper_size)
2340 return lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2345 void FormPreferences::Printer::build()
2347 dialog_.reset(build_preferences_printer(&parent_));
2349 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2350 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2351 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2352 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2353 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2354 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2355 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2356 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2357 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2358 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2359 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2360 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2361 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2362 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2363 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2364 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2365 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2367 // set up the feedback mechanism
2368 setPrehandler(dialog_->input_command);
2369 setPrehandler(dialog_->input_page_range);
2370 setPrehandler(dialog_->input_copies);
2371 setPrehandler(dialog_->input_reverse);
2372 setPrehandler(dialog_->input_to_printer);
2373 setPrehandler(dialog_->input_file_extension);
2374 setPrehandler(dialog_->input_spool_command);
2375 setPrehandler(dialog_->input_paper_type);
2376 setPrehandler(dialog_->input_even_pages);
2377 setPrehandler(dialog_->input_odd_pages);
2378 setPrehandler(dialog_->input_collated);
2379 setPrehandler(dialog_->input_landscape);
2380 setPrehandler(dialog_->input_to_file);
2381 setPrehandler(dialog_->input_extra_options);
2382 setPrehandler(dialog_->input_spool_prefix);
2383 setPrehandler(dialog_->input_paper_size);
2384 setPrehandler(dialog_->input_name);
2385 setPrehandler(dialog_->check_adapt_output);
2389 void FormPreferences::Printer::update()
2391 fl_set_button(dialog_->check_adapt_output,
2392 lyxrc.print_adapt_output);
2393 fl_set_input(dialog_->input_command,
2394 lyxrc.print_command.c_str());
2395 fl_set_input(dialog_->input_page_range,
2396 lyxrc.print_pagerange_flag.c_str());
2397 fl_set_input(dialog_->input_copies,
2398 lyxrc.print_copies_flag.c_str());
2399 fl_set_input(dialog_->input_reverse,
2400 lyxrc.print_reverse_flag.c_str());
2401 fl_set_input(dialog_->input_to_printer,
2402 lyxrc.print_to_printer.c_str());
2403 fl_set_input(dialog_->input_file_extension,
2404 lyxrc.print_file_extension.c_str());
2405 fl_set_input(dialog_->input_spool_command,
2406 lyxrc.print_spool_command.c_str());
2407 fl_set_input(dialog_->input_paper_type,
2408 lyxrc.print_paper_flag.c_str());
2409 fl_set_input(dialog_->input_even_pages,
2410 lyxrc.print_evenpage_flag.c_str());
2411 fl_set_input(dialog_->input_odd_pages,
2412 lyxrc.print_oddpage_flag.c_str());
2413 fl_set_input(dialog_->input_collated,
2414 lyxrc.print_collcopies_flag.c_str());
2415 fl_set_input(dialog_->input_landscape,
2416 lyxrc.print_landscape_flag.c_str());
2417 fl_set_input(dialog_->input_to_file,
2418 lyxrc.print_to_file.c_str());
2419 fl_set_input(dialog_->input_extra_options,
2420 lyxrc.print_extra_options.c_str());
2421 fl_set_input(dialog_->input_spool_prefix,
2422 lyxrc.print_spool_printerprefix.c_str());
2423 fl_set_input(dialog_->input_paper_size,
2424 lyxrc.print_paper_dimension_flag.c_str());
2425 fl_set_input(dialog_->input_name,
2426 lyxrc.printer.c_str());
2430 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2435 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2437 return dialog_.get();
2441 void FormPreferences::ScreenFonts::apply() const
2443 bool changed = false;
2445 string str = fl_get_input(dialog_->input_roman);
2446 if (lyxrc.roman_font_name != str) {
2448 lyxrc.roman_font_name = str;
2451 str = fl_get_input(dialog_->input_sans);
2452 if (lyxrc.sans_font_name != str) {
2454 lyxrc.sans_font_name = str;
2457 str = fl_get_input(dialog_->input_typewriter);
2458 if (lyxrc.typewriter_font_name != str) {
2460 lyxrc.typewriter_font_name = str;
2463 str = fl_get_input(dialog_->input_screen_encoding);
2464 if (lyxrc.font_norm != str) {
2466 lyxrc.font_norm = str;
2469 bool button = fl_get_button(dialog_->check_scalable);
2470 if (lyxrc.use_scalable_fonts != button) {
2472 lyxrc.use_scalable_fonts = button;
2475 unsigned int ivalue = static_cast<unsigned int>
2476 (fl_get_counter_value(dialog_->counter_zoom));
2477 if (lyxrc.zoom != ivalue) {
2479 lyxrc.zoom = ivalue;
2482 ivalue = static_cast<unsigned int>
2483 (fl_get_counter_value(dialog_->counter_dpi));
2484 if (lyxrc.dpi != ivalue) {
2489 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2490 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2492 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2495 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2496 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2498 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2501 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2502 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2504 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2507 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2508 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2510 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2513 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2514 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2516 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2519 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2520 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2522 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2525 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2526 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2528 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2531 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2532 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2534 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2537 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2538 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2540 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2543 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2544 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2546 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2550 // Now update the buffers
2551 // Can anything below here affect the redraw process?
2552 parent_.lv_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
2557 void FormPreferences::ScreenFonts::build()
2559 dialog_.reset(build_preferences_screen_fonts(&parent_));
2561 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2562 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2564 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2565 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2566 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2567 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2568 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2569 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2570 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2571 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2572 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2573 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2574 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2575 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2576 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2577 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2578 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2579 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2581 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2582 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2583 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2584 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2585 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2586 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2587 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2588 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2589 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2590 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2592 // set up the feedback mechanism
2593 setPrehandler(dialog_->input_roman);
2594 setPrehandler(dialog_->input_sans);
2595 setPrehandler(dialog_->input_typewriter);
2596 setPrehandler(dialog_->counter_zoom);
2597 setPrehandler(dialog_->counter_dpi);
2598 setPrehandler(dialog_->check_scalable);
2599 setPrehandler(dialog_->input_screen_encoding);
2600 setPrehandler(dialog_->input_tiny);
2601 setPrehandler(dialog_->input_script);
2602 setPrehandler(dialog_->input_footnote);
2603 setPrehandler(dialog_->input_small);
2604 setPrehandler(dialog_->input_large);
2605 setPrehandler(dialog_->input_larger);
2606 setPrehandler(dialog_->input_largest);
2607 setPrehandler(dialog_->input_normal);
2608 setPrehandler(dialog_->input_huge);
2609 setPrehandler(dialog_->input_huger);
2614 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2616 if (ob == dialog_->input_roman)
2617 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2618 if (ob == dialog_->input_sans)
2619 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2620 if (ob == dialog_->input_typewriter)
2621 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2622 if (ob == dialog_->check_scalable)
2623 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2624 if (ob == dialog_->input_screen_encoding)
2625 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2626 if (ob == dialog_->counter_zoom)
2627 return lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2628 if (ob == dialog_->counter_dpi)
2629 return lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2630 if (ob == dialog_->input_tiny
2631 || ob == dialog_->input_script
2632 || ob == dialog_->input_footnote
2633 || ob == dialog_->input_small
2634 || ob == dialog_->input_large
2635 || ob == dialog_->input_larger
2636 || ob == dialog_->input_larger
2637 || ob == dialog_->input_largest
2638 || ob == dialog_->input_normal
2639 || ob == dialog_->input_huge
2640 || ob == dialog_->input_huger)
2641 return lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2646 bool FormPreferences::ScreenFonts::input()
2648 bool activate = true;
2651 // Make sure that all fonts all have positive entries
2652 // Also note that an empty entry is returned as 0.0 by strToDbl
2653 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2654 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2655 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2656 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2657 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2658 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2659 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2660 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2661 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2662 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2664 str = _("Fonts must be positive!");
2666 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2667 // Fontsizes -- tiny < script < footnote etc.
2668 strToDbl(fl_get_input(dialog_->input_script)) ||
2669 strToDbl(fl_get_input(dialog_->input_script)) >
2670 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2671 strToDbl(fl_get_input(dialog_->input_footnote)) >
2672 strToDbl(fl_get_input(dialog_->input_small)) ||
2673 strToDbl(fl_get_input(dialog_->input_small)) >
2674 strToDbl(fl_get_input(dialog_->input_normal)) ||
2675 strToDbl(fl_get_input(dialog_->input_normal)) >
2676 strToDbl(fl_get_input(dialog_->input_large)) ||
2677 strToDbl(fl_get_input(dialog_->input_large)) >
2678 strToDbl(fl_get_input(dialog_->input_larger)) ||
2679 strToDbl(fl_get_input(dialog_->input_larger)) >
2680 strToDbl(fl_get_input(dialog_->input_largest)) ||
2681 strToDbl(fl_get_input(dialog_->input_largest)) >
2682 strToDbl(fl_get_input(dialog_->input_huge)) ||
2683 strToDbl(fl_get_input(dialog_->input_huge)) >
2684 strToDbl(fl_get_input(dialog_->input_huger))) {
2687 str = _("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2691 parent_.postWarning(str);
2697 void FormPreferences::ScreenFonts::update()
2699 fl_set_input(dialog_->input_roman,
2700 lyxrc.roman_font_name.c_str());
2701 fl_set_input(dialog_->input_sans,
2702 lyxrc.sans_font_name.c_str());
2703 fl_set_input(dialog_->input_typewriter,
2704 lyxrc.typewriter_font_name.c_str());
2705 fl_set_input(dialog_->input_screen_encoding,
2706 lyxrc.font_norm.c_str());
2707 fl_set_button(dialog_->check_scalable,
2708 lyxrc.use_scalable_fonts);
2709 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2710 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2711 fl_set_input(dialog_->input_tiny,
2712 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2713 fl_set_input(dialog_->input_script,
2714 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2715 fl_set_input(dialog_->input_footnote,
2716 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2717 fl_set_input(dialog_->input_small,
2718 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2719 fl_set_input(dialog_->input_normal,
2720 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2721 fl_set_input(dialog_->input_large,
2722 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2723 fl_set_input(dialog_->input_larger,
2724 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2725 fl_set_input(dialog_->input_largest,
2726 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2727 fl_set_input(dialog_->input_huge,
2728 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2729 fl_set_input(dialog_->input_huger,
2730 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2735 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2740 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2742 return dialog_.get();
2746 void FormPreferences::SpellOptions::apply()
2749 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2750 choice = trim(choice);
2752 lyxrc.isp_command = choice;
2755 // If spell checker == "none", all other input set to off.
2756 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2757 lyxrc.isp_use_alt_lang = false;
2758 lyxrc.isp_alt_lang.erase();
2760 lyxrc.isp_use_esc_chars = false;
2761 lyxrc.isp_esc_chars.erase();
2763 lyxrc.isp_use_pers_dict = false;
2764 lyxrc.isp_pers_dict.erase();
2766 lyxrc.isp_accept_compound = false;
2767 lyxrc.isp_use_input_encoding = false;
2770 int button = fl_get_button(dialog_->check_alt_lang);
2771 choice = fl_get_input(dialog_->input_alt_lang);
2772 if (button && choice.empty()) button = 0;
2773 if (!button) choice.erase();
2775 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2776 lyxrc.isp_alt_lang = choice;
2778 button = fl_get_button(dialog_->check_escape_chars);
2779 choice = fl_get_input(dialog_->input_escape_chars);
2780 if (button && choice.empty()) button = 0;
2781 if (!button) choice.erase();
2783 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2784 lyxrc.isp_esc_chars = choice;
2786 button = fl_get_button(dialog_->check_personal_dict);
2787 choice = fl_get_input(dialog_->input_personal_dict);
2788 if (button && choice.empty()) button = 0;
2789 if (!button) choice.erase();
2791 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2792 lyxrc.isp_pers_dict = choice;
2794 button = fl_get_button(dialog_->check_compound_words);
2795 lyxrc.isp_accept_compound = static_cast<bool>(button);
2797 button = fl_get_button(dialog_->check_input_enc);
2798 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2809 void FormPreferences::SpellOptions::build()
2811 dialog_.reset(build_preferences_spelloptions(&parent_));
2813 fl_addto_choice(dialog_->choice_spell_command,
2814 _(" ispell | aspell "));
2815 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2816 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2817 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2819 // set up the feedback mechanism
2820 setPrehandler(dialog_->choice_spell_command);
2821 setPrehandler(dialog_->check_alt_lang);
2822 setPrehandler(dialog_->input_alt_lang);
2823 setPrehandler(dialog_->check_escape_chars);
2824 setPrehandler(dialog_->input_escape_chars);
2825 setPrehandler(dialog_->check_personal_dict);
2826 setPrehandler(dialog_->input_personal_dict);
2827 setPrehandler(dialog_->button_personal_dict);
2828 setPrehandler(dialog_->check_compound_words);
2829 setPrehandler(dialog_->check_input_enc);
2834 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2836 if (ob == dialog_->choice_spell_command)
2837 return lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2838 if (ob == dialog_->check_alt_lang)
2839 return lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2840 if (ob == dialog_->input_alt_lang)
2841 return lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2842 if (ob == dialog_->check_escape_chars)
2843 return lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2844 if (ob == dialog_->input_escape_chars)
2845 return lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2846 if (ob == dialog_->check_personal_dict)
2847 return lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2848 if (ob == dialog_->input_personal_dict)
2849 return lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2850 if (ob == dialog_->check_compound_words)
2851 return lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2852 if (ob == dialog_->check_input_enc)
2853 return lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2858 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2860 // !ob if function is called from updateSpellOptions() to de/activate
2862 // otherwise the function is called by an xforms CB via input().
2865 // If spell checker == "none", disable all input.
2866 if (!ob || ob == dialog_->choice_spell_command) {
2867 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2868 fl_deactivate_object(dialog_->check_alt_lang);
2869 fl_deactivate_object(dialog_->input_alt_lang);
2870 fl_deactivate_object(dialog_->check_escape_chars);
2871 fl_deactivate_object(dialog_->input_escape_chars);
2872 fl_deactivate_object(dialog_->check_personal_dict);
2873 fl_deactivate_object(dialog_->input_personal_dict);
2874 fl_deactivate_object(dialog_->check_compound_words);
2875 fl_deactivate_object(dialog_->check_input_enc);
2878 fl_activate_object(dialog_->check_alt_lang);
2879 fl_activate_object(dialog_->check_escape_chars);
2880 fl_activate_object(dialog_->check_personal_dict);
2881 fl_activate_object(dialog_->check_compound_words);
2882 fl_activate_object(dialog_->check_input_enc);
2887 if (!ob || ob == dialog_->check_alt_lang) {
2888 bool const enable = fl_get_button(dialog_->check_alt_lang);
2889 setEnabled(dialog_->input_alt_lang, enable);
2892 if (!ob || ob == dialog_->check_escape_chars) {
2893 bool const enable = fl_get_button(dialog_->check_escape_chars);
2894 setEnabled(dialog_->input_escape_chars, enable);
2897 if (!ob || ob == dialog_->check_personal_dict) {
2898 bool const enable = fl_get_button(dialog_->check_personal_dict);
2899 setEnabled(dialog_->input_personal_dict, enable);
2902 if (ob == dialog_->button_personal_dict) {
2903 parent_.browse(dialog_->input_personal_dict,
2904 _("Personal dictionary"), "*.ispell");
2907 return true; // All input is valid!
2911 void FormPreferences::SpellOptions::update()
2915 if (lyxrc.isp_command == "none")
2917 else if (lyxrc.isp_command == "ispell")
2919 else if (lyxrc.isp_command == "aspell")
2922 if (lyxrc.isp_command == "ispell")
2924 else if (lyxrc.isp_command == "aspell")
2927 fl_set_choice(dialog_->choice_spell_command, choice);
2930 if (lyxrc.isp_use_alt_lang)
2931 str = lyxrc.isp_alt_lang;
2933 fl_set_button(dialog_->check_alt_lang,
2934 lyxrc.isp_use_alt_lang);
2935 fl_set_input(dialog_->input_alt_lang, str.c_str());
2938 if (lyxrc.isp_use_esc_chars)
2939 str = lyxrc.isp_esc_chars;
2941 fl_set_button(dialog_->check_escape_chars,
2942 lyxrc.isp_use_esc_chars);
2943 fl_set_input(dialog_->input_escape_chars, str.c_str());
2946 if (lyxrc.isp_use_pers_dict)
2947 str = lyxrc.isp_pers_dict;
2949 fl_set_button(dialog_->check_personal_dict,
2950 lyxrc.isp_use_pers_dict);
2951 fl_set_input(dialog_->input_personal_dict, str.c_str());
2953 fl_set_button(dialog_->check_compound_words,
2954 lyxrc.isp_accept_compound);
2955 fl_set_button(dialog_->check_input_enc,
2956 lyxrc.isp_use_input_encoding);
2958 // Activate/Deactivate the input fields dependent on the state of the
2964 void FormPreferences::browse(FL_OBJECT * inpt,
2965 string const & title,
2966 string const & pattern,
2967 pair<string,string> const & dir1,
2968 pair<string,string> const & dir2)
2970 // Get the filename from the dialog
2971 string const filename = fl_get_input(inpt);
2973 // Show the file browser dialog
2974 string const new_filename =
2975 browseFile(&lv_, filename, title, pattern, dir1, dir2);
2977 // Save the filename to the dialog
2978 if (new_filename != filename && !new_filename.empty()) {
2979 fl_set_input(inpt, new_filename.c_str());