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 "FormPreferences.h"
14 #include "forms/form_preferences.h"
16 #include "FormColorpicker.h"
17 #include "forms_gettext.h"
18 #include "input_validators.h"
20 #include "xforms_helpers.h"
22 #include "controllers/ControlPrefs.h"
23 #include "controllers/frnt_lang.h"
24 #include "controllers/helper_funcs.h" // getSecond
27 #include "lastfiles.h"
31 #include "support/lstrings.h"
32 #include "support/tostr.h"
33 #include "support/path_defines.h"
34 #include "support/filetools.h"
36 #include "lyx_forms.h"
52 using support::AddName;
53 using support::ChangeExtension;
55 using support::strToDbl;
57 using support::user_lyxdir;
63 string makeFontName(string const & family, string const & foundry)
67 return family + ',' + foundry;
71 pair<string,string> parseFontName(string const & name)
73 string::size_type const idx = name.find(',');
74 if (idx == string::npos)
75 return make_pair(name, string());
76 return make_pair(name.substr(0, idx),
82 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
83 bool const scalableTabfolders = false;
85 bool const scalableTabfolders = true;
91 typedef FormController<ControlPrefs, FormView<FD_preferences> > base_class;
94 FormPreferences::FormPreferences(Dialog & parent)
95 : base_class(parent, _("Preferences"), scalableTabfolders),
96 colors_(*this), converters_(*this), copiers_(*this),
97 formats_(*this), identity_(*this), inputs_misc_(*this),
98 interface_(*this), language_(*this), lnf_misc_(*this),
99 outputs_misc_(*this), paths_(*this), printer_(*this),
100 screen_fonts_(*this), spelloptions_(*this)
104 void FormPreferences::redraw()
106 if (!(form() && form()->visible))
108 fl_redraw_form(form());
110 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
111 if (!(form2 && form2->visible))
113 fl_redraw_form(form2);
116 if (form2 == converters_tab_->form)
117 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
119 else if (form2 == look_n_feel_tab_->form)
120 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
122 else if (form2 == inputs_tab_->form)
123 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
125 else if (form2 == outputs_tab_->form)
126 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
128 else if (form2 == lang_opts_tab_->form)
129 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
131 if (form3 && form3->visible)
132 fl_redraw_form(form3);
136 void FormPreferences::hide()
138 // We need to hide the active tabfolder otherwise we get a
139 // BadDrawable error from X window and LyX crashes without saving.
140 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
141 if (inner_form && inner_form->visible)
142 fl_hide_form(inner_form);
143 FormDialogView::hide();
147 void FormPreferences::build()
149 dialog_.reset(build_preferences(this));
151 // Manage the restore, save, apply and cancel/close buttons
152 bcview().setOK(dialog_->button_ok);
153 bcview().setApply(dialog_->button_apply);
154 bcview().setCancel(dialog_->button_close);
155 bcview().setRestore(dialog_->button_restore);
157 // Allow the base class to control messages
158 setMessageWidget(dialog_->text_warning);
160 // build the tab folders
161 converters_tab_.reset(build_preferences_inner_tab(this));
162 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
163 inputs_tab_.reset(build_preferences_inner_tab(this));
164 outputs_tab_.reset(build_preferences_inner_tab(this));
165 lang_opts_tab_.reset(build_preferences_inner_tab(this));
167 // build actual tabfolder contents
168 // these will become nested tabfolders
173 inputs_misc_.build();
178 outputs_misc_.build();
181 screen_fonts_.build();
182 spelloptions_.build();
184 // Enable the tabfolders to be rescaled correctly.
185 if (scalableTabfolders) {
186 FL_OBJECT * folder = dialog_->tabfolder_prefs;
187 fl_set_tabfolder_autofit(folder, FL_FIT);
189 folder = look_n_feel_tab_->tabfolder_inner;
190 fl_set_tabfolder_autofit(folder, FL_FIT);
192 folder = converters_tab_->tabfolder_inner;
193 fl_set_tabfolder_autofit(folder, FL_FIT);
195 folder = inputs_tab_->tabfolder_inner;
196 fl_set_tabfolder_autofit(folder, FL_FIT);
198 folder = outputs_tab_->tabfolder_inner;
199 fl_set_tabfolder_autofit(folder, FL_FIT);
201 folder = lang_opts_tab_->tabfolder_inner;
202 fl_set_tabfolder_autofit(folder, FL_FIT);
206 // Now add them to the tabfolder
207 fl_addto_tabfolder(dialog_->tabfolder_prefs,
208 _("Look & Feel").c_str(),
209 look_n_feel_tab_->form);
210 fl_addto_tabfolder(dialog_->tabfolder_prefs,
211 _("Lang Opts").c_str(),
212 lang_opts_tab_->form);
213 fl_addto_tabfolder(dialog_->tabfolder_prefs,
214 _("Conversion").c_str(),
215 converters_tab_->form);
216 fl_addto_tabfolder(dialog_->tabfolder_prefs,
219 fl_addto_tabfolder(dialog_->tabfolder_prefs,
220 _("Outputs").c_str(),
223 // now build the nested tabfolders
224 // Starting with look and feel
225 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
226 _("Screen Fonts").c_str(),
227 screen_fonts_.dialog()->form);
228 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
229 _("Interface").c_str(),
230 interface_.dialog()->form);
231 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
233 colors_.dialog()->form);
234 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
236 lnf_misc_.dialog()->form);
237 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
238 _("Identity").c_str(),
239 identity_.dialog()->form);
241 // then build converters
242 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
243 _("Formats").c_str(),
244 formats_.dialog()->form);
245 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
246 _("Converters").c_str(),
247 converters_.dialog()->form);
248 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
249 _("Copiers").c_str(),
250 copiers_.dialog()->form);
253 // Paths should probably go in a few inner_tab called Files
254 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
256 paths_.dialog()->form);
257 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
259 inputs_misc_.dialog()->form);
261 // then building outputs
262 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
263 _("Printer").c_str(),
264 printer_.dialog()->form);
265 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
267 outputs_misc_.dialog()->form);
269 // then building usage
270 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
271 _("Spell checker").c_str(),
272 spelloptions_.dialog()->form);
273 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
274 _("Language").c_str(),
275 language_.dialog()->form);
279 void FormPreferences::apply()
281 // set the new lyxrc entries
282 // many of these need to trigger other functions when the assignment
283 // is made. For example, screen zoom and font types. These could be
284 // handled either by signals/slots in lyxrc or just directly call the
285 // associated functions here.
286 // There are other problems with this scheme. We really should check
287 // what we copy to make sure that it really is necessary to do things
288 // like update the screen fonts because that flushes the textcache
289 // and other stuff which may cost us a lot on slower/high-load
292 LyXRC & rc(controller().rc());
295 inputs_misc_.apply(rc);
296 interface_.apply(rc);
300 outputs_misc_.apply(rc);
303 screen_fonts_.apply(rc);
304 spelloptions_.apply(rc);
306 // The "Save" button has been pressed.
307 if (dialog().isClosing() && colors_.modifiedXformsPrefs) {
308 string const filename =
309 AddName(user_lyxdir(), "preferences.xform");
310 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
315 string const FormPreferences::getFeedback(FL_OBJECT * ob)
319 if (ob->form->fdui == colors_.dialog())
320 return colors_.feedback(ob);
321 if (ob->form->fdui == converters_.dialog())
322 return converters_.feedback(ob);
323 if (ob->form->fdui == copiers_.dialog())
324 return copiers_.feedback(ob);
325 if (ob->form->fdui == formats_.dialog())
326 return formats_.feedback(ob);
327 if (ob->form->fdui == inputs_misc_.dialog())
328 return inputs_misc_.feedback(ob);
329 if (ob->form->fdui == interface_.dialog())
330 return interface_.feedback(ob);
331 if (ob->form->fdui == language_.dialog())
332 return language_.feedback(ob);
333 if (ob->form->fdui == lnf_misc_.dialog())
334 return lnf_misc_.feedback(ob);
335 if (ob->form->fdui == outputs_misc_.dialog())
336 return outputs_misc_.feedback(ob);
337 if (ob->form->fdui == paths_.dialog())
338 return paths_.feedback(ob);
339 if (ob->form->fdui == printer_.dialog())
340 return printer_.feedback(ob);
341 if (ob->form->fdui == screen_fonts_.dialog())
342 return screen_fonts_.feedback(ob);
343 if (ob->form->fdui == spelloptions_.dialog())
344 return spelloptions_.feedback(ob);
350 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
356 // whatever checks you need to ensure the user hasn't entered
357 // some totally ridiculous value somewhere. Change activate to suit.
358 // comments before each test describe what is _valid_
360 if (ob->form->fdui == colors_.dialog()) {
362 } else if (ob->form->fdui == converters_.dialog()) {
363 valid = converters_.input(ob);
364 } else if (ob->form->fdui == copiers_.dialog()) {
365 valid = copiers_.input(ob);
366 } else if (ob->form->fdui == formats_.dialog()) {
367 valid = formats_.input(ob);
368 } else if (ob->form->fdui == interface_.dialog()) {
369 valid = interface_.input(ob);
370 } else if (ob->form->fdui == language_.dialog()) {
371 valid = language_.input(ob);
372 } else if (ob->form->fdui == paths_.dialog()) {
373 valid = paths_.input(ob);
374 } else if (ob->form->fdui == screen_fonts_.dialog()) {
375 valid = screen_fonts_.input();
376 } else if (ob->form->fdui == spelloptions_.dialog()) {
377 valid = spelloptions_.input(ob);
380 return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
384 void FormPreferences::update()
386 if (!dialog_.get()) return;
388 LyXRC const & rc(controller().rc());
390 // read lyxrc entries
392 formats_.update(); // Must be before converters_.update()
393 converters_.update();
395 inputs_misc_.update(rc);
396 interface_.update(rc);
397 language_.update(rc);
398 lnf_misc_.update(rc);
399 identity_.update(rc);
400 outputs_misc_.update(rc);
403 screen_fonts_.update(rc);
404 spelloptions_.update(rc);
408 FormPreferences::Colors::Colors(FormPreferences & p)
409 : modifiedXformsPrefs(false), parent_(p)
413 FD_preferences_colors const * FormPreferences::Colors::dialog()
415 return dialog_.get();
419 void FormPreferences::Colors::apply()
421 bool modifiedText = false;
422 bool modifiedBackground = false;
424 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
425 cit != xformsColorDB.end(); ++cit) {
427 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
428 if (col != cit->color()) {
429 modifiedXformsPrefs = true;
430 if (cit->colorID == FL_BLACK)
432 if (cit->colorID == FL_COL1)
433 modifiedBackground = true;
437 if (modifiedXformsPrefs) {
438 for (vector<XformsColor>::const_iterator cit =
439 xformsColorDB.begin();
440 cit != xformsColorDB.end(); ++cit) {
441 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
443 if (modifiedText && cit->colorID == FL_BLACK) {
444 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
447 if (modifiedBackground && cit->colorID == FL_COL1) {
448 AdjustVal(FL_MCOL, FL_COL1, 0.1);
449 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
450 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
452 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
453 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
456 if (cit->colorID == GUI_COLOR_CURSOR) {
457 fl_mapcolor(GUI_COLOR_CURSOR,
458 cit->r, cit->g, cit->b);
459 setCursorColor(GUI_COLOR_CURSOR);
462 parent_.controller().redrawGUI();
465 // Now do the same for the LyX LColors...
466 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
467 cit != lyxColorDB.end(); ++cit) {
468 LColor::color lc = lcolor.getFromLyXName(cit->lyxname);
469 if (lc == LColor::inherit) continue;
471 // Create a valid X11 name of the form "#rrggbb"
472 string const hexname = X11hexname(cit->color());
474 if (lcolor.getX11Name(lc) != hexname) {
476 << "FormPreferences::Colors::apply: "
477 << "resetting LColor " << lcolor.getGUIName(lc)
478 << " from \"" << lcolor.getX11Name(lc)
479 << "\" to \"" << hexname << "\"."
482 parent_.controller().setColor(lc, hexname);
488 void FormPreferences::Colors::build()
490 picker_.reset(new FormColorpicker);
491 dialog_.reset(build_preferences_colors(&parent_));
493 fl_set_object_color(dialog_->button_color,
494 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
496 // set up the feedback mechanism
497 setPrehandler(dialog_->browser_lyx_objs);
498 setPrehandler(dialog_->button_color);
499 setPrehandler(dialog_->button_modify);
504 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
506 if (ob == dialog_->browser_lyx_objs)
507 return _("LyX objects that can be assigned a color.");
509 if (ob == dialog_->button_modify)
510 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
516 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
518 if (ob == dialog_->browser_lyx_objs) {
521 } else if (ob == dialog_->button_modify) {
527 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
531 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
535 hsv.v = min(1.0, max(0.0, hsv.v));
538 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
542 void FormPreferences::Colors::InputBrowserLyX() const
544 vector<NamedColor>::size_type const selLyX =
545 fl_get_browser(dialog_->browser_lyx_objs);
546 if (selLyX < 1) return;
548 // Is the choice an Xforms color...
551 if (selLyX - 1 < xformsColorDB.size()) {
552 vector<XformsColor>::size_type const i = selLyX - 1;
553 col = xformsColorDB[i].color();
555 // or a LyX Logical color?
557 vector<NamedColor>::size_type const i = selLyX - 1 -
558 xformsColorDB.size();
559 col = lyxColorDB[i].color();
562 fl_freeze_form(dialog_->form);
564 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
565 fl_redraw_object(dialog_->button_color);
567 fl_unfreeze_form(dialog_->form);
571 void FormPreferences::Colors::LoadBrowserLyX()
573 if (!dialog_->browser_lyx_objs->visible)
576 // First, define the modifiable xforms colors
577 xformsColorDB.clear();
580 xcol.lyxname = "GUI background";
581 xcol.guiname = _("GUI background");
582 xcol.colorID = FL_COL1;
583 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
585 xformsColorDB.push_back(xcol);
587 xcol.lyxname = "GUI text";
588 xcol.guiname = _("GUI text");
589 xcol.colorID = FL_BLACK;
590 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
592 xformsColorDB.push_back(xcol);
594 xcol.lyxname = "GUI selection";
595 xcol.guiname = _("GUI selection");
596 xcol.colorID = FL_YELLOW;
597 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
599 xformsColorDB.push_back(xcol);
601 xcol.lyxname = "GUI pointer";
602 xcol.guiname = _("GUI pointer");
603 xcol.colorID = GUI_COLOR_CURSOR;
604 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
606 xformsColorDB.push_back(xcol);
608 // Now create the the LyX LColors database
610 for (int i=0; i<LColor::ignore; ++i) {
611 LColor::color lc = static_cast<LColor::color>(i);
612 if (lc == LColor::none
613 || lc == LColor::black
614 || lc == LColor::white
616 || lc == LColor::green
617 || lc == LColor::blue
618 || lc == LColor::cyan
619 || lc == LColor::magenta
620 || lc == LColor::yellow
621 || lc == LColor::inherit
622 || lc == LColor::ignore) continue;
625 bool const success = getRGBColor(lc, col.r, col.g, col.b);
627 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
628 << "LColor " << lcolor.getLyXName(lc)
629 << ": X can't find color \""
630 << lcolor.getX11Name(lc)
631 << "\". Set to \"black\"!" << endl;
633 string const arg = lcolor.getLyXName(lc) + " black";
634 parent_.controller().setColor(lc, "black");
638 // Create a valid X11 name of the form "#rrggbb" and change the
639 // LColor X11name to this. Don't want to trigger a redraw,
640 // as we're just changing the name not the RGB values.
641 // Also reset the system_lcolor names, so that we don't output
642 // unnecessary changes.
643 string const hexname = X11hexname(col);
645 if (lcolor.getX11Name(lc) != hexname) {
646 lcolor.setColor(lc, hexname);
647 system_lcolor.setColor(lc, hexname);
650 // Finally, push the color onto the database
651 NamedColor ncol(lcolor.getLyXName(lc), lcolor.getGUIName(lc), col);
652 lyxColorDB.push_back(ncol);
655 // Now construct the browser
656 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
657 fl_freeze_form(dialog_->form);
658 fl_clear_browser(colbr);
659 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
660 cit != xformsColorDB.end(); ++cit) {
661 fl_addto_browser(colbr, cit->guiname.c_str());
663 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
664 cit != lyxColorDB.end(); ++cit) {
665 fl_addto_browser(colbr, cit->guiname.c_str());
668 // just to be safe...
669 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
670 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
671 fl_unfreeze_form(dialog_->form);
677 void FormPreferences::Colors::Modify()
679 vector<NamedColor>::size_type const selLyX =
680 fl_get_browser(dialog_->browser_lyx_objs);
685 fl_getmcolor(GUI_COLOR_CHOICE, &before.r, &before.g, &before.b);
687 RGBColor col = picker_->requestColor(before);
691 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
692 fl_redraw_object(dialog_->button_color);
694 // Is the choice an Xforms color...
695 if (selLyX - 1 < xformsColorDB.size()) {
696 vector<XformsColor>::size_type const i = selLyX - 1;
697 xformsColorDB[i].r = col.r;
698 xformsColorDB[i].g = col.g;
699 xformsColorDB[i].b = col.b;
701 // or a LyX Logical color?
703 vector<NamedColor>::size_type const i = selLyX - 1 -
704 xformsColorDB.size();
705 lyxColorDB[i].r = col.r;
706 lyxColorDB[i].g = col.g;
707 lyxColorDB[i].b = col.b;
712 FormPreferences::Converters::Converters(FormPreferences & p)
717 FD_preferences_converters const * FormPreferences::Converters::dialog()
719 return dialog_.get();
723 ::Converters & FormPreferences::Converters::converters()
725 return parent_.controller().converters();
729 ::Formats & FormPreferences::Converters::formats()
731 return parent_.controller().formats();
735 void FormPreferences::Converters::build()
737 dialog_.reset(build_preferences_converters(&parent_));
739 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
740 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
742 // set up the feedback mechanism
743 setPrehandler(dialog_->browser_all);
744 setPrehandler(dialog_->button_delete);
745 setPrehandler(dialog_->button_add);
746 setPrehandler(dialog_->input_converter);
747 setPrehandler(dialog_->choice_from);
748 setPrehandler(dialog_->choice_to);
749 setPrehandler(dialog_->input_flags);
754 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
756 if (ob == dialog_->browser_all)
757 return _("All explicitly defined converters for LyX");
759 if (ob == dialog_->choice_from)
760 return _("Convert \"from\" this format");
762 if (ob == dialog_->choice_to)
763 return _("Convert \"to\" this format");
765 if (ob == dialog_->input_converter)
766 return _("The conversion command. $$i is the input file name, "
767 "$$b is the file name without its extension and $$o is "
768 "the name of the output file. $$s can be used as path to "
769 "LyX's own collection of conversion scripts.");
771 if (ob == dialog_->input_flags)
772 return _("Extra information for the Converter class, whether and "
773 "how to parse the result, and various other things.");
775 if (ob == dialog_->button_delete)
776 return _("Remove the current converter from the list of available "
777 "converters. Note: you must then \"Apply\" the change.");
779 if (ob == dialog_->button_add) {
780 if (string(ob->label) == _("Add"))
781 return _("Add the current converter to the list of available "
782 "converters. Note: you must then \"Apply\" the change.");
784 return _("Modify the contents of the current converter. "
785 "Note: you must then \"Apply\" the change.");
792 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
794 if (ob == dialog_->browser_all)
797 if (ob == dialog_->choice_from
798 || ob == dialog_->choice_to
799 || ob == dialog_->input_converter
800 || ob == dialog_->input_flags)
803 if (ob == dialog_->button_add)
806 if (ob == dialog_->button_delete)
813 void FormPreferences::Converters::update()
819 void FormPreferences::Converters::UpdateBrowser()
823 fl_freeze_form(dialog_->form);
824 fl_clear_browser(dialog_->browser_all);
825 for (::Converters::const_iterator cit = converters().begin();
826 cit != converters().end(); ++cit) {
827 string const name = cit->From->prettyname() + " -> "
828 + cit->To->prettyname();
829 fl_addto_browser(dialog_->browser_all, name.c_str());
832 fl_unfreeze_form(dialog_->form);
836 bool FormPreferences::Converters::Add()
838 string const from = GetFrom();
839 string const to = GetTo();
840 string const command = fl_get_input(dialog_->input_converter);
841 string const flags = fl_get_input(dialog_->input_flags);
843 Converter const * old = converters().getConverter(from, to);
844 converters().add(from, to, command, flags);
846 converters().updateLast(formats());
849 setEnabled(dialog_->button_add, false);
855 bool FormPreferences::Converters::Browser()
857 int const i = fl_get_browser(dialog_->browser_all);
858 if (i <= 0) return false;
860 fl_freeze_form(dialog_->form);
862 Converter const & c = converters().get(i - 1);
863 int j = formats().getNumber(c.from);
865 fl_set_choice(dialog_->choice_from, j + 1);
867 j = formats().getNumber(c.to);
869 fl_set_choice(dialog_->choice_to, j + 1);
871 fl_set_input(dialog_->input_converter, c.command.c_str());
872 fl_set_input(dialog_->input_flags, c.flags.c_str());
874 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
875 fl_set_button_shortcut(dialog_->button_add,
876 scex(_("Modify|#M")).c_str(), 1);
878 setEnabled(dialog_->button_add, false);
879 setEnabled(dialog_->button_delete, true);
881 fl_unfreeze_form(dialog_->form);
886 bool FormPreferences::Converters::erase()
888 string const from = GetFrom();
889 string const to = GetTo();
891 converters().erase(from, to);
897 bool FormPreferences::Converters::Input()
899 string const from = GetFrom();
900 string const to = GetTo();
901 int const sel = converters().getNumber(from, to);
903 fl_freeze_form(dialog_->form);
906 fl_set_object_label(dialog_->button_add,
907 idex(_("Add|#A")).c_str());
908 fl_set_button_shortcut(dialog_->button_add,
909 scex(_("Add|#A")).c_str(), 1);
911 fl_deselect_browser(dialog_->browser_all);
912 setEnabled(dialog_->button_delete, false);
915 fl_set_object_label(dialog_->button_add,
916 idex(_("Modify|#M")).c_str());
917 fl_set_button_shortcut(dialog_->button_add,
918 scex(_("Modify|#M")).c_str(), 1);
920 int top = max(sel-5, 0);
921 fl_set_browser_topline(dialog_->browser_all, top);
922 fl_select_browser_line(dialog_->browser_all, sel+1);
923 setEnabled(dialog_->button_delete, true);
926 string const command = rtrim(fl_get_input(dialog_->input_converter));
927 bool const enable = !(command.empty() || from == to);
928 setEnabled(dialog_->button_add, enable);
930 fl_unfreeze_form(dialog_->form);
935 string const FormPreferences::Converters::GetFrom()
937 ::Formats::FormatList::size_type const i =
938 fl_get_choice(dialog_->choice_from);
940 if (i > 0 && i <= formats().size())
941 return formats().get(i - 1).name();
943 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
948 string const FormPreferences::Converters::GetTo()
950 ::Formats::FormatList::size_type const i =
951 fl_get_choice(dialog_->choice_to);
953 if (i > 0 && i <= formats().size())
954 return formats().get(i - 1).name();
956 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
961 void FormPreferences::Converters::UpdateChoices()
964 for (::Formats::const_iterator cit = formats().begin();
965 cit != formats().end(); ++cit) {
970 choice += cit->prettyname();
974 fl_clear_choice(dialog_->choice_from);
975 fl_addto_choice(dialog_->choice_from, choice.c_str());
977 fl_clear_choice(dialog_->choice_to);
978 fl_addto_choice(dialog_->choice_to, choice.c_str());
982 FormPreferences::Copiers::Copiers(FormPreferences & p)
987 FD_preferences_copiers const * FormPreferences::Copiers::dialog()
989 return dialog_.get();
993 ::Movers & FormPreferences::Copiers::movers()
995 return parent_.controller().movers();
999 void FormPreferences::Copiers::build()
1001 dialog_.reset(build_preferences_copiers(&parent_));
1003 fl_set_input_return(dialog_->input_copier, FL_RETURN_CHANGED);
1005 // set up the feedback mechanism
1006 setPrehandler(dialog_->browser_all);
1007 setPrehandler(dialog_->button_delete);
1008 setPrehandler(dialog_->button_add);
1009 setPrehandler(dialog_->choice_format);
1010 setPrehandler(dialog_->input_copier);
1015 FormPreferences::Copiers::feedback(FL_OBJECT const * const ob) const
1017 if (ob == dialog_->browser_all)
1018 return _("All explicitly defined copiers for LyX");
1020 if (ob == dialog_->choice_format)
1021 return _("Copier for this format");
1023 if (ob == dialog_->input_copier)
1025 return _("The command used to copy the file. "
1026 "$$i is the \"from\" file name and "
1027 "$$o is the \"to\" file name.\n"
1028 "$$s can be used as path to "
1029 "LyX's own collection of scripts.");
1031 if (ob == dialog_->button_delete)
1032 return _("Remove the current copier from the list of available "
1033 "copiers. Note: you must then \"Apply\" the change.");
1035 if (ob == dialog_->button_add) {
1036 if (string(ob->label) == _("Add"))
1037 return _("Add the current copier to the list of available "
1038 "copiers. Note: you must then \"Apply\" the change.");
1040 return _("Modify the contents of the current copier. "
1041 "Note: you must then \"Apply\" the change.");
1048 bool FormPreferences::Copiers::input(FL_OBJECT const * const ob)
1050 if (ob == dialog_->browser_all)
1053 if (ob == dialog_->choice_format
1054 || ob == dialog_->input_copier)
1057 if (ob == dialog_->button_add)
1060 if (ob == dialog_->button_delete)
1067 void FormPreferences::Copiers::update()
1069 // Build data for the browser widget
1070 Movers::iterator const begin = movers().begin();
1071 Movers::iterator const end = movers().end();
1073 vector<string> fmts;
1074 fmts.reserve(std::distance(begin, end));
1075 for (Movers::iterator it = begin; it != end; ++it) {
1076 std::string const & command = it->second.command();
1077 if (command.empty())
1079 std::string const & fmt = it->first;
1080 fmts.push_back(::formats.prettyName(fmt));
1083 std::sort(fmts.begin(), fmts.end());
1085 // Build data for the choice widget
1087 for (::Formats::const_iterator it = ::formats.begin();
1088 it != ::formats.end(); ++it) {
1089 if (!choice.empty())
1093 choice += it->prettyname();
1098 fl_freeze_form(dialog_->form);
1099 fl_set_input(dialog_->input_copier, "");
1101 // The browser widget
1102 fl_clear_browser(dialog_->browser_all);
1104 vector<string>::const_iterator it = fmts.begin();
1105 vector<string>::const_iterator const fmts_end = fmts.end();
1106 for (; it != fmts_end; ++it)
1107 fl_addto_browser(dialog_->browser_all, it->c_str());
1109 // The choice widget
1110 fl_clear_choice(dialog_->choice_format);
1111 fl_addto_choice(dialog_->choice_format, choice.c_str());
1112 fl_set_choice(dialog_->choice_format, 1);
1115 fl_unfreeze_form(dialog_->form);
1121 struct SamePrettyName {
1122 SamePrettyName(string const & n) : pretty_name_(n) {}
1124 bool operator()(::Format const & fmt) const {
1125 return fmt.prettyname() == pretty_name_;
1129 string const pretty_name_;
1133 ::Format const * getFormat(std::string const & prettyname)
1135 ::Formats::const_iterator it = ::formats.begin();
1136 ::Formats::const_iterator const end = ::formats.end();
1137 it = std::find_if(it, end, SamePrettyName(prettyname));
1138 return it == end ? 0 : &*it;
1144 bool FormPreferences::Copiers::Add()
1146 ::Format const * fmt = getFormat(getString(dialog_->choice_format));
1150 string const command = getString(dialog_->input_copier);
1151 if (command.empty())
1154 fl_freeze_form(dialog_->form);
1156 movers().set(fmt->name(), command);
1158 setEnabled(dialog_->button_add, false);
1160 fl_unfreeze_form(dialog_->form);
1165 bool FormPreferences::Copiers::Browser()
1167 int const i = fl_get_browser(dialog_->browser_all);
1168 if (i <= 0) return false;
1170 ::Format const * fmt = getFormat(getString(dialog_->browser_all, i));
1174 string const & fmt_name = fmt->name();
1175 string const & gui_name = fmt->prettyname();
1176 string const & command = movers().command(fmt_name);
1178 fl_freeze_form(dialog_->form);
1180 int const choice_size = fl_get_choice_maxitems(dialog_->choice_format);
1181 for (int i = 1; i <= choice_size; ++i) {
1182 char const * const c_str =
1183 fl_get_choice_item_text(dialog_->choice_format, i);
1184 string const line = c_str ? trim(c_str) : string();
1185 if (line == gui_name) {
1186 fl_set_choice(dialog_->choice_format, i);
1191 fl_set_input(dialog_->input_copier, command.c_str());
1193 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
1194 fl_set_button_shortcut(dialog_->button_add,
1195 scex(_("Modify|#M")).c_str(), 1);
1197 setEnabled(dialog_->button_add, false);
1198 setEnabled(dialog_->button_delete, true);
1200 fl_unfreeze_form(dialog_->form);
1205 bool FormPreferences::Copiers::Erase()
1207 ::Format const * fmt = getFormat(getString(dialog_->choice_format));
1211 string const & fmt_name = fmt->name();
1213 movers().set(fmt_name, string());
1219 bool FormPreferences::Copiers::Input()
1221 ::Format const * fmt = getFormat(getString(dialog_->choice_format));
1225 string const & gui_name = fmt->prettyname();
1226 string const command = getString(dialog_->input_copier);
1228 fl_freeze_form(dialog_->form);
1229 fl_deselect_browser(dialog_->browser_all);
1230 bool found_line = false;
1231 int const browser_size = fl_get_browser_maxline(dialog_->browser_all);
1232 for (int i = 1; i <= browser_size; ++i) {
1233 char const * const c_str =
1234 fl_get_browser_line(dialog_->browser_all, i);
1235 string const line = c_str ? trim(c_str) : string();
1236 if (line == gui_name) {
1237 fl_select_browser_line(dialog_->browser_all, i);
1238 int top = max(i-5, 1);
1239 fl_set_browser_topline(dialog_->browser_all, top);
1246 fl_set_object_label(dialog_->button_add,
1247 idex(_("Add|#A")).c_str());
1248 fl_set_button_shortcut(dialog_->button_add,
1249 scex(_("Add|#A")).c_str(), 1);
1251 setEnabled(dialog_->button_delete, false);
1253 fl_set_object_label(dialog_->button_add,
1254 idex(_("Modify|#M")).c_str());
1255 fl_set_button_shortcut(dialog_->button_add,
1256 scex(_("Modify|#M")).c_str(), 1);
1258 setEnabled(dialog_->button_delete, true);
1261 setEnabled(dialog_->button_add, !command.empty());
1263 fl_unfreeze_form(dialog_->form);
1268 FormPreferences::Formats::Formats(FormPreferences & p)
1273 FD_preferences_formats const * FormPreferences::Formats::dialog()
1275 return dialog_.get();
1279 ::Converters & FormPreferences::Formats::converters()
1281 return parent_.controller().converters();
1285 ::Formats & FormPreferences::Formats::formats()
1287 return parent_.controller().formats();
1291 void FormPreferences::Formats::build()
1293 dialog_.reset(build_preferences_formats(&parent_));
1295 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1296 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1297 fl_set_input_return(dialog_->input_editor, FL_RETURN_CHANGED);
1298 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1299 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1300 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1302 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1304 // set up the feedback mechanism
1305 setPrehandler(dialog_->browser_all);
1306 setPrehandler(dialog_->input_format);
1307 setPrehandler(dialog_->input_gui_name);
1308 setPrehandler(dialog_->button_delete);
1309 setPrehandler(dialog_->button_add);
1310 setPrehandler(dialog_->input_extension);
1311 setPrehandler(dialog_->input_viewer);
1312 setPrehandler(dialog_->input_editor);
1313 setPrehandler(dialog_->input_shrtcut);
1318 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1320 if (ob == dialog_->browser_all)
1321 return _("All the currently defined formats known to LyX.");
1323 if (ob == dialog_->input_format)
1324 return _("The format identifier.");
1326 if (ob == dialog_->input_gui_name)
1327 return _("The format name as it will appear in the menus.");
1329 if (ob == dialog_->input_shrtcut)
1330 return _("The keyboard accelerator. Use a letter in the GUI name. "
1333 if (ob == dialog_->input_extension)
1334 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1336 if (ob == dialog_->input_viewer)
1337 return _("The command used to launch the viewer application.");
1339 if (ob == dialog_->input_editor)
1340 return _("The command used to launch the editor application.");
1342 if (ob == dialog_->button_delete)
1343 return _("Remove the current format from the list of available "
1344 "formats. Note: you must then \"Apply\" the change.");
1346 if (ob == dialog_->button_add) {
1347 if (string(ob->label) == _("Add"))
1348 return _("Add the current format to the list of available "
1349 "formats. Note: you must then \"Apply\" the change.");
1351 return _("Modify the contents of the current format. Note: "
1352 "you must then \"Apply\" the change.");
1359 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1361 if (ob == dialog_->browser_all)
1364 if (ob == dialog_->input_format
1365 || ob == dialog_->input_gui_name
1366 || ob == dialog_->input_shrtcut
1367 || ob == dialog_->input_extension
1368 || ob == dialog_->input_viewer
1369 || ob == dialog_->input_editor)
1372 if (ob == dialog_->button_add)
1375 if (ob == dialog_->button_delete)
1382 void FormPreferences::Formats::update()
1388 void FormPreferences::Formats::UpdateBrowser()
1392 fl_freeze_form(dialog_->form);
1393 fl_deselect_browser(dialog_->browser_all);
1394 fl_clear_browser(dialog_->browser_all);
1395 for (::Formats::const_iterator cit = formats().begin();
1396 cit != formats().end(); ++cit)
1397 fl_addto_browser(dialog_->browser_all,
1398 cit->prettyname().c_str());
1401 fl_unfreeze_form(dialog_->form);
1403 // Mustn't forget to update the Formats available to the converters_
1404 parent_.converters_.UpdateChoices();
1405 converters().update(formats());
1409 bool FormPreferences::Formats::Add()
1411 string const name = fl_get_input(dialog_->input_format);
1412 string const prettyname = fl_get_input(dialog_->input_gui_name);
1413 string const extension = fl_get_input(dialog_->input_extension);
1414 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1415 string const viewer = fl_get_input(dialog_->input_viewer);
1416 string const editor = fl_get_input(dialog_->input_editor);
1418 Format const * old = formats().getFormat(name);
1419 string const old_prettyname = old ? old->prettyname() : string();
1420 formats().add(name, extension, prettyname, shortcut, viewer, editor);
1421 if (!old || prettyname != old_prettyname) {
1424 parent_.converters_.UpdateBrowser();
1426 setEnabled(dialog_->button_add, false);
1432 bool FormPreferences::Formats::Browser()
1434 int const i = fl_get_browser(dialog_->browser_all);
1438 fl_freeze_form(dialog_->form);
1440 Format const & f = formats().get(i - 1);
1442 fl_set_input(dialog_->input_format, f.name().c_str());
1443 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1444 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1445 fl_set_input(dialog_->input_extension, f.extension().c_str());
1446 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1447 fl_set_input(dialog_->input_editor, f.editor().c_str());
1449 fl_set_object_label(dialog_->button_add,
1450 idex(_("Modify|#M")).c_str());
1451 fl_set_button_shortcut(dialog_->button_add,
1452 scex(_("Modify|#M")).c_str(), 1);
1454 setEnabled(dialog_->button_add, false);
1455 setEnabled(dialog_->button_delete, true);
1457 fl_unfreeze_form(dialog_->form);
1462 bool FormPreferences::Formats::erase()
1464 string const name = fl_get_input(dialog_->input_format);
1466 if (converters().formatIsUsed(name)) {
1467 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1468 "Remove the converter first."));
1469 setEnabled(dialog_->button_delete, false);
1473 formats().erase(name);
1479 bool FormPreferences::Formats::Input()
1481 string const name = fl_get_input(dialog_->input_format);
1482 int const sel = formats().getNumber(name);
1483 fl_freeze_form(dialog_->form);
1486 fl_set_object_label(dialog_->button_add,
1487 idex(_("Add|#A")).c_str());
1488 fl_set_button_shortcut(dialog_->button_add,
1489 scex(_("Add|#A")).c_str(), 1);
1491 fl_deselect_browser(dialog_->browser_all);
1492 setEnabled(dialog_->button_delete, false);
1495 fl_set_object_label(dialog_->button_add,
1496 idex(_("Modify|#M")).c_str());
1497 fl_set_button_shortcut(dialog_->button_add,
1498 scex(_("Modify|#M")).c_str(), 1);
1500 int const top = max(sel-5, 0);
1501 fl_set_browser_topline(dialog_->browser_all, top);
1502 fl_select_browser_line(dialog_->browser_all, sel+1);
1504 setEnabled(dialog_->button_add, true);
1505 setEnabled(dialog_->button_delete, true);
1508 string const prettyname = fl_get_input(dialog_->input_gui_name);
1509 bool const enable = !(name.empty() || prettyname.empty());
1510 setEnabled(dialog_->button_add, enable);
1512 fl_unfreeze_form(dialog_->form);
1517 FormPreferences::Identity::Identity(FormPreferences & p)
1522 FD_preferences_identity const * FormPreferences::Identity::dialog()
1524 return dialog_.get();
1528 void FormPreferences::Identity::apply(LyXRC & rc) const
1530 rc.user_name = fl_get_input(dialog_->input_user_name);
1531 rc.user_email = fl_get_input(dialog_->input_user_email);
1535 void FormPreferences::Identity::build()
1537 dialog_.reset(build_preferences_identity(&parent_));
1538 fl_set_input_return(dialog_->input_user_name, FL_RETURN_CHANGED);
1539 fl_set_input_return(dialog_->input_user_email, FL_RETURN_CHANGED);
1543 void FormPreferences::Identity::update(LyXRC const & rc)
1545 fl_set_input(dialog_->input_user_name, rc.user_name.c_str());
1546 fl_set_input(dialog_->input_user_email, rc.user_email.c_str());
1550 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1555 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1557 return dialog_.get();
1561 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1563 rc.date_insert_format =
1564 fl_get_input(dialog_->input_date_format);
1568 void FormPreferences::InputsMisc::build()
1570 dialog_.reset(build_preferences_inputs_misc(&parent_));
1572 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1574 // set up the feedback mechanism
1575 setPrehandler(dialog_->input_date_format);
1580 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1582 if (ob == dialog_->input_date_format)
1583 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1588 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1590 fl_set_input(dialog_->input_date_format,
1591 rc.date_insert_format.c_str());
1595 FormPreferences::Interface::Interface(FormPreferences & p)
1600 FD_preferences_interface const * FormPreferences::Interface::dialog()
1602 return dialog_.get();
1606 void FormPreferences::Interface::apply(LyXRC & rc) const
1608 rc.popup_normal_font =
1609 fl_get_input(dialog_->input_popup_normal_font);
1610 rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1611 rc.popup_font_encoding =
1612 fl_get_input(dialog_->input_popup_font_encoding);
1613 rc.bind_file = fl_get_input(dialog_->input_bind_file);
1614 rc.ui_file = fl_get_input(dialog_->input_ui_file);
1618 void FormPreferences::Interface::build()
1620 dialog_.reset(build_preferences_interface(&parent_));
1622 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1623 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1624 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1625 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1626 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1628 // set up the feedback mechanism
1629 setPrehandler(dialog_->input_popup_normal_font);
1630 setPrehandler(dialog_->input_popup_bold_font);
1631 setPrehandler(dialog_->input_popup_font_encoding);
1632 setPrehandler(dialog_->input_bind_file);
1633 setPrehandler(dialog_->button_bind_file_browse);
1634 setPrehandler(dialog_->input_ui_file);
1635 setPrehandler(dialog_->button_ui_file_browse);
1640 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1642 if (ob == dialog_->input_popup_normal_font)
1643 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1644 if (ob == dialog_->input_popup_bold_font)
1645 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1646 if (ob == dialog_->input_popup_font_encoding)
1647 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1648 if (ob == dialog_->input_bind_file)
1649 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1650 if (ob == dialog_->input_ui_file)
1651 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1656 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1658 if (ob == dialog_->button_bind_file_browse) {
1659 string f = parent_.controller().browsebind(
1660 fl_get_input(dialog_->input_bind_file));
1662 fl_set_input(dialog_->input_bind_file, f.c_str());
1663 } else if (ob == dialog_->button_ui_file_browse) {
1664 string f = parent_.controller().browseUI(
1665 fl_get_input(dialog_->input_ui_file));
1667 fl_set_input(dialog_->input_ui_file, f.c_str());
1674 void FormPreferences::Interface::update(LyXRC const & rc)
1676 fl_set_input(dialog_->input_popup_normal_font,
1677 rc.popup_normal_font.c_str());
1678 fl_set_input(dialog_->input_popup_bold_font,
1679 rc.popup_bold_font.c_str());
1680 fl_set_input(dialog_->input_popup_font_encoding,
1681 rc.popup_font_encoding.c_str());
1682 fl_set_input(dialog_->input_bind_file,
1683 rc.bind_file.c_str());
1684 fl_set_input(dialog_->input_ui_file,
1685 rc.ui_file.c_str());
1689 FormPreferences::Language::Language(FormPreferences & p)
1694 FD_preferences_language const * FormPreferences::Language::dialog()
1696 return dialog_.get();
1700 void FormPreferences::Language::apply(LyXRC & rc)
1702 int const pos = fl_get_combox(dialog_->combox_default_lang);
1703 rc.default_language = lang_[pos-1];
1705 int button = fl_get_button(dialog_->check_use_kbmap);
1706 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1707 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1709 button = !(name_1.empty() && name_2.empty());
1710 rc.use_kbmap = static_cast<bool>(button);
1713 rc.primary_kbmap = name_1;
1714 rc.secondary_kbmap = name_2;
1717 button = fl_get_button(dialog_->check_rtl_support);
1718 rc.rtl_support = static_cast<bool>(button);
1720 button = fl_get_button(dialog_->check_mark_foreign);
1721 rc.mark_foreign_language = static_cast<bool>(button);
1723 button = fl_get_button(dialog_->check_auto_begin);
1724 rc.language_auto_begin = static_cast<bool>(button);
1726 button = fl_get_button(dialog_->check_auto_end);
1727 rc.language_auto_end = static_cast<bool>(button);
1729 button = fl_get_button(dialog_->check_use_babel);
1730 rc.language_use_babel = static_cast<bool>(button);
1732 button = fl_get_button(dialog_->check_global_options);
1733 rc.language_global_options = static_cast<bool>(button);
1735 rc.language_package = fl_get_input(dialog_->input_package);
1736 rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1737 rc.language_command_end = fl_get_input(dialog_->input_command_end);
1739 // Ensure that all is self-consistent.
1744 void FormPreferences::Language::build()
1746 dialog_.reset(build_preferences_language(&parent_));
1748 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1749 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1750 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1752 // Store the lang identifiers for later
1753 vector<LanguagePair> const langs = getLanguageData(false);
1754 lang_ = getSecond(langs);
1756 FL_OBJECT * obj = dialog_->combox_default_lang;
1757 vector<LanguagePair>::const_iterator lit = langs.begin();
1758 vector<LanguagePair>::const_iterator lend = langs.end();
1759 for (; lit != lend; ++lit) {
1760 fl_addto_combox(obj, lit->first.c_str());
1762 fl_set_combox_browser_height(obj, 400);
1764 // set up the feedback mechanism
1765 setPrehandler(dialog_->input_package);
1766 setPrehandler(dialog_->check_use_kbmap);
1767 setPrehandler(dialog_->combox_default_lang);
1768 setPrehandler(dialog_->input_kbmap1);
1769 setPrehandler(dialog_->input_kbmap2);
1770 setPrehandler(dialog_->check_rtl_support);
1771 setPrehandler(dialog_->check_mark_foreign);
1772 setPrehandler(dialog_->check_auto_begin);
1773 setPrehandler(dialog_->check_auto_end);
1774 setPrehandler(dialog_->check_use_babel);
1775 setPrehandler(dialog_->check_global_options);
1776 setPrehandler(dialog_->input_command_begin);
1777 setPrehandler(dialog_->input_command_end);
1779 // Activate/Deactivate the input fields dependent on the state of the
1786 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1788 if (ob == dialog_->combox_default_lang)
1789 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1790 if (ob == dialog_->check_use_kbmap)
1791 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1792 if (ob == dialog_->input_kbmap1)
1793 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1794 if (ob == dialog_->input_kbmap2)
1795 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1796 if (ob == dialog_->check_rtl_support)
1797 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1798 if (ob == dialog_->check_mark_foreign)
1799 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1800 if (ob == dialog_->check_auto_begin)
1801 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1802 if (ob == dialog_->check_auto_end)
1803 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1804 if (ob == dialog_->check_use_babel)
1805 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1806 if (ob == dialog_->check_global_options)
1807 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1808 if (ob == dialog_->input_package)
1809 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1810 if (ob == dialog_->input_command_begin)
1811 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1812 if (ob == dialog_->input_command_end)
1813 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1818 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1820 bool activate = true;
1822 // !ob if function is called from Language::build() to de/activate
1824 // otherwise the function is called by an xforms CB via input().
1825 if (!ob || ob == dialog_->check_use_kbmap) {
1826 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1827 setEnabled(dialog_->button_kbmap1_browse, enable);
1828 setEnabled(dialog_->button_kbmap2_browse, enable);
1829 setEnabled(dialog_->input_kbmap1, enable);
1830 setEnabled(dialog_->input_kbmap2, enable);
1833 if (ob == dialog_->button_kbmap1_browse) {
1834 string f = parent_.controller().browsekbmap(
1835 fl_get_input(dialog_->input_kbmap1));
1837 fl_set_input(dialog_->input_kbmap1, f.c_str());
1838 } else if (ob == dialog_->button_kbmap2_browse) {
1839 string f = parent_.controller().browsekbmap(
1840 fl_get_input(dialog_->input_kbmap2));
1842 fl_set_input(dialog_->input_kbmap2, f.c_str());
1849 void FormPreferences::Language::update(LyXRC const & rc)
1851 fl_set_button(dialog_->check_use_kbmap,
1854 int const pos = int(findPos(lang_, rc.default_language));
1855 fl_set_combox(dialog_->combox_default_lang, pos + 1);
1858 fl_set_input(dialog_->input_kbmap1,
1859 rc.primary_kbmap.c_str());
1860 fl_set_input(dialog_->input_kbmap2,
1861 rc.secondary_kbmap.c_str());
1863 fl_set_input(dialog_->input_kbmap1, "");
1864 fl_set_input(dialog_->input_kbmap2, "");
1867 fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1868 fl_set_button(dialog_->check_mark_foreign,
1869 rc.mark_foreign_language);
1870 fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1871 fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1872 fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1873 fl_set_button(dialog_->check_global_options,
1874 rc.language_global_options);
1876 fl_set_input(dialog_->input_package,
1877 rc.language_package.c_str());
1878 fl_set_input(dialog_->input_command_begin,
1879 rc.language_command_begin.c_str());
1880 fl_set_input(dialog_->input_command_end,
1881 rc.language_command_end.c_str());
1883 // Activate/Deactivate the input fields dependent on the state of the
1889 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1894 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1896 return dialog_.get();
1900 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1902 rc.auto_region_delete =
1903 fl_get_button(dialog_->check_auto_region_delete);
1904 rc.cursor_follows_scrollbar =
1905 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1906 rc.dialogs_iconify_with_main =
1907 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1909 switch (fl_get_choice(dialog_->choice_instant_preview)) {
1911 rc.preview = LyXRC::PREVIEW_OFF;
1914 rc.preview = LyXRC::PREVIEW_NO_MATH;
1917 rc.preview = LyXRC::PREVIEW_ON;
1921 rc.autosave = static_cast<unsigned int>
1922 (fl_get_counter_value(dialog_->counter_autosave));
1923 rc.wheel_jump = static_cast<unsigned int>
1924 (fl_get_counter_value(dialog_->counter_wm_jump));
1927 // graphics::DisplayType old_value = rc.display_graphics;
1928 switch (fl_get_choice(dialog_->choice_graphics_display)) {
1930 rc.display_graphics = graphics::NoDisplay;
1933 rc.display_graphics = graphics::ColorDisplay;
1936 rc.display_graphics = graphics::GrayscaleDisplay;
1939 rc.display_graphics = graphics::MonochromeDisplay;
1942 rc.display_graphics = graphics::ColorDisplay;
1946 #ifdef WITH_WARNINGS
1947 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1950 if (old_value != rc.display_graphics) {
1951 graphics::GCache & gc = graphics::GCache::get();
1958 void FormPreferences::LnFmisc::build()
1960 dialog_.reset(build_preferences_lnf_misc(&parent_));
1962 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1963 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1965 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1966 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1968 // set up the feedback mechanism
1969 setPrehandler(dialog_->check_auto_region_delete);
1970 setPrehandler(dialog_->counter_autosave);
1971 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1972 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1973 setPrehandler(dialog_->choice_instant_preview);
1974 setPrehandler(dialog_->counter_wm_jump);
1976 fl_addto_choice(dialog_->choice_graphics_display,
1977 _("Monochrome|Grayscale|Color|Do not display").c_str());
1979 fl_addto_choice(dialog_->choice_instant_preview,
1980 _("Off|No math|On").c_str());
1985 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1987 if (ob == dialog_->check_auto_region_delete)
1988 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
1989 if (ob == dialog_->check_cursor_follows_scrollbar)
1990 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1991 if (ob == dialog_->check_dialogs_iconify_with_main)
1992 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1993 if (ob == dialog_->choice_instant_preview)
1994 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
1995 if (ob == dialog_->counter_autosave)
1996 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
1997 if (ob == dialog_->counter_wm_jump)
1998 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
1999 if (ob == dialog_->choice_graphics_display)
2000 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
2005 void FormPreferences::LnFmisc::update(LyXRC const & rc)
2007 fl_set_button(dialog_->check_auto_region_delete,
2008 rc.auto_region_delete);
2009 fl_set_button(dialog_->check_cursor_follows_scrollbar,
2010 rc.cursor_follows_scrollbar);
2011 fl_set_button(dialog_->check_dialogs_iconify_with_main,
2012 rc.dialogs_iconify_with_main);
2014 switch (rc.preview) {
2015 case LyXRC::PREVIEW_OFF:
2016 fl_set_choice(dialog_->choice_instant_preview, 1);
2018 case LyXRC::PREVIEW_NO_MATH:
2019 fl_set_choice(dialog_->choice_instant_preview, 2);
2021 case LyXRC::PREVIEW_ON:
2022 fl_set_choice(dialog_->choice_instant_preview, 3);
2026 fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
2027 fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
2029 switch (rc.display_graphics) {
2030 case graphics::NoDisplay:
2031 fl_set_choice(dialog_->choice_graphics_display, 4);
2033 case graphics::ColorDisplay:
2034 fl_set_choice(dialog_->choice_graphics_display, 3);
2036 case graphics::GrayscaleDisplay:
2037 fl_set_choice(dialog_->choice_graphics_display, 2);
2039 case graphics::MonochromeDisplay:
2040 fl_set_choice(dialog_->choice_graphics_display, 1);
2043 fl_set_choice(dialog_->choice_graphics_display, 3);
2049 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
2054 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
2056 return dialog_.get();
2060 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
2062 rc.ascii_linelen = static_cast<unsigned int>
2063 (fl_get_counter_value(dialog_->counter_line_len));
2064 rc.fontenc = fl_get_input(dialog_->input_tex_encoding);
2067 fl_get_choice(dialog_->choice_default_papersize) - 1;
2068 rc.default_papersize = static_cast<PAPER_SIZE>(choice);
2070 rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
2071 rc.chktex_command = fl_get_input(dialog_->input_checktex);
2072 rc.bibtex_command = fl_get_input(dialog_->input_bibtex);
2073 rc.index_command = fl_get_input(dialog_->input_index);
2074 rc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
2075 rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
2079 void FormPreferences::OutputsMisc::build()
2081 dialog_.reset(build_preferences_outputs_misc(&parent_));
2083 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
2085 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
2086 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
2087 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
2088 fl_set_input_return(dialog_->input_bibtex, FL_RETURN_CHANGED);
2089 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
2090 fl_set_input_return(dialog_->input_index, FL_RETURN_CHANGED);
2091 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
2093 fl_addto_choice(dialog_->choice_default_papersize,
2094 _(" default | US letter | US legal "
2095 "| US executive | A3 | A4 | A5 | B5 ").c_str());
2097 // set up the feedback mechanism
2098 setPrehandler(dialog_->counter_line_len);
2099 setPrehandler(dialog_->input_tex_encoding);
2100 setPrehandler(dialog_->choice_default_papersize);
2101 setPrehandler(dialog_->input_ascii_roff);
2102 setPrehandler(dialog_->input_bibtex);
2103 setPrehandler(dialog_->input_checktex);
2104 setPrehandler(dialog_->input_index);
2105 setPrehandler(dialog_->input_paperoption);
2106 setPrehandler(dialog_->check_autoreset_classopt);
2111 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
2113 if (ob == dialog_->counter_line_len)
2114 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
2115 if (ob == dialog_->input_tex_encoding)
2116 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
2117 if (ob == dialog_->input_ascii_roff)
2118 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
2119 if (ob == dialog_->input_bibtex)
2120 return LyXRC::getDescription(LyXRC::RC_BIBTEX_COMMAND);
2121 if (ob == dialog_->input_checktex)
2122 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
2123 if (ob == dialog_->input_index)
2124 return LyXRC::getDescription(LyXRC::RC_INDEX_COMMAND);
2125 if (ob == dialog_->choice_default_papersize)
2126 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2127 if (ob == dialog_->input_paperoption)
2128 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
2129 if (ob == dialog_->check_autoreset_classopt)
2130 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2135 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
2137 fl_set_counter_value(dialog_->counter_line_len,
2139 fl_set_input(dialog_->input_tex_encoding,
2140 rc.fontenc.c_str());
2141 fl_set_choice(dialog_->choice_default_papersize,
2142 rc.default_papersize + 1);
2143 fl_set_input(dialog_->input_ascii_roff,
2144 rc.ascii_roff_command.c_str());
2145 fl_set_input(dialog_->input_checktex,
2146 rc.chktex_command.c_str());
2147 fl_set_input(dialog_->input_bibtex,
2148 rc.bibtex_command.c_str());
2149 fl_set_input(dialog_->input_index,
2150 rc.index_command.c_str());
2151 fl_set_input(dialog_->input_paperoption,
2152 rc.view_dvi_paper_option.c_str());
2153 fl_set_button(dialog_->check_autoreset_classopt,
2154 rc.auto_reset_options);
2159 FormPreferences::Paths::Paths(FormPreferences & p)
2164 FD_preferences_paths const * FormPreferences::Paths::dialog()
2166 return dialog_.get();
2170 void FormPreferences::Paths::apply(LyXRC & rc)
2172 rc.document_path = fl_get_input(dialog_->input_default_path);
2173 rc.template_path = fl_get_input(dialog_->input_template_path);
2174 rc.tempdir_path = fl_get_input(dialog_->input_temp_dir);
2176 int button = fl_get_button(dialog_->check_last_files);
2177 string str = fl_get_input(dialog_->input_lastfiles);
2178 if (!button) str.erase();
2180 rc.check_lastfiles = button;
2182 rc.num_lastfiles = static_cast<unsigned int>
2183 (fl_get_counter_value(dialog_->counter_lastfiles));
2185 button = fl_get_button(dialog_->check_make_backups);
2186 str = fl_get_input(dialog_->input_backup_path);
2190 rc.make_backup = button;
2191 rc.backupdir_path = str;
2193 rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2200 void FormPreferences::Paths::build()
2202 dialog_.reset(build_preferences_paths(&parent_));
2204 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2205 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2206 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2207 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2208 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2209 fl_set_counter_bounds(dialog_->counter_lastfiles, 0, maxlastfiles);
2210 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2211 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2213 // set up the feedback mechanism
2214 setPrehandler(dialog_->input_default_path);
2215 setPrehandler(dialog_->counter_lastfiles);
2216 setPrehandler(dialog_->input_template_path);
2217 setPrehandler(dialog_->check_last_files);
2218 setPrehandler(dialog_->input_lastfiles);
2219 setPrehandler(dialog_->check_make_backups);
2220 setPrehandler(dialog_->input_backup_path);
2221 setPrehandler(dialog_->input_serverpipe);
2222 setPrehandler(dialog_->input_temp_dir);
2227 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2229 if (ob == dialog_->input_default_path)
2230 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2231 if (ob == dialog_->input_template_path)
2232 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2233 if (ob == dialog_->input_temp_dir)
2234 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2235 if (ob == dialog_->check_last_files)
2236 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2237 if (ob == dialog_->input_lastfiles)
2238 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
2239 if (ob == dialog_->counter_lastfiles)
2240 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2241 if (ob == dialog_->check_make_backups)
2242 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2243 if (ob == dialog_->input_backup_path)
2244 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2245 if (ob == dialog_->input_serverpipe)
2246 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2251 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2253 bool activate = true;
2255 // !ob if function is called from Paths::update() to de/activate
2257 // otherwise the function is called by an xforms CB via input().
2258 if (!ob || ob == dialog_->check_last_files) {
2259 bool const enable = fl_get_button(dialog_->check_last_files);
2260 setEnabled(dialog_->input_lastfiles, enable);
2263 if (!ob || ob == dialog_->check_make_backups) {
2264 bool const enable = fl_get_button(dialog_->check_make_backups);
2265 setEnabled(dialog_->input_backup_path, enable);
2268 if (!ob || ob == dialog_->input_default_path) {
2269 string const name = fl_get_input(dialog_->input_default_path);
2270 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2271 parent_.postWarning(RWInfo::ErrorMessage());
2276 if (!ob || ob == dialog_->input_template_path) {
2277 string const name = fl_get_input(dialog_->input_template_path);
2278 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2279 parent_.postWarning(RWInfo::ErrorMessage());
2284 if (!ob || ob == dialog_->input_temp_dir) {
2285 string const name = fl_get_input(dialog_->input_temp_dir);
2286 if (fl_get_button(dialog_->check_make_backups)
2288 && !RWInfo::WriteableDir(name)) {
2289 parent_.postWarning(RWInfo::ErrorMessage());
2294 if (!ob || ob == dialog_->input_backup_path) {
2295 string const name = fl_get_input(dialog_->input_backup_path);
2296 if (fl_get_button(dialog_->check_make_backups)
2298 && !RWInfo::WriteableDir(name)) {
2299 parent_.postWarning(RWInfo::ErrorMessage());
2304 if (!ob || ob == dialog_->input_lastfiles) {
2305 string const name = fl_get_input(dialog_->input_lastfiles);
2306 if (fl_get_button(dialog_->check_last_files)
2308 && !RWInfo::WriteableFile(name)) {
2309 parent_.postWarning(RWInfo::ErrorMessage());
2314 if (!ob || ob == dialog_->input_serverpipe) {
2315 string const name = fl_get_input(dialog_->input_serverpipe);
2316 if (!name.empty()) {
2317 // strip off the extension
2318 string const str = ChangeExtension(name, "");
2319 if (!RWInfo::WriteableFile(str + ".in")) {
2320 parent_.postWarning(RWInfo::ErrorMessage());
2323 if (!RWInfo::WriteableFile(str + ".out")) {
2324 parent_.postWarning(RWInfo::ErrorMessage());
2330 if (ob == dialog_->button_default_path_browse) {
2331 string f = parent_.controller().browsedir(
2332 fl_get_input(dialog_->input_default_path), _("Default path"));
2334 fl_set_input(dialog_->input_default_path, f.c_str());
2335 } else if (ob == dialog_->button_template_path_browse) {
2336 string f = parent_.controller().browsedir(
2337 fl_get_input(dialog_->input_template_path), _("Template path"));
2339 fl_set_input(dialog_->input_template_path, f.c_str());
2340 } else if (ob == dialog_->button_temp_dir_browse) {
2341 string f = parent_.controller().browsedir(
2342 fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2344 fl_set_input(dialog_->input_temp_dir, f.c_str());
2345 } else if (ob == dialog_->button_lastfiles_browse) {
2346 string f = parent_.controller().browse(
2347 fl_get_input(dialog_->input_lastfiles), _("Last files"));
2349 fl_set_input(dialog_->input_lastfiles, f.c_str());
2350 } else if (ob == dialog_->button_backup_path_browse) {
2351 string f = parent_.controller().browsedir(
2352 fl_get_input(dialog_->input_backup_path), _("Backup path"));
2354 fl_set_input(dialog_->input_backup_path, f.c_str());
2355 } else if (ob == dialog_->button_serverpipe_browse) {
2356 string f = parent_.controller().browse(
2357 fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2359 fl_set_input(dialog_->input_serverpipe, f.c_str());
2366 void FormPreferences::Paths::update(LyXRC const & rc)
2368 fl_set_input(dialog_->input_default_path,
2369 rc.document_path.c_str());
2370 fl_set_input(dialog_->input_template_path,
2371 rc.template_path.c_str());
2375 str = rc.backupdir_path;
2377 fl_set_button(dialog_->check_make_backups,
2379 fl_set_input(dialog_->input_backup_path, str.c_str());
2381 fl_set_input(dialog_->input_temp_dir, rc.tempdir_path.c_str());
2384 if (rc.check_lastfiles)
2387 fl_set_button(dialog_->check_last_files,
2388 rc.check_lastfiles);
2389 fl_set_input(dialog_->input_lastfiles, str.c_str());
2390 fl_set_counter_value(dialog_->counter_lastfiles,
2393 fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2395 // Activate/Deactivate the input fields dependent on the state of the
2401 FormPreferences::Printer::Printer(FormPreferences & p)
2406 FD_preferences_printer const * FormPreferences::Printer::dialog()
2408 return dialog_.get();
2412 void FormPreferences::Printer::apply(LyXRC & rc) const
2414 rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2415 rc.print_command = fl_get_input(dialog_->input_command);
2416 rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2417 rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2418 rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2419 rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2420 rc.print_file_extension =
2421 fl_get_input(dialog_->input_file_extension);
2422 rc.print_spool_command =
2423 fl_get_input(dialog_->input_spool_command);
2424 rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2425 rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2426 rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2427 rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2428 rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2429 rc.print_to_file = fl_get_input(dialog_->input_to_file);
2430 rc.print_extra_options =
2431 fl_get_input(dialog_->input_extra_options);
2432 rc.print_spool_printerprefix =
2433 fl_get_input(dialog_->input_spool_prefix);
2434 rc.print_paper_dimension_flag =
2435 fl_get_input(dialog_->input_paper_size);
2436 rc.printer = fl_get_input(dialog_->input_name);
2441 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2443 if (ob == dialog_->input_command)
2444 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2445 if (ob == dialog_->check_adapt_output)
2446 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2447 if (ob == dialog_->input_to_printer)
2448 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2449 if (ob == dialog_->input_to_file)
2450 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2451 if (ob == dialog_->input_file_extension)
2452 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2453 if (ob == dialog_->input_extra_options)
2454 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2455 if (ob == dialog_->input_spool_command)
2456 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2457 if (ob == dialog_->input_spool_prefix)
2458 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2459 if (ob == dialog_->input_name)
2460 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2461 if (ob == dialog_->input_even_pages)
2462 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2463 if (ob == dialog_->input_odd_pages)
2464 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2465 if (ob == dialog_->input_page_range)
2466 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2467 if (ob == dialog_->input_reverse)
2468 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2469 if (ob == dialog_->input_landscape)
2470 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2471 if (ob == dialog_->input_copies)
2472 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2473 if (ob == dialog_->input_collated)
2474 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2475 if (ob == dialog_->input_paper_type)
2476 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2477 if (ob == dialog_->input_paper_size)
2478 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2483 void FormPreferences::Printer::build()
2485 dialog_.reset(build_preferences_printer(&parent_));
2487 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2488 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2489 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2490 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2491 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2492 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2493 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2494 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2495 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2496 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2497 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2498 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2499 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2500 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2501 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2502 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2503 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2505 // set up the feedback mechanism
2506 setPrehandler(dialog_->input_command);
2507 setPrehandler(dialog_->input_page_range);
2508 setPrehandler(dialog_->input_copies);
2509 setPrehandler(dialog_->input_reverse);
2510 setPrehandler(dialog_->input_to_printer);
2511 setPrehandler(dialog_->input_file_extension);
2512 setPrehandler(dialog_->input_spool_command);
2513 setPrehandler(dialog_->input_paper_type);
2514 setPrehandler(dialog_->input_even_pages);
2515 setPrehandler(dialog_->input_odd_pages);
2516 setPrehandler(dialog_->input_collated);
2517 setPrehandler(dialog_->input_landscape);
2518 setPrehandler(dialog_->input_to_file);
2519 setPrehandler(dialog_->input_extra_options);
2520 setPrehandler(dialog_->input_spool_prefix);
2521 setPrehandler(dialog_->input_paper_size);
2522 setPrehandler(dialog_->input_name);
2523 setPrehandler(dialog_->check_adapt_output);
2527 void FormPreferences::Printer::update(LyXRC const & rc)
2529 fl_set_button(dialog_->check_adapt_output,
2530 rc.print_adapt_output);
2531 fl_set_input(dialog_->input_command,
2532 rc.print_command.c_str());
2533 fl_set_input(dialog_->input_page_range,
2534 rc.print_pagerange_flag.c_str());
2535 fl_set_input(dialog_->input_copies,
2536 rc.print_copies_flag.c_str());
2537 fl_set_input(dialog_->input_reverse,
2538 rc.print_reverse_flag.c_str());
2539 fl_set_input(dialog_->input_to_printer,
2540 rc.print_to_printer.c_str());
2541 fl_set_input(dialog_->input_file_extension,
2542 rc.print_file_extension.c_str());
2543 fl_set_input(dialog_->input_spool_command,
2544 rc.print_spool_command.c_str());
2545 fl_set_input(dialog_->input_paper_type,
2546 rc.print_paper_flag.c_str());
2547 fl_set_input(dialog_->input_even_pages,
2548 rc.print_evenpage_flag.c_str());
2549 fl_set_input(dialog_->input_odd_pages,
2550 rc.print_oddpage_flag.c_str());
2551 fl_set_input(dialog_->input_collated,
2552 rc.print_collcopies_flag.c_str());
2553 fl_set_input(dialog_->input_landscape,
2554 rc.print_landscape_flag.c_str());
2555 fl_set_input(dialog_->input_to_file,
2556 rc.print_to_file.c_str());
2557 fl_set_input(dialog_->input_extra_options,
2558 rc.print_extra_options.c_str());
2559 fl_set_input(dialog_->input_spool_prefix,
2560 rc.print_spool_printerprefix.c_str());
2561 fl_set_input(dialog_->input_paper_size,
2562 rc.print_paper_dimension_flag.c_str());
2563 fl_set_input(dialog_->input_name,
2564 rc.printer.c_str());
2568 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2573 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2575 return dialog_.get();
2579 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2581 bool changed = false;
2583 pair<string, string> tmp =
2584 parseFontName(fl_get_input(dialog_->input_roman));
2585 if (rc.roman_font_name != tmp.first ||
2586 rc.roman_font_foundry != tmp.second) {
2588 rc.roman_font_name = tmp.first;
2589 rc.roman_font_foundry = tmp.second;
2592 tmp = parseFontName(fl_get_input(dialog_->input_sans));
2593 if (rc.sans_font_name != tmp.first ||
2594 rc.sans_font_foundry != tmp.second) {
2596 rc.sans_font_name = tmp.first;
2597 rc.sans_font_foundry = tmp.second;
2600 tmp = parseFontName(fl_get_input(dialog_->input_typewriter));
2601 if (rc.typewriter_font_name != tmp.first ||
2602 rc.typewriter_font_foundry != tmp.second) {
2604 rc.typewriter_font_name = tmp.first;
2605 rc.typewriter_font_foundry = tmp.second;
2608 string str = fl_get_input(dialog_->input_screen_encoding);
2609 if (rc.font_norm != str) {
2612 rc.set_font_norm_type();
2615 bool button = fl_get_button(dialog_->check_scalable);
2616 if (rc.use_scalable_fonts != button) {
2618 rc.use_scalable_fonts = button;
2621 unsigned int ivalue = static_cast<unsigned int>
2622 (fl_get_counter_value(dialog_->counter_zoom));
2623 if (rc.zoom != ivalue) {
2628 ivalue = static_cast<unsigned int>
2629 (fl_get_counter_value(dialog_->counter_dpi));
2630 if (rc.dpi != ivalue) {
2635 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2636 if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2638 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2641 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2642 if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2644 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2647 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2648 if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2650 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2653 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2654 if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2656 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2659 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2660 if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2662 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2665 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2666 if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2668 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2671 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2672 if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2674 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2677 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2678 if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2680 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2683 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2684 if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2686 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2689 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2690 if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2692 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2696 // Now update the buffers
2697 // Can anything below here affect the redraw process?
2698 parent_.controller().updateScreenFonts();
2703 void FormPreferences::ScreenFonts::build()
2705 dialog_.reset(build_preferences_screen_fonts(&parent_));
2707 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2708 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2710 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2711 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2712 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2713 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2714 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2715 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2716 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2717 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2718 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2719 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2720 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2721 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2722 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2723 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2724 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2725 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2727 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2728 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2729 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2730 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2731 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2732 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2733 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2734 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2735 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2736 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2738 // set up the feedback mechanism
2739 setPrehandler(dialog_->input_roman);
2740 setPrehandler(dialog_->input_sans);
2741 setPrehandler(dialog_->input_typewriter);
2742 setPrehandler(dialog_->counter_zoom);
2743 setPrehandler(dialog_->counter_dpi);
2744 setPrehandler(dialog_->check_scalable);
2745 setPrehandler(dialog_->input_screen_encoding);
2746 setPrehandler(dialog_->input_tiny);
2747 setPrehandler(dialog_->input_script);
2748 setPrehandler(dialog_->input_footnote);
2749 setPrehandler(dialog_->input_small);
2750 setPrehandler(dialog_->input_large);
2751 setPrehandler(dialog_->input_larger);
2752 setPrehandler(dialog_->input_largest);
2753 setPrehandler(dialog_->input_normal);
2754 setPrehandler(dialog_->input_huge);
2755 setPrehandler(dialog_->input_huger);
2760 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2762 if (ob == dialog_->input_roman)
2763 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2764 if (ob == dialog_->input_sans)
2765 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2766 if (ob == dialog_->input_typewriter)
2767 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2768 if (ob == dialog_->check_scalable)
2769 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2770 if (ob == dialog_->input_screen_encoding)
2771 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2772 if (ob == dialog_->counter_zoom)
2773 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2774 if (ob == dialog_->counter_dpi)
2775 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2776 if (ob == dialog_->input_tiny
2777 || ob == dialog_->input_script
2778 || ob == dialog_->input_footnote
2779 || ob == dialog_->input_small
2780 || ob == dialog_->input_large
2781 || ob == dialog_->input_larger
2782 || ob == dialog_->input_larger
2783 || ob == dialog_->input_largest
2784 || ob == dialog_->input_normal
2785 || ob == dialog_->input_huge
2786 || ob == dialog_->input_huger)
2787 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2792 bool FormPreferences::ScreenFonts::input()
2794 bool activate = true;
2797 // Make sure that all fonts all have positive entries
2798 // Also note that an empty entry is returned as 0.0 by strToDbl
2799 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2800 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2801 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2802 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2803 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2804 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2805 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2806 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2807 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2808 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2810 str = _("Fonts must be positive!");
2812 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2813 // Fontsizes -- tiny < script < footnote etc.
2814 strToDbl(fl_get_input(dialog_->input_script)) ||
2815 strToDbl(fl_get_input(dialog_->input_script)) >
2816 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2817 strToDbl(fl_get_input(dialog_->input_footnote)) >
2818 strToDbl(fl_get_input(dialog_->input_small)) ||
2819 strToDbl(fl_get_input(dialog_->input_small)) >
2820 strToDbl(fl_get_input(dialog_->input_normal)) ||
2821 strToDbl(fl_get_input(dialog_->input_normal)) >
2822 strToDbl(fl_get_input(dialog_->input_large)) ||
2823 strToDbl(fl_get_input(dialog_->input_large)) >
2824 strToDbl(fl_get_input(dialog_->input_larger)) ||
2825 strToDbl(fl_get_input(dialog_->input_larger)) >
2826 strToDbl(fl_get_input(dialog_->input_largest)) ||
2827 strToDbl(fl_get_input(dialog_->input_largest)) >
2828 strToDbl(fl_get_input(dialog_->input_huge)) ||
2829 strToDbl(fl_get_input(dialog_->input_huge)) >
2830 strToDbl(fl_get_input(dialog_->input_huger))) {
2833 str = _("Fonts must be input in the order Tiny > Smallest > Smaller > Small > Normal > Large > Larger > Largest > Huge > Huger.");
2837 parent_.postWarning(str);
2843 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2845 fl_set_input(dialog_->input_roman,
2846 makeFontName(rc.roman_font_name,
2847 rc.roman_font_foundry).c_str());
2848 fl_set_input(dialog_->input_sans,
2849 makeFontName(rc.sans_font_name,
2850 rc.sans_font_foundry).c_str());
2851 fl_set_input(dialog_->input_typewriter,
2852 makeFontName(rc.typewriter_font_name,
2853 rc.typewriter_font_foundry).c_str());
2854 fl_set_input(dialog_->input_screen_encoding,
2855 rc.font_norm.c_str());
2856 fl_set_button(dialog_->check_scalable,
2857 rc.use_scalable_fonts);
2858 fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2859 fl_set_counter_value(dialog_->counter_dpi, rc.dpi);
2860 fl_set_input(dialog_->input_tiny,
2861 tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2862 fl_set_input(dialog_->input_script,
2863 tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2864 fl_set_input(dialog_->input_footnote,
2865 tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2866 fl_set_input(dialog_->input_small,
2867 tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2868 fl_set_input(dialog_->input_normal,
2869 tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2870 fl_set_input(dialog_->input_large,
2871 tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2872 fl_set_input(dialog_->input_larger,
2873 tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2874 fl_set_input(dialog_->input_largest,
2875 tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2876 fl_set_input(dialog_->input_huge,
2877 tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2878 fl_set_input(dialog_->input_huger,
2879 tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2884 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2889 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2891 return dialog_.get();
2895 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2897 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2898 choice = trim(choice);
2900 rc.isp_command = choice;
2903 // If spell checker == "none", all other input set to off.
2904 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2905 rc.isp_use_alt_lang = false;
2906 rc.isp_alt_lang.erase();
2908 rc.isp_use_esc_chars = false;
2909 rc.isp_esc_chars.erase();
2911 rc.isp_use_pers_dict = false;
2912 rc.isp_pers_dict.erase();
2914 rc.isp_accept_compound = false;
2915 rc.isp_use_input_encoding = false;
2918 int button = fl_get_button(dialog_->check_alt_lang);
2919 choice = fl_get_input(dialog_->input_alt_lang);
2920 if (button && choice.empty()) button = 0;
2921 if (!button) choice.erase();
2923 rc.isp_use_alt_lang = static_cast<bool>(button);
2924 rc.isp_alt_lang = choice;
2926 button = fl_get_button(dialog_->check_escape_chars);
2927 choice = fl_get_input(dialog_->input_escape_chars);
2928 if (button && choice.empty()) button = 0;
2929 if (!button) choice.erase();
2931 rc.isp_use_esc_chars = static_cast<bool>(button);
2932 rc.isp_esc_chars = choice;
2934 button = fl_get_button(dialog_->check_personal_dict);
2935 choice = fl_get_input(dialog_->input_personal_dict);
2936 if (button && choice.empty()) button = 0;
2937 if (!button) choice.erase();
2939 rc.isp_use_pers_dict = static_cast<bool>(button);
2940 rc.isp_pers_dict = choice;
2942 button = fl_get_button(dialog_->check_compound_words);
2943 rc.isp_accept_compound = static_cast<bool>(button);
2945 button = fl_get_button(dialog_->check_input_enc);
2946 rc.isp_use_input_encoding = static_cast<bool>(button);
2957 void FormPreferences::SpellOptions::build()
2959 dialog_.reset(build_preferences_spelloptions(&parent_));
2961 fl_addto_choice(dialog_->choice_spell_command,
2962 _(" ispell | aspell ").c_str());
2963 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2964 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2965 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2967 // set up the feedback mechanism
2968 setPrehandler(dialog_->choice_spell_command);
2969 setPrehandler(dialog_->check_alt_lang);
2970 setPrehandler(dialog_->input_alt_lang);
2971 setPrehandler(dialog_->check_escape_chars);
2972 setPrehandler(dialog_->input_escape_chars);
2973 setPrehandler(dialog_->check_personal_dict);
2974 setPrehandler(dialog_->input_personal_dict);
2975 setPrehandler(dialog_->button_personal_dict);
2976 setPrehandler(dialog_->check_compound_words);
2977 setPrehandler(dialog_->check_input_enc);
2982 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2984 if (ob == dialog_->choice_spell_command)
2985 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2986 if (ob == dialog_->check_alt_lang)
2987 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2988 if (ob == dialog_->input_alt_lang)
2989 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2990 if (ob == dialog_->check_escape_chars)
2991 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2992 if (ob == dialog_->input_escape_chars)
2993 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2994 if (ob == dialog_->check_personal_dict)
2995 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2996 if (ob == dialog_->input_personal_dict)
2997 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2998 if (ob == dialog_->check_compound_words)
2999 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
3000 if (ob == dialog_->check_input_enc)
3001 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
3006 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
3008 // !ob if function is called from updateSpellOptions() to de/activate
3010 // otherwise the function is called by an xforms CB via input().
3013 // If spell checker == "none", disable all input.
3014 if (!ob || ob == dialog_->choice_spell_command) {
3015 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
3016 fl_deactivate_object(dialog_->check_alt_lang);
3017 fl_deactivate_object(dialog_->input_alt_lang);
3018 fl_deactivate_object(dialog_->check_escape_chars);
3019 fl_deactivate_object(dialog_->input_escape_chars);
3020 fl_deactivate_object(dialog_->check_personal_dict);
3021 fl_deactivate_object(dialog_->input_personal_dict);
3022 fl_deactivate_object(dialog_->check_compound_words);
3023 fl_deactivate_object(dialog_->check_input_enc);
3026 fl_activate_object(dialog_->check_alt_lang);
3027 fl_activate_object(dialog_->check_escape_chars);
3028 fl_activate_object(dialog_->check_personal_dict);
3029 fl_activate_object(dialog_->check_compound_words);
3030 fl_activate_object(dialog_->check_input_enc);
3035 if (!ob || ob == dialog_->check_alt_lang) {
3036 bool const enable = fl_get_button(dialog_->check_alt_lang);
3037 setEnabled(dialog_->input_alt_lang, enable);
3040 if (!ob || ob == dialog_->check_escape_chars) {
3041 bool const enable = fl_get_button(dialog_->check_escape_chars);
3042 setEnabled(dialog_->input_escape_chars, enable);
3045 if (!ob || ob == dialog_->check_personal_dict) {
3046 bool const enable = fl_get_button(dialog_->check_personal_dict);
3047 setEnabled(dialog_->input_personal_dict, enable);
3050 if (ob == dialog_->button_personal_dict) {
3051 string f = parent_.controller().browsedict(
3052 fl_get_input(dialog_->input_personal_dict));
3053 fl_set_input(dialog_->input_personal_dict, f.c_str());
3056 return true; // All input is valid!
3060 void FormPreferences::SpellOptions::update(LyXRC const & rc)
3064 if (rc.isp_command == "none")
3066 else if (rc.isp_command == "ispell")
3068 else if (rc.isp_command == "aspell")
3071 if (rc.isp_command == "ispell")
3073 else if (rc.isp_command == "aspell")
3076 fl_set_choice(dialog_->choice_spell_command, choice);
3079 if (rc.isp_use_alt_lang)
3080 str = rc.isp_alt_lang;
3082 fl_set_button(dialog_->check_alt_lang,
3083 rc.isp_use_alt_lang);
3084 fl_set_input(dialog_->input_alt_lang, str.c_str());
3087 if (rc.isp_use_esc_chars)
3088 str = rc.isp_esc_chars;
3090 fl_set_button(dialog_->check_escape_chars,
3091 rc.isp_use_esc_chars);
3092 fl_set_input(dialog_->input_escape_chars, str.c_str());
3095 if (rc.isp_use_pers_dict)
3096 str = rc.isp_pers_dict;
3098 fl_set_button(dialog_->check_personal_dict,
3099 rc.isp_use_pers_dict);
3100 fl_set_input(dialog_->input_personal_dict, str.c_str());
3102 fl_set_button(dialog_->check_compound_words,
3103 rc.isp_accept_compound);
3104 fl_set_button(dialog_->check_input_enc,
3105 rc.isp_use_input_encoding);
3107 // Activate/Deactivate the input fields dependent on the state of the
3112 } // namespace frontend