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
30 #include "frontends/lyx_gui.h"
32 #include "support/convert.h"
33 #include "support/lstrings.h"
34 #include "support/package.h"
35 #include "support/filetools.h"
37 #include "lyx_forms.h"
55 using support::addName;
56 using support::changeExtension;
57 using support::package;
65 string makeFontName(string const & family, string const & foundry)
69 return family + ',' + foundry;
73 pair<string,string> parseFontName(string const & name)
75 string::size_type const idx = name.find(',');
76 if (idx == string::npos)
77 return make_pair(name, string());
78 return make_pair(name.substr(0, idx),
84 #if FL_VERSION == 0 || (FL_REVISION == 0 && FL_FIXLEVEL < 2)
85 bool const scalableTabfolders = false;
87 bool const scalableTabfolders = true;
93 typedef FormController<ControlPrefs, FormView<FD_preferences> > base_class;
96 FormPreferences::FormPreferences(Dialog & parent)
97 : base_class(parent, _("Preferences"), scalableTabfolders),
98 colors_(*this), converters_(*this), copiers_(*this),
99 formats_(*this), identity_(*this), inputs_misc_(*this),
100 interface_(*this), language_(*this), lnf_misc_(*this),
101 outputs_misc_(*this), paths_(*this), printer_(*this),
102 screen_fonts_(*this), spelloptions_(*this)
106 void FormPreferences::redraw()
108 if (!(form() && form()->visible))
110 fl_redraw_form(form());
112 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
113 if (!(form2 && form2->visible))
115 fl_redraw_form(form2);
118 if (form2 == converters_tab_->form)
119 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
121 else if (form2 == look_n_feel_tab_->form)
122 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
124 else if (form2 == inputs_tab_->form)
125 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
127 else if (form2 == outputs_tab_->form)
128 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
130 else if (form2 == lang_opts_tab_->form)
131 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
133 if (form3 && form3->visible)
134 fl_redraw_form(form3);
138 void FormPreferences::hide()
140 // We need to hide the active tabfolder otherwise we get a
141 // BadDrawable error from X window and LyX crashes without saving.
142 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
143 if (inner_form && inner_form->visible)
144 fl_hide_form(inner_form);
145 FormDialogView::hide();
149 void FormPreferences::build()
151 dialog_.reset(build_preferences(this));
153 // Manage the restore, save, apply and cancel/close buttons
154 bcview().setOK(dialog_->button_ok);
155 bcview().setApply(dialog_->button_apply);
156 bcview().setCancel(dialog_->button_close);
157 bcview().setRestore(dialog_->button_restore);
159 // Allow the base class to control messages
160 setMessageWidget(dialog_->text_warning);
162 // build the tab folders
163 converters_tab_.reset(build_preferences_inner_tab(this));
164 look_n_feel_tab_.reset(build_preferences_inner_tab(this));
165 inputs_tab_.reset(build_preferences_inner_tab(this));
166 outputs_tab_.reset(build_preferences_inner_tab(this));
167 lang_opts_tab_.reset(build_preferences_inner_tab(this));
169 // build actual tabfolder contents
170 // these will become nested tabfolders
175 inputs_misc_.build();
180 outputs_misc_.build();
183 screen_fonts_.build();
184 spelloptions_.build();
186 // Enable the tabfolders to be rescaled correctly.
187 if (scalableTabfolders) {
188 FL_OBJECT * folder = dialog_->tabfolder_prefs;
189 fl_set_tabfolder_autofit(folder, FL_FIT);
191 folder = look_n_feel_tab_->tabfolder_inner;
192 fl_set_tabfolder_autofit(folder, FL_FIT);
194 folder = converters_tab_->tabfolder_inner;
195 fl_set_tabfolder_autofit(folder, FL_FIT);
197 folder = inputs_tab_->tabfolder_inner;
198 fl_set_tabfolder_autofit(folder, FL_FIT);
200 folder = outputs_tab_->tabfolder_inner;
201 fl_set_tabfolder_autofit(folder, FL_FIT);
203 folder = lang_opts_tab_->tabfolder_inner;
204 fl_set_tabfolder_autofit(folder, FL_FIT);
208 // Now add them to the tabfolder
209 fl_addto_tabfolder(dialog_->tabfolder_prefs,
210 _("Look & Feel").c_str(),
211 look_n_feel_tab_->form);
212 fl_addto_tabfolder(dialog_->tabfolder_prefs,
213 _("Lang Opts").c_str(),
214 lang_opts_tab_->form);
215 fl_addto_tabfolder(dialog_->tabfolder_prefs,
216 _("Conversion").c_str(),
217 converters_tab_->form);
218 fl_addto_tabfolder(dialog_->tabfolder_prefs,
221 fl_addto_tabfolder(dialog_->tabfolder_prefs,
222 _("Outputs").c_str(),
225 // now build the nested tabfolders
226 // Starting with look and feel
227 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
228 _("Screen Fonts").c_str(),
229 screen_fonts_.dialog()->form);
230 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
231 _("Interface").c_str(),
232 interface_.dialog()->form);
233 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
235 colors_.dialog()->form);
236 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
238 lnf_misc_.dialog()->form);
239 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
240 _("Identity").c_str(),
241 identity_.dialog()->form);
243 // then build converters
244 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
245 _("Formats").c_str(),
246 formats_.dialog()->form);
247 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
248 _("Converters").c_str(),
249 converters_.dialog()->form);
250 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
251 _("Copiers").c_str(),
252 copiers_.dialog()->form);
255 // Paths should probably go in a few inner_tab called Files
256 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
258 paths_.dialog()->form);
259 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
261 inputs_misc_.dialog()->form);
263 // then building outputs
264 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
265 _("Printer").c_str(),
266 printer_.dialog()->form);
267 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
269 outputs_misc_.dialog()->form);
271 // then building usage
272 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
273 _("Spellchecker").c_str(),
274 spelloptions_.dialog()->form);
275 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
276 _("Language").c_str(),
277 language_.dialog()->form);
281 void FormPreferences::apply()
283 // set the new lyxrc entries
284 // many of these need to trigger other functions when the assignment
285 // is made. For example, screen zoom and font types. These could be
286 // handled either by signals/slots in lyxrc or just directly call the
287 // associated functions here.
288 // There are other problems with this scheme. We really should check
289 // what we copy to make sure that it really is necessary to do things
290 // like update the screen fonts because that flushes the textcache
291 // and other stuff which may cost us a lot on slower/high-load
294 LyXRC & rc(controller().rc());
297 inputs_misc_.apply(rc);
298 interface_.apply(rc);
302 outputs_misc_.apply(rc);
305 screen_fonts_.apply(rc);
306 spelloptions_.apply(rc);
308 // The "Save" button has been pressed.
309 if (dialog().isClosing() && colors_.modifiedXformsPrefs) {
310 string const filename =
311 addName(package().user_support(), "preferences.xform");
312 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
317 string const FormPreferences::getFeedback(FL_OBJECT * ob)
321 if (ob->form->fdui == colors_.dialog())
322 return colors_.feedback(ob);
323 if (ob->form->fdui == converters_.dialog())
324 return converters_.feedback(ob);
325 if (ob->form->fdui == copiers_.dialog())
326 return copiers_.feedback(ob);
327 if (ob->form->fdui == formats_.dialog())
328 return formats_.feedback(ob);
329 if (ob->form->fdui == inputs_misc_.dialog())
330 return inputs_misc_.feedback(ob);
331 if (ob->form->fdui == interface_.dialog())
332 return interface_.feedback(ob);
333 if (ob->form->fdui == language_.dialog())
334 return language_.feedback(ob);
335 if (ob->form->fdui == lnf_misc_.dialog())
336 return lnf_misc_.feedback(ob);
337 if (ob->form->fdui == outputs_misc_.dialog())
338 return outputs_misc_.feedback(ob);
339 if (ob->form->fdui == paths_.dialog())
340 return paths_.feedback(ob);
341 if (ob->form->fdui == printer_.dialog())
342 return printer_.feedback(ob);
343 if (ob->form->fdui == screen_fonts_.dialog())
344 return screen_fonts_.feedback(ob);
345 if (ob->form->fdui == spelloptions_.dialog())
346 return spelloptions_.feedback(ob);
352 ButtonPolicy::SMInput FormPreferences::input(FL_OBJECT * ob, long)
358 // whatever checks you need to ensure the user hasn't entered
359 // some totally ridiculous value somewhere. Change activate to suit.
360 // comments before each test describe what is _valid_
362 if (ob->form->fdui == colors_.dialog()) {
364 } else if (ob->form->fdui == converters_.dialog()) {
365 valid = converters_.input(ob);
366 } else if (ob->form->fdui == copiers_.dialog()) {
367 valid = copiers_.input(ob);
368 } else if (ob->form->fdui == formats_.dialog()) {
369 valid = formats_.input(ob);
370 } else if (ob->form->fdui == interface_.dialog()) {
371 valid = interface_.input(ob);
372 } else if (ob->form->fdui == language_.dialog()) {
373 valid = language_.input(ob);
374 } else if (ob->form->fdui == paths_.dialog()) {
375 valid = paths_.input(ob);
376 } else if (ob->form->fdui == screen_fonts_.dialog()) {
377 valid = screen_fonts_.input();
378 } else if (ob->form->fdui == spelloptions_.dialog()) {
379 valid = spelloptions_.input(ob);
382 return valid ? ButtonPolicy::SMI_VALID : ButtonPolicy::SMI_INVALID;
386 void FormPreferences::update()
388 if (!dialog_.get()) return;
390 LyXRC const & rc(controller().rc());
392 // read lyxrc entries
394 formats_.update(); // Must be before converters_.update()
395 converters_.update();
397 inputs_misc_.update(rc);
398 interface_.update(rc);
399 language_.update(rc);
400 lnf_misc_.update(rc);
401 identity_.update(rc);
402 outputs_misc_.update(rc);
405 screen_fonts_.update(rc);
406 spelloptions_.update(rc);
410 FormPreferences::Colors::Colors(FormPreferences & p)
411 : modifiedXformsPrefs(false), parent_(p)
415 FD_preferences_colors const * FormPreferences::Colors::dialog()
417 return dialog_.get();
421 void FormPreferences::Colors::apply()
423 bool modifiedText = false;
424 bool modifiedBackground = false;
426 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
427 cit != xformsColorDB.end(); ++cit) {
429 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
430 if (col != cit->color()) {
431 modifiedXformsPrefs = true;
432 if (cit->colorID == FL_BLACK)
434 if (cit->colorID == FL_COL1)
435 modifiedBackground = true;
439 if (modifiedXformsPrefs) {
440 for (vector<XformsColor>::const_iterator cit =
441 xformsColorDB.begin();
442 cit != xformsColorDB.end(); ++cit) {
443 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
445 if (modifiedText && cit->colorID == FL_BLACK) {
446 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
449 if (modifiedBackground && cit->colorID == FL_COL1) {
450 AdjustVal(FL_MCOL, FL_COL1, 0.1);
451 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
452 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
454 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
455 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
458 if (cit->colorID == GUI_COLOR_CURSOR) {
459 fl_mapcolor(GUI_COLOR_CURSOR,
460 cit->r, cit->g, cit->b);
461 setCursorColor(GUI_COLOR_CURSOR);
464 parent_.controller().redrawGUI();
467 // Now do the same for the LyX LColors...
468 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
469 cit != lyxColorDB.end(); ++cit) {
470 LColor::color lc = lcolor.getFromLyXName(cit->lyxname);
471 if (lc == LColor::inherit) continue;
473 // Create a valid X11 name of the form "#rrggbb"
474 string const hexname = X11hexname(cit->color());
476 if (lcolor.getX11Name(lc) != hexname) {
478 << "FormPreferences::Colors::apply: "
479 << "resetting LColor " << lcolor.getGUIName(lc)
480 << " from \"" << lcolor.getX11Name(lc)
481 << "\" to \"" << hexname << "\"."
484 parent_.controller().setColor(lc, hexname);
490 void FormPreferences::Colors::build()
492 picker_.reset(new FormColorpicker);
493 dialog_.reset(build_preferences_colors(&parent_));
495 fl_set_object_color(dialog_->button_color,
496 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
498 // set up the feedback mechanism
499 setPrehandler(dialog_->browser_lyx_objs);
500 setPrehandler(dialog_->button_color);
501 setPrehandler(dialog_->button_modify);
506 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
508 if (ob == dialog_->browser_lyx_objs)
509 return _("LyX objects that can be assigned a color.");
511 if (ob == dialog_->button_modify)
512 return _("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
518 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
520 if (ob == dialog_->browser_lyx_objs) {
523 } else if (ob == dialog_->button_modify) {
529 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
533 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
537 hsv.v = min(1.0, max(0.0, hsv.v));
540 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
544 void FormPreferences::Colors::InputBrowserLyX() const
546 vector<NamedColor>::size_type const selLyX =
547 fl_get_browser(dialog_->browser_lyx_objs);
548 if (selLyX < 1) return;
550 // Is the choice an Xforms color...
553 if (selLyX - 1 < xformsColorDB.size()) {
554 vector<XformsColor>::size_type const i = selLyX - 1;
555 col = xformsColorDB[i].color();
557 // or a LyX Logical color?
559 vector<NamedColor>::size_type const i = selLyX - 1 -
560 xformsColorDB.size();
561 col = lyxColorDB[i].color();
564 fl_freeze_form(dialog_->form);
566 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
567 fl_redraw_object(dialog_->button_color);
569 fl_unfreeze_form(dialog_->form);
573 void FormPreferences::Colors::LoadBrowserLyX()
575 if (!dialog_->browser_lyx_objs->visible)
578 // First, define the modifiable xforms colors
579 xformsColorDB.clear();
582 xcol.lyxname = "GUI background";
583 xcol.guiname = _("GUI background");
584 xcol.colorID = FL_COL1;
585 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
587 xformsColorDB.push_back(xcol);
589 xcol.lyxname = "GUI text";
590 xcol.guiname = _("GUI text");
591 xcol.colorID = FL_BLACK;
592 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
594 xformsColorDB.push_back(xcol);
596 xcol.lyxname = "GUI selection";
597 xcol.guiname = _("GUI selection");
598 xcol.colorID = FL_YELLOW;
599 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
601 xformsColorDB.push_back(xcol);
603 xcol.lyxname = "GUI pointer";
604 xcol.guiname = _("GUI pointer");
605 xcol.colorID = GUI_COLOR_CURSOR;
606 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
608 xformsColorDB.push_back(xcol);
610 // Now create the the LyX LColors database
612 for (int i=0; i<LColor::ignore; ++i) {
613 LColor::color lc = static_cast<LColor::color>(i);
614 if (lc == LColor::none
615 || lc == LColor::black
616 || lc == LColor::white
618 || lc == LColor::green
619 || lc == LColor::blue
620 || lc == LColor::cyan
621 || lc == LColor::magenta
622 || lc == LColor::yellow
623 || lc == LColor::inherit
624 || lc == LColor::ignore) continue;
627 bool const success = lyx_gui::getRGBColor(lc, col);
629 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
630 << "LColor " << lcolor.getLyXName(lc)
631 << ": X can't find color \""
632 << lcolor.getX11Name(lc)
633 << "\". Set to \"black\"!" << endl;
635 string const arg = lcolor.getLyXName(lc) + " black";
636 parent_.controller().setColor(lc, "black");
640 // Create a valid X11 name of the form "#rrggbb" and change the
641 // LColor X11name to this. Don't want to trigger a redraw,
642 // as we're just changing the name not the RGB values.
643 // Also reset the system_lcolor names, so that we don't output
644 // unnecessary changes.
645 string const hexname = X11hexname(col);
647 if (lcolor.getX11Name(lc) != hexname) {
648 lcolor.setColor(lc, hexname);
649 system_lcolor.setColor(lc, hexname);
652 // Finally, push the color onto the database
653 NamedColor ncol(lcolor.getLyXName(lc), lcolor.getGUIName(lc), col);
654 lyxColorDB.push_back(ncol);
657 // Now construct the browser
658 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
659 fl_freeze_form(dialog_->form);
660 fl_clear_browser(colbr);
661 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
662 cit != xformsColorDB.end(); ++cit) {
663 fl_addto_browser(colbr, cit->guiname.c_str());
665 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
666 cit != lyxColorDB.end(); ++cit) {
667 fl_addto_browser(colbr, cit->guiname.c_str());
670 // just to be safe...
671 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
672 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
673 fl_unfreeze_form(dialog_->form);
679 void FormPreferences::Colors::Modify()
681 vector<NamedColor>::size_type const selLyX =
682 fl_get_browser(dialog_->browser_lyx_objs);
687 fl_getmcolor(GUI_COLOR_CHOICE, &before.r, &before.g, &before.b);
689 RGBColor col = picker_->requestColor(before);
693 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
694 fl_redraw_object(dialog_->button_color);
696 // Is the choice an Xforms color...
697 if (selLyX - 1 < xformsColorDB.size()) {
698 vector<XformsColor>::size_type const i = selLyX - 1;
699 xformsColorDB[i].r = col.r;
700 xformsColorDB[i].g = col.g;
701 xformsColorDB[i].b = col.b;
703 // or a LyX Logical color?
705 vector<NamedColor>::size_type const i = selLyX - 1 -
706 xformsColorDB.size();
707 lyxColorDB[i].r = col.r;
708 lyxColorDB[i].g = col.g;
709 lyxColorDB[i].b = col.b;
714 FormPreferences::Converters::Converters(FormPreferences & p)
719 FD_preferences_converters const * FormPreferences::Converters::dialog()
721 return dialog_.get();
725 ::Converters & FormPreferences::Converters::converters()
727 return parent_.controller().converters();
731 ::Formats & FormPreferences::Converters::formats()
733 return parent_.controller().formats();
737 void FormPreferences::Converters::build()
739 dialog_.reset(build_preferences_converters(&parent_));
741 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
742 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
744 // set up the feedback mechanism
745 setPrehandler(dialog_->browser_all);
746 setPrehandler(dialog_->button_delete);
747 setPrehandler(dialog_->button_add);
748 setPrehandler(dialog_->input_converter);
749 setPrehandler(dialog_->choice_from);
750 setPrehandler(dialog_->choice_to);
751 setPrehandler(dialog_->input_flags);
756 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
758 if (ob == dialog_->browser_all)
759 return _("All explicitly defined converters for LyX");
761 if (ob == dialog_->choice_from)
762 return _("Convert \"from\" this format");
764 if (ob == dialog_->choice_to)
765 return _("Convert \"to\" this format");
767 if (ob == dialog_->input_converter)
768 return _("The conversion command. $$i is the input file name, "
769 "$$b is the file name without its extension and $$o "
770 "is the name of the output file. $$s can be used "
771 "as the path to the user/library directory.");
773 if (ob == dialog_->input_flags)
774 return _("Extra information for the Converter class, e.g., whether and "
775 "how to parse the result.");
777 if (ob == dialog_->button_delete)
778 return _("Remove the current converter from the list of available "
779 "converters. Note: you must then \"Apply\" the change.");
781 if (ob == dialog_->button_add) {
782 if (string(ob->label) == _("Add"))
783 return _("Add the current converter to the list of available "
784 "converters. Note: you must then \"Apply\" the change.");
786 return _("Modify the contents of the current converter. "
787 "Note: you must then \"Apply\" the change.");
794 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
796 if (ob == dialog_->browser_all)
799 if (ob == dialog_->choice_from
800 || ob == dialog_->choice_to
801 || ob == dialog_->input_converter
802 || ob == dialog_->input_flags)
805 if (ob == dialog_->button_add)
808 if (ob == dialog_->button_delete)
815 void FormPreferences::Converters::update()
821 void FormPreferences::Converters::UpdateBrowser()
825 fl_freeze_form(dialog_->form);
826 fl_clear_browser(dialog_->browser_all);
827 for (::Converters::const_iterator cit = converters().begin();
828 cit != converters().end(); ++cit) {
829 string const name = cit->From->prettyname() + " -> "
830 + cit->To->prettyname();
831 fl_addto_browser(dialog_->browser_all, name.c_str());
834 fl_unfreeze_form(dialog_->form);
838 bool FormPreferences::Converters::Add()
840 string const from = GetFrom();
841 string const to = GetTo();
842 string const command = getString(dialog_->input_converter);
843 string const flags = getString(dialog_->input_flags);
845 Converter const * old = converters().getConverter(from, to);
846 converters().add(from, to, command, flags);
848 converters().updateLast(formats());
851 setEnabled(dialog_->button_add, false);
857 bool FormPreferences::Converters::Browser()
859 int const i = fl_get_browser(dialog_->browser_all);
860 if (i <= 0) return false;
862 fl_freeze_form(dialog_->form);
864 Converter const & c = converters().get(i - 1);
865 int j = formats().getNumber(c.from);
867 fl_set_choice(dialog_->choice_from, j + 1);
869 j = formats().getNumber(c.to);
871 fl_set_choice(dialog_->choice_to, j + 1);
873 fl_set_input(dialog_->input_converter, c.command.c_str());
874 fl_set_input(dialog_->input_flags, c.flags.c_str());
876 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
877 fl_set_button_shortcut(dialog_->button_add,
878 scex(_("Modify|#M")).c_str(), 1);
880 setEnabled(dialog_->button_add, false);
881 setEnabled(dialog_->button_delete, true);
883 fl_unfreeze_form(dialog_->form);
888 bool FormPreferences::Converters::erase()
890 string const from = GetFrom();
891 string const to = GetTo();
893 converters().erase(from, to);
899 bool FormPreferences::Converters::Input()
901 string const from = GetFrom();
902 string const to = GetTo();
903 int const sel = converters().getNumber(from, to);
905 fl_freeze_form(dialog_->form);
908 fl_set_object_label(dialog_->button_add,
909 idex(_("Add|#A")).c_str());
910 fl_set_button_shortcut(dialog_->button_add,
911 scex(_("Add|#A")).c_str(), 1);
913 fl_deselect_browser(dialog_->browser_all);
914 setEnabled(dialog_->button_delete, false);
917 fl_set_object_label(dialog_->button_add,
918 idex(_("Modify|#M")).c_str());
919 fl_set_button_shortcut(dialog_->button_add,
920 scex(_("Modify|#M")).c_str(), 1);
922 int top = max(sel-5, 0);
923 fl_set_browser_topline(dialog_->browser_all, top);
924 fl_select_browser_line(dialog_->browser_all, sel+1);
925 setEnabled(dialog_->button_delete, true);
928 string const command = rtrim(getString(dialog_->input_converter));
929 bool const enable = !(command.empty() || from == to);
930 setEnabled(dialog_->button_add, enable);
932 fl_unfreeze_form(dialog_->form);
937 string const FormPreferences::Converters::GetFrom()
939 ::Formats::FormatList::size_type const i =
940 fl_get_choice(dialog_->choice_from);
942 if (i > 0 && i <= formats().size())
943 return formats().get(i - 1).name();
945 lyxerr << "FormPreferences::Converters::GetFrom: No choice!" << endl;
950 string const FormPreferences::Converters::GetTo()
952 ::Formats::FormatList::size_type const i =
953 fl_get_choice(dialog_->choice_to);
955 if (i > 0 && i <= formats().size())
956 return formats().get(i - 1).name();
958 lyxerr << "FormPreferences::Converters::GetTo: No choice!" << endl;
963 void FormPreferences::Converters::UpdateChoices()
966 for (::Formats::const_iterator cit = formats().begin();
967 cit != formats().end(); ++cit) {
972 choice += cit->prettyname();
976 fl_clear_choice(dialog_->choice_from);
977 fl_addto_choice(dialog_->choice_from, choice.c_str());
979 fl_clear_choice(dialog_->choice_to);
980 fl_addto_choice(dialog_->choice_to, choice.c_str());
984 FormPreferences::Copiers::Copiers(FormPreferences & p)
989 FD_preferences_copiers const * FormPreferences::Copiers::dialog()
991 return dialog_.get();
995 ::Movers & FormPreferences::Copiers::movers()
997 return parent_.controller().movers();
1001 void FormPreferences::Copiers::build()
1003 dialog_.reset(build_preferences_copiers(&parent_));
1005 fl_set_input_return(dialog_->input_copier, FL_RETURN_CHANGED);
1007 // set up the feedback mechanism
1008 setPrehandler(dialog_->browser_all);
1009 setPrehandler(dialog_->button_delete);
1010 setPrehandler(dialog_->button_add);
1011 setPrehandler(dialog_->choice_format);
1012 setPrehandler(dialog_->input_copier);
1017 FormPreferences::Copiers::feedback(FL_OBJECT const * const ob) const
1019 if (ob == dialog_->browser_all)
1020 return _("All explicitly defined copiers for LyX");
1022 if (ob == dialog_->choice_format)
1023 return _("Copier for this format");
1025 if (ob == dialog_->input_copier)
1027 return _("The command used to copy the file. "
1028 "$$i is the \"from\" file name and "
1029 "$$o is the \"to\" file name.\n"
1030 "$$s can be used as the path to the user/library "
1033 if (ob == dialog_->button_delete)
1034 return _("Remove the current copier from the list of available "
1035 "copiers. Note: you must then \"Apply\" the change.");
1037 if (ob == dialog_->button_add) {
1038 if (string(ob->label) == _("Add"))
1039 return _("Add the current copier to the list of available "
1040 "copiers. Note: you must then \"Apply\" the change.");
1042 return _("Modify the contents of the current copier. "
1043 "Note: you must then \"Apply\" the change.");
1050 bool FormPreferences::Copiers::input(FL_OBJECT const * const ob)
1052 if (ob == dialog_->browser_all)
1055 if (ob == dialog_->choice_format
1056 || ob == dialog_->input_copier)
1059 if (ob == dialog_->button_add)
1062 if (ob == dialog_->button_delete)
1069 void FormPreferences::Copiers::update()
1071 // Build data for the browser widget
1072 Movers::iterator const begin = movers().begin();
1073 Movers::iterator const end = movers().end();
1075 vector<string> fmts;
1076 fmts.reserve(std::distance(begin, end));
1077 for (Movers::iterator it = begin; it != end; ++it) {
1078 std::string const & command = it->second.command();
1079 if (command.empty())
1081 std::string const & fmt = it->first;
1082 fmts.push_back(::formats.prettyName(fmt));
1085 std::sort(fmts.begin(), fmts.end());
1087 // Build data for the choice widget
1089 for (::Formats::const_iterator it = ::formats.begin();
1090 it != ::formats.end(); ++it) {
1091 if (!choice.empty())
1095 choice += it->prettyname();
1100 fl_freeze_form(dialog_->form);
1101 fl_set_input(dialog_->input_copier, "");
1103 // The browser widget
1104 fl_clear_browser(dialog_->browser_all);
1106 vector<string>::const_iterator it = fmts.begin();
1107 vector<string>::const_iterator const fmts_end = fmts.end();
1108 for (; it != fmts_end; ++it)
1109 fl_addto_browser(dialog_->browser_all, it->c_str());
1111 // The choice widget
1112 fl_clear_choice(dialog_->choice_format);
1113 fl_addto_choice(dialog_->choice_format, choice.c_str());
1114 fl_set_choice(dialog_->choice_format, 1);
1117 fl_unfreeze_form(dialog_->form);
1123 struct SamePrettyName {
1124 SamePrettyName(string const & n) : pretty_name_(n) {}
1126 bool operator()(::Format const & fmt) const {
1127 return fmt.prettyname() == pretty_name_;
1131 string const pretty_name_;
1135 ::Format const * getFormat(std::string const & prettyname)
1137 ::Formats::const_iterator it = ::formats.begin();
1138 ::Formats::const_iterator const end = ::formats.end();
1139 it = std::find_if(it, end, SamePrettyName(prettyname));
1140 return it == end ? 0 : &*it;
1146 bool FormPreferences::Copiers::Add()
1148 ::Format const * fmt = getFormat(getString(dialog_->choice_format));
1152 string const command = getString(dialog_->input_copier);
1153 if (command.empty())
1156 fl_freeze_form(dialog_->form);
1158 movers().set(fmt->name(), command);
1160 setEnabled(dialog_->button_add, false);
1162 fl_unfreeze_form(dialog_->form);
1167 bool FormPreferences::Copiers::Browser()
1169 int const i = fl_get_browser(dialog_->browser_all);
1170 if (i <= 0) return false;
1172 ::Format const * fmt = getFormat(getString(dialog_->browser_all, i));
1176 string const & fmt_name = fmt->name();
1177 string const & gui_name = fmt->prettyname();
1178 string const & command = movers().command(fmt_name);
1180 fl_freeze_form(dialog_->form);
1182 int const choice_size = fl_get_choice_maxitems(dialog_->choice_format);
1183 for (int i = 1; i <= choice_size; ++i) {
1184 char const * const c_str =
1185 fl_get_choice_item_text(dialog_->choice_format, i);
1186 string const line = c_str ? trim(c_str) : string();
1187 if (line == gui_name) {
1188 fl_set_choice(dialog_->choice_format, i);
1193 fl_set_input(dialog_->input_copier, command.c_str());
1195 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")).c_str());
1196 fl_set_button_shortcut(dialog_->button_add,
1197 scex(_("Modify|#M")).c_str(), 1);
1199 setEnabled(dialog_->button_add, false);
1200 setEnabled(dialog_->button_delete, true);
1202 fl_unfreeze_form(dialog_->form);
1207 bool FormPreferences::Copiers::Erase()
1209 ::Format const * fmt = getFormat(getString(dialog_->choice_format));
1213 string const & fmt_name = fmt->name();
1215 movers().set(fmt_name, string());
1221 bool FormPreferences::Copiers::Input()
1223 ::Format const * fmt = getFormat(getString(dialog_->choice_format));
1227 string const & gui_name = fmt->prettyname();
1228 string const command = getString(dialog_->input_copier);
1230 fl_freeze_form(dialog_->form);
1231 fl_deselect_browser(dialog_->browser_all);
1232 bool found_line = false;
1233 int const browser_size = fl_get_browser_maxline(dialog_->browser_all);
1234 for (int i = 1; i <= browser_size; ++i) {
1235 char const * const c_str =
1236 fl_get_browser_line(dialog_->browser_all, i);
1237 string const line = c_str ? trim(c_str) : string();
1238 if (line == gui_name) {
1239 fl_select_browser_line(dialog_->browser_all, i);
1240 int top = max(i-5, 1);
1241 fl_set_browser_topline(dialog_->browser_all, top);
1248 fl_set_object_label(dialog_->button_add,
1249 idex(_("Add|#A")).c_str());
1250 fl_set_button_shortcut(dialog_->button_add,
1251 scex(_("Add|#A")).c_str(), 1);
1253 setEnabled(dialog_->button_delete, false);
1255 fl_set_object_label(dialog_->button_add,
1256 idex(_("Modify|#M")).c_str());
1257 fl_set_button_shortcut(dialog_->button_add,
1258 scex(_("Modify|#M")).c_str(), 1);
1260 setEnabled(dialog_->button_delete, true);
1263 setEnabled(dialog_->button_add, !command.empty());
1265 fl_unfreeze_form(dialog_->form);
1270 FormPreferences::Formats::Formats(FormPreferences & p)
1275 FD_preferences_formats const * FormPreferences::Formats::dialog()
1277 return dialog_.get();
1281 ::Converters & FormPreferences::Formats::converters()
1283 return parent_.controller().converters();
1287 ::Formats & FormPreferences::Formats::formats()
1289 return parent_.controller().formats();
1293 void FormPreferences::Formats::build()
1295 dialog_.reset(build_preferences_formats(&parent_));
1297 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1298 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1299 fl_set_input_return(dialog_->input_editor, FL_RETURN_CHANGED);
1300 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1301 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1302 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1304 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1306 // set up the feedback mechanism
1307 setPrehandler(dialog_->browser_all);
1308 setPrehandler(dialog_->input_format);
1309 setPrehandler(dialog_->input_gui_name);
1310 setPrehandler(dialog_->button_delete);
1311 setPrehandler(dialog_->button_add);
1312 setPrehandler(dialog_->input_extension);
1313 setPrehandler(dialog_->input_viewer);
1314 setPrehandler(dialog_->input_editor);
1315 setPrehandler(dialog_->input_shrtcut);
1316 setPrehandler(dialog_->check_document);
1321 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1323 if (ob == dialog_->browser_all)
1324 return _("All the currently defined formats known to LyX.");
1326 if (ob == dialog_->input_format)
1327 return _("The format identifier.");
1329 if (ob == dialog_->input_gui_name)
1330 return _("The format name as it will appear in the menus.");
1332 if (ob == dialog_->input_shrtcut)
1333 return _("The keyboard accelerator. Use a letter in the GUI name. "
1336 if (ob == dialog_->input_extension)
1337 return _("Used to recognize the file. E.g., ps, pdf, tex.");
1339 if (ob == dialog_->input_viewer)
1340 return _("The command used to launch the viewer application.");
1342 if (ob == dialog_->input_editor)
1343 return _("The command used to launch the editor application.");
1345 if (ob == dialog_->button_delete)
1346 return _("Remove the current format from the list of available "
1347 "formats. Note: you must then \"Apply\" the change.");
1349 if (ob == dialog_->check_document)
1350 return _("Tell whether this format is a document format. "
1351 "A document can not be exported to or viewed in a non-document format.");
1353 if (ob == dialog_->button_add) {
1354 if (string(ob->label) == _("Add"))
1355 return _("Add the current format to the list of available "
1356 "formats. Note: you must then \"Apply\" the change.");
1358 return _("Modify the contents of the current format. Note: "
1359 "you must then \"Apply\" the change.");
1366 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1368 if (ob == dialog_->browser_all)
1371 if (ob == dialog_->input_format
1372 || ob == dialog_->input_gui_name
1373 || ob == dialog_->input_shrtcut
1374 || ob == dialog_->input_extension
1375 || ob == dialog_->input_viewer
1376 || ob == dialog_->input_editor
1377 || ob == dialog_->check_document)
1380 if (ob == dialog_->button_add)
1383 if (ob == dialog_->button_delete)
1390 void FormPreferences::Formats::update()
1396 void FormPreferences::Formats::UpdateBrowser()
1400 fl_freeze_form(dialog_->form);
1401 fl_deselect_browser(dialog_->browser_all);
1402 fl_clear_browser(dialog_->browser_all);
1403 for (::Formats::const_iterator cit = formats().begin();
1404 cit != formats().end(); ++cit)
1405 fl_addto_browser(dialog_->browser_all,
1406 cit->prettyname().c_str());
1409 fl_unfreeze_form(dialog_->form);
1411 // Mustn't forget to update the Formats available to the converters_
1412 parent_.converters_.UpdateChoices();
1413 converters().update(formats());
1417 bool FormPreferences::Formats::Add()
1419 string const name = getString(dialog_->input_format);
1420 string const prettyname = getString(dialog_->input_gui_name);
1421 string const extension = getString(dialog_->input_extension);
1422 string const shortcut = getString(dialog_->input_shrtcut);
1423 string const viewer = getString(dialog_->input_viewer);
1424 string const editor = getString(dialog_->input_editor);
1425 bool const document = fl_get_button(dialog_->check_document);
1427 Format const * old = formats().getFormat(name);
1428 string const old_prettyname = old ? old->prettyname() : string();
1429 formats().add(name, extension, prettyname, shortcut, viewer, editor,
1431 if (!old || prettyname != old_prettyname) {
1434 parent_.converters_.UpdateBrowser();
1436 setEnabled(dialog_->button_add, false);
1442 bool FormPreferences::Formats::Browser()
1444 int const i = fl_get_browser(dialog_->browser_all);
1448 fl_freeze_form(dialog_->form);
1450 Format const & f = formats().get(i - 1);
1452 fl_set_input(dialog_->input_format, f.name().c_str());
1453 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1454 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1455 fl_set_input(dialog_->input_extension, f.extension().c_str());
1456 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1457 fl_set_input(dialog_->input_editor, f.editor().c_str());
1458 fl_set_button(dialog_->check_document, f.documentFormat());
1460 fl_set_object_label(dialog_->button_add,
1461 idex(_("Modify|#M")).c_str());
1462 fl_set_button_shortcut(dialog_->button_add,
1463 scex(_("Modify|#M")).c_str(), 1);
1465 setEnabled(dialog_->button_add, false);
1466 setEnabled(dialog_->button_delete, true);
1468 fl_unfreeze_form(dialog_->form);
1473 bool FormPreferences::Formats::erase()
1475 string const name = getString(dialog_->input_format);
1477 if (converters().formatIsUsed(name)) {
1478 parent_.postWarning(_("Cannot remove a Format used by a Converter. "
1479 "Remove the converter first."));
1480 setEnabled(dialog_->button_delete, false);
1484 formats().erase(name);
1490 bool FormPreferences::Formats::Input()
1492 string const name = getString(dialog_->input_format);
1493 int const sel = formats().getNumber(name);
1494 fl_freeze_form(dialog_->form);
1497 fl_set_object_label(dialog_->button_add,
1498 idex(_("Add|#A")).c_str());
1499 fl_set_button_shortcut(dialog_->button_add,
1500 scex(_("Add|#A")).c_str(), 1);
1502 fl_deselect_browser(dialog_->browser_all);
1503 setEnabled(dialog_->button_delete, false);
1506 fl_set_object_label(dialog_->button_add,
1507 idex(_("Modify|#M")).c_str());
1508 fl_set_button_shortcut(dialog_->button_add,
1509 scex(_("Modify|#M")).c_str(), 1);
1511 int const top = max(sel-5, 0);
1512 fl_set_browser_topline(dialog_->browser_all, top);
1513 fl_select_browser_line(dialog_->browser_all, sel+1);
1515 setEnabled(dialog_->button_add, true);
1516 setEnabled(dialog_->button_delete, true);
1519 string const prettyname = getString(dialog_->input_gui_name);
1520 bool const enable = !(name.empty() || prettyname.empty());
1521 setEnabled(dialog_->button_add, enable);
1523 fl_unfreeze_form(dialog_->form);
1528 FormPreferences::Identity::Identity(FormPreferences & p)
1533 FD_preferences_identity const * FormPreferences::Identity::dialog()
1535 return dialog_.get();
1539 void FormPreferences::Identity::apply(LyXRC & rc) const
1541 rc.user_name = getString(dialog_->input_user_name);
1542 rc.user_email = getString(dialog_->input_user_email);
1546 void FormPreferences::Identity::build()
1548 dialog_.reset(build_preferences_identity(&parent_));
1549 fl_set_input_return(dialog_->input_user_name, FL_RETURN_CHANGED);
1550 fl_set_input_return(dialog_->input_user_email, FL_RETURN_CHANGED);
1554 void FormPreferences::Identity::update(LyXRC const & rc)
1556 fl_set_input(dialog_->input_user_name, rc.user_name.c_str());
1557 fl_set_input(dialog_->input_user_email, rc.user_email.c_str());
1561 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1566 FD_preferences_inputs_misc const * FormPreferences::InputsMisc::dialog()
1568 return dialog_.get();
1572 void FormPreferences::InputsMisc::apply(LyXRC & rc) const
1574 rc.date_insert_format =
1575 getString(dialog_->input_date_format);
1579 void FormPreferences::InputsMisc::build()
1581 dialog_.reset(build_preferences_inputs_misc(&parent_));
1583 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1585 // set up the feedback mechanism
1586 setPrehandler(dialog_->input_date_format);
1591 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1593 if (ob == dialog_->input_date_format)
1594 return LyXRC::getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1599 void FormPreferences::InputsMisc::update(LyXRC const & rc)
1601 fl_set_input(dialog_->input_date_format,
1602 rc.date_insert_format.c_str());
1606 FormPreferences::Interface::Interface(FormPreferences & p)
1611 FD_preferences_interface const * FormPreferences::Interface::dialog()
1613 return dialog_.get();
1617 void FormPreferences::Interface::apply(LyXRC & rc) const
1619 rc.popup_normal_font =
1620 getString(dialog_->input_popup_normal_font);
1621 rc.popup_bold_font = getString(dialog_->input_popup_bold_font);
1622 rc.popup_font_encoding =
1623 getString(dialog_->input_popup_font_encoding);
1624 rc.bind_file = getString(dialog_->input_bind_file);
1625 rc.ui_file = getString(dialog_->input_ui_file);
1629 void FormPreferences::Interface::build()
1631 dialog_.reset(build_preferences_interface(&parent_));
1633 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1634 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1635 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1636 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1637 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1639 // set up the feedback mechanism
1640 setPrehandler(dialog_->input_popup_normal_font);
1641 setPrehandler(dialog_->input_popup_bold_font);
1642 setPrehandler(dialog_->input_popup_font_encoding);
1643 setPrehandler(dialog_->input_bind_file);
1644 setPrehandler(dialog_->button_bind_file_browse);
1645 setPrehandler(dialog_->input_ui_file);
1646 setPrehandler(dialog_->button_ui_file_browse);
1651 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1653 if (ob == dialog_->input_popup_normal_font)
1654 return LyXRC::getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1655 if (ob == dialog_->input_popup_bold_font)
1656 return LyXRC::getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1657 if (ob == dialog_->input_popup_font_encoding)
1658 return LyXRC::getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1659 if (ob == dialog_->input_bind_file)
1660 return LyXRC::getDescription(LyXRC::RC_BINDFILE);
1661 if (ob == dialog_->input_ui_file)
1662 return LyXRC::getDescription(LyXRC::RC_UIFILE);
1667 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1669 if (ob == dialog_->button_bind_file_browse) {
1670 string f = parent_.controller().browsebind(
1671 getString(dialog_->input_bind_file));
1673 fl_set_input(dialog_->input_bind_file, f.c_str());
1674 } else if (ob == dialog_->button_ui_file_browse) {
1675 string f = parent_.controller().browseUI(
1676 getString(dialog_->input_ui_file));
1678 fl_set_input(dialog_->input_ui_file, f.c_str());
1685 void FormPreferences::Interface::update(LyXRC const & rc)
1687 fl_set_input(dialog_->input_popup_normal_font,
1688 rc.popup_normal_font.c_str());
1689 fl_set_input(dialog_->input_popup_bold_font,
1690 rc.popup_bold_font.c_str());
1691 fl_set_input(dialog_->input_popup_font_encoding,
1692 rc.popup_font_encoding.c_str());
1693 fl_set_input(dialog_->input_bind_file,
1694 rc.bind_file.c_str());
1695 fl_set_input(dialog_->input_ui_file,
1696 rc.ui_file.c_str());
1700 FormPreferences::Language::Language(FormPreferences & p)
1705 FD_preferences_language const * FormPreferences::Language::dialog()
1707 return dialog_.get();
1711 void FormPreferences::Language::apply(LyXRC & rc)
1713 int const pos = fl_get_combox(dialog_->combox_default_lang);
1714 rc.default_language = lang_[pos-1];
1716 int button = fl_get_button(dialog_->check_use_kbmap);
1717 string const name_1 = getString(dialog_->input_kbmap1);
1718 string const name_2 = getString(dialog_->input_kbmap2);
1720 button = !(name_1.empty() && name_2.empty());
1721 rc.use_kbmap = static_cast<bool>(button);
1724 rc.primary_kbmap = name_1;
1725 rc.secondary_kbmap = name_2;
1728 button = fl_get_button(dialog_->check_rtl_support);
1729 rc.rtl_support = static_cast<bool>(button);
1731 button = fl_get_button(dialog_->check_mark_foreign);
1732 rc.mark_foreign_language = static_cast<bool>(button);
1734 button = fl_get_button(dialog_->check_auto_begin);
1735 rc.language_auto_begin = static_cast<bool>(button);
1737 button = fl_get_button(dialog_->check_auto_end);
1738 rc.language_auto_end = static_cast<bool>(button);
1740 button = fl_get_button(dialog_->check_use_babel);
1741 rc.language_use_babel = static_cast<bool>(button);
1743 button = fl_get_button(dialog_->check_global_options);
1744 rc.language_global_options = static_cast<bool>(button);
1746 rc.language_package = getString(dialog_->input_package);
1747 rc.language_command_begin = getString(dialog_->input_command_begin);
1748 rc.language_command_end = getString(dialog_->input_command_end);
1750 // Ensure that all is self-consistent.
1755 void FormPreferences::Language::build()
1757 dialog_.reset(build_preferences_language(&parent_));
1759 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1760 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1761 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1763 // Store the lang identifiers for later
1764 vector<LanguagePair> const langs = getLanguageData(false);
1765 lang_ = getSecond(langs);
1767 FL_OBJECT * obj = dialog_->combox_default_lang;
1768 vector<LanguagePair>::const_iterator lit = langs.begin();
1769 vector<LanguagePair>::const_iterator lend = langs.end();
1770 for (; lit != lend; ++lit) {
1771 fl_addto_combox(obj, lit->first.c_str());
1773 fl_set_combox_browser_height(obj, 400);
1775 // set up the feedback mechanism
1776 setPrehandler(dialog_->input_package);
1777 setPrehandler(dialog_->check_use_kbmap);
1778 setPrehandler(dialog_->combox_default_lang);
1779 setPrehandler(dialog_->input_kbmap1);
1780 setPrehandler(dialog_->input_kbmap2);
1781 setPrehandler(dialog_->check_rtl_support);
1782 setPrehandler(dialog_->check_mark_foreign);
1783 setPrehandler(dialog_->check_auto_begin);
1784 setPrehandler(dialog_->check_auto_end);
1785 setPrehandler(dialog_->check_use_babel);
1786 setPrehandler(dialog_->check_global_options);
1787 setPrehandler(dialog_->input_command_begin);
1788 setPrehandler(dialog_->input_command_end);
1790 // Activate/Deactivate the input fields dependent on the state of the
1797 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1799 if (ob == dialog_->combox_default_lang)
1800 return LyXRC::getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1801 if (ob == dialog_->check_use_kbmap)
1802 return LyXRC::getDescription(LyXRC::RC_KBMAP);
1803 if (ob == dialog_->input_kbmap1)
1804 return LyXRC::getDescription(LyXRC::RC_KBMAP_PRIMARY);
1805 if (ob == dialog_->input_kbmap2)
1806 return LyXRC::getDescription(LyXRC::RC_KBMAP_SECONDARY);
1807 if (ob == dialog_->check_rtl_support)
1808 return LyXRC::getDescription(LyXRC::RC_RTL_SUPPORT);
1809 if (ob == dialog_->check_mark_foreign)
1810 return LyXRC::getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1811 if (ob == dialog_->check_auto_begin)
1812 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1813 if (ob == dialog_->check_auto_end)
1814 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1815 if (ob == dialog_->check_use_babel)
1816 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1817 if (ob == dialog_->check_global_options)
1818 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1819 if (ob == dialog_->input_package)
1820 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1821 if (ob == dialog_->input_command_begin)
1822 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1823 if (ob == dialog_->input_command_end)
1824 return LyXRC::getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1829 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1831 bool activate = true;
1833 // !ob if function is called from Language::build() to de/activate
1835 // otherwise the function is called by an xforms CB via input().
1836 if (!ob || ob == dialog_->check_use_kbmap) {
1837 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1838 setEnabled(dialog_->button_kbmap1_browse, enable);
1839 setEnabled(dialog_->button_kbmap2_browse, enable);
1840 setEnabled(dialog_->input_kbmap1, enable);
1841 setEnabled(dialog_->input_kbmap2, enable);
1844 if (ob == dialog_->button_kbmap1_browse) {
1845 string f = parent_.controller().browsekbmap(
1846 getString(dialog_->input_kbmap1));
1848 fl_set_input(dialog_->input_kbmap1, f.c_str());
1849 } else if (ob == dialog_->button_kbmap2_browse) {
1850 string f = parent_.controller().browsekbmap(
1851 getString(dialog_->input_kbmap2));
1853 fl_set_input(dialog_->input_kbmap2, f.c_str());
1860 void FormPreferences::Language::update(LyXRC const & rc)
1862 fl_set_button(dialog_->check_use_kbmap,
1865 int const pos = int(findPos(lang_, rc.default_language));
1866 fl_set_combox(dialog_->combox_default_lang, pos + 1);
1869 fl_set_input(dialog_->input_kbmap1,
1870 rc.primary_kbmap.c_str());
1871 fl_set_input(dialog_->input_kbmap2,
1872 rc.secondary_kbmap.c_str());
1874 fl_set_input(dialog_->input_kbmap1, "");
1875 fl_set_input(dialog_->input_kbmap2, "");
1878 fl_set_button(dialog_->check_rtl_support, rc.rtl_support);
1879 fl_set_button(dialog_->check_mark_foreign,
1880 rc.mark_foreign_language);
1881 fl_set_button(dialog_->check_auto_begin, rc.language_auto_begin);
1882 fl_set_button(dialog_->check_auto_end, rc.language_auto_end);
1883 fl_set_button(dialog_->check_use_babel, rc.language_use_babel);
1884 fl_set_button(dialog_->check_global_options,
1885 rc.language_global_options);
1887 fl_set_input(dialog_->input_package,
1888 rc.language_package.c_str());
1889 fl_set_input(dialog_->input_command_begin,
1890 rc.language_command_begin.c_str());
1891 fl_set_input(dialog_->input_command_end,
1892 rc.language_command_end.c_str());
1894 // Activate/Deactivate the input fields dependent on the state of the
1900 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1905 FD_preferences_lnf_misc const * FormPreferences::LnFmisc::dialog()
1907 return dialog_.get();
1911 void FormPreferences::LnFmisc::apply(LyXRC & rc) const
1913 rc.auto_region_delete =
1914 fl_get_button(dialog_->check_auto_region_delete);
1915 rc.cursor_follows_scrollbar =
1916 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1917 rc.dialogs_iconify_with_main =
1918 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1920 switch (fl_get_choice(dialog_->choice_instant_preview)) {
1922 rc.preview = LyXRC::PREVIEW_OFF;
1925 rc.preview = LyXRC::PREVIEW_NO_MATH;
1928 rc.preview = LyXRC::PREVIEW_ON;
1932 rc.autosave = static_cast<unsigned int>
1933 (fl_get_counter_value(dialog_->counter_autosave));
1934 rc.wheel_jump = static_cast<unsigned int>
1935 (fl_get_counter_value(dialog_->counter_wm_jump));
1938 // graphics::DisplayType old_value = rc.display_graphics;
1939 switch (fl_get_choice(dialog_->choice_graphics_display)) {
1941 rc.display_graphics = graphics::NoDisplay;
1944 rc.display_graphics = graphics::ColorDisplay;
1947 rc.display_graphics = graphics::GrayscaleDisplay;
1950 rc.display_graphics = graphics::MonochromeDisplay;
1953 rc.display_graphics = graphics::ColorDisplay;
1957 #ifdef WITH_WARNINGS
1958 #warning FIXME!! The graphics cache no longer has a changeDisplay method.
1961 if (old_value != rc.display_graphics) {
1962 graphics::GCache & gc = graphics::GCache::get();
1969 void FormPreferences::LnFmisc::build()
1971 dialog_.reset(build_preferences_lnf_misc(&parent_));
1973 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1974 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1976 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1977 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1979 // set up the feedback mechanism
1980 setPrehandler(dialog_->check_auto_region_delete);
1981 setPrehandler(dialog_->counter_autosave);
1982 setPrehandler(dialog_->check_cursor_follows_scrollbar);
1983 setPrehandler(dialog_->check_dialogs_iconify_with_main);
1984 setPrehandler(dialog_->choice_instant_preview);
1985 setPrehandler(dialog_->counter_wm_jump);
1987 fl_addto_choice(dialog_->choice_graphics_display,
1988 _("Monochrome|Grayscale|Color|Do not display").c_str());
1990 fl_addto_choice(dialog_->choice_instant_preview,
1991 _("Off|No math|On").c_str());
1996 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1998 if (ob == dialog_->check_auto_region_delete)
1999 return LyXRC::getDescription(LyXRC::RC_AUTOREGIONDELETE);
2000 if (ob == dialog_->check_cursor_follows_scrollbar)
2001 return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
2002 if (ob == dialog_->check_dialogs_iconify_with_main)
2003 return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
2004 if (ob == dialog_->choice_instant_preview)
2005 return LyXRC::getDescription(LyXRC::RC_PREVIEW);
2006 if (ob == dialog_->counter_autosave)
2007 return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
2008 if (ob == dialog_->counter_wm_jump)
2009 return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
2010 if (ob == dialog_->choice_graphics_display)
2011 return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
2016 void FormPreferences::LnFmisc::update(LyXRC const & rc)
2018 fl_set_button(dialog_->check_auto_region_delete,
2019 rc.auto_region_delete);
2020 fl_set_button(dialog_->check_cursor_follows_scrollbar,
2021 rc.cursor_follows_scrollbar);
2022 fl_set_button(dialog_->check_dialogs_iconify_with_main,
2023 rc.dialogs_iconify_with_main);
2025 switch (rc.preview) {
2026 case LyXRC::PREVIEW_OFF:
2027 fl_set_choice(dialog_->choice_instant_preview, 1);
2029 case LyXRC::PREVIEW_NO_MATH:
2030 fl_set_choice(dialog_->choice_instant_preview, 2);
2032 case LyXRC::PREVIEW_ON:
2033 fl_set_choice(dialog_->choice_instant_preview, 3);
2037 fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
2038 fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
2040 switch (rc.display_graphics) {
2041 case graphics::NoDisplay:
2042 fl_set_choice(dialog_->choice_graphics_display, 4);
2044 case graphics::ColorDisplay:
2045 fl_set_choice(dialog_->choice_graphics_display, 3);
2047 case graphics::GrayscaleDisplay:
2048 fl_set_choice(dialog_->choice_graphics_display, 2);
2050 case graphics::MonochromeDisplay:
2051 fl_set_choice(dialog_->choice_graphics_display, 1);
2054 fl_set_choice(dialog_->choice_graphics_display, 3);
2060 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
2065 FD_preferences_outputs_misc const * FormPreferences::OutputsMisc::dialog()
2067 return dialog_.get();
2071 void FormPreferences::OutputsMisc::apply(LyXRC & rc) const
2073 rc.ascii_linelen = static_cast<unsigned int>
2074 (fl_get_counter_value(dialog_->counter_line_len));
2075 rc.fontenc = getString(dialog_->input_tex_encoding);
2078 fl_get_choice(dialog_->choice_default_papersize) - 1;
2079 rc.default_papersize = parent_.controller().toPaperSize(choice);
2081 rc.ascii_roff_command = getString(dialog_->input_ascii_roff);
2082 rc.chktex_command = getString(dialog_->input_checktex);
2083 rc.bibtex_command = getString(dialog_->input_bibtex);
2084 rc.index_command = getString(dialog_->input_index);
2085 rc.view_dvi_paper_option = getString(dialog_->input_paperoption);
2086 rc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
2088 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
2089 rc.cygwin_path_fix = fl_get_button(dialog_->check_cygwin_path);
2094 void FormPreferences::OutputsMisc::build()
2096 dialog_.reset(build_preferences_outputs_misc(&parent_));
2098 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
2100 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
2101 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
2102 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
2103 fl_set_input_return(dialog_->input_bibtex, FL_RETURN_CHANGED);
2104 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
2105 fl_set_input_return(dialog_->input_index, FL_RETURN_CHANGED);
2106 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
2108 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
2110 setEnabled(dialog_->check_cygwin_path, false);
2113 fl_addto_choice(dialog_->choice_default_papersize,
2114 _(" default | US letter | US legal "
2115 "| US executive | A3 | A4 | A5 | B5 ").c_str());
2117 // set up the feedback mechanism
2118 setPrehandler(dialog_->counter_line_len);
2119 setPrehandler(dialog_->input_tex_encoding);
2120 setPrehandler(dialog_->choice_default_papersize);
2121 setPrehandler(dialog_->input_ascii_roff);
2122 setPrehandler(dialog_->input_bibtex);
2123 setPrehandler(dialog_->input_checktex);
2124 setPrehandler(dialog_->input_index);
2125 setPrehandler(dialog_->input_paperoption);
2126 setPrehandler(dialog_->check_autoreset_classopt);
2127 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
2128 setPrehandler(dialog_->check_cygwin_path);
2134 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
2136 if (ob == dialog_->counter_line_len)
2137 return LyXRC::getDescription(LyXRC::RC_ASCII_LINELEN);
2138 if (ob == dialog_->input_tex_encoding)
2139 return LyXRC::getDescription(LyXRC::RC_FONT_ENCODING);
2140 if (ob == dialog_->input_ascii_roff)
2141 return LyXRC::getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
2142 if (ob == dialog_->input_bibtex)
2143 return LyXRC::getDescription(LyXRC::RC_BIBTEX_COMMAND);
2144 if (ob == dialog_->input_checktex)
2145 return LyXRC::getDescription(LyXRC::RC_CHKTEX_COMMAND);
2146 if (ob == dialog_->input_index)
2147 return LyXRC::getDescription(LyXRC::RC_INDEX_COMMAND);
2148 if (ob == dialog_->choice_default_papersize)
2149 return LyXRC::getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2150 if (ob == dialog_->input_paperoption)
2151 return LyXRC::getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
2152 if (ob == dialog_->check_autoreset_classopt)
2153 return LyXRC::getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2154 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
2155 if (ob == dialog_->check_cygwin_path)
2156 return _("Select if LyX should output Cygwin-style paths "
2157 "rather than Windows-style paths. Useful if you're "
2158 "using the Cygwin teTeX rather than a native Windows "
2159 "MikTeX. Note, however, that you'll need to write "
2160 "shell script wrappers for all your converters.");
2166 void FormPreferences::OutputsMisc::update(LyXRC const & rc)
2168 fl_set_counter_value(dialog_->counter_line_len,
2170 fl_set_input(dialog_->input_tex_encoding,
2171 rc.fontenc.c_str());
2172 fl_set_choice(dialog_->choice_default_papersize,
2173 parent_.controller().fromPaperSize(rc.default_papersize) + 1);
2174 fl_set_input(dialog_->input_ascii_roff,
2175 rc.ascii_roff_command.c_str());
2176 fl_set_input(dialog_->input_checktex,
2177 rc.chktex_command.c_str());
2178 fl_set_input(dialog_->input_bibtex,
2179 rc.bibtex_command.c_str());
2180 fl_set_input(dialog_->input_index,
2181 rc.index_command.c_str());
2182 fl_set_input(dialog_->input_paperoption,
2183 rc.view_dvi_paper_option.c_str());
2184 fl_set_button(dialog_->check_autoreset_classopt,
2185 rc.auto_reset_options);
2186 #if defined(__CYGWIN__) || defined(__CYGWIN32__)
2187 fl_set_button(dialog_->check_cygwin_path, rc.cygwin_path_fix);
2192 FormPreferences::Paths::Paths(FormPreferences & p)
2197 FD_preferences_paths const * FormPreferences::Paths::dialog()
2199 return dialog_.get();
2203 void FormPreferences::Paths::apply(LyXRC & rc)
2205 rc.document_path = getString(dialog_->input_default_path);
2206 rc.template_path = getString(dialog_->input_template_path);
2207 rc.tempdir_path = getString(dialog_->input_temp_dir);
2208 rc.path_prefix = getString(dialog_->input_path_prefix);
2210 int button = fl_get_button(dialog_->check_last_files);
2211 string str = getString(dialog_->input_lastfiles);
2212 if (!button) str.erase();
2214 rc.check_lastfiles = button;
2215 rc.num_lastfiles = static_cast<unsigned int>
2216 (fl_get_counter_value(dialog_->counter_lastfiles));
2218 button = fl_get_button(dialog_->check_make_backups);
2219 str = getString(dialog_->input_backup_path);
2223 rc.make_backup = button;
2224 rc.backupdir_path = str;
2226 rc.lyxpipes = getString(dialog_->input_serverpipe);
2233 void FormPreferences::Paths::build()
2235 dialog_.reset(build_preferences_paths(&parent_));
2237 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2238 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2239 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2240 fl_set_input_return(dialog_->input_path_prefix, FL_RETURN_CHANGED);
2241 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2242 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2243 fl_set_counter_bounds(dialog_->counter_lastfiles, 0, maxlastfiles);
2244 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2245 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2247 // set up the feedback mechanism
2248 setPrehandler(dialog_->input_default_path);
2249 setPrehandler(dialog_->counter_lastfiles);
2250 setPrehandler(dialog_->input_template_path);
2251 setPrehandler(dialog_->input_path_prefix);
2252 setPrehandler(dialog_->check_last_files);
2253 setPrehandler(dialog_->input_lastfiles);
2254 setPrehandler(dialog_->check_make_backups);
2255 setPrehandler(dialog_->input_backup_path);
2256 setPrehandler(dialog_->input_serverpipe);
2257 setPrehandler(dialog_->input_temp_dir);
2262 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2264 if (ob == dialog_->input_default_path)
2265 return LyXRC::getDescription(LyXRC::RC_DOCUMENTPATH);
2266 if (ob == dialog_->input_template_path)
2267 return LyXRC::getDescription(LyXRC::RC_TEMPLATEPATH);
2268 if (ob == dialog_->input_temp_dir)
2269 return LyXRC::getDescription(LyXRC::RC_TEMPDIRPATH);
2270 if (ob == dialog_->check_last_files)
2271 return LyXRC::getDescription(LyXRC::RC_CHECKLASTFILES);
2272 if (ob == dialog_->counter_lastfiles)
2273 return LyXRC::getDescription(LyXRC::RC_NUMLASTFILES);
2274 if (ob == dialog_->check_make_backups)
2275 return LyXRC::getDescription(LyXRC::RC_MAKE_BACKUP);
2276 if (ob == dialog_->input_backup_path)
2277 return LyXRC::getDescription(LyXRC::RC_BACKUPDIR_PATH);
2278 if (ob == dialog_->input_serverpipe)
2279 return LyXRC::getDescription(LyXRC::RC_SERVERPIPE);
2280 if (ob == dialog_->input_path_prefix)
2281 return LyXRC::getDescription(LyXRC::RC_PATH_PREFIX);
2286 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2288 bool activate = true;
2290 // !ob if function is called from Paths::update() to de/activate
2292 // otherwise the function is called by an xforms CB via input().
2293 if (!ob || ob == dialog_->check_last_files) {
2294 bool const enable = fl_get_button(dialog_->check_last_files);
2295 setEnabled(dialog_->input_lastfiles, enable);
2298 if (!ob || ob == dialog_->check_make_backups) {
2299 bool const enable = fl_get_button(dialog_->check_make_backups);
2300 setEnabled(dialog_->input_backup_path, enable);
2303 if (!ob || ob == dialog_->input_default_path) {
2304 string const name = getString(dialog_->input_default_path);
2305 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2306 parent_.postWarning(RWInfo::ErrorMessage());
2311 if (!ob || ob == dialog_->input_template_path) {
2312 string const name = getString(dialog_->input_template_path);
2313 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2314 parent_.postWarning(RWInfo::ErrorMessage());
2319 if (!ob || ob == dialog_->input_temp_dir) {
2320 string const name = getString(dialog_->input_temp_dir);
2321 if (fl_get_button(dialog_->check_make_backups)
2323 && !RWInfo::WriteableDir(name)) {
2324 parent_.postWarning(RWInfo::ErrorMessage());
2329 if (!ob || ob == dialog_->input_backup_path) {
2330 string const name = getString(dialog_->input_backup_path);
2331 if (fl_get_button(dialog_->check_make_backups)
2333 && !RWInfo::WriteableDir(name)) {
2334 parent_.postWarning(RWInfo::ErrorMessage());
2339 if (!ob || ob == dialog_->input_lastfiles) {
2340 string const name = getString(dialog_->input_lastfiles);
2341 if (fl_get_button(dialog_->check_last_files)
2343 && !RWInfo::WriteableFile(name)) {
2344 parent_.postWarning(RWInfo::ErrorMessage());
2349 if (!ob || ob == dialog_->input_serverpipe) {
2350 string const name = getString(dialog_->input_serverpipe);
2351 if (!name.empty()) {
2352 // strip off the extension
2353 string const str = changeExtension(name, "");
2354 if (!RWInfo::WriteableFile(str + ".in")) {
2355 parent_.postWarning(RWInfo::ErrorMessage());
2358 if (!RWInfo::WriteableFile(str + ".out")) {
2359 parent_.postWarning(RWInfo::ErrorMessage());
2365 if (ob == dialog_->button_default_path_browse) {
2366 string f = parent_.controller().browsedir(
2367 getString(dialog_->input_default_path), _("Default path"));
2369 fl_set_input(dialog_->input_default_path, f.c_str());
2370 } else if (ob == dialog_->button_template_path_browse) {
2371 string f = parent_.controller().browsedir(
2372 getString(dialog_->input_template_path), _("Template path"));
2374 fl_set_input(dialog_->input_template_path, f.c_str());
2375 } else if (ob == dialog_->button_temp_dir_browse) {
2376 string f = parent_.controller().browsedir(
2377 getString(dialog_->input_temp_dir), _("Temporary dir"));
2379 fl_set_input(dialog_->input_temp_dir, f.c_str());
2380 } else if (ob == dialog_->button_lastfiles_browse) {
2381 string f = parent_.controller().browse(
2382 getString(dialog_->input_lastfiles), _("Last files"));
2384 fl_set_input(dialog_->input_lastfiles, f.c_str());
2385 } else if (ob == dialog_->button_backup_path_browse) {
2386 string f = parent_.controller().browsedir(
2387 getString(dialog_->input_backup_path), _("Backup path"));
2389 fl_set_input(dialog_->input_backup_path, f.c_str());
2390 } else if (ob == dialog_->button_serverpipe_browse) {
2391 string f = parent_.controller().browse(
2392 getString(dialog_->input_serverpipe), _("LyX server pipes"));
2394 fl_set_input(dialog_->input_serverpipe, f.c_str());
2401 void FormPreferences::Paths::update(LyXRC const & rc)
2403 fl_set_input(dialog_->input_default_path,
2404 rc.document_path.c_str());
2405 fl_set_input(dialog_->input_template_path,
2406 rc.template_path.c_str());
2410 str = rc.backupdir_path;
2412 fl_set_button(dialog_->check_make_backups,
2414 fl_set_input(dialog_->input_backup_path, str.c_str());
2416 fl_set_input(dialog_->input_temp_dir, rc.tempdir_path.c_str());
2417 fl_set_input(dialog_->input_path_prefix, rc.path_prefix.c_str());
2419 fl_set_button(dialog_->check_last_files,
2420 rc.check_lastfiles);
2421 fl_set_counter_value(dialog_->counter_lastfiles,
2424 fl_set_input(dialog_->input_serverpipe, rc.lyxpipes.c_str());
2426 // Activate/Deactivate the input fields dependent on the state of the
2432 FormPreferences::Printer::Printer(FormPreferences & p)
2437 FD_preferences_printer const * FormPreferences::Printer::dialog()
2439 return dialog_.get();
2443 void FormPreferences::Printer::apply(LyXRC & rc) const
2445 rc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2446 rc.print_command = getString(dialog_->input_command);
2447 rc.print_pagerange_flag = getString(dialog_->input_page_range);
2448 rc.print_copies_flag = getString(dialog_->input_copies);
2449 rc.print_reverse_flag = getString(dialog_->input_reverse);
2450 rc.print_to_printer = getString(dialog_->input_to_printer);
2451 rc.print_file_extension =
2452 getString(dialog_->input_file_extension);
2453 rc.print_spool_command =
2454 getString(dialog_->input_spool_command);
2455 rc.print_paper_flag = getString(dialog_->input_paper_type);
2456 rc.print_evenpage_flag = getString(dialog_->input_even_pages);
2457 rc.print_oddpage_flag = getString(dialog_->input_odd_pages);
2458 rc.print_collcopies_flag = getString(dialog_->input_collated);
2459 rc.print_landscape_flag = getString(dialog_->input_landscape);
2460 rc.print_to_file = getString(dialog_->input_to_file);
2461 rc.print_extra_options =
2462 getString(dialog_->input_extra_options);
2463 rc.print_spool_printerprefix =
2464 getString(dialog_->input_spool_prefix);
2465 rc.print_paper_dimension_flag =
2466 getString(dialog_->input_paper_size);
2467 rc.printer = getString(dialog_->input_name);
2472 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2474 if (ob == dialog_->input_command)
2475 return LyXRC::getDescription(LyXRC::RC_PRINT_COMMAND);
2476 if (ob == dialog_->check_adapt_output)
2477 return LyXRC::getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2478 if (ob == dialog_->input_to_printer)
2479 return LyXRC::getDescription(LyXRC::RC_PRINTTOPRINTER);
2480 if (ob == dialog_->input_to_file)
2481 return LyXRC::getDescription(LyXRC::RC_PRINTTOFILE);
2482 if (ob == dialog_->input_file_extension)
2483 return LyXRC::getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2484 if (ob == dialog_->input_extra_options)
2485 return LyXRC::getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2486 if (ob == dialog_->input_spool_command)
2487 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2488 if (ob == dialog_->input_spool_prefix)
2489 return LyXRC::getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2490 if (ob == dialog_->input_name)
2491 return LyXRC::getDescription(LyXRC::RC_PRINTER);
2492 if (ob == dialog_->input_even_pages)
2493 return LyXRC::getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2494 if (ob == dialog_->input_odd_pages)
2495 return LyXRC::getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2496 if (ob == dialog_->input_page_range)
2497 return LyXRC::getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2498 if (ob == dialog_->input_reverse)
2499 return LyXRC::getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2500 if (ob == dialog_->input_landscape)
2501 return LyXRC::getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2502 if (ob == dialog_->input_copies)
2503 return LyXRC::getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2504 if (ob == dialog_->input_collated)
2505 return LyXRC::getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2506 if (ob == dialog_->input_paper_type)
2507 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERFLAG);
2508 if (ob == dialog_->input_paper_size)
2509 return LyXRC::getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2514 void FormPreferences::Printer::build()
2516 dialog_.reset(build_preferences_printer(&parent_));
2518 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2519 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2520 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2521 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2522 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2523 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2524 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2525 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2526 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2527 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2528 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2529 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2530 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2531 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2532 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2533 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2534 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2536 // set up the feedback mechanism
2537 setPrehandler(dialog_->input_command);
2538 setPrehandler(dialog_->input_page_range);
2539 setPrehandler(dialog_->input_copies);
2540 setPrehandler(dialog_->input_reverse);
2541 setPrehandler(dialog_->input_to_printer);
2542 setPrehandler(dialog_->input_file_extension);
2543 setPrehandler(dialog_->input_spool_command);
2544 setPrehandler(dialog_->input_paper_type);
2545 setPrehandler(dialog_->input_even_pages);
2546 setPrehandler(dialog_->input_odd_pages);
2547 setPrehandler(dialog_->input_collated);
2548 setPrehandler(dialog_->input_landscape);
2549 setPrehandler(dialog_->input_to_file);
2550 setPrehandler(dialog_->input_extra_options);
2551 setPrehandler(dialog_->input_spool_prefix);
2552 setPrehandler(dialog_->input_paper_size);
2553 setPrehandler(dialog_->input_name);
2554 setPrehandler(dialog_->check_adapt_output);
2558 void FormPreferences::Printer::update(LyXRC const & rc)
2560 fl_set_button(dialog_->check_adapt_output,
2561 rc.print_adapt_output);
2562 fl_set_input(dialog_->input_command,
2563 rc.print_command.c_str());
2564 fl_set_input(dialog_->input_page_range,
2565 rc.print_pagerange_flag.c_str());
2566 fl_set_input(dialog_->input_copies,
2567 rc.print_copies_flag.c_str());
2568 fl_set_input(dialog_->input_reverse,
2569 rc.print_reverse_flag.c_str());
2570 fl_set_input(dialog_->input_to_printer,
2571 rc.print_to_printer.c_str());
2572 fl_set_input(dialog_->input_file_extension,
2573 rc.print_file_extension.c_str());
2574 fl_set_input(dialog_->input_spool_command,
2575 rc.print_spool_command.c_str());
2576 fl_set_input(dialog_->input_paper_type,
2577 rc.print_paper_flag.c_str());
2578 fl_set_input(dialog_->input_even_pages,
2579 rc.print_evenpage_flag.c_str());
2580 fl_set_input(dialog_->input_odd_pages,
2581 rc.print_oddpage_flag.c_str());
2582 fl_set_input(dialog_->input_collated,
2583 rc.print_collcopies_flag.c_str());
2584 fl_set_input(dialog_->input_landscape,
2585 rc.print_landscape_flag.c_str());
2586 fl_set_input(dialog_->input_to_file,
2587 rc.print_to_file.c_str());
2588 fl_set_input(dialog_->input_extra_options,
2589 rc.print_extra_options.c_str());
2590 fl_set_input(dialog_->input_spool_prefix,
2591 rc.print_spool_printerprefix.c_str());
2592 fl_set_input(dialog_->input_paper_size,
2593 rc.print_paper_dimension_flag.c_str());
2594 fl_set_input(dialog_->input_name,
2595 rc.printer.c_str());
2599 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2604 FD_preferences_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2606 return dialog_.get();
2610 void FormPreferences::ScreenFonts::apply(LyXRC & rc) const
2612 bool changed = false;
2614 pair<string, string> tmp =
2615 parseFontName(getString(dialog_->input_roman));
2616 if (rc.roman_font_name != tmp.first ||
2617 rc.roman_font_foundry != tmp.second) {
2619 rc.roman_font_name = tmp.first;
2620 rc.roman_font_foundry = tmp.second;
2623 tmp = parseFontName(getString(dialog_->input_sans));
2624 if (rc.sans_font_name != tmp.first ||
2625 rc.sans_font_foundry != tmp.second) {
2627 rc.sans_font_name = tmp.first;
2628 rc.sans_font_foundry = tmp.second;
2631 tmp = parseFontName(getString(dialog_->input_typewriter));
2632 if (rc.typewriter_font_name != tmp.first ||
2633 rc.typewriter_font_foundry != tmp.second) {
2635 rc.typewriter_font_name = tmp.first;
2636 rc.typewriter_font_foundry = tmp.second;
2639 string str = getString(dialog_->input_screen_encoding);
2640 if (rc.font_norm != str) {
2643 rc.set_font_norm_type();
2646 bool button = fl_get_button(dialog_->check_scalable);
2647 if (rc.use_scalable_fonts != button) {
2649 rc.use_scalable_fonts = button;
2652 unsigned int ivalue = static_cast<unsigned int>
2653 (fl_get_counter_value(dialog_->counter_zoom));
2654 if (rc.zoom != ivalue) {
2659 ivalue = static_cast<unsigned int>
2660 (fl_get_counter_value(dialog_->counter_dpi));
2661 if (rc.dpi != ivalue) {
2666 string dvalue = getString(dialog_->input_tiny);
2667 if (rc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2669 rc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2672 dvalue = getString(dialog_->input_script);
2673 if (rc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2675 rc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2678 dvalue = getString(dialog_->input_footnote);
2679 if (rc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2681 rc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2684 dvalue = getString(dialog_->input_small);
2685 if (rc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2687 rc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2690 dvalue = getString(dialog_->input_normal);
2691 if (rc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2693 rc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2696 dvalue = getString(dialog_->input_large);
2697 if (rc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2699 rc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2702 dvalue = getString(dialog_->input_larger);
2703 if (rc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2705 rc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2708 dvalue = getString(dialog_->input_largest);
2709 if (rc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2711 rc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2714 dvalue = getString(dialog_->input_huge);
2715 if (rc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2717 rc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2720 dvalue = getString(dialog_->input_huger);
2721 if (rc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2723 rc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2727 // Now update the buffers
2728 // Can anything below here affect the redraw process?
2729 parent_.controller().updateScreenFonts();
2734 void FormPreferences::ScreenFonts::build()
2736 dialog_.reset(build_preferences_screen_fonts(&parent_));
2738 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2739 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2741 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2742 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2743 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2744 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2745 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2746 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2747 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2748 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2749 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2750 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2751 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2752 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2753 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2754 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2755 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2756 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2758 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2759 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2760 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2761 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2762 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2763 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2764 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2765 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2766 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2767 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2769 // set up the feedback mechanism
2770 setPrehandler(dialog_->input_roman);
2771 setPrehandler(dialog_->input_sans);
2772 setPrehandler(dialog_->input_typewriter);
2773 setPrehandler(dialog_->counter_zoom);
2774 setPrehandler(dialog_->counter_dpi);
2775 setPrehandler(dialog_->check_scalable);
2776 setPrehandler(dialog_->input_screen_encoding);
2777 setPrehandler(dialog_->input_tiny);
2778 setPrehandler(dialog_->input_script);
2779 setPrehandler(dialog_->input_footnote);
2780 setPrehandler(dialog_->input_small);
2781 setPrehandler(dialog_->input_large);
2782 setPrehandler(dialog_->input_larger);
2783 setPrehandler(dialog_->input_largest);
2784 setPrehandler(dialog_->input_normal);
2785 setPrehandler(dialog_->input_huge);
2786 setPrehandler(dialog_->input_huger);
2791 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2793 if (ob == dialog_->input_roman)
2794 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2795 if (ob == dialog_->input_sans)
2796 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2797 if (ob == dialog_->input_typewriter)
2798 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2799 if (ob == dialog_->check_scalable)
2800 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2801 if (ob == dialog_->input_screen_encoding)
2802 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2803 if (ob == dialog_->counter_zoom)
2804 return LyXRC::getDescription(LyXRC::RC_SCREEN_ZOOM);
2805 if (ob == dialog_->counter_dpi)
2806 return LyXRC::getDescription(LyXRC::RC_SCREEN_DPI);
2807 if (ob == dialog_->input_tiny
2808 || ob == dialog_->input_script
2809 || ob == dialog_->input_footnote
2810 || ob == dialog_->input_small
2811 || ob == dialog_->input_large
2812 || ob == dialog_->input_larger
2813 || ob == dialog_->input_larger
2814 || ob == dialog_->input_largest
2815 || ob == dialog_->input_normal
2816 || ob == dialog_->input_huge
2817 || ob == dialog_->input_huger)
2818 return LyXRC::getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2823 bool FormPreferences::ScreenFonts::input()
2825 bool activate = true;
2828 // Make sure that all fonts all have positive entries
2829 // Also note that an empty entry is returned as 0.0 by strToDbl
2830 if (0.0 >= convert<double>(fl_get_input(dialog_->input_tiny))
2831 || 0.0 >= convert<double>(fl_get_input(dialog_->input_script))
2832 || 0.0 >= convert<double>(fl_get_input(dialog_->input_footnote))
2833 || 0.0 >= convert<double>(fl_get_input(dialog_->input_small))
2834 || 0.0 >= convert<double>(fl_get_input(dialog_->input_normal))
2835 || 0.0 >= convert<double>(fl_get_input(dialog_->input_large))
2836 || 0.0 >= convert<double>(fl_get_input(dialog_->input_larger))
2837 || 0.0 >= convert<double>(fl_get_input(dialog_->input_largest))
2838 || 0.0 >= convert<double>(fl_get_input(dialog_->input_huge))
2839 || 0.0 >= convert<double>(fl_get_input(dialog_->input_huger))) {
2841 str = _("Fonts must be positive!");
2842 } else if (convert<double>(fl_get_input(dialog_->input_tiny)) >
2843 // Fontsizes -- tiny < script < footnote etc.
2844 convert<double>(fl_get_input(dialog_->input_script)) ||
2845 convert<double>(fl_get_input(dialog_->input_script)) >
2846 convert<double>(fl_get_input(dialog_->input_footnote)) ||
2847 convert<double>(fl_get_input(dialog_->input_footnote)) >
2848 convert<double>(fl_get_input(dialog_->input_small)) ||
2849 convert<double>(fl_get_input(dialog_->input_small)) >
2850 convert<double>(fl_get_input(dialog_->input_normal)) ||
2851 convert<double>(fl_get_input(dialog_->input_normal)) >
2852 convert<double>(fl_get_input(dialog_->input_large)) ||
2853 convert<double>(fl_get_input(dialog_->input_large)) >
2854 convert<double>(fl_get_input(dialog_->input_larger)) ||
2855 convert<double>(fl_get_input(dialog_->input_larger)) >
2856 convert<double>(fl_get_input(dialog_->input_largest)) ||
2857 convert<double>(fl_get_input(dialog_->input_largest)) >
2858 convert<double>(fl_get_input(dialog_->input_huge)) ||
2859 convert<double>(fl_get_input(dialog_->input_huge)) >
2860 convert<double>(fl_get_input(dialog_->input_huger))) {
2863 str = _("Fonts must be input in the order Tiny > Smallest > Smaller > Small > Normal > Large > Larger > Largest > Huge > Huger.");
2867 parent_.postWarning(str);
2873 void FormPreferences::ScreenFonts::update(LyXRC const & rc)
2875 fl_set_input(dialog_->input_roman,
2876 makeFontName(rc.roman_font_name,
2877 rc.roman_font_foundry).c_str());
2878 fl_set_input(dialog_->input_sans,
2879 makeFontName(rc.sans_font_name,
2880 rc.sans_font_foundry).c_str());
2881 fl_set_input(dialog_->input_typewriter,
2882 makeFontName(rc.typewriter_font_name,
2883 rc.typewriter_font_foundry).c_str());
2884 fl_set_input(dialog_->input_screen_encoding,
2885 rc.font_norm.c_str());
2886 fl_set_button(dialog_->check_scalable,
2887 rc.use_scalable_fonts);
2888 fl_set_counter_value(dialog_->counter_zoom, rc.zoom);
2889 fl_set_counter_value(dialog_->counter_dpi, rc.dpi);
2890 fl_set_input(dialog_->input_tiny,
2891 rc.font_sizes[LyXFont::SIZE_TINY].c_str());
2892 fl_set_input(dialog_->input_script,
2893 rc.font_sizes[LyXFont::SIZE_SCRIPT].c_str());
2894 fl_set_input(dialog_->input_footnote,
2895 rc.font_sizes[LyXFont::SIZE_FOOTNOTE].c_str());
2896 fl_set_input(dialog_->input_small,
2897 rc.font_sizes[LyXFont::SIZE_SMALL].c_str());
2898 fl_set_input(dialog_->input_normal,
2899 rc.font_sizes[LyXFont::SIZE_NORMAL].c_str());
2900 fl_set_input(dialog_->input_large,
2901 rc.font_sizes[LyXFont::SIZE_LARGE].c_str());
2902 fl_set_input(dialog_->input_larger,
2903 rc.font_sizes[LyXFont::SIZE_LARGER].c_str());
2904 fl_set_input(dialog_->input_largest,
2905 rc.font_sizes[LyXFont::SIZE_LARGEST].c_str());
2906 fl_set_input(dialog_->input_huge,
2907 rc.font_sizes[LyXFont::SIZE_HUGE].c_str());
2908 fl_set_input(dialog_->input_huger,
2909 rc.font_sizes[LyXFont::SIZE_HUGER].c_str());
2914 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2919 FD_preferences_spelloptions const * FormPreferences::SpellOptions::dialog()
2921 return dialog_.get();
2925 void FormPreferences::SpellOptions::apply(LyXRC & rc)
2927 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2928 choice = trim(choice);
2930 rc.isp_command = choice;
2933 // If spellchecker == "", all other input set to off.
2934 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2935 rc.isp_use_alt_lang = false;
2936 rc.isp_alt_lang.erase();
2938 rc.isp_use_esc_chars = false;
2939 rc.isp_esc_chars.erase();
2941 rc.isp_use_pers_dict = false;
2942 rc.isp_pers_dict.erase();
2944 rc.isp_accept_compound = false;
2945 rc.isp_use_input_encoding = false;
2948 int button = fl_get_button(dialog_->check_alt_lang);
2949 choice = getString(dialog_->input_alt_lang);
2950 if (button && choice.empty()) button = 0;
2951 if (!button) choice.erase();
2953 rc.isp_use_alt_lang = static_cast<bool>(button);
2954 rc.isp_alt_lang = choice;
2956 button = fl_get_button(dialog_->check_escape_chars);
2957 choice = getString(dialog_->input_escape_chars);
2958 if (button && choice.empty()) button = 0;
2959 if (!button) choice.erase();
2961 rc.isp_use_esc_chars = static_cast<bool>(button);
2962 rc.isp_esc_chars = choice;
2964 button = fl_get_button(dialog_->check_personal_dict);
2965 choice = getString(dialog_->input_personal_dict);
2966 if (button && choice.empty()) button = 0;
2967 if (!button) choice.erase();
2969 rc.isp_use_pers_dict = static_cast<bool>(button);
2970 rc.isp_pers_dict = choice;
2972 button = fl_get_button(dialog_->check_compound_words);
2973 rc.isp_accept_compound = static_cast<bool>(button);
2975 button = fl_get_button(dialog_->check_input_enc);
2976 rc.isp_use_input_encoding = static_cast<bool>(button);
2987 void FormPreferences::SpellOptions::build()
2989 dialog_.reset(build_preferences_spelloptions(&parent_));
2991 fl_addto_choice(dialog_->choice_spell_command,
2992 _(" ispell | aspell ").c_str());
2993 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2994 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2995 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2997 #if !defined (USE_ISPELL)
2998 setEnabled(dialog_->choice_spell_command, false);
3001 // set up the feedback mechanism
3002 setPrehandler(dialog_->choice_spell_command);
3003 setPrehandler(dialog_->check_alt_lang);
3004 setPrehandler(dialog_->input_alt_lang);
3005 setPrehandler(dialog_->check_escape_chars);
3006 setPrehandler(dialog_->input_escape_chars);
3007 setPrehandler(dialog_->check_personal_dict);
3008 setPrehandler(dialog_->input_personal_dict);
3009 setPrehandler(dialog_->button_personal_dict);
3010 setPrehandler(dialog_->check_compound_words);
3011 setPrehandler(dialog_->check_input_enc);
3016 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
3018 if (ob == dialog_->choice_spell_command)
3019 return LyXRC::getDescription(LyXRC::RC_SPELL_COMMAND);
3020 if (ob == dialog_->check_alt_lang)
3021 return LyXRC::getDescription(LyXRC::RC_USE_ALT_LANG);
3022 if (ob == dialog_->input_alt_lang)
3023 return LyXRC::getDescription(LyXRC::RC_ALT_LANG);
3024 if (ob == dialog_->check_escape_chars)
3025 return LyXRC::getDescription(LyXRC::RC_USE_ESC_CHARS);
3026 if (ob == dialog_->input_escape_chars)
3027 return LyXRC::getDescription(LyXRC::RC_ESC_CHARS);
3028 if (ob == dialog_->check_personal_dict)
3029 return LyXRC::getDescription(LyXRC::RC_USE_PERS_DICT);
3030 if (ob == dialog_->input_personal_dict)
3031 return LyXRC::getDescription(LyXRC::RC_PERS_DICT);
3032 if (ob == dialog_->check_compound_words)
3033 return LyXRC::getDescription(LyXRC::RC_ACCEPT_COMPOUND);
3034 if (ob == dialog_->check_input_enc)
3035 return LyXRC::getDescription(LyXRC::RC_USE_INP_ENC);
3040 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
3042 // !ob if function is called from updateSpellOptions() to de/activate
3044 // otherwise the function is called by an xforms CB via input().
3047 // If spellchecker == "", disable all input.
3048 if (!ob || ob == dialog_->choice_spell_command) {
3049 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
3050 fl_deactivate_object(dialog_->check_alt_lang);
3051 fl_deactivate_object(dialog_->input_alt_lang);
3052 fl_deactivate_object(dialog_->check_escape_chars);
3053 fl_deactivate_object(dialog_->input_escape_chars);
3054 fl_deactivate_object(dialog_->check_personal_dict);
3055 fl_deactivate_object(dialog_->input_personal_dict);
3056 fl_deactivate_object(dialog_->check_compound_words);
3057 fl_deactivate_object(dialog_->check_input_enc);
3060 fl_activate_object(dialog_->check_alt_lang);
3061 fl_activate_object(dialog_->check_escape_chars);
3062 fl_activate_object(dialog_->check_personal_dict);
3063 fl_activate_object(dialog_->check_compound_words);
3064 fl_activate_object(dialog_->check_input_enc);
3069 if (!ob || ob == dialog_->check_alt_lang) {
3070 bool const enable = fl_get_button(dialog_->check_alt_lang);
3071 setEnabled(dialog_->input_alt_lang, enable);
3074 if (!ob || ob == dialog_->check_escape_chars) {
3075 bool const enable = fl_get_button(dialog_->check_escape_chars);
3076 setEnabled(dialog_->input_escape_chars, enable);
3079 if (!ob || ob == dialog_->check_personal_dict) {
3080 bool const enable = fl_get_button(dialog_->check_personal_dict);
3081 setEnabled(dialog_->input_personal_dict, enable);
3084 if (ob == dialog_->button_personal_dict) {
3085 string f = parent_.controller().browsedict(
3086 getString(dialog_->input_personal_dict));
3087 fl_set_input(dialog_->input_personal_dict, f.c_str());
3090 return true; // All input is valid!
3094 void FormPreferences::SpellOptions::update(LyXRC const & rc)
3098 if (rc.isp_command == "")
3100 else if (rc.isp_command == "ispell")
3102 else if (rc.isp_command == "aspell")
3105 if (rc.isp_command == "ispell")
3107 else if (rc.isp_command == "aspell")
3110 fl_set_choice(dialog_->choice_spell_command, choice);
3113 if (rc.isp_use_alt_lang)
3114 str = rc.isp_alt_lang;
3116 fl_set_button(dialog_->check_alt_lang,
3117 rc.isp_use_alt_lang);
3118 fl_set_input(dialog_->input_alt_lang, str.c_str());
3121 if (rc.isp_use_esc_chars)
3122 str = rc.isp_esc_chars;
3124 fl_set_button(dialog_->check_escape_chars,
3125 rc.isp_use_esc_chars);
3126 fl_set_input(dialog_->input_escape_chars, str.c_str());
3129 if (rc.isp_use_pers_dict)
3130 str = rc.isp_pers_dict;
3132 fl_set_button(dialog_->check_personal_dict,
3133 rc.isp_use_pers_dict);
3134 fl_set_input(dialog_->input_personal_dict, str.c_str());
3136 fl_set_button(dialog_->check_compound_words,
3137 rc.isp_accept_compound);
3138 fl_set_button(dialog_->check_input_enc,
3139 rc.isp_use_input_encoding);
3141 // Activate/Deactivate the input fields dependent on the state of the
3146 } // namespace frontend