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
13 #include "ControlPrefs.h"
14 #include "FormPreferences.h"
15 #include "forms/form_preferences.h"
17 #include "ButtonController.h"
20 #include "input_validators.h"
21 #include "forms_gettext.h"
22 #include "xforms_helpers.h"
23 #include "helper_funcs.h" // getSecond
26 #include "converter.h"
30 #include "frnt_lang.h"
35 #include "funcrequest.h"
38 #include "support/lstrings.h"
39 #include "support/lyxfunctional.h"
40 #include "support/lyxmanip.h"
41 #include "support/tostr.h"
42 #include "support/filetools.h"
43 #include "support/LAssert.h"
45 #include "graphics/GraphicsCache.h"
46 #include "graphics/GraphicsTypes.h"
48 #include <boost/bind.hpp>
50 #include "lyx_forms.h"
66 extern string system_lyxdir;
67 extern string user_lyxdir;
69 using namespace lyx::support;
71 namespace grfx = lyx::graphics;
75 // These should probably go inside the class definition...
76 Formats local_formats;
77 Converters local_converters;
79 string makeFontName(string const & family, string const & foundry)
83 return family + ',' + foundry;
87 pair<string,string> parseFontName(string const & name)
89 string::size_type const idx = name.find(',');
90 if (idx == string::npos)
91 return make_pair(name, string());
92 return make_pair(name.substr(0, idx),
97 string const X11hexname(RGBColor const & col)
101 ostr << '#' << std::setbase(16) << setfill('0')
106 return STRCONV(ostr.str());
109 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
110 bool const scalableTabfolders = false;
112 bool const scalableTabfolders = true;
118 typedef FormCB<ControlPrefs, FormDB<FD_preferences> > base_class;
121 FormPreferences::FormPreferences()
122 : base_class(_("Preferences"), scalableTabfolders),
123 colors_(*this), converters_(*this), inputs_misc_(*this),
124 formats_(*this), interface_(*this), language_(*this),
125 lnf_misc_(*this), identity_(*this), outputs_misc_(*this),
126 paths_(*this), printer_(*this), screen_fonts_(*this),
132 void FormPreferences::redraw()
134 if (!(form() && form()->visible))
136 fl_redraw_form(form());
138 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
139 if (!(form2 && form2->visible))
141 fl_redraw_form(form2);
144 if (form2 == converters_tab_->form)
145 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
147 else if (form2 == look_n_feel_tab_->form)
148 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
150 else if (form2 == inputs_tab_->form)
151 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
153 else if (form2 == outputs_tab_->form)
154 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
156 else if (form2 == lang_opts_tab_->form)
157 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
159 if (form3 && form3->visible)
160 fl_redraw_form(form3);
164 void FormPreferences::hide()
166 // We need to hide the active tabfolder otherwise we get a
167 // BadDrawable error from X window and LyX crashes without saving.
168 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
169 if (inner_form && inner_form->visible)
170 fl_hide_form(inner_form);
175 void FormPreferences::build()
177 dialog_.reset(build_preferences(this));
179 // Manage the restore, save, apply and cancel/close buttons
180 bcview().setOK(dialog_->button_ok);
181 bcview().setApply(dialog_->button_apply);
182 bcview().setCancel(dialog_->button_close);
183 bcview().setRestore(dialog_->button_restore);
185 // Allow the base class to control messages
186 setMessageWidget(dialog_->text_warning);
188 // build the tab folders
189 converters_tab_.reset(build_preferences_inner_tab(this));
190 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
191 inputs_tab_.reset(build_preferences_inner_tab(this));
192 outputs_tab_.reset(build_preferences_inner_tab(this));
193 lang_opts_tab_.reset(build_preferences_inner_tab(this));
195 // build actual tabfolder contents
196 // these will become nested tabfolders
200 inputs_misc_.build();
205 outputs_misc_.build();
208 screen_fonts_.build();
209 spelloptions_.build();
211 // Enable the tabfolders to be rescaled correctly.
212 if (scalableTabfolders) {
213 FL_OBJECT * folder = dialog_->tabfolder_prefs;
214 fl_set_tabfolder_autofit(folder, FL_FIT);
216 folder = look_n_feel_tab_->tabfolder_inner;
217 fl_set_tabfolder_autofit(folder, FL_FIT);
219 folder = converters_tab_->tabfolder_inner;
220 fl_set_tabfolder_autofit(folder, FL_FIT);
222 folder = inputs_tab_->tabfolder_inner;
223 fl_set_tabfolder_autofit(folder, FL_FIT);
225 folder = outputs_tab_->tabfolder_inner;
226 fl_set_tabfolder_autofit(folder, FL_FIT);
228 folder = lang_opts_tab_->tabfolder_inner;
229 fl_set_tabfolder_autofit(folder, FL_FIT);
233 // Now add them to the tabfolder
234 fl_addto_tabfolder(dialog_->tabfolder_prefs,
235 _("Look & Feel").c_str(),
236 look_n_feel_tab_->form);
237 fl_addto_tabfolder(dialog_->tabfolder_prefs,
238 _("Lang Opts").c_str(),
239 lang_opts_tab_->form);
240 fl_addto_tabfolder(dialog_->tabfolder_prefs,
241 _("Conversion").c_str(),
242 converters_tab_->form);
243 fl_addto_tabfolder(dialog_->tabfolder_prefs,
246 fl_addto_tabfolder(dialog_->tabfolder_prefs,
247 _("Outputs").c_str(),
250 // now build the nested tabfolders
251 // Starting with look and feel
252 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
253 _("Screen Fonts").c_str(),
254 screen_fonts_.dialog()->form);
255 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
256 _("Interface").c_str(),
257 interface_.dialog()->form);
258 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
260 colors_.dialog()->form);
261 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
263 lnf_misc_.dialog()->form);
264 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
265 _("Identity").c_str(),
266 identity_.dialog()->form);
268 // then build converters
269 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
270 _("Formats").c_str(),
271 formats_.dialog()->form);
272 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
273 _("Converters").c_str(),
274 converters_.dialog()->form);
277 // Paths should probably go in a few inner_tab called Files
278 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
280 paths_.dialog()->form);
281 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
283 inputs_misc_.dialog()->form);
285 // then building outputs
286 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
287 _("Printer").c_str(),
288 printer_.dialog()->form);
289 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
291 outputs_misc_.dialog()->form);
293 // then building usage
294 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
295 _("Spell checker").c_str(),
296 spelloptions_.dialog()->form);
297 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
298 _("Language").c_str(),
299 language_.dialog()->form);
303 void FormPreferences::apply()
305 // set the new lyxrc entries
306 // many of these need to trigger other functions when the assignment
307 // is made. For example, screen zoom and font types. These could be
308 // handled either by signals/slots in lyxrc or just directly call the
309 // associated functions here.
310 // There are other problems with this scheme. We really should check
311 // what we copy to make sure that it really is necessary to do things
312 // like update the screen fonts because that flushes the textcache
313 // and other stuff which may cost us a lot on slower/high-load
316 LyXRC & rc(controller().rc());
319 formats_.apply(); // Must be before converters_.apply()
321 inputs_misc_.apply(rc);
322 interface_.apply(rc);
326 outputs_misc_.apply(rc);
329 screen_fonts_.apply(rc);
330 spelloptions_.apply(rc);
332 // The "Save" button has been pressed.
333 if (controller().isClosing() && colors_.modifiedXformsPrefs) {
334 string const filename =
335 AddName(user_lyxdir, "preferences.xform");
336 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
341 string const FormPreferences::getFeedback(FL_OBJECT * ob)
345 if (ob->form->fdui == colors_.dialog())
346 return colors_.feedback(ob);
347 if (ob->form->fdui == converters_.dialog())
348 return converters_.feedback(ob);
349 if (ob->form->fdui == formats_.dialog())
350 return formats_.feedback(ob);
351 if (ob->form->fdui == inputs_misc_.dialog())
352 return inputs_misc_.feedback(ob);
353 if (ob->form->fdui == interface_.dialog())
354 return interface_.feedback(ob);
355 if (ob->form->fdui == language_.dialog())
356 return language_.feedback(ob);
357 if (ob->form->fdui == lnf_misc_.dialog())
358 return lnf_misc_.feedback(ob);
359 if (ob->form->fdui == outputs_misc_.dialog())
360 return outputs_misc_.feedback(ob);
361 if (ob->form->fdui == paths_.dialog())
362 return paths_.feedback(ob);
363 if (ob->form->fdui == printer_.dialog())
364 return printer_.feedback(ob);
365 if (ob->form->fdui == screen_fonts_.dialog())
366 return screen_fonts_.feedback(ob);
367 if (ob->form->fdui == spelloptions_.dialog())
368 return spelloptions_.feedback(ob);
374 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
380 // whatever checks you need to ensure the user hasn't entered
381 // some totally ridiculous value somewhere. Change activate to suit.
382 // comments before each test describe what is _valid_
384 if (ob->form->fdui == colors_.dialog()) {
386 } else if (ob->form->fdui == converters_.dialog()) {
387 valid = converters_.input(ob);
388 } else if (ob->form->fdui == formats_.dialog()) {
389 valid = formats_.input(ob);
390 } else if (ob->form->fdui == interface_.dialog()) {
391 valid = interface_.input(ob);
392 } else if (ob->form->fdui == language_.dialog()) {
393 valid = language_.input(ob);
394 } else if (ob->form->fdui == paths_.dialog()) {
395 valid = paths_.input(ob);
396 } else if (ob->form->fdui == screen_fonts_.dialog()) {
397 valid = screen_fonts_.input();
398 } else if (ob->form->fdui == spelloptions_.dialog()) {
399 valid = spelloptions_.input(ob);
402 return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
406 void FormPreferences::update()
408 if (!dialog_.get()) return;
410 LyXRC const & rc(controller().rc());
412 // read lyxrc entries
414 formats_.update(); // Must be before converters_.update()
415 converters_.update();
416 inputs_misc_.update(rc);
417 interface_.update(rc);
418 language_.update(rc);
419 lnf_misc_.update(rc);
420 identity_.update(rc);
421 outputs_misc_.update(rc);
424 screen_fonts_.update(rc);
425 spelloptions_.update(rc);
429 FormPreferences::Colors::Colors(FormPreferences & p)
430 : modifiedXformsPrefs(false), parent_(p)
434 FD_preferences_colors const * FormPreferences::Colors::dialog()
436 return dialog_.get();
440 void FormPreferences::Colors::apply()
442 bool modifiedText = false;
443 bool modifiedBackground = false;
445 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
446 cit != xformsColorDB.end(); ++cit) {
448 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
449 if (col != cit->color()) {
450 modifiedXformsPrefs = true;
451 if (cit->colorID == FL_BLACK)
453 if (cit->colorID == FL_COL1)
454 modifiedBackground = true;
458 if (modifiedXformsPrefs) {
459 for (vector<XformsColor>::const_iterator cit =
460 xformsColorDB.begin();
461 cit != xformsColorDB.end(); ++cit) {
462 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
464 if (modifiedText && cit->colorID == FL_BLACK) {
465 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
468 if (modifiedBackground && cit->colorID == FL_COL1) {
469 AdjustVal(FL_MCOL, FL_COL1, 0.1);
470 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
471 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
473 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
474 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
477 if (cit->colorID == GUI_COLOR_CURSOR) {
478 fl_mapcolor(GUI_COLOR_CURSOR,
479 cit->r, cit->g, cit->b);
480 setCursorColor(GUI_COLOR_CURSOR);
483 parent_.controller().redrawGUI();
486 // Now do the same for the LyX LColors...
487 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
488 cit != lyxColorDB.end(); ++cit) {
489 LColor::color lc = lcolor.getFromGUIName(cit->getname());
490 if (lc == LColor::inherit) continue;
492 // Create a valid X11 name of the form "#rrggbb"
493 string const hexname = X11hexname(cit->color());
495 if (lcolor.getX11Name(lc) != hexname) {
497 << "FormPreferences::Colors::apply: "
498 << "resetting LColor " << lcolor.getGUIName(lc)
499 << " from \"" << lcolor.getX11Name(lc)
500 << "\" to \"" << hexname << "\"."
503 parent_.controller().setColor(lc, hexname);
509 void FormPreferences::Colors::build()
511 dialog_.reset(build_preferences_colors(&parent_));
513 fl_set_object_color(dialog_->button_color,
514 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
516 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
517 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
518 fl_set_dial_step(dialog_->dial_hue, 1.0);
519 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
521 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
522 fl_set_slider_step(dialog_->slider_saturation, 0.01);
523 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
525 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
526 fl_set_slider_step(dialog_->slider_value, 0.01);
527 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
529 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
530 fl_set_slider_step(dialog_->slider_red, 1.0);
531 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
533 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
534 fl_set_slider_step(dialog_->slider_green, 1.0);
535 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
537 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
538 fl_set_slider_step(dialog_->slider_blue, 1.0);
539 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
541 // set up the feedback mechanism
542 setPrehandler(dialog_->browser_lyx_objs);
543 setPrehandler(dialog_->button_color);
544 setPrehandler(dialog_->button_modify);
545 setPrehandler(dialog_->dial_hue);
546 setPrehandler(dialog_->slider_saturation);
547 setPrehandler(dialog_->slider_value);
548 setPrehandler(dialog_->slider_red);
549 setPrehandler(dialog_->slider_green);
550 setPrehandler(dialog_->slider_blue);
551 setPrehandler(dialog_->radio_rgb);
552 setPrehandler(dialog_->radio_hsv);
557 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
559 if (ob == dialog_->browser_lyx_objs)
560 return _("LyX objects that can be assigned a color.");
562 if (ob == dialog_->button_modify)
563 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
565 if (ob == dialog_->dial_hue ||
566 ob == dialog_->slider_saturation ||
567 ob == dialog_->slider_value ||
568 ob == dialog_->slider_red ||
569 ob == dialog_->slider_green ||
570 ob == dialog_->slider_blue)
571 return _("Find a new color.");
573 if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
574 return _("Toggle between RGB and HSV color spaces.");
580 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
582 if (ob == dialog_->browser_lyx_objs) {
585 } else if (ob == dialog_->dial_hue ||
586 ob == dialog_->slider_saturation ||
587 ob == dialog_->slider_value) {
590 } else if (ob == dialog_->slider_red ||
591 ob == dialog_->slider_green ||
592 ob == dialog_->slider_blue) {
595 } else if (ob == dialog_->radio_rgb ||
596 ob == dialog_->radio_hsv) {
599 } else if (ob == dialog_->button_modify) {
605 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
609 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
613 hsv.v = min(1.0, max(0.0, hsv.v));
616 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
620 void FormPreferences::Colors::InputBrowserLyX() const
622 vector<NamedColor>::size_type const selLyX =
623 fl_get_browser(dialog_->browser_lyx_objs);
624 if (selLyX < 1) return;
626 // Is the choice an Xforms color...
629 if (selLyX - 1 < xformsColorDB.size()) {
630 vector<XformsColor>::size_type const i = selLyX - 1;
631 col = xformsColorDB[i].color();
633 // or a LyX Logical color?
635 vector<NamedColor>::size_type const i = selLyX - 1 -
636 xformsColorDB.size();
637 col = lyxColorDB[i].color();
640 fl_freeze_form(dialog_->form);
642 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
643 fl_redraw_object(dialog_->button_color);
645 // Display either RGB or HSV but not both!
648 // Deactivate the modify button to begin with...
649 setEnabled(dialog_->button_modify, false);
651 fl_unfreeze_form(dialog_->form);
655 void FormPreferences::Colors::InputHSV()
657 double const hue = fl_get_dial_value(dialog_->dial_hue);
658 double const sat = fl_get_slider_value(dialog_->slider_saturation);
659 double const val = fl_get_slider_value(dialog_->slider_value);
661 int const h = int(hue);
662 int const s = int(100.0 * sat);
663 int const v = int(100.0 * val);
665 string const label = tostr(h) + ", " + tostr(s) + ", " + tostr(v);
666 fl_set_object_label(dialog_->text_color_values, label.c_str());
668 RGBColor col = HSVColor(hue, sat, val);
670 fl_freeze_form(dialog_->form);
672 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
673 fl_redraw_object(dialog_->button_color);
675 col = HSVColor(hue, 1.0, 1.0);
676 col.r = max(col.r, 0u);
677 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
678 fl_redraw_object(dialog_->dial_hue);
680 // Ascertain whether to activate the Modify button.
681 vector<NamedColor>::size_type const selLyX =
682 fl_get_browser(dialog_->browser_lyx_objs);
684 fl_unfreeze_form(dialog_->form);
685 if (selLyX < 1) return;
687 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
690 // Is the choice an Xforms color...
691 if (selLyX - 1 < xformsColorDB.size()) {
692 vector<XformsColor>::size_type const i = selLyX - 1;
693 modify = (xformsColorDB[i].color() != col);
695 // or a LyX Logical color?
697 vector<NamedColor>::size_type const i = selLyX - 1 -
698 xformsColorDB.size();
699 modify = (lyxColorDB[i].color() != col);
702 setEnabled(dialog_->button_modify, modify);
706 void FormPreferences::Colors::InputRGB()
708 int const red = int(fl_get_slider_value(dialog_->slider_red));
709 int const green = int(fl_get_slider_value(dialog_->slider_green));
710 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
712 string const label = tostr(red) + string(", ") + tostr(green) +
713 string(", ") + tostr(blue);
714 fl_set_object_label(dialog_->text_color_values, label.c_str());
716 fl_freeze_form(dialog_->form);
718 RGBColor col = RGBColor(red, green, blue);
719 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
720 fl_redraw_object(dialog_->button_color);
722 // Ascertain whether to activate the Modify button.
723 vector<NamedColor>::size_type const selLyX =
724 fl_get_browser(dialog_->browser_lyx_objs);
726 fl_unfreeze_form(dialog_->form);
727 if (selLyX < 1) return;
731 // Is the choice an Xforms color...
732 if (selLyX - 1 < xformsColorDB.size()) {
733 vector<XformsColor>::size_type const i = selLyX - 1;
734 modify = (xformsColorDB[i].color() != col);
736 // or a LyX Logical color?
738 vector<NamedColor>::size_type const i = selLyX - 1 -
739 xformsColorDB.size();
740 modify = (lyxColorDB[i].color() != col);
743 setEnabled(dialog_->button_modify, modify);
747 void FormPreferences::Colors::LoadBrowserLyX()
749 if (!dialog_->browser_lyx_objs->visible)
752 // First, define the modifiable xforms colors
753 xformsColorDB.clear();
756 xcol.name = _("GUI background");
757 xcol.colorID = FL_COL1;
758 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
760 xformsColorDB.push_back(xcol);
762 xcol.name = _("GUI text");
763 xcol.colorID = FL_BLACK;
764 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
766 xformsColorDB.push_back(xcol);
768 xcol.name = _("GUI selection");
769 xcol.colorID = FL_YELLOW;
770 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
772 xformsColorDB.push_back(xcol);
774 xcol.name = _("GUI pointer");
775 xcol.colorID = GUI_COLOR_CURSOR;
776 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
778 xformsColorDB.push_back(xcol);
780 // Now create the the LyX LColors database
782 for (int i=0; i<LColor::ignore; ++i) {
783 LColor::color lc = static_cast<LColor::color>(i);
784 if (lc == LColor::none
785 || lc == LColor::black
786 || lc == LColor::white
788 || lc == LColor::green
789 || lc == LColor::blue
790 || lc == LColor::cyan
791 || lc == LColor::magenta
792 || lc == LColor::yellow
793 || lc == LColor::inherit
794 || lc == LColor::ignore) continue;
797 bool const success = getRGBColor(lc, col.r, col.g, col.b);
799 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
800 << "LColor " << lcolor.getLyXName(lc)
801 << ": X can't find color \""
802 << lcolor.getX11Name(lc)
803 << "\". Set to \"black\"!" << endl;
805 string const arg = lcolor.getLyXName(lc) + " black";
806 parent_.controller().setColor(lc, "black");
810 // Create a valid X11 name of the form "#rrggbb" and change the
811 // LColor X11name to this. Don't want to trigger a redraw,
812 // as we're just changing the name not the RGB values.
813 // Also reset the system_lcolor names, so that we don't output
814 // unnecessary changes.
815 string const hexname = X11hexname(col);
817 if (lcolor.getX11Name(lc) != hexname) {
818 lcolor.setColor(lc, hexname);
819 system_lcolor.setColor(lc, hexname);
822 // Finally, push the color onto the database
823 NamedColor ncol(lcolor.getGUIName(lc), col);
824 lyxColorDB.push_back(ncol);
827 // Now construct the browser
828 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
829 fl_freeze_form(dialog_->form);
830 fl_clear_browser(colbr);
831 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
832 cit != xformsColorDB.end(); ++cit) {
833 fl_addto_browser(colbr, cit->getname().c_str());
835 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
836 cit != lyxColorDB.end(); ++cit) {
837 fl_addto_browser(colbr, cit->getname().c_str());
840 // just to be safe...
841 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
842 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
843 fl_unfreeze_form(dialog_->form);
849 void FormPreferences::Colors::Modify()
851 vector<NamedColor>::size_type const selLyX =
852 fl_get_browser(dialog_->browser_lyx_objs);
857 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
859 // Is the choice an Xforms color...
860 if (selLyX - 1 < xformsColorDB.size()) {
861 vector<XformsColor>::size_type const i = selLyX - 1;
862 xformsColorDB[i].r = col.r;
863 xformsColorDB[i].g = col.g;
864 xformsColorDB[i].b = col.b;
866 // or a LyX Logical color?
868 vector<NamedColor>::size_type const i = selLyX - 1 -
869 xformsColorDB.size();
870 lyxColorDB[i].r = col.r;
871 lyxColorDB[i].g = col.g;
872 lyxColorDB[i].b = col.b;
875 fl_freeze_form(dialog_->form);
876 setEnabled(dialog_->button_modify, false);
877 fl_unfreeze_form(dialog_->form);
881 void FormPreferences::Colors::SwitchColorSpace() const
883 bool const hsv = fl_get_button(dialog_->radio_hsv);
886 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
888 fl_freeze_form(dialog_->form);
891 fl_hide_object(dialog_->slider_red);
892 fl_hide_object(dialog_->slider_blue);
893 fl_hide_object(dialog_->slider_green);
894 fl_show_object(dialog_->dial_hue);
895 fl_show_object(dialog_->slider_saturation);
896 fl_show_object(dialog_->slider_value);
898 HSVColor hsv = HSVColor(col);
899 hsv.h = max(hsv.h, 0.0);
901 fl_set_dial_value(dialog_->dial_hue, hsv.h);
902 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
903 fl_set_slider_value(dialog_->slider_value, hsv.v);
905 col = HSVColor(hsv.h, 1.0, 1.0);
906 col.r = max(col.r, 0u);
907 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
908 fl_redraw_object(dialog_->dial_hue);
910 // Adjust the label a bit, but not the actual values.
911 // Means that toggling from one space to the other has no
912 // effect on the final color.
913 int const h = int(hsv.h);
914 int const s = int(100 * hsv.s);
915 int const v = int(100 * hsv.v);
916 string const label = tostr(h) + ", " + tostr(s) +
918 fl_set_object_label(dialog_->text_color_values, label.c_str());
921 fl_show_object(dialog_->slider_red);
922 fl_show_object(dialog_->slider_blue);
923 fl_show_object(dialog_->slider_green);
924 fl_hide_object(dialog_->dial_hue);
925 fl_hide_object(dialog_->slider_saturation);
926 fl_hide_object(dialog_->slider_value);
928 fl_set_slider_value(dialog_->slider_red, col.r);
929 fl_set_slider_value(dialog_->slider_green, col.g);
930 fl_set_slider_value(dialog_->slider_blue, col.b);
932 // Adjust the label a bit. Same reasoning as above.
933 int const r = int(col.r);
934 int const g = int(col.g);
935 int const b = int(col.b);
936 string const label = tostr(r) + ", " + tostr(g) +
938 fl_set_object_label(dialog_->text_color_values, label.c_str());
941 fl_unfreeze_form(dialog_->form);
945 FormPreferences::Converters::Converters(FormPreferences & p)
950 FD_preferences_converters const * FormPreferences::Converters::dialog()
952 return dialog_.get();
956 void FormPreferences::Converters::apply() const
958 parent_.controller().setConverters(local_converters);
962 void FormPreferences::Converters::build()
964 dialog_.reset(build_preferences_converters(&parent_));
966 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
967 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
969 // set up the feedback mechanism
970 setPrehandler(dialog_->browser_all);
971 setPrehandler(dialog_->button_delete);
972 setPrehandler(dialog_->button_add);
973 setPrehandler(dialog_->input_converter);
974 setPrehandler(dialog_->choice_from);
975 setPrehandler(dialog_->choice_to);
976 setPrehandler(dialog_->input_flags);
981 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
983 if (ob == dialog_->browser_all)
984 return _("All explicitly defined converters for LyX");
986 if (ob == dialog_->choice_from)
987 return _("Convert \"from\" this format");
989 if (ob == dialog_->choice_to)
990 return _("Convert \"to\" this format");
992 if (ob == dialog_->input_converter)
993 return _("The conversion command. $$i is the input file name, "
994 "$$b is the file name without its extension and $$o is "
995 "the name of the output file. $$s can be used as path to "
996 "LyX's own collection of conversion scripts.");
998 if (ob == dialog_->input_flags)
999 return _("Extra information for the Converter class, whether and "
1000 "how to parse the result, and various other things.");
1002 if (ob == dialog_->button_delete)
1003 return _("Remove the current converter from the list of available "
1004 "converters. Note: you must then \"Apply\" the change.");
1006 if (ob == dialog_->button_add) {
1007 if (string(ob->label) == _("Add"))
1008 return _("Add the current converter to the list of available "
1009 "converters. Note: you must then \"Apply\" the change.");
1011 return _("Modify the contents of the current converter. "
1012 "Note: you must then \"Apply\" the change.");
1019 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
1021 if (ob == dialog_->browser_all)
1024 if (ob == dialog_->choice_from
1025 || ob == dialog_->choice_to
1026 || ob == dialog_->input_converter
1027 || ob == dialog_->input_flags)
1030 if (ob == dialog_->button_add)
1033 if (ob == dialog_->button_delete)
1040 void FormPreferences::Converters::update()
1042 local_converters = converters;
1043 local_converters.update(local_formats);
1048 void FormPreferences::Converters::UpdateBrowser()
1050 local_converters.sort();
1052 fl_freeze_form(dialog_->form);
1053 fl_clear_browser(dialog_->browser_all);
1054 for (::Converters::const_iterator cit = local_converters.begin();
1055 cit != local_converters.end(); ++cit) {
1056 string const name = cit->From->prettyname() + " -> "
1057 + cit->To->prettyname();
1058 fl_addto_browser(dialog_->browser_all, name.c_str());
1061 fl_unfreeze_form(dialog_->form);
1065 bool FormPreferences::Converters::Add()
1067 string const from = GetFrom();
1068 string const to = GetTo();
1069 string const command = fl_get_input(dialog_->input_converter);
1070 string const flags = fl_get_input(dialog_->input_flags);
1072 Converter const * old = local_converters.getConverter(from, to);
1073 local_converters.add(from, to, command, flags);
1075 local_converters.updateLast(local_formats);
1078 setEnabled(dialog_->button_add, false);
1084 bool FormPreferences::Converters::Browser()
1086 int const i = fl_get_browser(dialog_->browser_all);
1087 if (i <= 0) return false;
1089 fl_freeze_form(dialog_->form);
1091 Converter const & c = local_converters.get(i - 1);
1092 int j = local_formats.getNumber(c.from);
1094 fl_set_choice(dialog_->choice_from, j + 1);
1096 j = local_formats.getNumber(c.to);
1098 fl_set_choice(dialog_->choice_to, j + 1);
1100 fl_set_input(dialog_->input_converter, c.command.c_str());
1101 fl_set_input(dialog_->input_flags, c.flags.c_str());
1103 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
1104 fl_set_button_shortcut(dialog_->button_add,
1105 scex(_("Modify|#M")).c_str(), 1);
1107 setEnabled(dialog_->button_add, false);
1108 setEnabled(dialog_->button_delete, true);
1110 fl_unfreeze_form(dialog_->form);
1115 bool FormPreferences::Converters::erase()
1117 string const from = GetFrom();
1118 string const to = GetTo();
1120 local_converters.erase(from, to);
1126 bool FormPreferences::Converters::Input()
1128 string const from = GetFrom();
1129 string const to = GetTo();
1130 int const sel = local_converters.getNumber(from, to);
1132 fl_freeze_form(dialog_->form);
1135 fl_set_object_label(dialog_->button_add,
1136 idex(_("Add|#A")).c_str());
1137 fl_set_button_shortcut(dialog_->button_add,
1138 scex(_("Add|#A")).c_str(), 1);
1140 fl_deselect_browser(dialog_->browser_all);
1141 setEnabled(dialog_->button_delete, false);
1144 fl_set_object_label(dialog_->button_add,
1145 idex(_("Modify|#M")).c_str());
1146 fl_set_button_shortcut(dialog_->button_add,
1147 scex(_("Modify|#M")).c_str(), 1);
1149 int top = max(sel-5, 0);
1150 fl_set_browser_topline(dialog_->browser_all, top);
1151 fl_select_browser_line(dialog_->browser_all, sel+1);
1152 setEnabled(dialog_->button_delete, true);
1155 string const command = rtrim(fl_get_input(dialog_->input_converter));
1156 bool const enable = !(command.empty() || from == to);
1157 setEnabled(dialog_->button_add, enable);
1159 fl_unfreeze_form(dialog_->form);
1164 string const FormPreferences::Converters::GetFrom() const
1166 ::Formats::FormatList::size_type const i =
1167 fl_get_choice(dialog_->choice_from);
1169 if (i > 0 && i <= local_formats.size())
1170 return local_formats.get(i - 1).name();
1172 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1177 string const FormPreferences::Converters::GetTo() const
1179 ::Formats::FormatList::size_type const i =
1180 fl_get_choice(dialog_->choice_to);
1182 if (i > 0 && i <= local_formats.size())
1183 return local_formats.get(i - 1).name();
1185 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1190 void FormPreferences::Converters::UpdateChoices() const
1193 for (::Formats::const_iterator cit = local_formats.begin();
1194 cit != local_formats.end(); ++cit) {
1195 if (!choice.empty())
1199 choice += cit->prettyname();
1203 fl_clear_choice(dialog_->choice_from);
1204 fl_addto_choice(dialog_->choice_from, choice.c_str());
1206 fl_clear_choice(dialog_->choice_to);
1207 fl_addto_choice(dialog_->choice_to, choice.c_str());
1211 FormPreferences::Formats::Formats(FormPreferences & p)
1216 FD_preferences_formats const * FormPreferences::Formats::dialog()
1218 return dialog_.get();
1222 void FormPreferences::Formats::apply() const
1224 parent_.controller().setFormats(local_formats);
1228 void FormPreferences::Formats::build()
1230 dialog_.reset(build_preferences_formats(&parent_));
1232 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1233 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1234 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1235 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1236 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1238 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1240 // set up the feedback mechanism
1241 setPrehandler(dialog_->browser_all);
1242 setPrehandler(dialog_->input_format);
1243 setPrehandler(dialog_->input_gui_name);
1244 setPrehandler(dialog_->button_delete);
1245 setPrehandler(dialog_->button_add);
1246 setPrehandler(dialog_->input_extension);
1247 setPrehandler(dialog_->input_viewer);
1248 setPrehandler(dialog_->input_shrtcut);
1253 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1255 if (ob == dialog_->browser_all)
1256 return _("All the currently defined formats known to LyX.");
1258 if (ob == dialog_->input_format)
1259 return _("The format identifier.");
1261 if (ob == dialog_->input_gui_name)
1262 return _("The format name as it will appear in the menus.");
1264 if (ob == dialog_->input_shrtcut)
1265 return _("The keyboard accelerator. Use a letter in the GUI name. "
1268 if (ob == dialog_->input_extension)
1269 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1271 if (ob == dialog_->input_viewer)
1272 return _("The command used to launch the viewer application.");
1274 if (ob == dialog_->button_delete)
1275 return _("Remove the current format from the list of available "
1276 "formats. Note: you must then \"Apply\" the change.");
1278 if (ob == dialog_->button_add) {
1279 if (string(ob->label) == _("Add"))
1280 return _("Add the current format to the list of available "
1281 "formats. Note: you must then \"Apply\" the change.");
1283 return _("Modify the contents of the current format. Note: "
1284 "you must then \"Apply\" the change.");
1291 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1293 if (ob == dialog_->browser_all)
1296 if (ob == dialog_->input_format
1297 || ob == dialog_->input_gui_name
1298 || ob == dialog_->input_shrtcut
1299 || ob == dialog_->input_extension
1300 || ob == dialog_->input_viewer)
1303 if (ob == dialog_->button_add)
1306 if (ob == dialog_->button_delete)
1313 void FormPreferences::Formats::update()
1315 local_formats = formats;
1320 void FormPreferences::Formats::UpdateBrowser()
1322 local_formats.sort();
1324 fl_freeze_form(dialog_->form);
1325 fl_deselect_browser(dialog_->browser_all);
1326 fl_clear_browser(dialog_->browser_all);
1327 for (::Formats::const_iterator cit = local_formats.begin();
1328 cit != local_formats.end(); ++cit)
1329 fl_addto_browser(dialog_->browser_all,
1330 cit->prettyname().c_str());
1333 fl_unfreeze_form(dialog_->form);
1335 // Mustn't forget to update the Formats available to the converters_
1336 parent_.converters_.UpdateChoices();
1337 local_converters.update(local_formats);
1341 bool FormPreferences::Formats::Add()
1343 string const name = fl_get_input(dialog_->input_format);
1344 string const prettyname = fl_get_input(dialog_->input_gui_name);
1345 string const extension = fl_get_input(dialog_->input_extension);
1346 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1347 string const viewer = fl_get_input(dialog_->input_viewer);
1349 Format const * old = local_formats.getFormat(name);
1350 string const old_prettyname = old ? old->prettyname() : string();
1351 local_formats.add(name, extension, prettyname, shortcut);
1352 local_formats.setViewer(name, viewer);
1353 if (!old || prettyname != old_prettyname) {
1356 parent_.converters_.UpdateBrowser();
1358 setEnabled(dialog_->button_add, false);
1364 bool FormPreferences::Formats::Browser()
1366 int const i = fl_get_browser(dialog_->browser_all);
1370 fl_freeze_form(dialog_->form);
1372 Format const & f = local_formats.get(i - 1);
1374 fl_set_input(dialog_->input_format, f.name().c_str());
1375 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1376 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1377 fl_set_input(dialog_->input_extension, f.extension().c_str());
1378 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1380 fl_set_object_label(dialog_->button_add,
1381 idex(_("Modify|#M")).c_str());
1382 fl_set_button_shortcut(dialog_->button_add,
1383 scex(_("Modify|#M")).c_str(), 1);
1385 setEnabled(dialog_->button_add, false);
1386 setEnabled(dialog_->button_delete, true);
1388 fl_unfreeze_form(dialog_->form);
1393 bool FormPreferences::Formats::erase()
1395 string const name = fl_get_input(dialog_->input_format);
1397 if (local_converters.formatIsUsed(name)) {
1398 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1399 "Remove the converter first."));
1400 setEnabled(dialog_->button_delete, false);
1404 local_formats.erase(name);
1410 bool FormPreferences::Formats::Input()
1412 string const name = fl_get_input(dialog_->input_format);
1413 int const sel = local_formats.getNumber(name);
1414 fl_freeze_form(dialog_->form);
1417 fl_set_object_label(dialog_->button_add,
1418 idex(_("Add|#A")).c_str());
1419 fl_set_button_shortcut(dialog_->button_add,
1420 scex(_("Add|#A")).c_str(), 1);
1422 fl_deselect_browser(dialog_->browser_all);
1423 setEnabled(dialog_->button_delete, false);
1426 fl_set_object_label(dialog_->button_add,
1427 idex(_("Modify|#M")).c_str());
1428 fl_set_button_shortcut(dialog_->button_add,
1429 scex(_("Modify|#M")).c_str(), 1);
1431 int const top = max(sel-5, 0);
1432 fl_set_browser_topline(dialog_->browser_all, top);
1433 fl_select_browser_line(dialog_->browser_all, sel+1);
1435 setEnabled(dialog_->button_add, true);
1436 setEnabled(dialog_->button_delete, true);
1439 string const prettyname = fl_get_input(dialog_->input_gui_name);
1440 bool const enable = !(name.empty() || prettyname.empty());
1441 setEnabled(dialog_->button_add, enable);
1443 fl_unfreeze_form(dialog_->form);
1448 FormPreferences::Identity::Identity(FormPreferences & p)
1453 FD_preferences_identity const * FormPreferences::Identity::dialog()
1455 return dialog_.get();
1459 void FormPreferences::Identity::apply(LyXRC & rc) const
1461 rc.user_name = fl_get_input(dialog_->input_user_name);
1462 rc.user_email = fl_get_input(dialog_->input_user_email);
1466 void FormPreferences::Identity::build()
1468 dialog_.reset(build_preferences_identity(&parent_));
1469 fl_set_input_return(dialog_->input_user_name, FL_RETURN_CHANGED);
1470 fl_set_input_return(dialog_->input_user_email, FL_RETURN_CHANGED);
1474 void FormPreferences::Identity::update(LyXRC const & rc)
1476 fl_set_input(dialog_->input_user_name, rc.user_name.c_str());
1477 fl_set_input(dialog_->input_user_email, rc.user_email.c_str());
1481 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1486 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1488 return dialog_.get();
1492 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1494 rc.date_insert_format =
1495 fl_get_input(dialog_->input_date_format);
1499 void FormPreferences::InputsMisc::build()
1501 dialog_.reset(build_preferences_inputs_misc(&parent_));
1503 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1505 // set up the feedback mechanism
1506 setPrehandler(dialog_->input_date_format);
1511 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1513 if (ob == dialog_->input_date_format)
1514 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1519 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1521 fl_set_input(dialog_->input_date_format,
1522 rc.date_insert_format.c_str());
1526 FormPreferences::Interface::Interface(FormPreferences & p)
1531 FD_preferences_interface const * FormPreferences::Interface::dialog()
1533 return dialog_.get();
1537 void FormPreferences::Interface::apply(LyXRC & rc) const
1539 rc.popup_normal_font =
1540 fl_get_input(dialog_->input_popup_normal_font);
1541 rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1542 rc.popup_font_encoding =
1543 fl_get_input(dialog_->input_popup_font_encoding);
1544 rc.bind_file = fl_get_input(dialog_->input_bind_file);
1545 rc.ui_file = fl_get_input(dialog_->input_ui_file);
1549 void FormPreferences::Interface::build()
1551 dialog_.reset(build_preferences_interface(&parent_));
1553 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1554 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1555 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1556 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1557 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1559 // set up the feedback mechanism
1560 setPrehandler(dialog_->input_popup_normal_font);
1561 setPrehandler(dialog_->input_popup_bold_font);
1562 setPrehandler(dialog_->input_popup_font_encoding);
1563 setPrehandler(dialog_->input_bind_file);
1564 setPrehandler(dialog_->button_bind_file_browse);
1565 setPrehandler(dialog_->input_ui_file);
1566 setPrehandler(dialog_->button_ui_file_browse);
1571 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1573 if (ob == dialog_->input_popup_normal_font)
1574 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1575 if (ob == dialog_->input_popup_bold_font)
1576 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1577 if (ob == dialog_->input_popup_font_encoding)
1578 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1579 if (ob == dialog_->input_bind_file)
1580 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1581 if (ob == dialog_->input_ui_file)
1582 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1587 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1589 if (ob == dialog_->button_bind_file_browse) {
1590 string f = parent_.controller().browsebind(
1591 fl_get_input(dialog_->input_bind_file));
1593 fl_set_input(dialog_->input_bind_file, f.c_str());
1594 } else if (ob == dialog_->button_ui_file_browse) {
1595 string f = parent_.controller().browseUI(
1596 fl_get_input(dialog_->input_ui_file));
1598 fl_set_input(dialog_->input_ui_file, f.c_str());
1605 void FormPreferences::Interface::update(LyXRC const & rc)
1607 fl_set_input(dialog_->input_popup_normal_font,
1608 rc.popup_normal_font.c_str());
1609 fl_set_input(dialog_->input_popup_bold_font,
1610 rc.popup_bold_font.c_str());
1611 fl_set_input(dialog_->input_popup_font_encoding,
1612 rc.popup_font_encoding.c_str());
1613 fl_set_input(dialog_->input_bind_file,
1614 rc.bind_file.c_str());
1615 fl_set_input(dialog_->input_ui_file,
1616 rc.ui_file.c_str());
1620 FormPreferences::Language::Language(FormPreferences & p)
1625 FD_preferences_language const * FormPreferences::Language::dialog()
1627 return dialog_.get();
1631 void FormPreferences::Language::apply(LyXRC & rc)
1633 int const pos = fl_get_combox(dialog_->combox_default_lang);
1634 rc.default_language = lang_[pos-1];
1636 int button = fl_get_button(dialog_->check_use_kbmap);
1637 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1638 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1640 button = !(name_1.empty() && name_2.empty());
1641 rc.use_kbmap = static_cast<bool>(button);
1644 rc.primary_kbmap = name_1;
1645 rc.secondary_kbmap = name_2;
1648 button = fl_get_button(dialog_->check_rtl_support);
1649 rc.rtl_support = static_cast<bool>(button);
1651 button = fl_get_button(dialog_->check_mark_foreign);
1652 rc.mark_foreign_language = static_cast<bool>(button);
1654 button = fl_get_button(dialog_->check_auto_begin);
1655 rc.language_auto_begin = static_cast<bool>(button);
1657 button = fl_get_button(dialog_->check_auto_end);
1658 rc.language_auto_end = static_cast<bool>(button);
1660 button = fl_get_button(dialog_->check_use_babel);
1661 rc.language_use_babel = static_cast<bool>(button);
1663 button = fl_get_button(dialog_->check_global_options);
1664 rc.language_global_options = static_cast<bool>(button);
1666 rc.language_package = fl_get_input(dialog_->input_package);
1667 rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1668 rc.language_command_end = fl_get_input(dialog_->input_command_end);
1670 // Ensure that all is self-consistent.
1675 void FormPreferences::Language::build()
1677 dialog_.reset(build_preferences_language(&parent_));
1679 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1680 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1681 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1683 // Store the lang identifiers for later
1684 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1685 lang_ = getSecond(langs);
1687 FL_OBJECT * obj = dialog_->combox_default_lang;
1688 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1689 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1690 for (; lit != lend; ++lit) {
1691 fl_addto_combox(obj, lit->first.c_str());
1693 fl_set_combox_browser_height(obj, 400);
1695 // set up the feedback mechanism
1696 setPrehandler(dialog_->input_package);
1697 setPrehandler(dialog_->check_use_kbmap);
1698 setPrehandler(dialog_->combox_default_lang);
1699 setPrehandler(dialog_->input_kbmap1);
1700 setPrehandler(dialog_->input_kbmap2);
1701 setPrehandler(dialog_->check_rtl_support);
1702 setPrehandler(dialog_->check_mark_foreign);
1703 setPrehandler(dialog_->check_auto_begin);
1704 setPrehandler(dialog_->check_auto_end);
1705 setPrehandler(dialog_->check_use_babel);
1706 setPrehandler(dialog_->check_global_options);
1707 setPrehandler(dialog_->input_command_begin);
1708 setPrehandler(dialog_->input_command_end);
1710 // Activate/Deactivate the input fields dependent on the state of the
1717 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1719 if (ob == dialog_->combox_default_lang)
1720 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1721 if (ob == dialog_->check_use_kbmap)
1722 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1723 if (ob == dialog_->input_kbmap1)
1724 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1725 if (ob == dialog_->input_kbmap2)
1726 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1727 if (ob == dialog_->check_rtl_support)
1728 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1729 if (ob == dialog_->check_mark_foreign)
1730 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1731 if (ob == dialog_->check_auto_begin)
1732 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1733 if (ob == dialog_->check_auto_end)
1734 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1735 if (ob == dialog_->check_use_babel)
1736 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1737 if (ob == dialog_->check_global_options)
1738 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1739 if (ob == dialog_->input_package)
1740 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1741 if (ob == dialog_->input_command_begin)
1742 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1743 if (ob == dialog_->input_command_end)
1744 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1749 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1751 bool activate = true;
1753 // !ob if function is called from Language::build() to de/activate
1755 // otherwise the function is called by an xforms CB via input().
1756 if (!ob || ob == dialog_->check_use_kbmap) {
1757 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1758 setEnabled(dialog_->button_kbmap1_browse, enable);
1759 setEnabled(dialog_->button_kbmap2_browse, enable);
1760 setEnabled(dialog_->input_kbmap1, enable);
1761 setEnabled(dialog_->input_kbmap2, enable);
1764 if (ob == dialog_->button_kbmap1_browse) {
1765 string f = parent_.controller().browsekbmap(
1766 fl_get_input(dialog_->input_kbmap1));
1768 fl_set_input(dialog_->input_kbmap1, f.c_str());
1769 } else if (ob == dialog_->button_kbmap2_browse) {
1770 string f = parent_.controller().browsekbmap(
1771 fl_get_input(dialog_->input_kbmap2));
1773 fl_set_input(dialog_->input_kbmap2, f.c_str());
1780 void FormPreferences::Language::update(LyXRC const & rc)
1782 fl_set_button(dialog_->check_use_kbmap,
1785 int const pos = int(findPos(lang_, rc.default_language));
1786 fl_set_combox(dialog_->combox_default_lang, pos + 1);
1789 fl_set_input(dialog_->input_kbmap1,
1790 rc.primary_kbmap.c_str());
1791 fl_set_input(dialog_->input_kbmap2,
1792 rc.secondary_kbmap.c_str());
1794 fl_set_input(dialog_->input_kbmap1, "");
1795 fl_set_input(dialog_->input_kbmap2, "");
1798 fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1799 fl_set_button(dialog_->check_mark_foreign,
1800 rc.mark_foreign_language);
1801 fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1802 fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1803 fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1804 fl_set_button(dialog_->check_global_options,
1805 rc.language_global_options);
1807 fl_set_input(dialog_->input_package,
1808 rc.language_package.c_str());
1809 fl_set_input(dialog_->input_command_begin,
1810 rc.language_command_begin.c_str());
1811 fl_set_input(dialog_->input_command_end,
1812 rc.language_command_end.c_str());
1814 // Activate/Deactivate the input fields dependent on the state of the
1820 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1825 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1827 return dialog_.get();
1831 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1833 rc.auto_region_delete =
1834 fl_get_button(dialog_->check_auto_region_delete);
1835 rc.cursor_follows_scrollbar =
1836 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1837 rc.dialogs_iconify_with_main =
1838 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1839 rc.preview = fl_get_button(dialog_->check_preview_latex);
1840 rc.autosave = static_cast<unsigned int>
1841 (fl_get_counter_value(dialog_->counter_autosave));
1842 rc.wheel_jump = static_cast<unsigned int>
1843 (fl_get_counter_value(dialog_->counter_wm_jump));
1846 // grfx::DisplayType old_value = rc.display_graphics;
1847 switch (fl_get_choice(dialog_->choice_display)) {
1849 rc.display_graphics = grfx::NoDisplay;
1852 rc.display_graphics = grfx::ColorDisplay;
1855 rc.display_graphics = grfx::GrayscaleDisplay;
1858 rc.display_graphics = grfx::MonochromeDisplay;
1861 rc.display_graphics = grfx::ColorDisplay;
1865 #ifdef WITH_WARNINGS
1866 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1869 if (old_value != rc.display_graphics) {
1870 grfx::GCache & gc = grfx::GCache::get();
1877 void FormPreferences::LnFmisc::build()
1879 dialog_.reset(build_preferences_lnf_misc(&parent_));
1881 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1882 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1884 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1885 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1887 // set up the feedback mechanism
1888 setPrehandler(dialog_->check_auto_region_delete);
1889 setPrehandler(dialog_->counter_autosave);
1890 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1891 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1892 setPrehandler(dialog_->check_preview_latex);
1893 setPrehandler(dialog_->counter_wm_jump);
1895 fl_addto_choice(dialog_->choice_display,
1896 _("Monochrome|Grayscale|Color|Do not display").c_str());
1901 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1903 if (ob == dialog_->check_auto_region_delete)
1904 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
1905 if (ob == dialog_->check_cursor_follows_scrollbar)
1906 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1907 if (ob == dialog_->check_dialogs_iconify_with_main)
1908 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1909 if (ob == dialog_->check_preview_latex)
1910 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
1911 if (ob == dialog_->counter_autosave)
1912 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
1913 if (ob == dialog_->counter_wm_jump)
1914 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
1915 if (ob == dialog_->choice_display)
1916 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1921 void FormPreferences::LnFmisc::update(LyXRC const & rc)
1923 fl_set_button(dialog_->check_auto_region_delete,
1924 rc.auto_region_delete);
1925 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1926 rc.cursor_follows_scrollbar);
1927 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1928 rc.dialogs_iconify_with_main);
1929 fl_set_button(dialog_->check_preview_latex,
1931 fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
1932 fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
1934 switch (rc.display_graphics) {
1935 case grfx::NoDisplay:
1936 fl_set_choice(dialog_->choice_display, 4);
1938 case grfx::ColorDisplay:
1939 fl_set_choice(dialog_->choice_display, 3);
1941 case grfx::GrayscaleDisplay:
1942 fl_set_choice(dialog_->choice_display, 2);
1944 case grfx::MonochromeDisplay:
1945 fl_set_choice(dialog_->choice_display, 1);
1948 fl_set_choice(dialog_->choice_display, 3);
1954 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1959 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1961 return dialog_.get();
1965 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
1967 rc.ascii_linelen = static_cast<unsigned int>
1968 (fl_get_counter_value(dialog_->counter_line_len));
1969 rc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1972 fl_get_choice(dialog_->choice_default_papersize) - 1;
1973 rc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1975 rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1976 rc.chktex_command = fl_get_input(dialog_->input_checktex);
1977 rc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1978 rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1982 void FormPreferences::OutputsMisc::build()
1984 dialog_.reset(build_preferences_outputs_misc(&parent_));
1986 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1988 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1989 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1990 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1991 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1992 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1994 fl_addto_choice(dialog_->choice_default_papersize,
1995 _(" default | US letter | US legal "
1996 "| US executive | A3 | A4 | A5 | B5 ").c_str());
1998 // set up the feedback mechanism
1999 setPrehandler(dialog_->counter_line_len);
2000 setPrehandler(dialog_->input_tex_encoding);
2001 setPrehandler(dialog_->choice_default_papersize);
2002 setPrehandler(dialog_->input_ascii_roff);
2003 setPrehandler(dialog_->input_checktex);
2004 setPrehandler(dialog_->input_paperoption);
2005 setPrehandler(dialog_->check_autoreset_classopt);
2010 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
2012 if (ob == dialog_->counter_line_len)
2013 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
2014 if (ob == dialog_->input_tex_encoding)
2015 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
2016 if (ob == dialog_->input_ascii_roff)
2017 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
2018 if (ob == dialog_->input_checktex)
2019 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
2020 if (ob == dialog_->choice_default_papersize)
2021 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2022 if (ob == dialog_->input_paperoption)
2023 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
2024 if (ob == dialog_->check_autoreset_classopt)
2025 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2030 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
2032 fl_set_counter_value(dialog_->counter_line_len,
2034 fl_set_input(dialog_->input_tex_encoding,
2035 rc.fontenc.c_str());
2036 fl_set_choice(dialog_->choice_default_papersize,
2037 rc.default_papersize + 1);
2038 fl_set_input(dialog_->input_ascii_roff,
2039 rc.ascii_roff_command.c_str());
2040 fl_set_input(dialog_->input_checktex,
2041 rc.chktex_command.c_str());
2042 fl_set_input(dialog_->input_paperoption,
2043 rc.view_dvi_paper_option.c_str());
2044 fl_set_button(dialog_->check_autoreset_classopt,
2045 rc.auto_reset_options);
2050 FormPreferences::Paths::Paths(FormPreferences & p)
2055 FD_preferences_paths const * FormPreferences::Paths::dialog()
2057 return dialog_.get();
2061 void FormPreferences::Paths::apply(LyXRC & rc)
2063 rc.document_path = fl_get_input(dialog_->input_default_path);
2064 rc.template_path = fl_get_input(dialog_->input_template_path);
2066 int button = fl_get_button(dialog_->check_use_temp_dir);
2067 string str = fl_get_input(dialog_->input_temp_dir);
2071 rc.use_tempdir = button;
2072 rc.tempdir_path = str;
2074 button = fl_get_button(dialog_->check_last_files);
2075 str = fl_get_input(dialog_->input_lastfiles);
2076 if (!button) str.erase();
2078 rc.check_lastfiles = button;
2080 rc.num_lastfiles = static_cast<unsigned int>
2081 (fl_get_counter_value(dialog_->counter_lastfiles));
2083 button = fl_get_button(dialog_->check_make_backups);
2084 str = fl_get_input(dialog_->input_backup_path);
2088 rc.make_backup = button;
2089 rc.backupdir_path = str;
2091 rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2098 void FormPreferences::Paths::build()
2100 dialog_.reset(build_preferences_paths(&parent_));
2102 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2103 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2104 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2105 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2106 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2107 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2108 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2110 // set up the feedback mechanism
2111 setPrehandler(dialog_->input_default_path);
2112 setPrehandler(dialog_->counter_lastfiles);
2113 setPrehandler(dialog_->input_template_path);
2114 setPrehandler(dialog_->check_last_files);
2115 setPrehandler(dialog_->input_lastfiles);
2116 setPrehandler(dialog_->check_make_backups);
2117 setPrehandler(dialog_->input_backup_path);
2118 setPrehandler(dialog_->input_serverpipe);
2119 setPrehandler(dialog_->input_temp_dir);
2120 setPrehandler(dialog_->check_use_temp_dir);
2125 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2127 if (ob == dialog_->input_default_path)
2128 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2129 if (ob == dialog_->input_template_path)
2130 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2131 if (ob == dialog_->check_use_temp_dir)
2132 return LyXRC::getDescription(LyXRC::RC_USETEMPDIR);
2133 if (ob == dialog_->input_temp_dir)
2134 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2135 if (ob == dialog_->check_last_files)
2136 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2137 if (ob == dialog_->input_lastfiles)
2138 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
2139 if (ob == dialog_->counter_lastfiles)
2140 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2141 if (ob == dialog_->check_make_backups)
2142 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2143 if (ob == dialog_->input_backup_path)
2144 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2145 if (ob == dialog_->input_serverpipe)
2146 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2151 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2153 bool activate = true;
2155 // !ob if function is called from Paths::update() to de/activate
2157 // otherwise the function is called by an xforms CB via input().
2158 if (!ob || ob == dialog_->check_use_temp_dir) {
2159 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2160 setEnabled(dialog_->input_temp_dir, enable);
2163 if (!ob || ob == dialog_->check_last_files) {
2164 bool const enable = fl_get_button(dialog_->check_last_files);
2165 setEnabled(dialog_->input_lastfiles, enable);
2168 if (!ob || ob == dialog_->check_make_backups) {
2169 bool const enable = fl_get_button(dialog_->check_make_backups);
2170 setEnabled(dialog_->input_backup_path, enable);
2173 if (!ob || ob == dialog_->input_default_path) {
2174 string const name = fl_get_input(dialog_->input_default_path);
2175 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2176 parent_.postWarning(RWInfo::ErrorMessage());
2181 if (!ob || ob == dialog_->input_template_path) {
2182 string const name = fl_get_input(dialog_->input_template_path);
2183 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2184 parent_.postWarning(RWInfo::ErrorMessage());
2189 if (!ob || ob == dialog_->input_temp_dir) {
2190 string const name = fl_get_input(dialog_->input_temp_dir);
2191 if (fl_get_button(dialog_->check_make_backups)
2193 && !RWInfo::WriteableDir(name)) {
2194 parent_.postWarning(RWInfo::ErrorMessage());
2199 if (!ob || ob == dialog_->input_backup_path) {
2200 string const name = fl_get_input(dialog_->input_backup_path);
2201 if (fl_get_button(dialog_->check_make_backups)
2203 && !RWInfo::WriteableDir(name)) {
2204 parent_.postWarning(RWInfo::ErrorMessage());
2209 if (!ob || ob == dialog_->input_lastfiles) {
2210 string const name = fl_get_input(dialog_->input_lastfiles);
2211 if (fl_get_button(dialog_->check_last_files)
2213 && !RWInfo::WriteableFile(name)) {
2214 parent_.postWarning(RWInfo::ErrorMessage());
2219 if (!ob || ob == dialog_->input_serverpipe) {
2220 string const name = fl_get_input(dialog_->input_serverpipe);
2221 if (!name.empty()) {
2222 // strip off the extension
2223 string const str = ChangeExtension(name, "");
2224 if (!RWInfo::WriteableFile(str + ".in")) {
2225 parent_.postWarning(RWInfo::ErrorMessage());
2228 if (!RWInfo::WriteableFile(str + ".out")) {
2229 parent_.postWarning(RWInfo::ErrorMessage());
2235 if (ob == dialog_->button_default_path_browse) {
2236 string f = parent_.controller().browsedir(
2237 fl_get_input(dialog_->input_default_path), _("Default path"));
2239 fl_set_input(dialog_->input_default_path, f.c_str());
2240 } else if (ob == dialog_->button_template_path_browse) {
2241 string f = parent_.controller().browsedir(
2242 fl_get_input(dialog_->input_template_path), _("Template path"));
2244 fl_set_input(dialog_->input_template_path, f.c_str());
2245 } else if (ob == dialog_->button_temp_dir_browse) {
2246 string f = parent_.controller().browsedir(
2247 fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2249 fl_set_input(dialog_->input_temp_dir, f.c_str());
2250 } else if (ob == dialog_->button_lastfiles_browse) {
2251 string f = parent_.controller().browse(
2252 fl_get_input(dialog_->input_lastfiles), _("Last files"));
2254 fl_set_input(dialog_->input_lastfiles, f.c_str());
2255 } else if (ob == dialog_->button_backup_path_browse) {
2256 string f = parent_.controller().browsedir(
2257 fl_get_input(dialog_->input_backup_path), _("Backup path"));
2259 fl_set_input(dialog_->input_backup_path, f.c_str());
2260 } else if (ob == dialog_->button_serverpipe_browse) {
2261 string f = parent_.controller().browse(
2262 fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2264 fl_set_input(dialog_->input_serverpipe, f.c_str());
2271 void FormPreferences::Paths::update(LyXRC const & rc)
2273 fl_set_input(dialog_->input_default_path,
2274 rc.document_path.c_str());
2275 fl_set_input(dialog_->input_template_path,
2276 rc.template_path.c_str());
2280 str = rc.backupdir_path;
2282 fl_set_button(dialog_->check_make_backups,
2284 fl_set_input(dialog_->input_backup_path, str.c_str());
2288 str = rc.tempdir_path;
2290 fl_set_button(dialog_->check_use_temp_dir,
2292 fl_set_input(dialog_->input_temp_dir, str.c_str());
2295 if (rc.check_lastfiles)
2298 fl_set_button(dialog_->check_last_files,
2299 rc.check_lastfiles);
2300 fl_set_input(dialog_->input_lastfiles, str.c_str());
2301 fl_set_counter_value(dialog_->counter_lastfiles,
2304 fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2306 // Activate/Deactivate the input fields dependent on the state of the
2312 FormPreferences::Printer::Printer(FormPreferences & p)
2317 FD_preferences_printer const * FormPreferences::Printer::dialog()
2319 return dialog_.get();
2323 void FormPreferences::Printer::apply(LyXRC & rc) const
2325 rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2326 rc.print_command = fl_get_input(dialog_->input_command);
2327 rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2328 rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2329 rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2330 rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2331 rc.print_file_extension =
2332 fl_get_input(dialog_->input_file_extension);
2333 rc.print_spool_command =
2334 fl_get_input(dialog_->input_spool_command);
2335 rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2336 rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2337 rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2338 rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2339 rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2340 rc.print_to_file = fl_get_input(dialog_->input_to_file);
2341 rc.print_extra_options =
2342 fl_get_input(dialog_->input_extra_options);
2343 rc.print_spool_printerprefix =
2344 fl_get_input(dialog_->input_spool_prefix);
2345 rc.print_paper_dimension_flag =
2346 fl_get_input(dialog_->input_paper_size);
2347 rc.printer = fl_get_input(dialog_->input_name);
2352 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2354 if (ob == dialog_->input_command)
2355 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2356 if (ob == dialog_->check_adapt_output)
2357 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2358 if (ob == dialog_->input_to_printer)
2359 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2360 if (ob == dialog_->input_to_file)
2361 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2362 if (ob == dialog_->input_file_extension)
2363 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2364 if (ob == dialog_->input_extra_options)
2365 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2366 if (ob == dialog_->input_spool_command)
2367 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2368 if (ob == dialog_->input_spool_prefix)
2369 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2370 if (ob == dialog_->input_name)
2371 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2372 if (ob == dialog_->input_even_pages)
2373 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2374 if (ob == dialog_->input_odd_pages)
2375 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2376 if (ob == dialog_->input_page_range)
2377 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2378 if (ob == dialog_->input_reverse)
2379 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2380 if (ob == dialog_->input_landscape)
2381 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2382 if (ob == dialog_->input_copies)
2383 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2384 if (ob == dialog_->input_collated)
2385 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2386 if (ob == dialog_->input_paper_type)
2387 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2388 if (ob == dialog_->input_paper_size)
2389 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2394 void FormPreferences::Printer::build()
2396 dialog_.reset(build_preferences_printer(&parent_));
2398 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2399 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2400 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2401 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2402 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2403 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2404 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2405 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2406 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2407 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2408 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2409 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2410 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2411 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2412 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2413 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2414 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2416 // set up the feedback mechanism
2417 setPrehandler(dialog_->input_command);
2418 setPrehandler(dialog_->input_page_range);
2419 setPrehandler(dialog_->input_copies);
2420 setPrehandler(dialog_->input_reverse);
2421 setPrehandler(dialog_->input_to_printer);
2422 setPrehandler(dialog_->input_file_extension);
2423 setPrehandler(dialog_->input_spool_command);
2424 setPrehandler(dialog_->input_paper_type);
2425 setPrehandler(dialog_->input_even_pages);
2426 setPrehandler(dialog_->input_odd_pages);
2427 setPrehandler(dialog_->input_collated);
2428 setPrehandler(dialog_->input_landscape);
2429 setPrehandler(dialog_->input_to_file);
2430 setPrehandler(dialog_->input_extra_options);
2431 setPrehandler(dialog_->input_spool_prefix);
2432 setPrehandler(dialog_->input_paper_size);
2433 setPrehandler(dialog_->input_name);
2434 setPrehandler(dialog_->check_adapt_output);
2438 void FormPreferences::Printer::update(LyXRC const & rc)
2440 fl_set_button(dialog_->check_adapt_output,
2441 rc.print_adapt_output);
2442 fl_set_input(dialog_->input_command,
2443 rc.print_command.c_str());
2444 fl_set_input(dialog_->input_page_range,
2445 rc.print_pagerange_flag.c_str());
2446 fl_set_input(dialog_->input_copies,
2447 rc.print_copies_flag.c_str());
2448 fl_set_input(dialog_->input_reverse,
2449 rc.print_reverse_flag.c_str());
2450 fl_set_input(dialog_->input_to_printer,
2451 rc.print_to_printer.c_str());
2452 fl_set_input(dialog_->input_file_extension,
2453 rc.print_file_extension.c_str());
2454 fl_set_input(dialog_->input_spool_command,
2455 rc.print_spool_command.c_str());
2456 fl_set_input(dialog_->input_paper_type,
2457 rc.print_paper_flag.c_str());
2458 fl_set_input(dialog_->input_even_pages,
2459 rc.print_evenpage_flag.c_str());
2460 fl_set_input(dialog_->input_odd_pages,
2461 rc.print_oddpage_flag.c_str());
2462 fl_set_input(dialog_->input_collated,
2463 rc.print_collcopies_flag.c_str());
2464 fl_set_input(dialog_->input_landscape,
2465 rc.print_landscape_flag.c_str());
2466 fl_set_input(dialog_->input_to_file,
2467 rc.print_to_file.c_str());
2468 fl_set_input(dialog_->input_extra_options,
2469 rc.print_extra_options.c_str());
2470 fl_set_input(dialog_->input_spool_prefix,
2471 rc.print_spool_printerprefix.c_str());
2472 fl_set_input(dialog_->input_paper_size,
2473 rc.print_paper_dimension_flag.c_str());
2474 fl_set_input(dialog_->input_name,
2475 rc.printer.c_str());
2479 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2484 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2486 return dialog_.get();
2490 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2492 bool changed = false;
2494 pair<string, string> tmp =
2495 parseFontName(fl_get_input(dialog_->input_roman));
2496 if (rc.roman_font_name != tmp.first ||
2497 rc.roman_font_foundry != tmp.second) {
2499 rc.roman_font_name = tmp.first;
2500 rc.roman_font_foundry = tmp.second;
2503 tmp = parseFontName(fl_get_input(dialog_->input_sans));
2504 if (rc.sans_font_name != tmp.first ||
2505 rc.sans_font_foundry != tmp.second) {
2507 rc.sans_font_name = tmp.first;
2508 rc.sans_font_foundry = tmp.second;
2511 tmp = parseFontName(fl_get_input(dialog_->input_typewriter));
2512 if (rc.typewriter_font_name != tmp.first ||
2513 rc.typewriter_font_foundry != tmp.second) {
2515 rc.typewriter_font_name = tmp.first;
2516 rc.typewriter_font_foundry = tmp.second;
2519 string str = fl_get_input(dialog_->input_screen_encoding);
2520 if (rc.font_norm != str) {
2523 rc.set_font_norm_type();
2526 bool button = fl_get_button(dialog_->check_scalable);
2527 if (rc.use_scalable_fonts != button) {
2529 rc.use_scalable_fonts = button;
2532 unsigned int ivalue = static_cast<unsigned int>
2533 (fl_get_counter_value(dialog_->counter_zoom));
2534 if (rc.zoom != ivalue) {
2539 ivalue = static_cast<unsigned int>
2540 (fl_get_counter_value(dialog_->counter_dpi));
2541 if (rc.dpi != ivalue) {
2546 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2547 if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2549 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2552 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2553 if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2555 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2558 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2559 if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2561 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2564 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2565 if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2567 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2570 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2571 if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2573 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2576 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2577 if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2579 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2582 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2583 if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2585 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2588 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2589 if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2591 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2594 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2595 if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2597 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2600 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2601 if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2603 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2607 // Now update the buffers
2608 // Can anything below here affect the redraw process?
2609 parent_.controller().updateScreenFonts();
2614 void FormPreferences::ScreenFonts::build()
2616 dialog_.reset(build_preferences_screen_fonts(&parent_));
2618 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2619 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2621 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2622 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2623 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2624 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2625 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2626 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2627 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2628 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2629 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2630 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2631 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2632 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2633 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2634 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2635 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2636 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2638 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2639 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2640 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2641 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2642 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2643 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2644 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2645 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2646 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2647 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2649 // set up the feedback mechanism
2650 setPrehandler(dialog_->input_roman);
2651 setPrehandler(dialog_->input_sans);
2652 setPrehandler(dialog_->input_typewriter);
2653 setPrehandler(dialog_->counter_zoom);
2654 setPrehandler(dialog_->counter_dpi);
2655 setPrehandler(dialog_->check_scalable);
2656 setPrehandler(dialog_->input_screen_encoding);
2657 setPrehandler(dialog_->input_tiny);
2658 setPrehandler(dialog_->input_script);
2659 setPrehandler(dialog_->input_footnote);
2660 setPrehandler(dialog_->input_small);
2661 setPrehandler(dialog_->input_large);
2662 setPrehandler(dialog_->input_larger);
2663 setPrehandler(dialog_->input_largest);
2664 setPrehandler(dialog_->input_normal);
2665 setPrehandler(dialog_->input_huge);
2666 setPrehandler(dialog_->input_huger);
2671 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2673 if (ob == dialog_->input_roman)
2674 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2675 if (ob == dialog_->input_sans)
2676 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2677 if (ob == dialog_->input_typewriter)
2678 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2679 if (ob == dialog_->check_scalable)
2680 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2681 if (ob == dialog_->input_screen_encoding)
2682 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2683 if (ob == dialog_->counter_zoom)
2684 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2685 if (ob == dialog_->counter_dpi)
2686 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2687 if (ob == dialog_->input_tiny
2688 || ob == dialog_->input_script
2689 || ob == dialog_->input_footnote
2690 || ob == dialog_->input_small
2691 || ob == dialog_->input_large
2692 || ob == dialog_->input_larger
2693 || ob == dialog_->input_larger
2694 || ob == dialog_->input_largest
2695 || ob == dialog_->input_normal
2696 || ob == dialog_->input_huge
2697 || ob == dialog_->input_huger)
2698 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2703 bool FormPreferences::ScreenFonts::input()
2705 bool activate = true;
2708 // Make sure that all fonts all have positive entries
2709 // Also note that an empty entry is returned as 0.0 by strToDbl
2710 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2711 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2712 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2713 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2714 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2715 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2716 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2717 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2718 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2719 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2721 str = _("Fonts must be positive!");
2723 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2724 // Fontsizes -- tiny < script < footnote etc.
2725 strToDbl(fl_get_input(dialog_->input_script)) ||
2726 strToDbl(fl_get_input(dialog_->input_script)) >
2727 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2728 strToDbl(fl_get_input(dialog_->input_footnote)) >
2729 strToDbl(fl_get_input(dialog_->input_small)) ||
2730 strToDbl(fl_get_input(dialog_->input_small)) >
2731 strToDbl(fl_get_input(dialog_->input_normal)) ||
2732 strToDbl(fl_get_input(dialog_->input_normal)) >
2733 strToDbl(fl_get_input(dialog_->input_large)) ||
2734 strToDbl(fl_get_input(dialog_->input_large)) >
2735 strToDbl(fl_get_input(dialog_->input_larger)) ||
2736 strToDbl(fl_get_input(dialog_->input_larger)) >
2737 strToDbl(fl_get_input(dialog_->input_largest)) ||
2738 strToDbl(fl_get_input(dialog_->input_largest)) >
2739 strToDbl(fl_get_input(dialog_->input_huge)) ||
2740 strToDbl(fl_get_input(dialog_->input_huge)) >
2741 strToDbl(fl_get_input(dialog_->input_huger))) {
2744 str = _("Fonts must be input in the order Tiny > Smallest > Smaller > Small > Normal > Large > Larger > Largest > Huge > Huger.");
2748 parent_.postWarning(str);
2754 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2756 fl_set_input(dialog_->input_roman,
2757 makeFontName(rc.roman_font_name,
2758 rc.roman_font_foundry).c_str());
2759 fl_set_input(dialog_->input_sans,
2760 makeFontName(rc.sans_font_name,
2761 rc.sans_font_foundry).c_str());
2762 fl_set_input(dialog_->input_typewriter,
2763 makeFontName(rc.typewriter_font_name,
2764 rc.typewriter_font_foundry).c_str());
2765 fl_set_input(dialog_->input_screen_encoding,
2766 rc.font_norm.c_str());
2767 fl_set_button(dialog_->check_scalable,
2768 rc.use_scalable_fonts);
2769 fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2770 fl_set_counter_value(dialog_->counter_dpi, rc.dpi);
2771 fl_set_input(dialog_->input_tiny,
2772 tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2773 fl_set_input(dialog_->input_script,
2774 tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2775 fl_set_input(dialog_->input_footnote,
2776 tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2777 fl_set_input(dialog_->input_small,
2778 tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2779 fl_set_input(dialog_->input_normal,
2780 tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2781 fl_set_input(dialog_->input_large,
2782 tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2783 fl_set_input(dialog_->input_larger,
2784 tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2785 fl_set_input(dialog_->input_largest,
2786 tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2787 fl_set_input(dialog_->input_huge,
2788 tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2789 fl_set_input(dialog_->input_huger,
2790 tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2795 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2800 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2802 return dialog_.get();
2806 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2808 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2809 choice = trim(choice);
2811 rc.isp_command = choice;
2814 // If spell checker == "none", all other input set to off.
2815 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2816 rc.isp_use_alt_lang = false;
2817 rc.isp_alt_lang.erase();
2819 rc.isp_use_esc_chars = false;
2820 rc.isp_esc_chars.erase();
2822 rc.isp_use_pers_dict = false;
2823 rc.isp_pers_dict.erase();
2825 rc.isp_accept_compound = false;
2826 rc.isp_use_input_encoding = false;
2829 int button = fl_get_button(dialog_->check_alt_lang);
2830 choice = fl_get_input(dialog_->input_alt_lang);
2831 if (button && choice.empty()) button = 0;
2832 if (!button) choice.erase();
2834 rc.isp_use_alt_lang = static_cast<bool>(button);
2835 rc.isp_alt_lang = choice;
2837 button = fl_get_button(dialog_->check_escape_chars);
2838 choice = fl_get_input(dialog_->input_escape_chars);
2839 if (button && choice.empty()) button = 0;
2840 if (!button) choice.erase();
2842 rc.isp_use_esc_chars = static_cast<bool>(button);
2843 rc.isp_esc_chars = choice;
2845 button = fl_get_button(dialog_->check_personal_dict);
2846 choice = fl_get_input(dialog_->input_personal_dict);
2847 if (button && choice.empty()) button = 0;
2848 if (!button) choice.erase();
2850 rc.isp_use_pers_dict = static_cast<bool>(button);
2851 rc.isp_pers_dict = choice;
2853 button = fl_get_button(dialog_->check_compound_words);
2854 rc.isp_accept_compound = static_cast<bool>(button);
2856 button = fl_get_button(dialog_->check_input_enc);
2857 rc.isp_use_input_encoding = static_cast<bool>(button);
2868 void FormPreferences::SpellOptions::build()
2870 dialog_.reset(build_preferences_spelloptions(&parent_));
2872 fl_addto_choice(dialog_->choice_spell_command,
2873 _(" ispell | aspell ").c_str());
2874 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2875 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2876 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2878 // set up the feedback mechanism
2879 setPrehandler(dialog_->choice_spell_command);
2880 setPrehandler(dialog_->check_alt_lang);
2881 setPrehandler(dialog_->input_alt_lang);
2882 setPrehandler(dialog_->check_escape_chars);
2883 setPrehandler(dialog_->input_escape_chars);
2884 setPrehandler(dialog_->check_personal_dict);
2885 setPrehandler(dialog_->input_personal_dict);
2886 setPrehandler(dialog_->button_personal_dict);
2887 setPrehandler(dialog_->check_compound_words);
2888 setPrehandler(dialog_->check_input_enc);
2893 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2895 if (ob == dialog_->choice_spell_command)
2896 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2897 if (ob == dialog_->check_alt_lang)
2898 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2899 if (ob == dialog_->input_alt_lang)
2900 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2901 if (ob == dialog_->check_escape_chars)
2902 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2903 if (ob == dialog_->input_escape_chars)
2904 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2905 if (ob == dialog_->check_personal_dict)
2906 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2907 if (ob == dialog_->input_personal_dict)
2908 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2909 if (ob == dialog_->check_compound_words)
2910 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2911 if (ob == dialog_->check_input_enc)
2912 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
2917 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2919 // !ob if function is called from updateSpellOptions() to de/activate
2921 // otherwise the function is called by an xforms CB via input().
2924 // If spell checker == "none", disable all input.
2925 if (!ob || ob == dialog_->choice_spell_command) {
2926 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2927 fl_deactivate_object(dialog_->check_alt_lang);
2928 fl_deactivate_object(dialog_->input_alt_lang);
2929 fl_deactivate_object(dialog_->check_escape_chars);
2930 fl_deactivate_object(dialog_->input_escape_chars);
2931 fl_deactivate_object(dialog_->check_personal_dict);
2932 fl_deactivate_object(dialog_->input_personal_dict);
2933 fl_deactivate_object(dialog_->check_compound_words);
2934 fl_deactivate_object(dialog_->check_input_enc);
2937 fl_activate_object(dialog_->check_alt_lang);
2938 fl_activate_object(dialog_->check_escape_chars);
2939 fl_activate_object(dialog_->check_personal_dict);
2940 fl_activate_object(dialog_->check_compound_words);
2941 fl_activate_object(dialog_->check_input_enc);
2946 if (!ob || ob == dialog_->check_alt_lang) {
2947 bool const enable = fl_get_button(dialog_->check_alt_lang);
2948 setEnabled(dialog_->input_alt_lang, enable);
2951 if (!ob || ob == dialog_->check_escape_chars) {
2952 bool const enable = fl_get_button(dialog_->check_escape_chars);
2953 setEnabled(dialog_->input_escape_chars, enable);
2956 if (!ob || ob == dialog_->check_personal_dict) {
2957 bool const enable = fl_get_button(dialog_->check_personal_dict);
2958 setEnabled(dialog_->input_personal_dict, enable);
2961 if (ob == dialog_->button_personal_dict) {
2962 string f = parent_.controller().browsedict(
2963 fl_get_input(dialog_->input_personal_dict));
2964 fl_set_input(dialog_->input_personal_dict, f.c_str());
2967 return true; // All input is valid!
2971 void FormPreferences::SpellOptions::update(LyXRC const & rc)
2975 if (rc.isp_command == "none")
2977 else if (rc.isp_command == "ispell")
2979 else if (rc.isp_command == "aspell")
2982 if (rc.isp_command == "ispell")
2984 else if (rc.isp_command == "aspell")
2987 fl_set_choice(dialog_->choice_spell_command, choice);
2990 if (rc.isp_use_alt_lang)
2991 str = rc.isp_alt_lang;
2993 fl_set_button(dialog_->check_alt_lang,
2994 rc.isp_use_alt_lang);
2995 fl_set_input(dialog_->input_alt_lang, str.c_str());
2998 if (rc.isp_use_esc_chars)
2999 str = rc.isp_esc_chars;
3001 fl_set_button(dialog_->check_escape_chars,
3002 rc.isp_use_esc_chars);
3003 fl_set_input(dialog_->input_escape_chars, str.c_str());
3006 if (rc.isp_use_pers_dict)
3007 str = rc.isp_pers_dict;
3009 fl_set_button(dialog_->check_personal_dict,
3010 rc.isp_use_pers_dict);
3011 fl_set_input(dialog_->input_personal_dict, str.c_str());
3013 fl_set_button(dialog_->check_compound_words,
3014 rc.isp_accept_compound);
3015 fl_set_button(dialog_->check_input_enc,
3016 rc.isp_use_input_encoding);
3018 // Activate/Deactivate the input fields dependent on the state of the