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), inputs_misc_(*this),
97 formats_(*this), interface_(*this), language_(*this),
98 lnf_misc_(*this), identity_(*this), outputs_misc_(*this),
99 paths_(*this), printer_(*this), screen_fonts_(*this),
105 void FormPreferences::redraw()
107 if (!(form() && form()->visible))
109 fl_redraw_form(form());
111 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
112 if (!(form2 && form2->visible))
114 fl_redraw_form(form2);
117 if (form2 == converters_tab_->form)
118 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
120 else if (form2 == look_n_feel_tab_->form)
121 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
123 else if (form2 == inputs_tab_->form)
124 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
126 else if (form2 == outputs_tab_->form)
127 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
129 else if (form2 == lang_opts_tab_->form)
130 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
132 if (form3 && form3->visible)
133 fl_redraw_form(form3);
137 void FormPreferences::hide()
139 // We need to hide the active tabfolder otherwise we get a
140 // BadDrawable error from X window and LyX crashes without saving.
141 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
142 if (inner_form && inner_form->visible)
143 fl_hide_form(inner_form);
144 FormDialogView::hide();
148 void FormPreferences::build()
150 dialog_.reset(build_preferences(this));
152 // Manage the restore, save, apply and cancel/close buttons
153 bcview().setOK(dialog_->button_ok);
154 bcview().setApply(dialog_->button_apply);
155 bcview().setCancel(dialog_->button_close);
156 bcview().setRestore(dialog_->button_restore);
158 // Allow the base class to control messages
159 setMessageWidget(dialog_->text_warning);
161 // build the tab folders
162 converters_tab_.reset(build_preferences_inner_tab(this));
163 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
164 inputs_tab_.reset(build_preferences_inner_tab(this));
165 outputs_tab_.reset(build_preferences_inner_tab(this));
166 lang_opts_tab_.reset(build_preferences_inner_tab(this));
168 // build actual tabfolder contents
169 // 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);
250 // Paths should probably go in a few inner_tab called Files
251 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
253 paths_.dialog()->form);
254 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
256 inputs_misc_.dialog()->form);
258 // then building outputs
259 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
260 _("Printer").c_str(),
261 printer_.dialog()->form);
262 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
264 outputs_misc_.dialog()->form);
266 // then building usage
267 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
268 _("Spell checker").c_str(),
269 spelloptions_.dialog()->form);
270 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
271 _("Language").c_str(),
272 language_.dialog()->form);
276 void FormPreferences::apply()
278 // set the new lyxrc entries
279 // many of these need to trigger other functions when the assignment
280 // is made. For example, screen zoom and font types. These could be
281 // handled either by signals/slots in lyxrc or just directly call the
282 // associated functions here.
283 // There are other problems with this scheme. We really should check
284 // what we copy to make sure that it really is necessary to do things
285 // like update the screen fonts because that flushes the textcache
286 // and other stuff which may cost us a lot on slower/high-load
289 LyXRC & rc(controller().rc());
292 inputs_misc_.apply(rc);
293 interface_.apply(rc);
297 outputs_misc_.apply(rc);
300 screen_fonts_.apply(rc);
301 spelloptions_.apply(rc);
303 // The "Save" button has been pressed.
304 if (dialog().isClosing() && colors_.modifiedXformsPrefs) {
305 string const filename =
306 AddName(user_lyxdir(), "preferences.xform");
307 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
312 string const FormPreferences::getFeedback(FL_OBJECT * ob)
316 if (ob->form->fdui == colors_.dialog())
317 return colors_.feedback(ob);
318 if (ob->form->fdui == converters_.dialog())
319 return converters_.feedback(ob);
320 if (ob->form->fdui == formats_.dialog())
321 return formats_.feedback(ob);
322 if (ob->form->fdui == inputs_misc_.dialog())
323 return inputs_misc_.feedback(ob);
324 if (ob->form->fdui == interface_.dialog())
325 return interface_.feedback(ob);
326 if (ob->form->fdui == language_.dialog())
327 return language_.feedback(ob);
328 if (ob->form->fdui == lnf_misc_.dialog())
329 return lnf_misc_.feedback(ob);
330 if (ob->form->fdui == outputs_misc_.dialog())
331 return outputs_misc_.feedback(ob);
332 if (ob->form->fdui == paths_.dialog())
333 return paths_.feedback(ob);
334 if (ob->form->fdui == printer_.dialog())
335 return printer_.feedback(ob);
336 if (ob->form->fdui == screen_fonts_.dialog())
337 return screen_fonts_.feedback(ob);
338 if (ob->form->fdui == spelloptions_.dialog())
339 return spelloptions_.feedback(ob);
345 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
351 // whatever checks you need to ensure the user hasn't entered
352 // some totally ridiculous value somewhere. Change activate to suit.
353 // comments before each test describe what is _valid_
355 if (ob->form->fdui == colors_.dialog()) {
357 } else if (ob->form->fdui == converters_.dialog()) {
358 valid = converters_.input(ob);
359 } else if (ob->form->fdui == formats_.dialog()) {
360 valid = formats_.input(ob);
361 } else if (ob->form->fdui == interface_.dialog()) {
362 valid = interface_.input(ob);
363 } else if (ob->form->fdui == language_.dialog()) {
364 valid = language_.input(ob);
365 } else if (ob->form->fdui == paths_.dialog()) {
366 valid = paths_.input(ob);
367 } else if (ob->form->fdui == screen_fonts_.dialog()) {
368 valid = screen_fonts_.input();
369 } else if (ob->form->fdui == spelloptions_.dialog()) {
370 valid = spelloptions_.input(ob);
373 return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
377 void FormPreferences::update()
379 if (!dialog_.get()) return;
381 LyXRC const & rc(controller().rc());
383 // read lyxrc entries
385 formats_.update(); // Must be before converters_.update()
386 converters_.update();
387 inputs_misc_.update(rc);
388 interface_.update(rc);
389 language_.update(rc);
390 lnf_misc_.update(rc);
391 identity_.update(rc);
392 outputs_misc_.update(rc);
395 screen_fonts_.update(rc);
396 spelloptions_.update(rc);
400 FormPreferences::Colors::Colors(FormPreferences & p)
401 : modifiedXformsPrefs(false), parent_(p)
405 FD_preferences_colors const * FormPreferences::Colors::dialog()
407 return dialog_.get();
411 void FormPreferences::Colors::apply()
413 bool modifiedText = false;
414 bool modifiedBackground = false;
416 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
417 cit != xformsColorDB.end(); ++cit) {
419 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
420 if (col != cit->color()) {
421 modifiedXformsPrefs = true;
422 if (cit->colorID == FL_BLACK)
424 if (cit->colorID == FL_COL1)
425 modifiedBackground = true;
429 if (modifiedXformsPrefs) {
430 for (vector<XformsColor>::const_iterator cit =
431 xformsColorDB.begin();
432 cit != xformsColorDB.end(); ++cit) {
433 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
435 if (modifiedText && cit->colorID == FL_BLACK) {
436 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
439 if (modifiedBackground && cit->colorID == FL_COL1) {
440 AdjustVal(FL_MCOL, FL_COL1, 0.1);
441 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
442 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
444 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
445 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
448 if (cit->colorID == GUI_COLOR_CURSOR) {
449 fl_mapcolor(GUI_COLOR_CURSOR,
450 cit->r, cit->g, cit->b);
451 setCursorColor(GUI_COLOR_CURSOR);
454 parent_.controller().redrawGUI();
457 // Now do the same for the LyX LColors...
458 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
459 cit != lyxColorDB.end(); ++cit) {
460 LColor::color lc = lcolor.getFromLyXName(cit->lyxname);
461 if (lc == LColor::inherit) continue;
463 // Create a valid X11 name of the form "#rrggbb"
464 string const hexname = X11hexname(cit->color());
466 if (lcolor.getX11Name(lc) != hexname) {
468 << "FormPreferences::Colors::apply: "
469 << "resetting LColor " << lcolor.getGUIName(lc)
470 << " from \"" << lcolor.getX11Name(lc)
471 << "\" to \"" << hexname << "\"."
474 parent_.controller().setColor(lc, hexname);
480 void FormPreferences::Colors::build()
482 picker_.reset(new FormColorpicker);
483 dialog_.reset(build_preferences_colors(&parent_));
485 fl_set_object_color(dialog_->button_color,
486 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
488 // set up the feedback mechanism
489 setPrehandler(dialog_->browser_lyx_objs);
490 setPrehandler(dialog_->button_color);
491 setPrehandler(dialog_->button_modify);
496 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
498 if (ob == dialog_->browser_lyx_objs)
499 return _("LyX objects that can be assigned a color.");
501 if (ob == dialog_->button_modify)
502 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
508 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
510 if (ob == dialog_->browser_lyx_objs) {
513 } else if (ob == dialog_->button_modify) {
519 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
523 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
527 hsv.v = min(1.0, max(0.0, hsv.v));
530 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
534 void FormPreferences::Colors::InputBrowserLyX() const
536 vector<NamedColor>::size_type const selLyX =
537 fl_get_browser(dialog_->browser_lyx_objs);
538 if (selLyX < 1) return;
540 // Is the choice an Xforms color...
543 if (selLyX - 1 < xformsColorDB.size()) {
544 vector<XformsColor>::size_type const i = selLyX - 1;
545 col = xformsColorDB[i].color();
547 // or a LyX Logical color?
549 vector<NamedColor>::size_type const i = selLyX - 1 -
550 xformsColorDB.size();
551 col = lyxColorDB[i].color();
554 fl_freeze_form(dialog_->form);
556 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
557 fl_redraw_object(dialog_->button_color);
559 fl_unfreeze_form(dialog_->form);
563 void FormPreferences::Colors::LoadBrowserLyX()
565 if (!dialog_->browser_lyx_objs->visible)
568 // First, define the modifiable xforms colors
569 xformsColorDB.clear();
572 xcol.lyxname = "GUI background";
573 xcol.guiname = _("GUI background");
574 xcol.colorID = FL_COL1;
575 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
577 xformsColorDB.push_back(xcol);
579 xcol.lyxname = "GUI text";
580 xcol.guiname = _("GUI text");
581 xcol.colorID = FL_BLACK;
582 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
584 xformsColorDB.push_back(xcol);
586 xcol.lyxname = "GUI selection";
587 xcol.guiname = _("GUI selection");
588 xcol.colorID = FL_YELLOW;
589 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
591 xformsColorDB.push_back(xcol);
593 xcol.lyxname = "GUI pointer";
594 xcol.guiname = _("GUI pointer");
595 xcol.colorID = GUI_COLOR_CURSOR;
596 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
598 xformsColorDB.push_back(xcol);
600 // Now create the the LyX LColors database
602 for (int i=0; i<LColor::ignore; ++i) {
603 LColor::color lc = static_cast<LColor::color>(i);
604 if (lc == LColor::none
605 || lc == LColor::black
606 || lc == LColor::white
608 || lc == LColor::green
609 || lc == LColor::blue
610 || lc == LColor::cyan
611 || lc == LColor::magenta
612 || lc == LColor::yellow
613 || lc == LColor::inherit
614 || lc == LColor::ignore) continue;
617 bool const success = getRGBColor(lc, col.r, col.g, col.b);
619 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
620 << "LColor " << lcolor.getLyXName(lc)
621 << ": X can't find color \""
622 << lcolor.getX11Name(lc)
623 << "\". Set to \"black\"!" << endl;
625 string const arg = lcolor.getLyXName(lc) + " black";
626 parent_.controller().setColor(lc, "black");
630 // Create a valid X11 name of the form "#rrggbb" and change the
631 // LColor X11name to this. Don't want to trigger a redraw,
632 // as we're just changing the name not the RGB values.
633 // Also reset the system_lcolor names, so that we don't output
634 // unnecessary changes.
635 string const hexname = X11hexname(col);
637 if (lcolor.getX11Name(lc) != hexname) {
638 lcolor.setColor(lc, hexname);
639 system_lcolor.setColor(lc, hexname);
642 // Finally, push the color onto the database
643 NamedColor ncol(lcolor.getLyXName(lc), lcolor.getGUIName(lc), col);
644 lyxColorDB.push_back(ncol);
647 // Now construct the browser
648 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
649 fl_freeze_form(dialog_->form);
650 fl_clear_browser(colbr);
651 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
652 cit != xformsColorDB.end(); ++cit) {
653 fl_addto_browser(colbr, cit->guiname.c_str());
655 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
656 cit != lyxColorDB.end(); ++cit) {
657 fl_addto_browser(colbr, cit->guiname.c_str());
660 // just to be safe...
661 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
662 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
663 fl_unfreeze_form(dialog_->form);
669 void FormPreferences::Colors::Modify()
671 vector<NamedColor>::size_type const selLyX =
672 fl_get_browser(dialog_->browser_lyx_objs);
677 fl_getmcolor(GUI_COLOR_CHOICE, &before.r, &before.g, &before.b);
679 RGBColor col = picker_->requestColor(before);
683 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
684 fl_redraw_object(dialog_->button_color);
686 // Is the choice an Xforms color...
687 if (selLyX - 1 < xformsColorDB.size()) {
688 vector<XformsColor>::size_type const i = selLyX - 1;
689 xformsColorDB[i].r = col.r;
690 xformsColorDB[i].g = col.g;
691 xformsColorDB[i].b = col.b;
693 // or a LyX Logical color?
695 vector<NamedColor>::size_type const i = selLyX - 1 -
696 xformsColorDB.size();
697 lyxColorDB[i].r = col.r;
698 lyxColorDB[i].g = col.g;
699 lyxColorDB[i].b = col.b;
704 FormPreferences::Converters::Converters(FormPreferences & p)
709 FD_preferences_converters const * FormPreferences::Converters::dialog()
711 return dialog_.get();
715 ::Converters & FormPreferences::Converters::converters()
717 return parent_.controller().converters();
721 ::Formats & FormPreferences::Converters::formats()
723 return parent_.controller().formats();
727 void FormPreferences::Converters::build()
729 dialog_.reset(build_preferences_converters(&parent_));
731 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
732 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
734 // set up the feedback mechanism
735 setPrehandler(dialog_->browser_all);
736 setPrehandler(dialog_->button_delete);
737 setPrehandler(dialog_->button_add);
738 setPrehandler(dialog_->input_converter);
739 setPrehandler(dialog_->choice_from);
740 setPrehandler(dialog_->choice_to);
741 setPrehandler(dialog_->input_flags);
746 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
748 if (ob == dialog_->browser_all)
749 return _("All explicitly defined converters for LyX");
751 if (ob == dialog_->choice_from)
752 return _("Convert \"from\" this format");
754 if (ob == dialog_->choice_to)
755 return _("Convert \"to\" this format");
757 if (ob == dialog_->input_converter)
758 return _("The conversion command. $$i is the input file name, "
759 "$$b is the file name without its extension and $$o is "
760 "the name of the output file. $$s can be used as path to "
761 "LyX's own collection of conversion scripts.");
763 if (ob == dialog_->input_flags)
764 return _("Extra information for the Converter class, whether and "
765 "how to parse the result, and various other things.");
767 if (ob == dialog_->button_delete)
768 return _("Remove the current converter from the list of available "
769 "converters. Note: you must then \"Apply\" the change.");
771 if (ob == dialog_->button_add) {
772 if (string(ob->label) == _("Add"))
773 return _("Add the current converter to the list of available "
774 "converters. Note: you must then \"Apply\" the change.");
776 return _("Modify the contents of the current converter. "
777 "Note: you must then \"Apply\" the change.");
784 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
786 if (ob == dialog_->browser_all)
789 if (ob == dialog_->choice_from
790 || ob == dialog_->choice_to
791 || ob == dialog_->input_converter
792 || ob == dialog_->input_flags)
795 if (ob == dialog_->button_add)
798 if (ob == dialog_->button_delete)
805 void FormPreferences::Converters::update()
811 void FormPreferences::Converters::UpdateBrowser()
815 fl_freeze_form(dialog_->form);
816 fl_clear_browser(dialog_->browser_all);
817 for (::Converters::const_iterator cit = converters().begin();
818 cit != converters().end(); ++cit) {
819 string const name = cit->From->prettyname() + " -> "
820 + cit->To->prettyname();
821 fl_addto_browser(dialog_->browser_all, name.c_str());
824 fl_unfreeze_form(dialog_->form);
828 bool FormPreferences::Converters::Add()
830 string const from = GetFrom();
831 string const to = GetTo();
832 string const command = fl_get_input(dialog_->input_converter);
833 string const flags = fl_get_input(dialog_->input_flags);
835 Converter const * old = converters().getConverter(from, to);
836 converters().add(from, to, command, flags);
838 converters().updateLast(formats());
841 setEnabled(dialog_->button_add, false);
847 bool FormPreferences::Converters::Browser()
849 int const i = fl_get_browser(dialog_->browser_all);
850 if (i <= 0) return false;
852 fl_freeze_form(dialog_->form);
854 Converter const & c = converters().get(i - 1);
855 int j = formats().getNumber(c.from);
857 fl_set_choice(dialog_->choice_from, j + 1);
859 j = formats().getNumber(c.to);
861 fl_set_choice(dialog_->choice_to, j + 1);
863 fl_set_input(dialog_->input_converter, c.command.c_str());
864 fl_set_input(dialog_->input_flags, c.flags.c_str());
866 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
867 fl_set_button_shortcut(dialog_->button_add,
868 scex(_("Modify|#M")).c_str(), 1);
870 setEnabled(dialog_->button_add, false);
871 setEnabled(dialog_->button_delete, true);
873 fl_unfreeze_form(dialog_->form);
878 bool FormPreferences::Converters::erase()
880 string const from = GetFrom();
881 string const to = GetTo();
883 converters().erase(from, to);
889 bool FormPreferences::Converters::Input()
891 string const from = GetFrom();
892 string const to = GetTo();
893 int const sel = converters().getNumber(from, to);
895 fl_freeze_form(dialog_->form);
898 fl_set_object_label(dialog_->button_add,
899 idex(_("Add|#A")).c_str());
900 fl_set_button_shortcut(dialog_->button_add,
901 scex(_("Add|#A")).c_str(), 1);
903 fl_deselect_browser(dialog_->browser_all);
904 setEnabled(dialog_->button_delete, false);
907 fl_set_object_label(dialog_->button_add,
908 idex(_("Modify|#M")).c_str());
909 fl_set_button_shortcut(dialog_->button_add,
910 scex(_("Modify|#M")).c_str(), 1);
912 int top = max(sel-5, 0);
913 fl_set_browser_topline(dialog_->browser_all, top);
914 fl_select_browser_line(dialog_->browser_all, sel+1);
915 setEnabled(dialog_->button_delete, true);
918 string const command = rtrim(fl_get_input(dialog_->input_converter));
919 bool const enable = !(command.empty() || from == to);
920 setEnabled(dialog_->button_add, enable);
922 fl_unfreeze_form(dialog_->form);
927 string const FormPreferences::Converters::GetFrom()
929 ::Formats::FormatList::size_type const i =
930 fl_get_choice(dialog_->choice_from);
932 if (i > 0 && i <= formats().size())
933 return formats().get(i - 1).name();
935 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
940 string const FormPreferences::Converters::GetTo()
942 ::Formats::FormatList::size_type const i =
943 fl_get_choice(dialog_->choice_to);
945 if (i > 0 && i <= formats().size())
946 return formats().get(i - 1).name();
948 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
953 void FormPreferences::Converters::UpdateChoices()
956 for (::Formats::const_iterator cit = formats().begin();
957 cit != formats().end(); ++cit) {
962 choice += cit->prettyname();
966 fl_clear_choice(dialog_->choice_from);
967 fl_addto_choice(dialog_->choice_from, choice.c_str());
969 fl_clear_choice(dialog_->choice_to);
970 fl_addto_choice(dialog_->choice_to, choice.c_str());
974 FormPreferences::Formats::Formats(FormPreferences & p)
979 FD_preferences_formats const * FormPreferences::Formats::dialog()
981 return dialog_.get();
985 ::Converters & FormPreferences::Formats::converters()
987 return parent_.controller().converters();
991 ::Formats & FormPreferences::Formats::formats()
993 return parent_.controller().formats();
997 void FormPreferences::Formats::build()
999 dialog_.reset(build_preferences_formats(&parent_));
1001 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1002 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1003 fl_set_input_return(dialog_->input_editor, FL_RETURN_CHANGED);
1004 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1005 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1006 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1008 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1010 // set up the feedback mechanism
1011 setPrehandler(dialog_->browser_all);
1012 setPrehandler(dialog_->input_format);
1013 setPrehandler(dialog_->input_gui_name);
1014 setPrehandler(dialog_->button_delete);
1015 setPrehandler(dialog_->button_add);
1016 setPrehandler(dialog_->input_extension);
1017 setPrehandler(dialog_->input_viewer);
1018 setPrehandler(dialog_->input_editor);
1019 setPrehandler(dialog_->input_shrtcut);
1024 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1026 if (ob == dialog_->browser_all)
1027 return _("All the currently defined formats known to LyX.");
1029 if (ob == dialog_->input_format)
1030 return _("The format identifier.");
1032 if (ob == dialog_->input_gui_name)
1033 return _("The format name as it will appear in the menus.");
1035 if (ob == dialog_->input_shrtcut)
1036 return _("The keyboard accelerator. Use a letter in the GUI name. "
1039 if (ob == dialog_->input_extension)
1040 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1042 if (ob == dialog_->input_viewer)
1043 return _("The command used to launch the viewer application.");
1045 if (ob == dialog_->input_editor)
1046 return _("The command used to launch the editor application.");
1048 if (ob == dialog_->button_delete)
1049 return _("Remove the current format from the list of available "
1050 "formats. Note: you must then \"Apply\" the change.");
1052 if (ob == dialog_->button_add) {
1053 if (string(ob->label) == _("Add"))
1054 return _("Add the current format to the list of available "
1055 "formats. Note: you must then \"Apply\" the change.");
1057 return _("Modify the contents of the current format. Note: "
1058 "you must then \"Apply\" the change.");
1065 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1067 if (ob == dialog_->browser_all)
1070 if (ob == dialog_->input_format
1071 || ob == dialog_->input_gui_name
1072 || ob == dialog_->input_shrtcut
1073 || ob == dialog_->input_extension
1074 || ob == dialog_->input_viewer
1075 || ob == dialog_->input_editor)
1078 if (ob == dialog_->button_add)
1081 if (ob == dialog_->button_delete)
1088 void FormPreferences::Formats::update()
1094 void FormPreferences::Formats::UpdateBrowser()
1098 fl_freeze_form(dialog_->form);
1099 fl_deselect_browser(dialog_->browser_all);
1100 fl_clear_browser(dialog_->browser_all);
1101 for (::Formats::const_iterator cit = formats().begin();
1102 cit != formats().end(); ++cit)
1103 fl_addto_browser(dialog_->browser_all,
1104 cit->prettyname().c_str());
1107 fl_unfreeze_form(dialog_->form);
1109 // Mustn't forget to update the Formats available to the converters_
1110 parent_.converters_.UpdateChoices();
1111 converters().update(formats());
1115 bool FormPreferences::Formats::Add()
1117 string const name = fl_get_input(dialog_->input_format);
1118 string const prettyname = fl_get_input(dialog_->input_gui_name);
1119 string const extension = fl_get_input(dialog_->input_extension);
1120 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1121 string const viewer = fl_get_input(dialog_->input_viewer);
1122 string const editor = fl_get_input(dialog_->input_editor);
1124 Format const * old = formats().getFormat(name);
1125 string const old_prettyname = old ? old->prettyname() : string();
1126 formats().add(name, extension, prettyname, shortcut, viewer, editor);
1127 if (!old || prettyname != old_prettyname) {
1130 parent_.converters_.UpdateBrowser();
1132 setEnabled(dialog_->button_add, false);
1138 bool FormPreferences::Formats::Browser()
1140 int const i = fl_get_browser(dialog_->browser_all);
1144 fl_freeze_form(dialog_->form);
1146 Format const & f = formats().get(i - 1);
1148 fl_set_input(dialog_->input_format, f.name().c_str());
1149 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1150 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1151 fl_set_input(dialog_->input_extension, f.extension().c_str());
1152 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1153 fl_set_input(dialog_->input_editor, f.editor().c_str());
1155 fl_set_object_label(dialog_->button_add,
1156 idex(_("Modify|#M")).c_str());
1157 fl_set_button_shortcut(dialog_->button_add,
1158 scex(_("Modify|#M")).c_str(), 1);
1160 setEnabled(dialog_->button_add, false);
1161 setEnabled(dialog_->button_delete, true);
1163 fl_unfreeze_form(dialog_->form);
1168 bool FormPreferences::Formats::erase()
1170 string const name = fl_get_input(dialog_->input_format);
1172 if (converters().formatIsUsed(name)) {
1173 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1174 "Remove the converter first."));
1175 setEnabled(dialog_->button_delete, false);
1179 formats().erase(name);
1185 bool FormPreferences::Formats::Input()
1187 string const name = fl_get_input(dialog_->input_format);
1188 int const sel = formats().getNumber(name);
1189 fl_freeze_form(dialog_->form);
1192 fl_set_object_label(dialog_->button_add,
1193 idex(_("Add|#A")).c_str());
1194 fl_set_button_shortcut(dialog_->button_add,
1195 scex(_("Add|#A")).c_str(), 1);
1197 fl_deselect_browser(dialog_->browser_all);
1198 setEnabled(dialog_->button_delete, false);
1201 fl_set_object_label(dialog_->button_add,
1202 idex(_("Modify|#M")).c_str());
1203 fl_set_button_shortcut(dialog_->button_add,
1204 scex(_("Modify|#M")).c_str(), 1);
1206 int const top = max(sel-5, 0);
1207 fl_set_browser_topline(dialog_->browser_all, top);
1208 fl_select_browser_line(dialog_->browser_all, sel+1);
1210 setEnabled(dialog_->button_add, true);
1211 setEnabled(dialog_->button_delete, true);
1214 string const prettyname = fl_get_input(dialog_->input_gui_name);
1215 bool const enable = !(name.empty() || prettyname.empty());
1216 setEnabled(dialog_->button_add, enable);
1218 fl_unfreeze_form(dialog_->form);
1223 FormPreferences::Identity::Identity(FormPreferences & p)
1228 FD_preferences_identity const * FormPreferences::Identity::dialog()
1230 return dialog_.get();
1234 void FormPreferences::Identity::apply(LyXRC & rc) const
1236 rc.user_name = fl_get_input(dialog_->input_user_name);
1237 rc.user_email = fl_get_input(dialog_->input_user_email);
1241 void FormPreferences::Identity::build()
1243 dialog_.reset(build_preferences_identity(&parent_));
1244 fl_set_input_return(dialog_->input_user_name, FL_RETURN_CHANGED);
1245 fl_set_input_return(dialog_->input_user_email, FL_RETURN_CHANGED);
1249 void FormPreferences::Identity::update(LyXRC const & rc)
1251 fl_set_input(dialog_->input_user_name, rc.user_name.c_str());
1252 fl_set_input(dialog_->input_user_email, rc.user_email.c_str());
1256 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1261 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1263 return dialog_.get();
1267 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1269 rc.date_insert_format =
1270 fl_get_input(dialog_->input_date_format);
1274 void FormPreferences::InputsMisc::build()
1276 dialog_.reset(build_preferences_inputs_misc(&parent_));
1278 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1280 // set up the feedback mechanism
1281 setPrehandler(dialog_->input_date_format);
1286 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1288 if (ob == dialog_->input_date_format)
1289 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1294 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1296 fl_set_input(dialog_->input_date_format,
1297 rc.date_insert_format.c_str());
1301 FormPreferences::Interface::Interface(FormPreferences & p)
1306 FD_preferences_interface const * FormPreferences::Interface::dialog()
1308 return dialog_.get();
1312 void FormPreferences::Interface::apply(LyXRC & rc) const
1314 rc.popup_normal_font =
1315 fl_get_input(dialog_->input_popup_normal_font);
1316 rc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1317 rc.popup_font_encoding =
1318 fl_get_input(dialog_->input_popup_font_encoding);
1319 rc.bind_file = fl_get_input(dialog_->input_bind_file);
1320 rc.ui_file = fl_get_input(dialog_->input_ui_file);
1324 void FormPreferences::Interface::build()
1326 dialog_.reset(build_preferences_interface(&parent_));
1328 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1329 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1330 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1331 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1332 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1334 // set up the feedback mechanism
1335 setPrehandler(dialog_->input_popup_normal_font);
1336 setPrehandler(dialog_->input_popup_bold_font);
1337 setPrehandler(dialog_->input_popup_font_encoding);
1338 setPrehandler(dialog_->input_bind_file);
1339 setPrehandler(dialog_->button_bind_file_browse);
1340 setPrehandler(dialog_->input_ui_file);
1341 setPrehandler(dialog_->button_ui_file_browse);
1346 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1348 if (ob == dialog_->input_popup_normal_font)
1349 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1350 if (ob == dialog_->input_popup_bold_font)
1351 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1352 if (ob == dialog_->input_popup_font_encoding)
1353 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1354 if (ob == dialog_->input_bind_file)
1355 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1356 if (ob == dialog_->input_ui_file)
1357 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1362 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1364 if (ob == dialog_->button_bind_file_browse) {
1365 string f = parent_.controller().browsebind(
1366 fl_get_input(dialog_->input_bind_file));
1368 fl_set_input(dialog_->input_bind_file, f.c_str());
1369 } else if (ob == dialog_->button_ui_file_browse) {
1370 string f = parent_.controller().browseUI(
1371 fl_get_input(dialog_->input_ui_file));
1373 fl_set_input(dialog_->input_ui_file, f.c_str());
1380 void FormPreferences::Interface::update(LyXRC const & rc)
1382 fl_set_input(dialog_->input_popup_normal_font,
1383 rc.popup_normal_font.c_str());
1384 fl_set_input(dialog_->input_popup_bold_font,
1385 rc.popup_bold_font.c_str());
1386 fl_set_input(dialog_->input_popup_font_encoding,
1387 rc.popup_font_encoding.c_str());
1388 fl_set_input(dialog_->input_bind_file,
1389 rc.bind_file.c_str());
1390 fl_set_input(dialog_->input_ui_file,
1391 rc.ui_file.c_str());
1395 FormPreferences::Language::Language(FormPreferences & p)
1400 FD_preferences_language const * FormPreferences::Language::dialog()
1402 return dialog_.get();
1406 void FormPreferences::Language::apply(LyXRC & rc)
1408 int const pos = fl_get_combox(dialog_->combox_default_lang);
1409 rc.default_language = lang_[pos-1];
1411 int button = fl_get_button(dialog_->check_use_kbmap);
1412 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1413 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1415 button = !(name_1.empty() && name_2.empty());
1416 rc.use_kbmap = static_cast<bool>(button);
1419 rc.primary_kbmap = name_1;
1420 rc.secondary_kbmap = name_2;
1423 button = fl_get_button(dialog_->check_rtl_support);
1424 rc.rtl_support = static_cast<bool>(button);
1426 button = fl_get_button(dialog_->check_mark_foreign);
1427 rc.mark_foreign_language = static_cast<bool>(button);
1429 button = fl_get_button(dialog_->check_auto_begin);
1430 rc.language_auto_begin = static_cast<bool>(button);
1432 button = fl_get_button(dialog_->check_auto_end);
1433 rc.language_auto_end = static_cast<bool>(button);
1435 button = fl_get_button(dialog_->check_use_babel);
1436 rc.language_use_babel = static_cast<bool>(button);
1438 button = fl_get_button(dialog_->check_global_options);
1439 rc.language_global_options = static_cast<bool>(button);
1441 rc.language_package = fl_get_input(dialog_->input_package);
1442 rc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1443 rc.language_command_end = fl_get_input(dialog_->input_command_end);
1445 // Ensure that all is self-consistent.
1450 void FormPreferences::Language::build()
1452 dialog_.reset(build_preferences_language(&parent_));
1454 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1455 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1456 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1458 // Store the lang identifiers for later
1459 vector<LanguagePair> const langs = getLanguageData(false);
1460 lang_ = getSecond(langs);
1462 FL_OBJECT * obj = dialog_->combox_default_lang;
1463 vector<LanguagePair>::const_iterator lit = langs.begin();
1464 vector<LanguagePair>::const_iterator lend = langs.end();
1465 for (; lit != lend; ++lit) {
1466 fl_addto_combox(obj, lit->first.c_str());
1468 fl_set_combox_browser_height(obj, 400);
1470 // set up the feedback mechanism
1471 setPrehandler(dialog_->input_package);
1472 setPrehandler(dialog_->check_use_kbmap);
1473 setPrehandler(dialog_->combox_default_lang);
1474 setPrehandler(dialog_->input_kbmap1);
1475 setPrehandler(dialog_->input_kbmap2);
1476 setPrehandler(dialog_->check_rtl_support);
1477 setPrehandler(dialog_->check_mark_foreign);
1478 setPrehandler(dialog_->check_auto_begin);
1479 setPrehandler(dialog_->check_auto_end);
1480 setPrehandler(dialog_->check_use_babel);
1481 setPrehandler(dialog_->check_global_options);
1482 setPrehandler(dialog_->input_command_begin);
1483 setPrehandler(dialog_->input_command_end);
1485 // Activate/Deactivate the input fields dependent on the state of the
1492 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1494 if (ob == dialog_->combox_default_lang)
1495 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1496 if (ob == dialog_->check_use_kbmap)
1497 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1498 if (ob == dialog_->input_kbmap1)
1499 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1500 if (ob == dialog_->input_kbmap2)
1501 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1502 if (ob == dialog_->check_rtl_support)
1503 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1504 if (ob == dialog_->check_mark_foreign)
1505 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1506 if (ob == dialog_->check_auto_begin)
1507 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1508 if (ob == dialog_->check_auto_end)
1509 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1510 if (ob == dialog_->check_use_babel)
1511 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1512 if (ob == dialog_->check_global_options)
1513 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1514 if (ob == dialog_->input_package)
1515 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1516 if (ob == dialog_->input_command_begin)
1517 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1518 if (ob == dialog_->input_command_end)
1519 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1524 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1526 bool activate = true;
1528 // !ob if function is called from Language::build() to de/activate
1530 // otherwise the function is called by an xforms CB via input().
1531 if (!ob || ob == dialog_->check_use_kbmap) {
1532 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1533 setEnabled(dialog_->button_kbmap1_browse, enable);
1534 setEnabled(dialog_->button_kbmap2_browse, enable);
1535 setEnabled(dialog_->input_kbmap1, enable);
1536 setEnabled(dialog_->input_kbmap2, enable);
1539 if (ob == dialog_->button_kbmap1_browse) {
1540 string f = parent_.controller().browsekbmap(
1541 fl_get_input(dialog_->input_kbmap1));
1543 fl_set_input(dialog_->input_kbmap1, f.c_str());
1544 } else if (ob == dialog_->button_kbmap2_browse) {
1545 string f = parent_.controller().browsekbmap(
1546 fl_get_input(dialog_->input_kbmap2));
1548 fl_set_input(dialog_->input_kbmap2, f.c_str());
1555 void FormPreferences::Language::update(LyXRC const & rc)
1557 fl_set_button(dialog_->check_use_kbmap,
1560 int const pos = int(findPos(lang_, rc.default_language));
1561 fl_set_combox(dialog_->combox_default_lang, pos + 1);
1564 fl_set_input(dialog_->input_kbmap1,
1565 rc.primary_kbmap.c_str());
1566 fl_set_input(dialog_->input_kbmap2,
1567 rc.secondary_kbmap.c_str());
1569 fl_set_input(dialog_->input_kbmap1, "");
1570 fl_set_input(dialog_->input_kbmap2, "");
1573 fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1574 fl_set_button(dialog_->check_mark_foreign,
1575 rc.mark_foreign_language);
1576 fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1577 fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1578 fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1579 fl_set_button(dialog_->check_global_options,
1580 rc.language_global_options);
1582 fl_set_input(dialog_->input_package,
1583 rc.language_package.c_str());
1584 fl_set_input(dialog_->input_command_begin,
1585 rc.language_command_begin.c_str());
1586 fl_set_input(dialog_->input_command_end,
1587 rc.language_command_end.c_str());
1589 // Activate/Deactivate the input fields dependent on the state of the
1595 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1600 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1602 return dialog_.get();
1606 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1608 rc.auto_region_delete =
1609 fl_get_button(dialog_->check_auto_region_delete);
1610 rc.cursor_follows_scrollbar =
1611 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1612 rc.dialogs_iconify_with_main =
1613 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1615 switch (fl_get_choice(dialog_->choice_instant_preview)) {
1617 rc.preview = LyXRC::PREVIEW_OFF;
1620 rc.preview = LyXRC::PREVIEW_NO_MATH;
1623 rc.preview = LyXRC::PREVIEW_ON;
1627 rc.autosave = static_cast<unsigned int>
1628 (fl_get_counter_value(dialog_->counter_autosave));
1629 rc.wheel_jump = static_cast<unsigned int>
1630 (fl_get_counter_value(dialog_->counter_wm_jump));
1633 // graphics::DisplayType old_value = rc.display_graphics;
1634 switch (fl_get_choice(dialog_->choice_graphics_display)) {
1636 rc.display_graphics = graphics::NoDisplay;
1639 rc.display_graphics = graphics::ColorDisplay;
1642 rc.display_graphics = graphics::GrayscaleDisplay;
1645 rc.display_graphics = graphics::MonochromeDisplay;
1648 rc.display_graphics = graphics::ColorDisplay;
1652 #ifdef WITH_WARNINGS
1653 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1656 if (old_value != rc.display_graphics) {
1657 graphics::GCache & gc = graphics::GCache::get();
1664 void FormPreferences::LnFmisc::build()
1666 dialog_.reset(build_preferences_lnf_misc(&parent_));
1668 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1669 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1671 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1672 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1674 // set up the feedback mechanism
1675 setPrehandler(dialog_->check_auto_region_delete);
1676 setPrehandler(dialog_->counter_autosave);
1677 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1678 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1679 setPrehandler(dialog_->choice_instant_preview);
1680 setPrehandler(dialog_->counter_wm_jump);
1682 fl_addto_choice(dialog_->choice_graphics_display,
1683 _("Monochrome|Grayscale|Color|Do not display").c_str());
1685 fl_addto_choice(dialog_->choice_instant_preview,
1686 _("Off|No math|On").c_str());
1691 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1693 if (ob == dialog_->check_auto_region_delete)
1694 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
1695 if (ob == dialog_->check_cursor_follows_scrollbar)
1696 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1697 if (ob == dialog_->check_dialogs_iconify_with_main)
1698 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1699 if (ob == dialog_->choice_instant_preview)
1700 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
1701 if (ob == dialog_->counter_autosave)
1702 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
1703 if (ob == dialog_->counter_wm_jump)
1704 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
1705 if (ob == dialog_->choice_graphics_display)
1706 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1711 void FormPreferences::LnFmisc::update(LyXRC const & rc)
1713 fl_set_button(dialog_->check_auto_region_delete,
1714 rc.auto_region_delete);
1715 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1716 rc.cursor_follows_scrollbar);
1717 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1718 rc.dialogs_iconify_with_main);
1720 switch (rc.preview) {
1721 case LyXRC::PREVIEW_OFF:
1722 fl_set_choice(dialog_->choice_instant_preview, 1);
1724 case LyXRC::PREVIEW_NO_MATH:
1725 fl_set_choice(dialog_->choice_instant_preview, 2);
1727 case LyXRC::PREVIEW_ON:
1728 fl_set_choice(dialog_->choice_instant_preview, 3);
1732 fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
1733 fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
1735 switch (rc.display_graphics) {
1736 case graphics::NoDisplay:
1737 fl_set_choice(dialog_->choice_graphics_display, 4);
1739 case graphics::ColorDisplay:
1740 fl_set_choice(dialog_->choice_graphics_display, 3);
1742 case graphics::GrayscaleDisplay:
1743 fl_set_choice(dialog_->choice_graphics_display, 2);
1745 case graphics::MonochromeDisplay:
1746 fl_set_choice(dialog_->choice_graphics_display, 1);
1749 fl_set_choice(dialog_->choice_graphics_display, 3);
1755 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1760 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1762 return dialog_.get();
1766 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
1768 rc.ascii_linelen = static_cast<unsigned int>
1769 (fl_get_counter_value(dialog_->counter_line_len));
1770 rc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1773 fl_get_choice(dialog_->choice_default_papersize) - 1;
1774 rc.default_papersize = static_cast<PAPER_SIZE>(choice);
1776 rc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1777 rc.chktex_command = fl_get_input(dialog_->input_checktex);
1778 rc.bibtex_command = fl_get_input(dialog_->input_bibtex);
1779 rc.index_command = fl_get_input(dialog_->input_index);
1780 rc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1781 rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1785 void FormPreferences::OutputsMisc::build()
1787 dialog_.reset(build_preferences_outputs_misc(&parent_));
1789 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1791 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1792 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1793 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1794 fl_set_input_return(dialog_->input_bibtex, FL_RETURN_CHANGED);
1795 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1796 fl_set_input_return(dialog_->input_index, FL_RETURN_CHANGED);
1797 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1799 fl_addto_choice(dialog_->choice_default_papersize,
1800 _(" default | US letter | US legal "
1801 "| US executive | A3 | A4 | A5 | B5 ").c_str());
1803 // set up the feedback mechanism
1804 setPrehandler(dialog_->counter_line_len);
1805 setPrehandler(dialog_->input_tex_encoding);
1806 setPrehandler(dialog_->choice_default_papersize);
1807 setPrehandler(dialog_->input_ascii_roff);
1808 setPrehandler(dialog_->input_bibtex);
1809 setPrehandler(dialog_->input_checktex);
1810 setPrehandler(dialog_->input_index);
1811 setPrehandler(dialog_->input_paperoption);
1812 setPrehandler(dialog_->check_autoreset_classopt);
1817 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1819 if (ob == dialog_->counter_line_len)
1820 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
1821 if (ob == dialog_->input_tex_encoding)
1822 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
1823 if (ob == dialog_->input_ascii_roff)
1824 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1825 if (ob == dialog_->input_bibtex)
1826 return LyXRC::getDescription(LyXRC::RC_BIBTEX_COMMAND);
1827 if (ob == dialog_->input_checktex)
1828 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
1829 if (ob == dialog_->input_index)
1830 return LyXRC::getDescription(LyXRC::RC_INDEX_COMMAND);
1831 if (ob == dialog_->choice_default_papersize)
1832 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1833 if (ob == dialog_->input_paperoption)
1834 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
1835 if (ob == dialog_->check_autoreset_classopt)
1836 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
1841 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
1843 fl_set_counter_value(dialog_->counter_line_len,
1845 fl_set_input(dialog_->input_tex_encoding,
1846 rc.fontenc.c_str());
1847 fl_set_choice(dialog_->choice_default_papersize,
1848 rc.default_papersize + 1);
1849 fl_set_input(dialog_->input_ascii_roff,
1850 rc.ascii_roff_command.c_str());
1851 fl_set_input(dialog_->input_checktex,
1852 rc.chktex_command.c_str());
1853 fl_set_input(dialog_->input_bibtex,
1854 rc.bibtex_command.c_str());
1855 fl_set_input(dialog_->input_index,
1856 rc.index_command.c_str());
1857 fl_set_input(dialog_->input_paperoption,
1858 rc.view_dvi_paper_option.c_str());
1859 fl_set_button(dialog_->check_autoreset_classopt,
1860 rc.auto_reset_options);
1865 FormPreferences::Paths::Paths(FormPreferences & p)
1870 FD_preferences_paths const * FormPreferences::Paths::dialog()
1872 return dialog_.get();
1876 void FormPreferences::Paths::apply(LyXRC & rc)
1878 rc.document_path = fl_get_input(dialog_->input_default_path);
1879 rc.template_path = fl_get_input(dialog_->input_template_path);
1880 rc.tempdir_path = fl_get_input(dialog_->input_temp_dir);
1882 int button = fl_get_button(dialog_->check_last_files);
1883 string str = fl_get_input(dialog_->input_lastfiles);
1884 if (!button) str.erase();
1886 rc.check_lastfiles = button;
1888 rc.num_lastfiles = static_cast<unsigned int>
1889 (fl_get_counter_value(dialog_->counter_lastfiles));
1891 button = fl_get_button(dialog_->check_make_backups);
1892 str = fl_get_input(dialog_->input_backup_path);
1896 rc.make_backup = button;
1897 rc.backupdir_path = str;
1899 rc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
1906 void FormPreferences::Paths::build()
1908 dialog_.reset(build_preferences_paths(&parent_));
1910 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
1911 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
1912 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
1913 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
1914 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
1915 fl_set_counter_bounds(dialog_->counter_lastfiles, 0, maxlastfiles);
1916 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
1917 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
1919 // set up the feedback mechanism
1920 setPrehandler(dialog_->input_default_path);
1921 setPrehandler(dialog_->counter_lastfiles);
1922 setPrehandler(dialog_->input_template_path);
1923 setPrehandler(dialog_->check_last_files);
1924 setPrehandler(dialog_->input_lastfiles);
1925 setPrehandler(dialog_->check_make_backups);
1926 setPrehandler(dialog_->input_backup_path);
1927 setPrehandler(dialog_->input_serverpipe);
1928 setPrehandler(dialog_->input_temp_dir);
1933 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
1935 if (ob == dialog_->input_default_path)
1936 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
1937 if (ob == dialog_->input_template_path)
1938 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
1939 if (ob == dialog_->input_temp_dir)
1940 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
1941 if (ob == dialog_->check_last_files)
1942 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
1943 if (ob == dialog_->input_lastfiles)
1944 return LyXRC::getDescription(LyXRC::RC_LASTFILES);
1945 if (ob == dialog_->counter_lastfiles)
1946 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
1947 if (ob == dialog_->check_make_backups)
1948 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
1949 if (ob == dialog_->input_backup_path)
1950 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
1951 if (ob == dialog_->input_serverpipe)
1952 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
1957 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
1959 bool activate = true;
1961 // !ob if function is called from Paths::update() to de/activate
1963 // otherwise the function is called by an xforms CB via input().
1964 if (!ob || ob == dialog_->check_last_files) {
1965 bool const enable = fl_get_button(dialog_->check_last_files);
1966 setEnabled(dialog_->input_lastfiles, enable);
1969 if (!ob || ob == dialog_->check_make_backups) {
1970 bool const enable = fl_get_button(dialog_->check_make_backups);
1971 setEnabled(dialog_->input_backup_path, enable);
1974 if (!ob || ob == dialog_->input_default_path) {
1975 string const name = fl_get_input(dialog_->input_default_path);
1976 if (!name.empty() && !RWInfo::WriteableDir(name)) {
1977 parent_.postWarning(RWInfo::ErrorMessage());
1982 if (!ob || ob == dialog_->input_template_path) {
1983 string const name = fl_get_input(dialog_->input_template_path);
1984 if (!name.empty() && !RWInfo::ReadableDir(name)) {
1985 parent_.postWarning(RWInfo::ErrorMessage());
1990 if (!ob || ob == dialog_->input_temp_dir) {
1991 string const name = fl_get_input(dialog_->input_temp_dir);
1992 if (fl_get_button(dialog_->check_make_backups)
1994 && !RWInfo::WriteableDir(name)) {
1995 parent_.postWarning(RWInfo::ErrorMessage());
2000 if (!ob || ob == dialog_->input_backup_path) {
2001 string const name = fl_get_input(dialog_->input_backup_path);
2002 if (fl_get_button(dialog_->check_make_backups)
2004 && !RWInfo::WriteableDir(name)) {
2005 parent_.postWarning(RWInfo::ErrorMessage());
2010 if (!ob || ob == dialog_->input_lastfiles) {
2011 string const name = fl_get_input(dialog_->input_lastfiles);
2012 if (fl_get_button(dialog_->check_last_files)
2014 && !RWInfo::WriteableFile(name)) {
2015 parent_.postWarning(RWInfo::ErrorMessage());
2020 if (!ob || ob == dialog_->input_serverpipe) {
2021 string const name = fl_get_input(dialog_->input_serverpipe);
2022 if (!name.empty()) {
2023 // strip off the extension
2024 string const str = ChangeExtension(name, "");
2025 if (!RWInfo::WriteableFile(str + ".in")) {
2026 parent_.postWarning(RWInfo::ErrorMessage());
2029 if (!RWInfo::WriteableFile(str + ".out")) {
2030 parent_.postWarning(RWInfo::ErrorMessage());
2036 if (ob == dialog_->button_default_path_browse) {
2037 string f = parent_.controller().browsedir(
2038 fl_get_input(dialog_->input_default_path), _("Default path"));
2040 fl_set_input(dialog_->input_default_path, f.c_str());
2041 } else if (ob == dialog_->button_template_path_browse) {
2042 string f = parent_.controller().browsedir(
2043 fl_get_input(dialog_->input_template_path), _("Template path"));
2045 fl_set_input(dialog_->input_template_path, f.c_str());
2046 } else if (ob == dialog_->button_temp_dir_browse) {
2047 string f = parent_.controller().browsedir(
2048 fl_get_input(dialog_->input_temp_dir), _("Temporary dir"));
2050 fl_set_input(dialog_->input_temp_dir, f.c_str());
2051 } else if (ob == dialog_->button_lastfiles_browse) {
2052 string f = parent_.controller().browse(
2053 fl_get_input(dialog_->input_lastfiles), _("Last files"));
2055 fl_set_input(dialog_->input_lastfiles, f.c_str());
2056 } else if (ob == dialog_->button_backup_path_browse) {
2057 string f = parent_.controller().browsedir(
2058 fl_get_input(dialog_->input_backup_path), _("Backup path"));
2060 fl_set_input(dialog_->input_backup_path, f.c_str());
2061 } else if (ob == dialog_->button_serverpipe_browse) {
2062 string f = parent_.controller().browse(
2063 fl_get_input(dialog_->input_serverpipe), _("LyX server pipes"));
2065 fl_set_input(dialog_->input_serverpipe, f.c_str());
2072 void FormPreferences::Paths::update(LyXRC const & rc)
2074 fl_set_input(dialog_->input_default_path,
2075 rc.document_path.c_str());
2076 fl_set_input(dialog_->input_template_path,
2077 rc.template_path.c_str());
2081 str = rc.backupdir_path;
2083 fl_set_button(dialog_->check_make_backups,
2085 fl_set_input(dialog_->input_backup_path, str.c_str());
2087 fl_set_input(dialog_->input_temp_dir, rc.tempdir_path.c_str());
2090 if (rc.check_lastfiles)
2093 fl_set_button(dialog_->check_last_files,
2094 rc.check_lastfiles);
2095 fl_set_input(dialog_->input_lastfiles, str.c_str());
2096 fl_set_counter_value(dialog_->counter_lastfiles,
2099 fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2101 // Activate/Deactivate the input fields dependent on the state of the
2107 FormPreferences::Printer::Printer(FormPreferences & p)
2112 FD_preferences_printer const * FormPreferences::Printer::dialog()
2114 return dialog_.get();
2118 void FormPreferences::Printer::apply(LyXRC & rc) const
2120 rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2121 rc.print_command = fl_get_input(dialog_->input_command);
2122 rc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2123 rc.print_copies_flag = fl_get_input(dialog_->input_copies);
2124 rc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2125 rc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2126 rc.print_file_extension =
2127 fl_get_input(dialog_->input_file_extension);
2128 rc.print_spool_command =
2129 fl_get_input(dialog_->input_spool_command);
2130 rc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2131 rc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2132 rc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2133 rc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2134 rc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2135 rc.print_to_file = fl_get_input(dialog_->input_to_file);
2136 rc.print_extra_options =
2137 fl_get_input(dialog_->input_extra_options);
2138 rc.print_spool_printerprefix =
2139 fl_get_input(dialog_->input_spool_prefix);
2140 rc.print_paper_dimension_flag =
2141 fl_get_input(dialog_->input_paper_size);
2142 rc.printer = fl_get_input(dialog_->input_name);
2147 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2149 if (ob == dialog_->input_command)
2150 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2151 if (ob == dialog_->check_adapt_output)
2152 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2153 if (ob == dialog_->input_to_printer)
2154 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2155 if (ob == dialog_->input_to_file)
2156 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2157 if (ob == dialog_->input_file_extension)
2158 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2159 if (ob == dialog_->input_extra_options)
2160 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2161 if (ob == dialog_->input_spool_command)
2162 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2163 if (ob == dialog_->input_spool_prefix)
2164 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2165 if (ob == dialog_->input_name)
2166 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2167 if (ob == dialog_->input_even_pages)
2168 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2169 if (ob == dialog_->input_odd_pages)
2170 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2171 if (ob == dialog_->input_page_range)
2172 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2173 if (ob == dialog_->input_reverse)
2174 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2175 if (ob == dialog_->input_landscape)
2176 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2177 if (ob == dialog_->input_copies)
2178 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2179 if (ob == dialog_->input_collated)
2180 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2181 if (ob == dialog_->input_paper_type)
2182 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2183 if (ob == dialog_->input_paper_size)
2184 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2189 void FormPreferences::Printer::build()
2191 dialog_.reset(build_preferences_printer(&parent_));
2193 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2194 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2195 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2196 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2197 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2198 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2199 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2200 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2201 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2202 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2203 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2204 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2205 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2206 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2207 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2208 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2209 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2211 // set up the feedback mechanism
2212 setPrehandler(dialog_->input_command);
2213 setPrehandler(dialog_->input_page_range);
2214 setPrehandler(dialog_->input_copies);
2215 setPrehandler(dialog_->input_reverse);
2216 setPrehandler(dialog_->input_to_printer);
2217 setPrehandler(dialog_->input_file_extension);
2218 setPrehandler(dialog_->input_spool_command);
2219 setPrehandler(dialog_->input_paper_type);
2220 setPrehandler(dialog_->input_even_pages);
2221 setPrehandler(dialog_->input_odd_pages);
2222 setPrehandler(dialog_->input_collated);
2223 setPrehandler(dialog_->input_landscape);
2224 setPrehandler(dialog_->input_to_file);
2225 setPrehandler(dialog_->input_extra_options);
2226 setPrehandler(dialog_->input_spool_prefix);
2227 setPrehandler(dialog_->input_paper_size);
2228 setPrehandler(dialog_->input_name);
2229 setPrehandler(dialog_->check_adapt_output);
2233 void FormPreferences::Printer::update(LyXRC const & rc)
2235 fl_set_button(dialog_->check_adapt_output,
2236 rc.print_adapt_output);
2237 fl_set_input(dialog_->input_command,
2238 rc.print_command.c_str());
2239 fl_set_input(dialog_->input_page_range,
2240 rc.print_pagerange_flag.c_str());
2241 fl_set_input(dialog_->input_copies,
2242 rc.print_copies_flag.c_str());
2243 fl_set_input(dialog_->input_reverse,
2244 rc.print_reverse_flag.c_str());
2245 fl_set_input(dialog_->input_to_printer,
2246 rc.print_to_printer.c_str());
2247 fl_set_input(dialog_->input_file_extension,
2248 rc.print_file_extension.c_str());
2249 fl_set_input(dialog_->input_spool_command,
2250 rc.print_spool_command.c_str());
2251 fl_set_input(dialog_->input_paper_type,
2252 rc.print_paper_flag.c_str());
2253 fl_set_input(dialog_->input_even_pages,
2254 rc.print_evenpage_flag.c_str());
2255 fl_set_input(dialog_->input_odd_pages,
2256 rc.print_oddpage_flag.c_str());
2257 fl_set_input(dialog_->input_collated,
2258 rc.print_collcopies_flag.c_str());
2259 fl_set_input(dialog_->input_landscape,
2260 rc.print_landscape_flag.c_str());
2261 fl_set_input(dialog_->input_to_file,
2262 rc.print_to_file.c_str());
2263 fl_set_input(dialog_->input_extra_options,
2264 rc.print_extra_options.c_str());
2265 fl_set_input(dialog_->input_spool_prefix,
2266 rc.print_spool_printerprefix.c_str());
2267 fl_set_input(dialog_->input_paper_size,
2268 rc.print_paper_dimension_flag.c_str());
2269 fl_set_input(dialog_->input_name,
2270 rc.printer.c_str());
2274 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2279 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2281 return dialog_.get();
2285 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2287 bool changed = false;
2289 pair<string, string> tmp =
2290 parseFontName(fl_get_input(dialog_->input_roman));
2291 if (rc.roman_font_name != tmp.first ||
2292 rc.roman_font_foundry != tmp.second) {
2294 rc.roman_font_name = tmp.first;
2295 rc.roman_font_foundry = tmp.second;
2298 tmp = parseFontName(fl_get_input(dialog_->input_sans));
2299 if (rc.sans_font_name != tmp.first ||
2300 rc.sans_font_foundry != tmp.second) {
2302 rc.sans_font_name = tmp.first;
2303 rc.sans_font_foundry = tmp.second;
2306 tmp = parseFontName(fl_get_input(dialog_->input_typewriter));
2307 if (rc.typewriter_font_name != tmp.first ||
2308 rc.typewriter_font_foundry != tmp.second) {
2310 rc.typewriter_font_name = tmp.first;
2311 rc.typewriter_font_foundry = tmp.second;
2314 string str = fl_get_input(dialog_->input_screen_encoding);
2315 if (rc.font_norm != str) {
2318 rc.set_font_norm_type();
2321 bool button = fl_get_button(dialog_->check_scalable);
2322 if (rc.use_scalable_fonts != button) {
2324 rc.use_scalable_fonts = button;
2327 unsigned int ivalue = static_cast<unsigned int>
2328 (fl_get_counter_value(dialog_->counter_zoom));
2329 if (rc.zoom != ivalue) {
2334 ivalue = static_cast<unsigned int>
2335 (fl_get_counter_value(dialog_->counter_dpi));
2336 if (rc.dpi != ivalue) {
2341 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2342 if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2344 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2347 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2348 if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2350 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2353 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2354 if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2356 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2359 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2360 if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2362 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2365 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2366 if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2368 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2371 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2372 if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2374 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2377 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2378 if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2380 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2383 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2384 if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2386 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2389 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2390 if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2392 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2395 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2396 if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2398 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2402 // Now update the buffers
2403 // Can anything below here affect the redraw process?
2404 parent_.controller().updateScreenFonts();
2409 void FormPreferences::ScreenFonts::build()
2411 dialog_.reset(build_preferences_screen_fonts(&parent_));
2413 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2414 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2416 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2417 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2418 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2419 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2420 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2421 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2422 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2423 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2424 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2425 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2426 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2427 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2428 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2429 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2430 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2431 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2433 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2434 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2435 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2436 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2437 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2438 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2439 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2440 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2441 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2442 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2444 // set up the feedback mechanism
2445 setPrehandler(dialog_->input_roman);
2446 setPrehandler(dialog_->input_sans);
2447 setPrehandler(dialog_->input_typewriter);
2448 setPrehandler(dialog_->counter_zoom);
2449 setPrehandler(dialog_->counter_dpi);
2450 setPrehandler(dialog_->check_scalable);
2451 setPrehandler(dialog_->input_screen_encoding);
2452 setPrehandler(dialog_->input_tiny);
2453 setPrehandler(dialog_->input_script);
2454 setPrehandler(dialog_->input_footnote);
2455 setPrehandler(dialog_->input_small);
2456 setPrehandler(dialog_->input_large);
2457 setPrehandler(dialog_->input_larger);
2458 setPrehandler(dialog_->input_largest);
2459 setPrehandler(dialog_->input_normal);
2460 setPrehandler(dialog_->input_huge);
2461 setPrehandler(dialog_->input_huger);
2466 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2468 if (ob == dialog_->input_roman)
2469 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2470 if (ob == dialog_->input_sans)
2471 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2472 if (ob == dialog_->input_typewriter)
2473 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2474 if (ob == dialog_->check_scalable)
2475 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2476 if (ob == dialog_->input_screen_encoding)
2477 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2478 if (ob == dialog_->counter_zoom)
2479 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2480 if (ob == dialog_->counter_dpi)
2481 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2482 if (ob == dialog_->input_tiny
2483 || ob == dialog_->input_script
2484 || ob == dialog_->input_footnote
2485 || ob == dialog_->input_small
2486 || ob == dialog_->input_large
2487 || ob == dialog_->input_larger
2488 || ob == dialog_->input_larger
2489 || ob == dialog_->input_largest
2490 || ob == dialog_->input_normal
2491 || ob == dialog_->input_huge
2492 || ob == dialog_->input_huger)
2493 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2498 bool FormPreferences::ScreenFonts::input()
2500 bool activate = true;
2503 // Make sure that all fonts all have positive entries
2504 // Also note that an empty entry is returned as 0.0 by strToDbl
2505 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2506 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2507 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2508 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2509 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2510 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2511 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2512 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2513 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2514 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2516 str = _("Fonts must be positive!");
2518 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2519 // Fontsizes -- tiny < script < footnote etc.
2520 strToDbl(fl_get_input(dialog_->input_script)) ||
2521 strToDbl(fl_get_input(dialog_->input_script)) >
2522 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2523 strToDbl(fl_get_input(dialog_->input_footnote)) >
2524 strToDbl(fl_get_input(dialog_->input_small)) ||
2525 strToDbl(fl_get_input(dialog_->input_small)) >
2526 strToDbl(fl_get_input(dialog_->input_normal)) ||
2527 strToDbl(fl_get_input(dialog_->input_normal)) >
2528 strToDbl(fl_get_input(dialog_->input_large)) ||
2529 strToDbl(fl_get_input(dialog_->input_large)) >
2530 strToDbl(fl_get_input(dialog_->input_larger)) ||
2531 strToDbl(fl_get_input(dialog_->input_larger)) >
2532 strToDbl(fl_get_input(dialog_->input_largest)) ||
2533 strToDbl(fl_get_input(dialog_->input_largest)) >
2534 strToDbl(fl_get_input(dialog_->input_huge)) ||
2535 strToDbl(fl_get_input(dialog_->input_huge)) >
2536 strToDbl(fl_get_input(dialog_->input_huger))) {
2539 str = _("Fonts must be input in the order Tiny > Smallest > Smaller > Small > Normal > Large > Larger > Largest > Huge > Huger.");
2543 parent_.postWarning(str);
2549 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2551 fl_set_input(dialog_->input_roman,
2552 makeFontName(rc.roman_font_name,
2553 rc.roman_font_foundry).c_str());
2554 fl_set_input(dialog_->input_sans,
2555 makeFontName(rc.sans_font_name,
2556 rc.sans_font_foundry).c_str());
2557 fl_set_input(dialog_->input_typewriter,
2558 makeFontName(rc.typewriter_font_name,
2559 rc.typewriter_font_foundry).c_str());
2560 fl_set_input(dialog_->input_screen_encoding,
2561 rc.font_norm.c_str());
2562 fl_set_button(dialog_->check_scalable,
2563 rc.use_scalable_fonts);
2564 fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2565 fl_set_counter_value(dialog_->counter_dpi, rc.dpi);
2566 fl_set_input(dialog_->input_tiny,
2567 tostr(rc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2568 fl_set_input(dialog_->input_script,
2569 tostr(rc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2570 fl_set_input(dialog_->input_footnote,
2571 tostr(rc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2572 fl_set_input(dialog_->input_small,
2573 tostr(rc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2574 fl_set_input(dialog_->input_normal,
2575 tostr(rc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2576 fl_set_input(dialog_->input_large,
2577 tostr(rc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2578 fl_set_input(dialog_->input_larger,
2579 tostr(rc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2580 fl_set_input(dialog_->input_largest,
2581 tostr(rc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2582 fl_set_input(dialog_->input_huge,
2583 tostr(rc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2584 fl_set_input(dialog_->input_huger,
2585 tostr(rc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2590 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2595 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2597 return dialog_.get();
2601 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2603 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2604 choice = trim(choice);
2606 rc.isp_command = choice;
2609 // If spell checker == "none", all other input set to off.
2610 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2611 rc.isp_use_alt_lang = false;
2612 rc.isp_alt_lang.erase();
2614 rc.isp_use_esc_chars = false;
2615 rc.isp_esc_chars.erase();
2617 rc.isp_use_pers_dict = false;
2618 rc.isp_pers_dict.erase();
2620 rc.isp_accept_compound = false;
2621 rc.isp_use_input_encoding = false;
2624 int button = fl_get_button(dialog_->check_alt_lang);
2625 choice = fl_get_input(dialog_->input_alt_lang);
2626 if (button && choice.empty()) button = 0;
2627 if (!button) choice.erase();
2629 rc.isp_use_alt_lang = static_cast<bool>(button);
2630 rc.isp_alt_lang = choice;
2632 button = fl_get_button(dialog_->check_escape_chars);
2633 choice = fl_get_input(dialog_->input_escape_chars);
2634 if (button && choice.empty()) button = 0;
2635 if (!button) choice.erase();
2637 rc.isp_use_esc_chars = static_cast<bool>(button);
2638 rc.isp_esc_chars = choice;
2640 button = fl_get_button(dialog_->check_personal_dict);
2641 choice = fl_get_input(dialog_->input_personal_dict);
2642 if (button && choice.empty()) button = 0;
2643 if (!button) choice.erase();
2645 rc.isp_use_pers_dict = static_cast<bool>(button);
2646 rc.isp_pers_dict = choice;
2648 button = fl_get_button(dialog_->check_compound_words);
2649 rc.isp_accept_compound = static_cast<bool>(button);
2651 button = fl_get_button(dialog_->check_input_enc);
2652 rc.isp_use_input_encoding = static_cast<bool>(button);
2663 void FormPreferences::SpellOptions::build()
2665 dialog_.reset(build_preferences_spelloptions(&parent_));
2667 fl_addto_choice(dialog_->choice_spell_command,
2668 _(" ispell | aspell ").c_str());
2669 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2670 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2671 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2673 // set up the feedback mechanism
2674 setPrehandler(dialog_->choice_spell_command);
2675 setPrehandler(dialog_->check_alt_lang);
2676 setPrehandler(dialog_->input_alt_lang);
2677 setPrehandler(dialog_->check_escape_chars);
2678 setPrehandler(dialog_->input_escape_chars);
2679 setPrehandler(dialog_->check_personal_dict);
2680 setPrehandler(dialog_->input_personal_dict);
2681 setPrehandler(dialog_->button_personal_dict);
2682 setPrehandler(dialog_->check_compound_words);
2683 setPrehandler(dialog_->check_input_enc);
2688 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2690 if (ob == dialog_->choice_spell_command)
2691 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
2692 if (ob == dialog_->check_alt_lang)
2693 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
2694 if (ob == dialog_->input_alt_lang)
2695 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
2696 if (ob == dialog_->check_escape_chars)
2697 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
2698 if (ob == dialog_->input_escape_chars)
2699 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
2700 if (ob == dialog_->check_personal_dict)
2701 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
2702 if (ob == dialog_->input_personal_dict)
2703 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
2704 if (ob == dialog_->check_compound_words)
2705 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2706 if (ob == dialog_->check_input_enc)
2707 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
2712 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2714 // !ob if function is called from updateSpellOptions() to de/activate
2716 // otherwise the function is called by an xforms CB via input().
2719 // If spell checker == "none", disable all input.
2720 if (!ob || ob == dialog_->choice_spell_command) {
2721 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2722 fl_deactivate_object(dialog_->check_alt_lang);
2723 fl_deactivate_object(dialog_->input_alt_lang);
2724 fl_deactivate_object(dialog_->check_escape_chars);
2725 fl_deactivate_object(dialog_->input_escape_chars);
2726 fl_deactivate_object(dialog_->check_personal_dict);
2727 fl_deactivate_object(dialog_->input_personal_dict);
2728 fl_deactivate_object(dialog_->check_compound_words);
2729 fl_deactivate_object(dialog_->check_input_enc);
2732 fl_activate_object(dialog_->check_alt_lang);
2733 fl_activate_object(dialog_->check_escape_chars);
2734 fl_activate_object(dialog_->check_personal_dict);
2735 fl_activate_object(dialog_->check_compound_words);
2736 fl_activate_object(dialog_->check_input_enc);
2741 if (!ob || ob == dialog_->check_alt_lang) {
2742 bool const enable = fl_get_button(dialog_->check_alt_lang);
2743 setEnabled(dialog_->input_alt_lang, enable);
2746 if (!ob || ob == dialog_->check_escape_chars) {
2747 bool const enable = fl_get_button(dialog_->check_escape_chars);
2748 setEnabled(dialog_->input_escape_chars, enable);
2751 if (!ob || ob == dialog_->check_personal_dict) {
2752 bool const enable = fl_get_button(dialog_->check_personal_dict);
2753 setEnabled(dialog_->input_personal_dict, enable);
2756 if (ob == dialog_->button_personal_dict) {
2757 string f = parent_.controller().browsedict(
2758 fl_get_input(dialog_->input_personal_dict));
2759 fl_set_input(dialog_->input_personal_dict, f.c_str());
2762 return true; // All input is valid!
2766 void FormPreferences::SpellOptions::update(LyXRC const & rc)
2770 if (rc.isp_command == "none")
2772 else if (rc.isp_command == "ispell")
2774 else if (rc.isp_command == "aspell")
2777 if (rc.isp_command == "ispell")
2779 else if (rc.isp_command == "aspell")
2782 fl_set_choice(dialog_->choice_spell_command, choice);
2785 if (rc.isp_use_alt_lang)
2786 str = rc.isp_alt_lang;
2788 fl_set_button(dialog_->check_alt_lang,
2789 rc.isp_use_alt_lang);
2790 fl_set_input(dialog_->input_alt_lang, str.c_str());
2793 if (rc.isp_use_esc_chars)
2794 str = rc.isp_esc_chars;
2796 fl_set_button(dialog_->check_escape_chars,
2797 rc.isp_use_esc_chars);
2798 fl_set_input(dialog_->input_escape_chars, str.c_str());
2801 if (rc.isp_use_pers_dict)
2802 str = rc.isp_pers_dict;
2804 fl_set_button(dialog_->check_personal_dict,
2805 rc.isp_use_pers_dict);
2806 fl_set_input(dialog_->input_personal_dict, str.c_str());
2808 fl_set_button(dialog_->check_compound_words,
2809 rc.isp_accept_compound);
2810 fl_set_button(dialog_->check_input_enc,
2811 rc.isp_use_input_encoding);
2813 // Activate/Deactivate the input fields dependent on the state of the
2818 } // namespace frontend