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;
73 // These should probably go inside the class definition...
74 Formats local_formats;
75 Converters local_converters;
77 string makeFontName(string const & family, string const & foundry)
81 return family + ',' + foundry;
85 pair<string,string> parseFontName(string const & name)
87 string::size_type const idx = name.find(',');
88 if (idx == string::npos)
89 return make_pair(name, string());
90 return make_pair(name.substr(0, idx),
95 string const X11hexname(RGBColor const & col)
99 ostr << '#' << std::setbase(16) << setfill('0')
104 return STRCONV(ostr.str());
107 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
108 bool const scalableTabfolders = false;
110 bool const scalableTabfolders = true;
116 typedef FormCB<ControlPrefs, FormDB<FD_preferences> > base_class;
119 FormPreferences::FormPreferences()
120 : base_class(_("Preferences"), scalableTabfolders),
121 colors_(*this), converters_(*this), inputs_misc_(*this),
122 formats_(*this), interface_(*this), language_(*this),
123 lnf_misc_(*this), identity_(*this), outputs_misc_(*this),
124 paths_(*this), printer_(*this), screen_fonts_(*this),
130 void FormPreferences::redraw()
132 if (!(form() && form()->visible))
134 fl_redraw_form(form());
136 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
137 if (!(form2 && form2->visible))
139 fl_redraw_form(form2);
142 if (form2 == converters_tab_->form)
143 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
145 else if (form2 == look_n_feel_tab_->form)
146 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
148 else if (form2 == inputs_tab_->form)
149 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
151 else if (form2 == outputs_tab_->form)
152 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
154 else if (form2 == lang_opts_tab_->form)
155 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
157 if (form3 && form3->visible)
158 fl_redraw_form(form3);
162 void FormPreferences::hide()
164 // We need to hide the active tabfolder otherwise we get a
165 // BadDrawable error from X window and LyX crashes without saving.
166 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
167 if (inner_form && inner_form->visible)
168 fl_hide_form(inner_form);
173 void FormPreferences::build()
175 dialog_.reset(build_preferences(this));
177 // Manage the restore, save, apply and cancel/close buttons
178 bcview().setOK(dialog_->button_ok);
179 bcview().setApply(dialog_->button_apply);
180 bcview().setCancel(dialog_->button_close);
181 bcview().setRestore(dialog_->button_restore);
183 // Allow the base class to control messages
184 setMessageWidget(dialog_->text_warning);
186 // build the tab folders
187 converters_tab_.reset(build_preferences_inner_tab(this));
188 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
189 inputs_tab_.reset(build_preferences_inner_tab(this));
190 outputs_tab_.reset(build_preferences_inner_tab(this));
191 lang_opts_tab_.reset(build_preferences_inner_tab(this));
193 // build actual tabfolder contents
194 // these will become nested tabfolders
198 inputs_misc_.build();
203 outputs_misc_.build();
206 screen_fonts_.build();
207 spelloptions_.build();
209 // Enable the tabfolders to be rescaled correctly.
210 if (scalableTabfolders) {
211 FL_OBJECT * folder = dialog_->tabfolder_prefs;
212 fl_set_tabfolder_autofit(folder, FL_FIT);
214 folder = look_n_feel_tab_->tabfolder_inner;
215 fl_set_tabfolder_autofit(folder, FL_FIT);
217 folder = converters_tab_->tabfolder_inner;
218 fl_set_tabfolder_autofit(folder, FL_FIT);
220 folder = inputs_tab_->tabfolder_inner;
221 fl_set_tabfolder_autofit(folder, FL_FIT);
223 folder = outputs_tab_->tabfolder_inner;
224 fl_set_tabfolder_autofit(folder, FL_FIT);
226 folder = lang_opts_tab_->tabfolder_inner;
227 fl_set_tabfolder_autofit(folder, FL_FIT);
231 // Now add them to the tabfolder
232 fl_addto_tabfolder(dialog_->tabfolder_prefs,
233 _("Look & Feel").c_str(),
234 look_n_feel_tab_->form);
235 fl_addto_tabfolder(dialog_->tabfolder_prefs,
236 _("Lang Opts").c_str(),
237 lang_opts_tab_->form);
238 fl_addto_tabfolder(dialog_->tabfolder_prefs,
239 _("Conversion").c_str(),
240 converters_tab_->form);
241 fl_addto_tabfolder(dialog_->tabfolder_prefs,
244 fl_addto_tabfolder(dialog_->tabfolder_prefs,
245 _("Outputs").c_str(),
248 // now build the nested tabfolders
249 // Starting with look and feel
250 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
251 _("Screen Fonts").c_str(),
252 screen_fonts_.dialog()->form);
253 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
254 _("Interface").c_str(),
255 interface_.dialog()->form);
256 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
258 colors_.dialog()->form);
259 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
261 lnf_misc_.dialog()->form);
262 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
263 _("Identity").c_str(),
264 identity_.dialog()->form);
266 // then build converters
267 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
268 _("Formats").c_str(),
269 formats_.dialog()->form);
270 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
271 _("Converters").c_str(),
272 converters_.dialog()->form);
275 // Paths should probably go in a few inner_tab called Files
276 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
278 paths_.dialog()->form);
279 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
281 inputs_misc_.dialog()->form);
283 // then building outputs
284 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
285 _("Printer").c_str(),
286 printer_.dialog()->form);
287 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
289 outputs_misc_.dialog()->form);
291 // then building usage
292 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
293 _("Spell checker").c_str(),
294 spelloptions_.dialog()->form);
295 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
296 _("Language").c_str(),
297 language_.dialog()->form);
301 void FormPreferences::apply()
303 // set the new lyxrc entries
304 // many of these need to trigger other functions when the assignment
305 // is made. For example, screen zoom and font types. These could be
306 // handled either by signals/slots in lyxrc or just directly call the
307 // associated functions here.
308 // There are other problems with this scheme. We really should check
309 // what we copy to make sure that it really is necessary to do things
310 // like update the screen fonts because that flushes the textcache
311 // and other stuff which may cost us a lot on slower/high-load
314 LyXRC & rc(controller().rc());
317 formats_.apply(); // Must be before converters_.apply()
319 inputs_misc_.apply(rc);
320 interface_.apply(rc);
324 outputs_misc_.apply(rc);
327 screen_fonts_.apply(rc);
328 spelloptions_.apply(rc);
330 // The "Save" button has been pressed.
331 if (controller().isClosing() && colors_.modifiedXformsPrefs) {
332 string const filename =
333 AddName(user_lyxdir, "preferences.xform");
334 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
339 string const FormPreferences::getFeedback(FL_OBJECT * ob)
343 if (ob->form->fdui == colors_.dialog())
344 return colors_.feedback(ob);
345 if (ob->form->fdui == converters_.dialog())
346 return converters_.feedback(ob);
347 if (ob->form->fdui == formats_.dialog())
348 return formats_.feedback(ob);
349 if (ob->form->fdui == inputs_misc_.dialog())
350 return inputs_misc_.feedback(ob);
351 if (ob->form->fdui == interface_.dialog())
352 return interface_.feedback(ob);
353 if (ob->form->fdui == language_.dialog())
354 return language_.feedback(ob);
355 if (ob->form->fdui == lnf_misc_.dialog())
356 return lnf_misc_.feedback(ob);
357 if (ob->form->fdui == outputs_misc_.dialog())
358 return outputs_misc_.feedback(ob);
359 if (ob->form->fdui == paths_.dialog())
360 return paths_.feedback(ob);
361 if (ob->form->fdui == printer_.dialog())
362 return printer_.feedback(ob);
363 if (ob->form->fdui == screen_fonts_.dialog())
364 return screen_fonts_.feedback(ob);
365 if (ob->form->fdui == spelloptions_.dialog())
366 return spelloptions_.feedback(ob);
372 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
378 // whatever checks you need to ensure the user hasn't entered
379 // some totally ridiculous value somewhere. Change activate to suit.
380 // comments before each test describe what is _valid_
382 if (ob->form->fdui == colors_.dialog()) {
384 } else if (ob->form->fdui == converters_.dialog()) {
385 valid = converters_.input(ob);
386 } else if (ob->form->fdui == formats_.dialog()) {
387 valid = formats_.input(ob);
388 } else if (ob->form->fdui == interface_.dialog()) {
389 valid = interface_.input(ob);
390 } else if (ob->form->fdui == language_.dialog()) {
391 valid = language_.input(ob);
392 } else if (ob->form->fdui == paths_.dialog()) {
393 valid = paths_.input(ob);
394 } else if (ob->form->fdui == screen_fonts_.dialog()) {
395 valid = screen_fonts_.input();
396 } else if (ob->form->fdui == spelloptions_.dialog()) {
397 valid = spelloptions_.input(ob);
400 return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
404 void FormPreferences::update()
406 if (!dialog_.get()) return;
408 LyXRC const & rc(controller().rc());
410 // read lyxrc entries
412 formats_.update(); // Must be before converters_.update()
413 converters_.update();
414 inputs_misc_.update(rc);
415 interface_.update(rc);
416 language_.update(rc);
417 lnf_misc_.update(rc);
418 identity_.update(rc);
419 outputs_misc_.update(rc);
422 screen_fonts_.update(rc);
423 spelloptions_.update(rc);
427 FormPreferences::Colors::Colors(FormPreferences & p)
428 : modifiedXformsPrefs(false), parent_(p)
432 FD_preferences_colors const * FormPreferences::Colors::dialog()
434 return dialog_.get();
438 void FormPreferences::Colors::apply()
440 bool modifiedText = false;
441 bool modifiedBackground = false;
443 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
444 cit != xformsColorDB.end(); ++cit) {
446 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
447 if (col != cit->color()) {
448 modifiedXformsPrefs = true;
449 if (cit->colorID == FL_BLACK)
451 if (cit->colorID == FL_COL1)
452 modifiedBackground = true;
456 if (modifiedXformsPrefs) {
457 for (vector<XformsColor>::const_iterator cit =
458 xformsColorDB.begin();
459 cit != xformsColorDB.end(); ++cit) {
460 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
462 if (modifiedText && cit->colorID == FL_BLACK) {
463 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
466 if (modifiedBackground && cit->colorID == FL_COL1) {
467 AdjustVal(FL_MCOL, FL_COL1, 0.1);
468 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
469 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
471 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
472 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
475 if (cit->colorID == GUI_COLOR_CURSOR) {
476 fl_mapcolor(GUI_COLOR_CURSOR,
477 cit->r, cit->g, cit->b);
478 setCursorColor(GUI_COLOR_CURSOR);
481 parent_.controller().redrawGUI();
484 // Now do the same for the LyX LColors...
485 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
486 cit != lyxColorDB.end(); ++cit) {
487 LColor::color lc = lcolor.getFromGUIName(cit->getname());
488 if (lc == LColor::inherit) continue;
490 // Create a valid X11 name of the form "#rrggbb"
491 string const hexname = X11hexname(cit->color());
493 if (lcolor.getX11Name(lc) != hexname) {
495 << "FormPreferences::Colors::apply: "
496 << "resetting LColor " << lcolor.getGUIName(lc)
497 << " from \"" << lcolor.getX11Name(lc)
498 << "\" to \"" << hexname << "\"."
501 parent_.controller().setColor(lc, hexname);
507 void FormPreferences::Colors::build()
509 dialog_.reset(build_preferences_colors(&parent_));
511 fl_set_object_color(dialog_->button_color,
512 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
514 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
515 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
516 fl_set_dial_step(dialog_->dial_hue, 1.0);
517 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
519 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
520 fl_set_slider_step(dialog_->slider_saturation, 0.01);
521 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
523 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
524 fl_set_slider_step(dialog_->slider_value, 0.01);
525 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
527 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
528 fl_set_slider_step(dialog_->slider_red, 1.0);
529 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
531 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
532 fl_set_slider_step(dialog_->slider_green, 1.0);
533 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
535 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
536 fl_set_slider_step(dialog_->slider_blue, 1.0);
537 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
539 // set up the feedback mechanism
540 setPrehandler(dialog_->browser_lyx_objs);
541 setPrehandler(dialog_->button_color);
542 setPrehandler(dialog_->button_modify);
543 setPrehandler(dialog_->dial_hue);
544 setPrehandler(dialog_->slider_saturation);
545 setPrehandler(dialog_->slider_value);
546 setPrehandler(dialog_->slider_red);
547 setPrehandler(dialog_->slider_green);
548 setPrehandler(dialog_->slider_blue);
549 setPrehandler(dialog_->radio_rgb);
550 setPrehandler(dialog_->radio_hsv);
555 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
557 if (ob == dialog_->browser_lyx_objs)
558 return _("LyX objects that can be assigned a color.");
560 if (ob == dialog_->button_modify)
561 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
563 if (ob == dialog_->dial_hue ||
564 ob == dialog_->slider_saturation ||
565 ob == dialog_->slider_value ||
566 ob == dialog_->slider_red ||
567 ob == dialog_->slider_green ||
568 ob == dialog_->slider_blue)
569 return _("Find a new color.");
571 if (ob == dialog_->radio_rgb || ob == dialog_->radio_hsv)
572 return _("Toggle between RGB and HSV color spaces.");
578 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
580 if (ob == dialog_->browser_lyx_objs) {
583 } else if (ob == dialog_->dial_hue ||
584 ob == dialog_->slider_saturation ||
585 ob == dialog_->slider_value) {
588 } else if (ob == dialog_->slider_red ||
589 ob == dialog_->slider_green ||
590 ob == dialog_->slider_blue) {
593 } else if (ob == dialog_->radio_rgb ||
594 ob == dialog_->radio_hsv) {
597 } else if (ob == dialog_->button_modify) {
603 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
607 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
611 hsv.v = min(1.0, max(0.0, hsv.v));
614 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
618 void FormPreferences::Colors::InputBrowserLyX() const
620 vector<NamedColor>::size_type const selLyX =
621 fl_get_browser(dialog_->browser_lyx_objs);
622 if (selLyX < 1) return;
624 // Is the choice an Xforms color...
627 if (selLyX - 1 < xformsColorDB.size()) {
628 vector<XformsColor>::size_type const i = selLyX - 1;
629 col = xformsColorDB[i].color();
631 // or a LyX Logical color?
633 vector<NamedColor>::size_type const i = selLyX - 1 -
634 xformsColorDB.size();
635 col = lyxColorDB[i].color();
638 fl_freeze_form(dialog_->form);
640 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
641 fl_redraw_object(dialog_->button_color);
643 // Display either RGB or HSV but not both!
646 // Deactivate the modify button to begin with...
647 setEnabled(dialog_->button_modify, false);
649 fl_unfreeze_form(dialog_->form);
653 void FormPreferences::Colors::InputHSV()
655 double const hue = fl_get_dial_value(dialog_->dial_hue);
656 double const sat = fl_get_slider_value(dialog_->slider_saturation);
657 double const val = fl_get_slider_value(dialog_->slider_value);
659 int const h = int(hue);
660 int const s = int(100.0 * sat);
661 int const v = int(100.0 * val);
663 string const label = tostr(h) + ", " + tostr(s) + ", " + tostr(v);
664 fl_set_object_label(dialog_->text_color_values, label.c_str());
666 RGBColor col = HSVColor(hue, sat, val);
668 fl_freeze_form(dialog_->form);
670 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
671 fl_redraw_object(dialog_->button_color);
673 col = HSVColor(hue, 1.0, 1.0);
674 col.r = max(col.r, 0u);
675 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
676 fl_redraw_object(dialog_->dial_hue);
678 // Ascertain whether to activate the Modify button.
679 vector<NamedColor>::size_type const selLyX =
680 fl_get_browser(dialog_->browser_lyx_objs);
682 fl_unfreeze_form(dialog_->form);
683 if (selLyX < 1) return;
685 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
688 // Is the choice an Xforms color...
689 if (selLyX - 1 < xformsColorDB.size()) {
690 vector<XformsColor>::size_type const i = selLyX - 1;
691 modify = (xformsColorDB[i].color() != col);
693 // or a LyX Logical color?
695 vector<NamedColor>::size_type const i = selLyX - 1 -
696 xformsColorDB.size();
697 modify = (lyxColorDB[i].color() != col);
700 setEnabled(dialog_->button_modify, modify);
704 void FormPreferences::Colors::InputRGB()
706 int const red = int(fl_get_slider_value(dialog_->slider_red));
707 int const green = int(fl_get_slider_value(dialog_->slider_green));
708 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
710 string const label = tostr(red) + string(", ") + tostr(green) +
711 string(", ") + tostr(blue);
712 fl_set_object_label(dialog_->text_color_values, label.c_str());
714 fl_freeze_form(dialog_->form);
716 RGBColor col = RGBColor(red, green, blue);
717 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
718 fl_redraw_object(dialog_->button_color);
720 // Ascertain whether to activate the Modify button.
721 vector<NamedColor>::size_type const selLyX =
722 fl_get_browser(dialog_->browser_lyx_objs);
724 fl_unfreeze_form(dialog_->form);
725 if (selLyX < 1) return;
729 // Is the choice an Xforms color...
730 if (selLyX - 1 < xformsColorDB.size()) {
731 vector<XformsColor>::size_type const i = selLyX - 1;
732 modify = (xformsColorDB[i].color() != col);
734 // or a LyX Logical color?
736 vector<NamedColor>::size_type const i = selLyX - 1 -
737 xformsColorDB.size();
738 modify = (lyxColorDB[i].color() != col);
741 setEnabled(dialog_->button_modify, modify);
745 void FormPreferences::Colors::LoadBrowserLyX()
747 if (!dialog_->browser_lyx_objs->visible)
750 // First, define the modifiable xforms colors
751 xformsColorDB.clear();
754 xcol.name = _("GUI background");
755 xcol.colorID = FL_COL1;
756 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
758 xformsColorDB.push_back(xcol);
760 xcol.name = _("GUI text");
761 xcol.colorID = FL_BLACK;
762 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
764 xformsColorDB.push_back(xcol);
766 xcol.name = _("GUI selection");
767 xcol.colorID = FL_YELLOW;
768 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
770 xformsColorDB.push_back(xcol);
772 xcol.name = _("GUI pointer");
773 xcol.colorID = GUI_COLOR_CURSOR;
774 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
776 xformsColorDB.push_back(xcol);
778 // Now create the the LyX LColors database
780 for (int i=0; i<LColor::ignore; ++i) {
781 LColor::color lc = static_cast<LColor::color>(i);
782 if (lc == LColor::none
783 || lc == LColor::black
784 || lc == LColor::white
786 || lc == LColor::green
787 || lc == LColor::blue
788 || lc == LColor::cyan
789 || lc == LColor::magenta
790 || lc == LColor::yellow
791 || lc == LColor::inherit
792 || lc == LColor::ignore) continue;
795 bool const success = getRGBColor(lc, col.r, col.g, col.b);
797 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
798 << "LColor " << lcolor.getLyXName(lc)
799 << ": X can't find color \""
800 << lcolor.getX11Name(lc)
801 << "\". Set to \"black\"!" << endl;
803 string const arg = lcolor.getLyXName(lc) + " black";
804 parent_.controller().setColor(lc, "black");
808 // Create a valid X11 name of the form "#rrggbb" and change the
809 // LColor X11name to this. Don't want to trigger a redraw,
810 // as we're just changing the name not the RGB values.
811 // Also reset the system_lcolor names, so that we don't output
812 // unnecessary changes.
813 string const hexname = X11hexname(col);
815 if (lcolor.getX11Name(lc) != hexname) {
816 lcolor.setColor(lc, hexname);
817 system_lcolor.setColor(lc, hexname);
820 // Finally, push the color onto the database
821 NamedColor ncol(lcolor.getGUIName(lc), col);
822 lyxColorDB.push_back(ncol);
825 // Now construct the browser
826 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
827 fl_freeze_form(dialog_->form);
828 fl_clear_browser(colbr);
829 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
830 cit != xformsColorDB.end(); ++cit) {
831 fl_addto_browser(colbr, cit->getname().c_str());
833 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
834 cit != lyxColorDB.end(); ++cit) {
835 fl_addto_browser(colbr, cit->getname().c_str());
838 // just to be safe...
839 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
840 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
841 fl_unfreeze_form(dialog_->form);
847 void FormPreferences::Colors::Modify()
849 vector<NamedColor>::size_type const selLyX =
850 fl_get_browser(dialog_->browser_lyx_objs);
855 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
857 // Is the choice an Xforms color...
858 if (selLyX - 1 < xformsColorDB.size()) {
859 vector<XformsColor>::size_type const i = selLyX - 1;
860 xformsColorDB[i].r = col.r;
861 xformsColorDB[i].g = col.g;
862 xformsColorDB[i].b = col.b;
864 // or a LyX Logical color?
866 vector<NamedColor>::size_type const i = selLyX - 1 -
867 xformsColorDB.size();
868 lyxColorDB[i].r = col.r;
869 lyxColorDB[i].g = col.g;
870 lyxColorDB[i].b = col.b;
873 fl_freeze_form(dialog_->form);
874 setEnabled(dialog_->button_modify, false);
875 fl_unfreeze_form(dialog_->form);
879 void FormPreferences::Colors::SwitchColorSpace() const
881 bool const hsv = fl_get_button(dialog_->radio_hsv);
884 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
886 fl_freeze_form(dialog_->form);
889 fl_hide_object(dialog_->slider_red);
890 fl_hide_object(dialog_->slider_blue);
891 fl_hide_object(dialog_->slider_green);
892 fl_show_object(dialog_->dial_hue);
893 fl_show_object(dialog_->slider_saturation);
894 fl_show_object(dialog_->slider_value);
896 HSVColor hsv = HSVColor(col);
897 hsv.h = max(hsv.h, 0.0);
899 fl_set_dial_value(dialog_->dial_hue, hsv.h);
900 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
901 fl_set_slider_value(dialog_->slider_value, hsv.v);
903 col = HSVColor(hsv.h, 1.0, 1.0);
904 col.r = max(col.r, 0u);
905 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
906 fl_redraw_object(dialog_->dial_hue);
908 // Adjust the label a bit, but not the actual values.
909 // Means that toggling from one space to the other has no
910 // effect on the final color.
911 int const h = int(hsv.h);
912 int const s = int(100 * hsv.s);
913 int const v = int(100 * hsv.v);
914 string const label = tostr(h) + ", " + tostr(s) +
916 fl_set_object_label(dialog_->text_color_values, label.c_str());
919 fl_show_object(dialog_->slider_red);
920 fl_show_object(dialog_->slider_blue);
921 fl_show_object(dialog_->slider_green);
922 fl_hide_object(dialog_->dial_hue);
923 fl_hide_object(dialog_->slider_saturation);
924 fl_hide_object(dialog_->slider_value);
926 fl_set_slider_value(dialog_->slider_red, col.r);
927 fl_set_slider_value(dialog_->slider_green, col.g);
928 fl_set_slider_value(dialog_->slider_blue, col.b);
930 // Adjust the label a bit. Same reasoning as above.
931 int const r = int(col.r);
932 int const g = int(col.g);
933 int const b = int(col.b);
934 string const label = tostr(r) + ", " + tostr(g) +
936 fl_set_object_label(dialog_->text_color_values, label.c_str());
939 fl_unfreeze_form(dialog_->form);
943 FormPreferences::Converters::Converters(FormPreferences & p)
948 FD_preferences_converters const * FormPreferences::Converters::dialog()
950 return dialog_.get();
954 void FormPreferences::Converters::apply() const
956 parent_.controller().setConverters(local_converters);
960 void FormPreferences::Converters::build()
962 dialog_.reset(build_preferences_converters(&parent_));
964 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
965 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
967 // set up the feedback mechanism
968 setPrehandler(dialog_->browser_all);
969 setPrehandler(dialog_->button_delete);
970 setPrehandler(dialog_->button_add);
971 setPrehandler(dialog_->input_converter);
972 setPrehandler(dialog_->choice_from);
973 setPrehandler(dialog_->choice_to);
974 setPrehandler(dialog_->input_flags);
979 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
981 if (ob == dialog_->browser_all)
982 return _("All explicitly defined converters for LyX");
984 if (ob == dialog_->choice_from)
985 return _("Convert \"from\" this format");
987 if (ob == dialog_->choice_to)
988 return _("Convert \"to\" this format");
990 if (ob == dialog_->input_converter)
991 return _("The conversion command. $$i is the input file name, "
992 "$$b is the file name without its extension and $$o is "
993 "the name of the output file. $$s can be used as path to "
994 "LyX's own collection of conversion scripts.");
996 if (ob == dialog_->input_flags)
997 return _("Extra information for the Converter class, whether and "
998 "how to parse the result, and various other things.");
1000 if (ob == dialog_->button_delete)
1001 return _("Remove the current converter from the list of available "
1002 "converters. Note: you must then \"Apply\" the change.");
1004 if (ob == dialog_->button_add) {
1005 if (string(ob->label) == _("Add"))
1006 return _("Add the current converter to the list of available "
1007 "converters. Note: you must then \"Apply\" the change.");
1009 return _("Modify the contents of the current converter. "
1010 "Note: you must then \"Apply\" the change.");
1017 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
1019 if (ob == dialog_->browser_all)
1022 if (ob == dialog_->choice_from
1023 || ob == dialog_->choice_to
1024 || ob == dialog_->input_converter
1025 || ob == dialog_->input_flags)
1028 if (ob == dialog_->button_add)
1031 if (ob == dialog_->button_delete)
1038 void FormPreferences::Converters::update()
1040 local_converters = converters;
1041 local_converters.update(local_formats);
1046 void FormPreferences::Converters::UpdateBrowser()
1048 local_converters.sort();
1050 fl_freeze_form(dialog_->form);
1051 fl_clear_browser(dialog_->browser_all);
1052 for (::Converters::const_iterator cit = local_converters.begin();
1053 cit != local_converters.end(); ++cit) {
1054 string const name = cit->From->prettyname() + " -> "
1055 + cit->To->prettyname();
1056 fl_addto_browser(dialog_->browser_all, name.c_str());
1059 fl_unfreeze_form(dialog_->form);
1063 bool FormPreferences::Converters::Add()
1065 string const from = GetFrom();
1066 string const to = GetTo();
1067 string const command = fl_get_input(dialog_->input_converter);
1068 string const flags = fl_get_input(dialog_->input_flags);
1070 Converter const * old = local_converters.getConverter(from, to);
1071 local_converters.add(from, to, command, flags);
1073 local_converters.updateLast(local_formats);
1076 setEnabled(dialog_->button_add, false);
1082 bool FormPreferences::Converters::Browser()
1084 int const i = fl_get_browser(dialog_->browser_all);
1085 if (i <= 0) return false;
1087 fl_freeze_form(dialog_->form);
1089 Converter const & c = local_converters.get(i - 1);
1090 int j = local_formats.getNumber(c.from);
1092 fl_set_choice(dialog_->choice_from, j + 1);
1094 j = local_formats.getNumber(c.to);
1096 fl_set_choice(dialog_->choice_to, j + 1);
1098 fl_set_input(dialog_->input_converter, c.command.c_str());
1099 fl_set_input(dialog_->input_flags, c.flags.c_str());
1101 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
1102 fl_set_button_shortcut(dialog_->button_add,
1103 scex(_("Modify|#M")).c_str(), 1);
1105 setEnabled(dialog_->button_add, false);
1106 setEnabled(dialog_->button_delete, true);
1108 fl_unfreeze_form(dialog_->form);
1113 bool FormPreferences::Converters::erase()
1115 string const from = GetFrom();
1116 string const to = GetTo();
1118 local_converters.erase(from, to);
1124 bool FormPreferences::Converters::Input()
1126 string const from = GetFrom();
1127 string const to = GetTo();
1128 int const sel = local_converters.getNumber(from, to);
1130 fl_freeze_form(dialog_->form);
1133 fl_set_object_label(dialog_->button_add,
1134 idex(_("Add|#A")).c_str());
1135 fl_set_button_shortcut(dialog_->button_add,
1136 scex(_("Add|#A")).c_str(), 1);
1138 fl_deselect_browser(dialog_->browser_all);
1139 setEnabled(dialog_->button_delete, false);
1142 fl_set_object_label(dialog_->button_add,
1143 idex(_("Modify|#M")).c_str());
1144 fl_set_button_shortcut(dialog_->button_add,
1145 scex(_("Modify|#M")).c_str(), 1);
1147 int top = max(sel-5, 0);
1148 fl_set_browser_topline(dialog_->browser_all, top);
1149 fl_select_browser_line(dialog_->browser_all, sel+1);
1150 setEnabled(dialog_->button_delete, true);
1153 string const command = rtrim(fl_get_input(dialog_->input_converter));
1154 bool const enable = !(command.empty() || from == to);
1155 setEnabled(dialog_->button_add, enable);
1157 fl_unfreeze_form(dialog_->form);
1162 string const FormPreferences::Converters::GetFrom() const
1164 ::Formats::FormatList::size_type const i =
1165 fl_get_choice(dialog_->choice_from);
1167 if (i > 0 && i <= local_formats.size())
1168 return local_formats.get(i - 1).name();
1170 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
1175 string const FormPreferences::Converters::GetTo() const
1177 ::Formats::FormatList::size_type const i =
1178 fl_get_choice(dialog_->choice_to);
1180 if (i > 0 && i <= local_formats.size())
1181 return local_formats.get(i - 1).name();
1183 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
1188 void FormPreferences::Converters::UpdateChoices() const
1191 for (::Formats::const_iterator cit = local_formats.begin();
1192 cit != local_formats.end(); ++cit) {
1193 if (!choice.empty())
1197 choice += cit->prettyname();
1201 fl_clear_choice(dialog_->choice_from);
1202 fl_addto_choice(dialog_->choice_from, choice.c_str());
1204 fl_clear_choice(dialog_->choice_to);
1205 fl_addto_choice(dialog_->choice_to, choice.c_str());
1209 FormPreferences::Formats::Formats(FormPreferences & p)
1214 FD_preferences_formats const * FormPreferences::Formats::dialog()
1216 return dialog_.get();
1220 void FormPreferences::Formats::apply() const
1222 parent_.controller().setFormats(local_formats);
1226 void FormPreferences::Formats::build()
1228 dialog_.reset(build_preferences_formats(&parent_));
1230 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1231 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1232 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1233 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1234 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1236 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1238 // set up the feedback mechanism
1239 setPrehandler(dialog_->browser_all);
1240 setPrehandler(dialog_->input_format);
1241 setPrehandler(dialog_->input_gui_name);
1242 setPrehandler(dialog_->button_delete);
1243 setPrehandler(dialog_->button_add);
1244 setPrehandler(dialog_->input_extension);
1245 setPrehandler(dialog_->input_viewer);
1246 setPrehandler(dialog_->input_shrtcut);
1251 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1253 if (ob == dialog_->browser_all)
1254 return _("All the currently defined formats known to LyX.");
1256 if (ob == dialog_->input_format)
1257 return _("The format identifier.");
1259 if (ob == dialog_->input_gui_name)
1260 return _("The format name as it will appear in the menus.");
1262 if (ob == dialog_->input_shrtcut)
1263 return _("The keyboard accelerator. Use a letter in the GUI name. "
1266 if (ob == dialog_->input_extension)
1267 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1269 if (ob == dialog_->input_viewer)
1270 return _("The command used to launch the viewer application.");
1272 if (ob == dialog_->button_delete)
1273 return _("Remove the current format from the list of available "
1274 "formats. Note: you must then \"Apply\" the change.");
1276 if (ob == dialog_->button_add) {
1277 if (string(ob->label) == _("Add"))
1278 return _("Add the current format to the list of available "
1279 "formats. Note: you must then \"Apply\" the change.");
1281 return _("Modify the contents of the current format. Note: "
1282 "you must then \"Apply\" the change.");
1289 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1291 if (ob == dialog_->browser_all)
1294 if (ob == dialog_->input_format
1295 || ob == dialog_->input_gui_name
1296 || ob == dialog_->input_shrtcut
1297 || ob == dialog_->input_extension
1298 || ob == dialog_->input_viewer)
1301 if (ob == dialog_->button_add)
1304 if (ob == dialog_->button_delete)
1311 void FormPreferences::Formats::update()
1313 local_formats = formats;
1318 void FormPreferences::Formats::UpdateBrowser()
1320 local_formats.sort();
1322 fl_freeze_form(dialog_->form);
1323 fl_deselect_browser(dialog_->browser_all);
1324 fl_clear_browser(dialog_->browser_all);
1325 for (::Formats::const_iterator cit = local_formats.begin();
1326 cit != local_formats.end(); ++cit)
1327 fl_addto_browser(dialog_->browser_all,
1328 cit->prettyname().c_str());
1331 fl_unfreeze_form(dialog_->form);
1333 // Mustn't forget to update the Formats available to the converters_
1334 parent_.converters_.UpdateChoices();
1335 local_converters.update(local_formats);
1339 bool FormPreferences::Formats::Add()
1341 string const name = fl_get_input(dialog_->input_format);
1342 string const prettyname = fl_get_input(dialog_->input_gui_name);
1343 string const extension = fl_get_input(dialog_->input_extension);
1344 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1345 string const viewer = fl_get_input(dialog_->input_viewer);
1347 Format const * old = local_formats.getFormat(name);
1348 string const old_prettyname = old ? old->prettyname() : string();
1349 local_formats.add(name, extension, prettyname, shortcut);
1350 local_formats.setViewer(name, viewer);
1351 if (!old || prettyname != old_prettyname) {
1354 parent_.converters_.UpdateBrowser();
1356 setEnabled(dialog_->button_add, false);
1362 bool FormPreferences::Formats::Browser()
1364 int const i = fl_get_browser(dialog_->browser_all);
1368 fl_freeze_form(dialog_->form);
1370 Format const & f = local_formats.get(i - 1);
1372 fl_set_input(dialog_->input_format, f.name().c_str());
1373 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1374 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1375 fl_set_input(dialog_->input_extension, f.extension().c_str());
1376 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1378 fl_set_object_label(dialog_->button_add,
1379 idex(_("Modify|#M")).c_str());
1380 fl_set_button_shortcut(dialog_->button_add,
1381 scex(_("Modify|#M")).c_str(), 1);
1383 setEnabled(dialog_->button_add, false);
1384 setEnabled(dialog_->button_delete, true);
1386 fl_unfreeze_form(dialog_->form);
1391 bool FormPreferences::Formats::erase()
1393 string const name = fl_get_input(dialog_->input_format);
1395 if (local_converters.formatIsUsed(name)) {
1396 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1397 "Remove the converter first."));
1398 setEnabled(dialog_->button_delete, false);
1402 local_formats.erase(name);
1408 bool FormPreferences::Formats::Input()
1410 string const name = fl_get_input(dialog_->input_format);
1411 int const sel = local_formats.getNumber(name);
1412 fl_freeze_form(dialog_->form);
1415 fl_set_object_label(dialog_->button_add,
1416 idex(_("Add|#A")).c_str());
1417 fl_set_button_shortcut(dialog_->button_add,
1418 scex(_("Add|#A")).c_str(), 1);
1420 fl_deselect_browser(dialog_->browser_all);
1421 setEnabled(dialog_->button_delete, false);
1424 fl_set_object_label(dialog_->button_add,
1425 idex(_("Modify|#M")).c_str());
1426 fl_set_button_shortcut(dialog_->button_add,
1427 scex(_("Modify|#M")).c_str(), 1);
1429 int const top = max(sel-5, 0);
1430 fl_set_browser_topline(dialog_->browser_all, top);
1431 fl_select_browser_line(dialog_->browser_all, sel+1);
1433 setEnabled(dialog_->button_add, true);
1434 setEnabled(dialog_->button_delete, true);
1437 string const prettyname = fl_get_input(dialog_->input_gui_name);
1438 bool const enable = !(name.empty() || prettyname.empty());
1439 setEnabled(dialog_->button_add, enable);
1441 fl_unfreeze_form(dialog_->form);
1446 FormPreferences::Identity::Identity(FormPreferences & p)
1451 FD_preferences_identity const * FormPreferences::Identity::dialog()
1453 return dialog_.get();
1457 void FormPreferences::Identity::apply(LyXRC & rc) const
1459 rc.user_name = fl_get_input(dialog_->input_user_name);
1460 rc.user_email = fl_get_input(dialog_->input_user_email);
1464 void FormPreferences::Identity::build()
1466 dialog_.reset(build_preferences_identity(&parent_));
1467 fl_set_input_return(dialog_->input_user_name, FL_RETURN_CHANGED);
1468 fl_set_input_return(dialog_->input_user_email, FL_RETURN_CHANGED);
1472 void FormPreferences::Identity::update(LyXRC const & rc)
1474 fl_set_input(dialog_->input_user_name, rc.user_name.c_str());
1475 fl_set_input(dialog_->input_user_email, rc.user_email.c_str());
1479 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1484 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1486 return dialog_.get();
1490 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1492 rc.date_insert_format =
1493 fl_get_input(dialog_->input_date_format);
1497 void FormPreferences::InputsMisc::build()
1499 dialog_.reset(build_preferences_inputs_misc(&parent_));
1501 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1503 // set up the feedback mechanism
1504 setPrehandler(dialog_->input_date_format);
1509 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1511 if (ob == dialog_->input_date_format)
1512 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1517 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1519 fl_set_input(dialog_->input_date_format,
1520 rc.date_insert_format.c_str());
1524 FormPreferences::Interface::Interface(FormPreferences & p)
1529 FD_preferences_interface const * FormPreferences::Interface::dialog()
1531 return dialog_.get();
1535 void FormPreferences::Interface::apply(LyXRC & rc) const
1537 rc.popup_normal_font =
1538 fl_get_input(dialog_->input_popup_normal_font);
1539 rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1540 rc.popup_font_encoding =
1541 fl_get_input(dialog_->input_popup_font_encoding);
1542 rc.bind_file = fl_get_input(dialog_->input_bind_file);
1543 rc.ui_file = fl_get_input(dialog_->input_ui_file);
1547 void FormPreferences::Interface::build()
1549 dialog_.reset(build_preferences_interface(&parent_));
1551 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1552 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1553 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1554 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1555 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1557 // set up the feedback mechanism
1558 setPrehandler(dialog_->input_popup_normal_font);
1559 setPrehandler(dialog_->input_popup_bold_font);
1560 setPrehandler(dialog_->input_popup_font_encoding);
1561 setPrehandler(dialog_->input_bind_file);
1562 setPrehandler(dialog_->button_bind_file_browse);
1563 setPrehandler(dialog_->input_ui_file);
1564 setPrehandler(dialog_->button_ui_file_browse);
1569 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1571 if (ob == dialog_->input_popup_normal_font)
1572 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1573 if (ob == dialog_->input_popup_bold_font)
1574 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1575 if (ob == dialog_->input_popup_font_encoding)
1576 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1577 if (ob == dialog_->input_bind_file)
1578 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1579 if (ob == dialog_->input_ui_file)
1580 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1585 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1587 if (ob == dialog_->button_bind_file_browse) {
1588 string f = parent_.controller().browsebind(
1589 fl_get_input(dialog_->input_bind_file));
1591 fl_set_input(dialog_->input_bind_file, f.c_str());
1592 } else if (ob == dialog_->button_ui_file_browse) {
1593 string f = parent_.controller().browseUI(
1594 fl_get_input(dialog_->input_ui_file));
1596 fl_set_input(dialog_->input_ui_file, f.c_str());
1603 void FormPreferences::Interface::update(LyXRC const & rc)
1605 fl_set_input(dialog_->input_popup_normal_font,
1606 rc.popup_normal_font.c_str());
1607 fl_set_input(dialog_->input_popup_bold_font,
1608 rc.popup_bold_font.c_str());
1609 fl_set_input(dialog_->input_popup_font_encoding,
1610 rc.popup_font_encoding.c_str());
1611 fl_set_input(dialog_->input_bind_file,
1612 rc.bind_file.c_str());
1613 fl_set_input(dialog_->input_ui_file,
1614 rc.ui_file.c_str());
1618 FormPreferences::Language::Language(FormPreferences & p)
1623 FD_preferences_language const * FormPreferences::Language::dialog()
1625 return dialog_.get();
1629 void FormPreferences::Language::apply(LyXRC & rc)
1631 int const pos = fl_get_combox(dialog_->combox_default_lang);
1632 rc.default_language = lang_[pos-1];
1634 int button = fl_get_button(dialog_->check_use_kbmap);
1635 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1636 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1638 button = !(name_1.empty() && name_2.empty());
1639 rc.use_kbmap = static_cast<bool>(button);
1642 rc.primary_kbmap = name_1;
1643 rc.secondary_kbmap = name_2;
1646 button = fl_get_button(dialog_->check_rtl_support);
1647 rc.rtl_support = static_cast<bool>(button);
1649 button = fl_get_button(dialog_->check_mark_foreign);
1650 rc.mark_foreign_language = static_cast<bool>(button);
1652 button = fl_get_button(dialog_->check_auto_begin);
1653 rc.language_auto_begin = static_cast<bool>(button);
1655 button = fl_get_button(dialog_->check_auto_end);
1656 rc.language_auto_end = static_cast<bool>(button);
1658 button = fl_get_button(dialog_->check_use_babel);
1659 rc.language_use_babel = static_cast<bool>(button);
1661 button = fl_get_button(dialog_->check_global_options);
1662 rc.language_global_options = static_cast<bool>(button);
1664 rc.language_package = fl_get_input(dialog_->input_package);
1665 rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1666 rc.language_command_end = fl_get_input(dialog_->input_command_end);
1668 // Ensure that all is self-consistent.
1673 void FormPreferences::Language::build()
1675 dialog_.reset(build_preferences_language(&parent_));
1677 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1678 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1679 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1681 // Store the lang identifiers for later
1682 vector<frnt::LanguagePair> const langs = frnt::getLanguageData(false);
1683 lang_ = getSecond(langs);
1685 FL_OBJECT * obj = dialog_->combox_default_lang;
1686 vector<frnt::LanguagePair>::const_iterator lit = langs.begin();
1687 vector<frnt::LanguagePair>::const_iterator lend = langs.end();
1688 for (; lit != lend; ++lit) {
1689 fl_addto_combox(obj, lit->first.c_str());
1691 fl_set_combox_browser_height(obj, 400);
1693 // set up the feedback mechanism
1694 setPrehandler(dialog_->input_package);
1695 setPrehandler(dialog_->check_use_kbmap);
1696 setPrehandler(dialog_->combox_default_lang);
1697 setPrehandler(dialog_->input_kbmap1);
1698 setPrehandler(dialog_->input_kbmap2);
1699 setPrehandler(dialog_->check_rtl_support);
1700 setPrehandler(dialog_->check_mark_foreign);
1701 setPrehandler(dialog_->check_auto_begin);
1702 setPrehandler(dialog_->check_auto_end);
1703 setPrehandler(dialog_->check_use_babel);
1704 setPrehandler(dialog_->check_global_options);
1705 setPrehandler(dialog_->input_command_begin);
1706 setPrehandler(dialog_->input_command_end);
1708 // Activate/Deactivate the input fields dependent on the state of the
1715 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1717 if (ob == dialog_->combox_default_lang)
1718 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1719 if (ob == dialog_->check_use_kbmap)
1720 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1721 if (ob == dialog_->input_kbmap1)
1722 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1723 if (ob == dialog_->input_kbmap2)
1724 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1725 if (ob == dialog_->check_rtl_support)
1726 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1727 if (ob == dialog_->check_mark_foreign)
1728 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1729 if (ob == dialog_->check_auto_begin)
1730 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1731 if (ob == dialog_->check_auto_end)
1732 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1733 if (ob == dialog_->check_use_babel)
1734 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1735 if (ob == dialog_->check_global_options)
1736 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1737 if (ob == dialog_->input_package)
1738 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1739 if (ob == dialog_->input_command_begin)
1740 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1741 if (ob == dialog_->input_command_end)
1742 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1747 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1749 bool activate = true;
1751 // !ob if function is called from Language::build() to de/activate
1753 // otherwise the function is called by an xforms CB via input().
1754 if (!ob || ob == dialog_->check_use_kbmap) {
1755 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1756 setEnabled(dialog_->button_kbmap1_browse, enable);
1757 setEnabled(dialog_->button_kbmap2_browse, enable);
1758 setEnabled(dialog_->input_kbmap1, enable);
1759 setEnabled(dialog_->input_kbmap2, enable);
1762 if (ob == dialog_->button_kbmap1_browse) {
1763 string f = parent_.controller().browsekbmap(
1764 fl_get_input(dialog_->input_kbmap1));
1766 fl_set_input(dialog_->input_kbmap1, f.c_str());
1767 } else if (ob == dialog_->button_kbmap2_browse) {
1768 string f = parent_.controller().browsekbmap(
1769 fl_get_input(dialog_->input_kbmap2));
1771 fl_set_input(dialog_->input_kbmap2, f.c_str());
1778 void FormPreferences::Language::update(LyXRC const & rc)
1780 fl_set_button(dialog_->check_use_kbmap,
1783 int const pos = int(findPos(lang_, rc.default_language));
1784 fl_set_combox(dialog_->combox_default_lang, pos + 1);
1787 fl_set_input(dialog_->input_kbmap1,
1788 rc.primary_kbmap.c_str());
1789 fl_set_input(dialog_->input_kbmap2,
1790 rc.secondary_kbmap.c_str());
1792 fl_set_input(dialog_->input_kbmap1, "");
1793 fl_set_input(dialog_->input_kbmap2, "");
1796 fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1797 fl_set_button(dialog_->check_mark_foreign,
1798 rc.mark_foreign_language);
1799 fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1800 fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1801 fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1802 fl_set_button(dialog_->check_global_options,
1803 rc.language_global_options);
1805 fl_set_input(dialog_->input_package,
1806 rc.language_package.c_str());
1807 fl_set_input(dialog_->input_command_begin,
1808 rc.language_command_begin.c_str());
1809 fl_set_input(dialog_->input_command_end,
1810 rc.language_command_end.c_str());
1812 // Activate/Deactivate the input fields dependent on the state of the
1818 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1823 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1825 return dialog_.get();
1829 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1831 rc.auto_region_delete =
1832 fl_get_button(dialog_->check_auto_region_delete);
1833 rc.cursor_follows_scrollbar =
1834 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1835 rc.dialogs_iconify_with_main =
1836 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1837 rc.preview = fl_get_button(dialog_->check_preview_latex);
1838 rc.autosave = static_cast<unsigned int>
1839 (fl_get_counter_value(dialog_->counter_autosave));
1840 rc.wheel_jump = static_cast<unsigned int>
1841 (fl_get_counter_value(dialog_->counter_wm_jump));
1844 // grfx::DisplayType old_value = rc.display_graphics;
1845 switch (fl_get_choice(dialog_->choice_display)) {
1847 rc.display_graphics = grfx::NoDisplay;
1850 rc.display_graphics = grfx::ColorDisplay;
1853 rc.display_graphics = grfx::GrayscaleDisplay;
1856 rc.display_graphics = grfx::MonochromeDisplay;
1859 rc.display_graphics = grfx::ColorDisplay;
1863 #ifdef WITH_WARNINGS
1864 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1867 if (old_value != rc.display_graphics) {
1868 grfx::GCache & gc = grfx::GCache::get();
1875 void FormPreferences::LnFmisc::build()
1877 dialog_.reset(build_preferences_lnf_misc(&parent_));
1879 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1880 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1882 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1883 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1885 // set up the feedback mechanism
1886 setPrehandler(dialog_->check_auto_region_delete);
1887 setPrehandler(dialog_->counter_autosave);
1888 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1889 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1890 setPrehandler(dialog_->check_preview_latex);
1891 setPrehandler(dialog_->counter_wm_jump);
1893 fl_addto_choice(dialog_->choice_display,
1894 _("Monochrome|Grayscale|Color|Do not display").c_str());
1899 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1901 if (ob == dialog_->check_auto_region_delete)
1902 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
1903 if (ob == dialog_->check_cursor_follows_scrollbar)
1904 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1905 if (ob == dialog_->check_dialogs_iconify_with_main)
1906 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1907 if (ob == dialog_->check_preview_latex)
1908 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
1909 if (ob == dialog_->counter_autosave)
1910 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
1911 if (ob == dialog_->counter_wm_jump)
1912 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
1913 if (ob == dialog_->choice_display)
1914 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1919 void FormPreferences::LnFmisc::update(LyXRC const & rc)
1921 fl_set_button(dialog_->check_auto_region_delete,
1922 rc.auto_region_delete);
1923 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1924 rc.cursor_follows_scrollbar);
1925 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1926 rc.dialogs_iconify_with_main);
1927 fl_set_button(dialog_->check_preview_latex,
1929 fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
1930 fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
1932 switch (rc.display_graphics) {
1933 case grfx::NoDisplay:
1934 fl_set_choice(dialog_->choice_display, 4);
1936 case grfx::ColorDisplay:
1937 fl_set_choice(dialog_->choice_display, 3);
1939 case grfx::GrayscaleDisplay:
1940 fl_set_choice(dialog_->choice_display, 2);
1942 case grfx::MonochromeDisplay:
1943 fl_set_choice(dialog_->choice_display, 1);
1946 fl_set_choice(dialog_->choice_display, 3);
1952 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1957 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1959 return dialog_.get();
1963 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
1965 rc.ascii_linelen = static_cast<unsigned int>
1966 (fl_get_counter_value(dialog_->counter_line_len));
1967 rc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1970 fl_get_choice(dialog_->choice_default_papersize) - 1;
1971 rc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1973 rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1974 rc.chktex_command = fl_get_input(dialog_->input_checktex);
1975 rc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1976 rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1980 void FormPreferences::OutputsMisc::build()
1982 dialog_.reset(build_preferences_outputs_misc(&parent_));
1984 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1986 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1987 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1988 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1989 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1990 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1992 fl_addto_choice(dialog_->choice_default_papersize,
1993 _(" default | US letter | US legal "
1994 "| US executive | A3 | A4 | A5 | B5 ").c_str());
1996 // set up the feedback mechanism
1997 setPrehandler(dialog_->counter_line_len);
1998 setPrehandler(dialog_->input_tex_encoding);
1999 setPrehandler(dialog_->choice_default_papersize);
2000 setPrehandler(dialog_->input_ascii_roff);
2001 setPrehandler(dialog_->input_checktex);
2002 setPrehandler(dialog_->input_paperoption);
2003 setPrehandler(dialog_->check_autoreset_classopt);
2008 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
2010 if (ob == dialog_->counter_line_len)
2011 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
2012 if (ob == dialog_->input_tex_encoding)
2013 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
2014 if (ob == dialog_->input_ascii_roff)
2015 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
2016 if (ob == dialog_->input_checktex)
2017 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
2018 if (ob == dialog_->choice_default_papersize)
2019 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2020 if (ob == dialog_->input_paperoption)
2021 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
2022 if (ob == dialog_->check_autoreset_classopt)
2023 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2028 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
2030 fl_set_counter_value(dialog_->counter_line_len,
2032 fl_set_input(dialog_->input_tex_encoding,
2033 rc.fontenc.c_str());
2034 fl_set_choice(dialog_->choice_default_papersize,
2035 rc.default_papersize + 1);
2036 fl_set_input(dialog_->input_ascii_roff,
2037 rc.ascii_roff_command.c_str());
2038 fl_set_input(dialog_->input_checktex,
2039 rc.chktex_command.c_str());
2040 fl_set_input(dialog_->input_paperoption,
2041 rc.view_dvi_paper_option.c_str());
2042 fl_set_button(dialog_->check_autoreset_classopt,
2043 rc.auto_reset_options);
2048 FormPreferences::Paths::Paths(FormPreferences & p)
2053 FD_preferences_paths const * FormPreferences::Paths::dialog()
2055 return dialog_.get();
2059 void FormPreferences::Paths::apply(LyXRC & rc)
2061 rc.document_path = fl_get_input(dialog_->input_default_path);
2062 rc.template_path = fl_get_input(dialog_->input_template_path);
2064 int button = fl_get_button(dialog_->check_use_temp_dir);
2065 string str = fl_get_input(dialog_->input_temp_dir);
2069 rc.use_tempdir = button;
2070 rc.tempdir_path = str;
2072 button = fl_get_button(dialog_->check_last_files);
2073 str = fl_get_input(dialog_->input_lastfiles);
2074 if (!button) str.erase();
2076 rc.check_lastfiles = button;
2078 rc.num_lastfiles = static_cast<unsigned int>
2079 (fl_get_counter_value(dialog_->counter_lastfiles));
2081 button = fl_get_button(dialog_->check_make_backups);
2082 str = fl_get_input(dialog_->input_backup_path);
2086 rc.make_backup = button;
2087 rc.backupdir_path = str;
2089 rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2096 void FormPreferences::Paths::build()
2098 dialog_.reset(build_preferences_paths(&parent_));
2100 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2101 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2102 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2103 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2104 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2105 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2106 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2108 // set up the feedback mechanism
2109 setPrehandler(dialog_->input_default_path);
2110 setPrehandler(dialog_->counter_lastfiles);
2111 setPrehandler(dialog_->input_template_path);
2112 setPrehandler(dialog_->check_last_files);
2113 setPrehandler(dialog_->input_lastfiles);
2114 setPrehandler(dialog_->check_make_backups);
2115 setPrehandler(dialog_->input_backup_path);
2116 setPrehandler(dialog_->input_serverpipe);
2117 setPrehandler(dialog_->input_temp_dir);
2118 setPrehandler(dialog_->check_use_temp_dir);
2123 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2125 if (ob == dialog_->input_default_path)
2126 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2127 if (ob == dialog_->input_template_path)
2128 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2129 if (ob == dialog_->check_use_temp_dir)
2130 return LyXRC::getDescription(LyXRC::RC_USETEMPDIR);
2131 if (ob == dialog_->input_temp_dir)
2132 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2133 if (ob == dialog_->check_last_files)
2134 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2135 if (ob == dialog_->input_lastfiles)
2136 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
2137 if (ob == dialog_->counter_lastfiles)
2138 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2139 if (ob == dialog_->check_make_backups)
2140 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2141 if (ob == dialog_->input_backup_path)
2142 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2143 if (ob == dialog_->input_serverpipe)
2144 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2149 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2151 bool activate = true;
2153 // !ob if function is called from Paths::update() to de/activate
2155 // otherwise the function is called by an xforms CB via input().
2156 if (!ob || ob == dialog_->check_use_temp_dir) {
2157 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2158 setEnabled(dialog_->input_temp_dir, enable);
2161 if (!ob || ob == dialog_->check_last_files) {
2162 bool const enable = fl_get_button(dialog_->check_last_files);
2163 setEnabled(dialog_->input_lastfiles, enable);
2166 if (!ob || ob == dialog_->check_make_backups) {
2167 bool const enable = fl_get_button(dialog_->check_make_backups);
2168 setEnabled(dialog_->input_backup_path, enable);
2171 if (!ob || ob == dialog_->input_default_path) {
2172 string const name = fl_get_input(dialog_->input_default_path);
2173 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2174 parent_.postWarning(RWInfo::ErrorMessage());
2179 if (!ob || ob == dialog_->input_template_path) {
2180 string const name = fl_get_input(dialog_->input_template_path);
2181 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2182 parent_.postWarning(RWInfo::ErrorMessage());
2187 if (!ob || ob == dialog_->input_temp_dir) {
2188 string const name = fl_get_input(dialog_->input_temp_dir);
2189 if (fl_get_button(dialog_->check_make_backups)
2191 && !RWInfo::WriteableDir(name)) {
2192 parent_.postWarning(RWInfo::ErrorMessage());
2197 if (!ob || ob == dialog_->input_backup_path) {
2198 string const name = fl_get_input(dialog_->input_backup_path);
2199 if (fl_get_button(dialog_->check_make_backups)
2201 && !RWInfo::WriteableDir(name)) {
2202 parent_.postWarning(RWInfo::ErrorMessage());
2207 if (!ob || ob == dialog_->input_lastfiles) {
2208 string const name = fl_get_input(dialog_->input_lastfiles);
2209 if (fl_get_button(dialog_->check_last_files)
2211 && !RWInfo::WriteableFile(name)) {
2212 parent_.postWarning(RWInfo::ErrorMessage());
2217 if (!ob || ob == dialog_->input_serverpipe) {
2218 string const name = fl_get_input(dialog_->input_serverpipe);
2219 if (!name.empty()) {
2220 // strip off the extension
2221 string const str = ChangeExtension(name, "");
2222 if (!RWInfo::WriteableFile(str + ".in")) {
2223 parent_.postWarning(RWInfo::ErrorMessage());
2226 if (!RWInfo::WriteableFile(str + ".out")) {
2227 parent_.postWarning(RWInfo::ErrorMessage());
2233 if (ob == dialog_->button_default_path_browse) {
2234 string f = parent_.controller().browsedir(
2235 fl_get_input(dialog_->input_default_path), _("Default path"));
2237 fl_set_input(dialog_->input_default_path, f.c_str());
2238 } else if (ob == dialog_->button_template_path_browse) {
2239 string f = parent_.controller().browsedir(
2240 fl_get_input(dialog_->input_template_path), _("Template path"));
2242 fl_set_input(dialog_->input_template_path, f.c_str());
2243 } else if (ob == dialog_->button_temp_dir_browse) {
2244 string f = parent_.controller().browsedir(
2245 fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2247 fl_set_input(dialog_->input_temp_dir, f.c_str());
2248 } else if (ob == dialog_->button_lastfiles_browse) {
2249 string f = parent_.controller().browse(
2250 fl_get_input(dialog_->input_lastfiles), _("Last files"));
2252 fl_set_input(dialog_->input_lastfiles, f.c_str());
2253 } else if (ob == dialog_->button_backup_path_browse) {
2254 string f = parent_.controller().browsedir(
2255 fl_get_input(dialog_->input_backup_path), _("Backup path"));
2257 fl_set_input(dialog_->input_backup_path, f.c_str());
2258 } else if (ob == dialog_->button_serverpipe_browse) {
2259 string f = parent_.controller().browse(
2260 fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2262 fl_set_input(dialog_->input_serverpipe, f.c_str());
2269 void FormPreferences::Paths::update(LyXRC const & rc)
2271 fl_set_input(dialog_->input_default_path,
2272 rc.document_path.c_str());
2273 fl_set_input(dialog_->input_template_path,
2274 rc.template_path.c_str());
2278 str = rc.backupdir_path;
2280 fl_set_button(dialog_->check_make_backups,
2282 fl_set_input(dialog_->input_backup_path, str.c_str());
2286 str = rc.tempdir_path;
2288 fl_set_button(dialog_->check_use_temp_dir,
2290 fl_set_input(dialog_->input_temp_dir, str.c_str());
2293 if (rc.check_lastfiles)
2296 fl_set_button(dialog_->check_last_files,
2297 rc.check_lastfiles);
2298 fl_set_input(dialog_->input_lastfiles, str.c_str());
2299 fl_set_counter_value(dialog_->counter_lastfiles,
2302 fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2304 // Activate/Deactivate the input fields dependent on the state of the
2310 FormPreferences::Printer::Printer(FormPreferences & p)
2315 FD_preferences_printer const * FormPreferences::Printer::dialog()
2317 return dialog_.get();
2321 void FormPreferences::Printer::apply(LyXRC & rc) const
2323 rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2324 rc.print_command = fl_get_input(dialog_->input_command);
2325 rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2326 rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2327 rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2328 rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2329 rc.print_file_extension =
2330 fl_get_input(dialog_->input_file_extension);
2331 rc.print_spool_command =
2332 fl_get_input(dialog_->input_spool_command);
2333 rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2334 rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2335 rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2336 rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2337 rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2338 rc.print_to_file = fl_get_input(dialog_->input_to_file);
2339 rc.print_extra_options =
2340 fl_get_input(dialog_->input_extra_options);
2341 rc.print_spool_printerprefix =
2342 fl_get_input(dialog_->input_spool_prefix);
2343 rc.print_paper_dimension_flag =
2344 fl_get_input(dialog_->input_paper_size);
2345 rc.printer = fl_get_input(dialog_->input_name);
2350 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2352 if (ob == dialog_->input_command)
2353 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2354 if (ob == dialog_->check_adapt_output)
2355 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2356 if (ob == dialog_->input_to_printer)
2357 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2358 if (ob == dialog_->input_to_file)
2359 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2360 if (ob == dialog_->input_file_extension)
2361 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2362 if (ob == dialog_->input_extra_options)
2363 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2364 if (ob == dialog_->input_spool_command)
2365 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2366 if (ob == dialog_->input_spool_prefix)
2367 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2368 if (ob == dialog_->input_name)
2369 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2370 if (ob == dialog_->input_even_pages)
2371 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2372 if (ob == dialog_->input_odd_pages)
2373 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2374 if (ob == dialog_->input_page_range)
2375 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2376 if (ob == dialog_->input_reverse)
2377 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2378 if (ob == dialog_->input_landscape)
2379 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2380 if (ob == dialog_->input_copies)
2381 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2382 if (ob == dialog_->input_collated)
2383 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2384 if (ob == dialog_->input_paper_type)
2385 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2386 if (ob == dialog_->input_paper_size)
2387 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2392 void FormPreferences::Printer::build()
2394 dialog_.reset(build_preferences_printer(&parent_));
2396 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2397 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2398 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2399 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2400 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2401 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2402 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2403 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2404 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2405 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2406 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2407 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2408 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2409 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2410 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2411 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2412 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2414 // set up the feedback mechanism
2415 setPrehandler(dialog_->input_command);
2416 setPrehandler(dialog_->input_page_range);
2417 setPrehandler(dialog_->input_copies);
2418 setPrehandler(dialog_->input_reverse);
2419 setPrehandler(dialog_->input_to_printer);
2420 setPrehandler(dialog_->input_file_extension);
2421 setPrehandler(dialog_->input_spool_command);
2422 setPrehandler(dialog_->input_paper_type);
2423 setPrehandler(dialog_->input_even_pages);
2424 setPrehandler(dialog_->input_odd_pages);
2425 setPrehandler(dialog_->input_collated);
2426 setPrehandler(dialog_->input_landscape);
2427 setPrehandler(dialog_->input_to_file);
2428 setPrehandler(dialog_->input_extra_options);
2429 setPrehandler(dialog_->input_spool_prefix);
2430 setPrehandler(dialog_->input_paper_size);
2431 setPrehandler(dialog_->input_name);
2432 setPrehandler(dialog_->check_adapt_output);
2436 void FormPreferences::Printer::update(LyXRC const & rc)
2438 fl_set_button(dialog_->check_adapt_output,
2439 rc.print_adapt_output);
2440 fl_set_input(dialog_->input_command,
2441 rc.print_command.c_str());
2442 fl_set_input(dialog_->input_page_range,
2443 rc.print_pagerange_flag.c_str());
2444 fl_set_input(dialog_->input_copies,
2445 rc.print_copies_flag.c_str());
2446 fl_set_input(dialog_->input_reverse,
2447 rc.print_reverse_flag.c_str());
2448 fl_set_input(dialog_->input_to_printer,
2449 rc.print_to_printer.c_str());
2450 fl_set_input(dialog_->input_file_extension,
2451 rc.print_file_extension.c_str());
2452 fl_set_input(dialog_->input_spool_command,
2453 rc.print_spool_command.c_str());
2454 fl_set_input(dialog_->input_paper_type,
2455 rc.print_paper_flag.c_str());
2456 fl_set_input(dialog_->input_even_pages,
2457 rc.print_evenpage_flag.c_str());
2458 fl_set_input(dialog_->input_odd_pages,
2459 rc.print_oddpage_flag.c_str());
2460 fl_set_input(dialog_->input_collated,
2461 rc.print_collcopies_flag.c_str());
2462 fl_set_input(dialog_->input_landscape,
2463 rc.print_landscape_flag.c_str());
2464 fl_set_input(dialog_->input_to_file,
2465 rc.print_to_file.c_str());
2466 fl_set_input(dialog_->input_extra_options,
2467 rc.print_extra_options.c_str());
2468 fl_set_input(dialog_->input_spool_prefix,
2469 rc.print_spool_printerprefix.c_str());
2470 fl_set_input(dialog_->input_paper_size,
2471 rc.print_paper_dimension_flag.c_str());
2472 fl_set_input(dialog_->input_name,
2473 rc.printer.c_str());
2477 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2482 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2484 return dialog_.get();
2488 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2490 bool changed = false;
2492 pair<string, string> tmp =
2493 parseFontName(fl_get_input(dialog_->input_roman));
2494 if (rc.roman_font_name != tmp.first ||
2495 rc.roman_font_foundry != tmp.second) {
2497 rc.roman_font_name = tmp.first;
2498 rc.roman_font_foundry = tmp.second;
2501 tmp = parseFontName(fl_get_input(dialog_->input_sans));
2502 if (rc.sans_font_name != tmp.first ||
2503 rc.sans_font_foundry != tmp.second) {
2505 rc.sans_font_name = tmp.first;
2506 rc.sans_font_foundry = tmp.second;
2509 tmp = parseFontName(fl_get_input(dialog_->input_typewriter));
2510 if (rc.typewriter_font_name != tmp.first ||
2511 rc.typewriter_font_foundry != tmp.second) {
2513 rc.typewriter_font_name = tmp.first;
2514 rc.typewriter_font_foundry = tmp.second;
2517 string str = fl_get_input(dialog_->input_screen_encoding);
2518 if (rc.font_norm != str) {
2521 rc.set_font_norm_type();
2524 bool button = fl_get_button(dialog_->check_scalable);
2525 if (rc.use_scalable_fonts != button) {
2527 rc.use_scalable_fonts = button;
2530 unsigned int ivalue = static_cast<unsigned int>
2531 (fl_get_counter_value(dialog_->counter_zoom));
2532 if (rc.zoom != ivalue) {
2537 ivalue = static_cast<unsigned int>
2538 (fl_get_counter_value(dialog_->counter_dpi));
2539 if (rc.dpi != ivalue) {
2544 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2545 if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2547 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2550 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2551 if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2553 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2556 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2557 if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2559 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2562 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2563 if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2565 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2568 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2569 if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2571 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2574 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2575 if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2577 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2580 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2581 if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2583 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2586 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2587 if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2589 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2592 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2593 if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2595 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2598 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2599 if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2601 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2605 // Now update the buffers
2606 // Can anything below here affect the redraw process?
2607 parent_.controller().updateScreenFonts();
2612 void FormPreferences::ScreenFonts::build()
2614 dialog_.reset(build_preferences_screen_fonts(&parent_));
2616 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2617 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2619 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2620 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2621 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2622 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2623 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2624 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2625 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2626 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2627 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2628 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2629 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2630 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2631 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2632 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2633 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2634 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2636 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2637 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2638 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2639 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2640 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2641 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2642 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2643 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2644 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2645 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2647 // set up the feedback mechanism
2648 setPrehandler(dialog_->input_roman);
2649 setPrehandler(dialog_->input_sans);
2650 setPrehandler(dialog_->input_typewriter);
2651 setPrehandler(dialog_->counter_zoom);
2652 setPrehandler(dialog_->counter_dpi);
2653 setPrehandler(dialog_->check_scalable);
2654 setPrehandler(dialog_->input_screen_encoding);
2655 setPrehandler(dialog_->input_tiny);
2656 setPrehandler(dialog_->input_script);
2657 setPrehandler(dialog_->input_footnote);
2658 setPrehandler(dialog_->input_small);
2659 setPrehandler(dialog_->input_large);
2660 setPrehandler(dialog_->input_larger);
2661 setPrehandler(dialog_->input_largest);
2662 setPrehandler(dialog_->input_normal);
2663 setPrehandler(dialog_->input_huge);
2664 setPrehandler(dialog_->input_huger);
2669 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2671 if (ob == dialog_->input_roman)
2672 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2673 if (ob == dialog_->input_sans)
2674 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2675 if (ob == dialog_->input_typewriter)
2676 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2677 if (ob == dialog_->check_scalable)
2678 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2679 if (ob == dialog_->input_screen_encoding)
2680 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2681 if (ob == dialog_->counter_zoom)
2682 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2683 if (ob == dialog_->counter_dpi)
2684 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2685 if (ob == dialog_->input_tiny
2686 || ob == dialog_->input_script
2687 || ob == dialog_->input_footnote
2688 || ob == dialog_->input_small
2689 || ob == dialog_->input_large
2690 || ob == dialog_->input_larger
2691 || ob == dialog_->input_larger
2692 || ob == dialog_->input_largest
2693 || ob == dialog_->input_normal
2694 || ob == dialog_->input_huge
2695 || ob == dialog_->input_huger)
2696 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2701 bool FormPreferences::ScreenFonts::input()
2703 bool activate = true;
2706 // Make sure that all fonts all have positive entries
2707 // Also note that an empty entry is returned as 0.0 by strToDbl
2708 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2709 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2710 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2711 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2712 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2713 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2714 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2715 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2716 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2717 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2719 str = _("Fonts must be positive!");
2721 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2722 // Fontsizes -- tiny < script < footnote etc.
2723 strToDbl(fl_get_input(dialog_->input_script)) ||
2724 strToDbl(fl_get_input(dialog_->input_script)) >
2725 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2726 strToDbl(fl_get_input(dialog_->input_footnote)) >
2727 strToDbl(fl_get_input(dialog_->input_small)) ||
2728 strToDbl(fl_get_input(dialog_->input_small)) >
2729 strToDbl(fl_get_input(dialog_->input_normal)) ||
2730 strToDbl(fl_get_input(dialog_->input_normal)) >
2731 strToDbl(fl_get_input(dialog_->input_large)) ||
2732 strToDbl(fl_get_input(dialog_->input_large)) >
2733 strToDbl(fl_get_input(dialog_->input_larger)) ||
2734 strToDbl(fl_get_input(dialog_->input_larger)) >
2735 strToDbl(fl_get_input(dialog_->input_largest)) ||
2736 strToDbl(fl_get_input(dialog_->input_largest)) >
2737 strToDbl(fl_get_input(dialog_->input_huge)) ||
2738 strToDbl(fl_get_input(dialog_->input_huge)) >
2739 strToDbl(fl_get_input(dialog_->input_huger))) {
2742 str = _("Fonts must be input in the order Tiny > Smallest > Smaller > Small > Normal > Large > Larger > Largest > Huge > Huger.");
2746 parent_.postWarning(str);
2752 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2754 fl_set_input(dialog_->input_roman,
2755 makeFontName(rc.roman_font_name,
2756 rc.roman_font_foundry).c_str());
2757 fl_set_input(dialog_->input_sans,
2758 makeFontName(rc.sans_font_name,
2759 rc.sans_font_foundry).c_str());
2760 fl_set_input(dialog_->input_typewriter,
2761 makeFontName(rc.typewriter_font_name,
2762 rc.typewriter_font_foundry).c_str());
2763 fl_set_input(dialog_->input_screen_encoding,
2764 rc.font_norm.c_str());
2765 fl_set_button(dialog_->check_scalable,
2766 rc.use_scalable_fonts);
2767 fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2768 fl_set_counter_value(dialog_->counter_dpi, rc.dpi);
2769 fl_set_input(dialog_->input_tiny,
2770 tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2771 fl_set_input(dialog_->input_script,
2772 tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2773 fl_set_input(dialog_->input_footnote,
2774 tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2775 fl_set_input(dialog_->input_small,
2776 tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2777 fl_set_input(dialog_->input_normal,
2778 tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2779 fl_set_input(dialog_->input_large,
2780 tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2781 fl_set_input(dialog_->input_larger,
2782 tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2783 fl_set_input(dialog_->input_largest,
2784 tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2785 fl_set_input(dialog_->input_huge,
2786 tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2787 fl_set_input(dialog_->input_huger,
2788 tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2793 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2798 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2800 return dialog_.get();
2804 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2806 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2807 choice = trim(choice);
2809 rc.isp_command = choice;
2812 // If spell checker == "none", all other input set to off.
2813 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2814 rc.isp_use_alt_lang = false;
2815 rc.isp_alt_lang.erase();
2817 rc.isp_use_esc_chars = false;
2818 rc.isp_esc_chars.erase();
2820 rc.isp_use_pers_dict = false;
2821 rc.isp_pers_dict.erase();
2823 rc.isp_accept_compound = false;
2824 rc.isp_use_input_encoding = false;
2827 int button = fl_get_button(dialog_->check_alt_lang);
2828 choice = fl_get_input(dialog_->input_alt_lang);
2829 if (button && choice.empty()) button = 0;
2830 if (!button) choice.erase();
2832 rc.isp_use_alt_lang = static_cast<bool>(button);
2833 rc.isp_alt_lang = choice;
2835 button = fl_get_button(dialog_->check_escape_chars);
2836 choice = fl_get_input(dialog_->input_escape_chars);
2837 if (button && choice.empty()) button = 0;
2838 if (!button) choice.erase();
2840 rc.isp_use_esc_chars = static_cast<bool>(button);
2841 rc.isp_esc_chars = choice;
2843 button = fl_get_button(dialog_->check_personal_dict);
2844 choice = fl_get_input(dialog_->input_personal_dict);
2845 if (button && choice.empty()) button = 0;
2846 if (!button) choice.erase();
2848 rc.isp_use_pers_dict = static_cast<bool>(button);
2849 rc.isp_pers_dict = choice;
2851 button = fl_get_button(dialog_->check_compound_words);
2852 rc.isp_accept_compound = static_cast<bool>(button);
2854 button = fl_get_button(dialog_->check_input_enc);
2855 rc.isp_use_input_encoding = static_cast<bool>(button);
2866 void FormPreferences::SpellOptions::build()
2868 dialog_.reset(build_preferences_spelloptions(&parent_));
2870 fl_addto_choice(dialog_->choice_spell_command,
2871 _(" ispell | aspell ").c_str());
2872 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2873 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2874 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2876 // set up the feedback mechanism
2877 setPrehandler(dialog_->choice_spell_command);
2878 setPrehandler(dialog_->check_alt_lang);
2879 setPrehandler(dialog_->input_alt_lang);
2880 setPrehandler(dialog_->check_escape_chars);
2881 setPrehandler(dialog_->input_escape_chars);
2882 setPrehandler(dialog_->check_personal_dict);
2883 setPrehandler(dialog_->input_personal_dict);
2884 setPrehandler(dialog_->button_personal_dict);
2885 setPrehandler(dialog_->check_compound_words);
2886 setPrehandler(dialog_->check_input_enc);
2891 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2893 if (ob == dialog_->choice_spell_command)
2894 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2895 if (ob == dialog_->check_alt_lang)
2896 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2897 if (ob == dialog_->input_alt_lang)
2898 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2899 if (ob == dialog_->check_escape_chars)
2900 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2901 if (ob == dialog_->input_escape_chars)
2902 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2903 if (ob == dialog_->check_personal_dict)
2904 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2905 if (ob == dialog_->input_personal_dict)
2906 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2907 if (ob == dialog_->check_compound_words)
2908 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2909 if (ob == dialog_->check_input_enc)
2910 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
2915 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2917 // !ob if function is called from updateSpellOptions() to de/activate
2919 // otherwise the function is called by an xforms CB via input().
2922 // If spell checker == "none", disable all input.
2923 if (!ob || ob == dialog_->choice_spell_command) {
2924 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2925 fl_deactivate_object(dialog_->check_alt_lang);
2926 fl_deactivate_object(dialog_->input_alt_lang);
2927 fl_deactivate_object(dialog_->check_escape_chars);
2928 fl_deactivate_object(dialog_->input_escape_chars);
2929 fl_deactivate_object(dialog_->check_personal_dict);
2930 fl_deactivate_object(dialog_->input_personal_dict);
2931 fl_deactivate_object(dialog_->check_compound_words);
2932 fl_deactivate_object(dialog_->check_input_enc);
2935 fl_activate_object(dialog_->check_alt_lang);
2936 fl_activate_object(dialog_->check_escape_chars);
2937 fl_activate_object(dialog_->check_personal_dict);
2938 fl_activate_object(dialog_->check_compound_words);
2939 fl_activate_object(dialog_->check_input_enc);
2944 if (!ob || ob == dialog_->check_alt_lang) {
2945 bool const enable = fl_get_button(dialog_->check_alt_lang);
2946 setEnabled(dialog_->input_alt_lang, enable);
2949 if (!ob || ob == dialog_->check_escape_chars) {
2950 bool const enable = fl_get_button(dialog_->check_escape_chars);
2951 setEnabled(dialog_->input_escape_chars, enable);
2954 if (!ob || ob == dialog_->check_personal_dict) {
2955 bool const enable = fl_get_button(dialog_->check_personal_dict);
2956 setEnabled(dialog_->input_personal_dict, enable);
2959 if (ob == dialog_->button_personal_dict) {
2960 string f = parent_.controller().browsedict(
2961 fl_get_input(dialog_->input_personal_dict));
2962 fl_set_input(dialog_->input_personal_dict, f.c_str());
2965 return true; // All input is valid!
2969 void FormPreferences::SpellOptions::update(LyXRC const & rc)
2973 if (rc.isp_command == "none")
2975 else if (rc.isp_command == "ispell")
2977 else if (rc.isp_command == "aspell")
2980 if (rc.isp_command == "ispell")
2982 else if (rc.isp_command == "aspell")
2985 fl_set_choice(dialog_->choice_spell_command, choice);
2988 if (rc.isp_use_alt_lang)
2989 str = rc.isp_alt_lang;
2991 fl_set_button(dialog_->check_alt_lang,
2992 rc.isp_use_alt_lang);
2993 fl_set_input(dialog_->input_alt_lang, str.c_str());
2996 if (rc.isp_use_esc_chars)
2997 str = rc.isp_esc_chars;
2999 fl_set_button(dialog_->check_escape_chars,
3000 rc.isp_use_esc_chars);
3001 fl_set_input(dialog_->input_escape_chars, str.c_str());
3004 if (rc.isp_use_pers_dict)
3005 str = rc.isp_pers_dict;
3007 fl_set_button(dialog_->check_personal_dict,
3008 rc.isp_use_pers_dict);
3009 fl_set_input(dialog_->input_personal_dict, str.c_str());
3011 fl_set_button(dialog_->check_compound_words,
3012 rc.isp_accept_compound);
3013 fl_set_button(dialog_->check_input_enc,
3014 rc.isp_use_input_encoding);
3016 // Activate/Deactivate the input fields dependent on the state of the