1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 *======================================================*/
11 * FormPreferences Interface Class Implementation
20 #include FORMS_H_LOCATION
23 #pragma implementation
29 #include "FormPreferences.h"
30 #include "form_preferences.h"
31 #include "input_validators.h"
39 #include "support/filetools.h"
40 #include "support/LAssert.h"
41 #include "lyx_gui_misc.h" // idex, scex
43 #include "input_validators.h"
44 #include "xforms_helpers.h"
45 #include "helper_funcs.h"
46 #include "converter.h"
47 #include "support/lyxfunctional.h"
48 #include "support/lyxmanip.h"
58 extern string system_lyxdir;
59 extern string user_lyxdir;
60 extern Languages languages;
64 // These should probably go inside the class definition...
65 Formats local_formats;
66 Converters local_converters;
71 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
72 : FormBaseBI(lv, d, _("Preferences")),
74 colors_(*this), converters_(*this), inputs_misc_(*this),
75 formats_(*this), interface_(*this), language_(*this),
76 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
77 printer_(*this), screen_fonts_(*this), spelloptions_(*this)
79 // let the dialog be shown
80 // This is a permanent connection so we won't bother
81 // storing a copy because we won't be disconnecting.
82 d->showPreferences.connect(slot(this, &FormPreferences::show));
83 d->showSpellcheckerPreferences.connect(slot(this, &FormPreferences::showSpellPref));
87 void FormPreferences::connect()
89 fl_set_form_maxsize( dialog_->form, minw_, minh_ );
91 FormBaseBI::connect();
95 void FormPreferences::disconnect()
97 // colors_->disconnect();
98 // converters_->disconnect(); //local_converters.Clear();
99 // formats_->disconnect(); //local_formats.Clear();
101 FormBaseBI::disconnect();
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_outer);
120 else if (form2 == look_n_feel_tab_->form)
121 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_outer);
123 else if (form2 == inputs_tab_->form)
124 form3 = fl_get_active_folder(inputs_tab_->tabfolder_outer);
126 else if (form2 == outputs_tab_->form)
127 form3 = fl_get_active_folder(outputs_tab_->tabfolder_outer);
129 else if (form2 == lang_opts_tab_->form)
130 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_outer);
132 if (form3 && form3->visible)
133 fl_redraw_form(form3);
137 FL_FORM * FormPreferences::form() const
139 if (dialog_.get()) return dialog_->form;
144 void FormPreferences::showSpellPref()
147 fl_set_folder(dialog_->tabfolder_prefs, lang_opts_tab_->form);
148 fl_set_folder(lang_opts_tab_->tabfolder_outer, spelloptions_.dialog()->form);
152 void FormPreferences::ok()
154 FormBaseDeprecated::ok();
156 if (colors_.modifiedXformsPrefs) {
157 string const filename =
158 AddName(user_lyxdir, "preferences.xform");
159 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
162 lv_->getLyXFunc()->dispatch(LFUN_SAVEPREFERENCES);
166 void FormPreferences::hide()
168 // We need to hide the active tabfolder otherwise we get a
169 // BadDrawable error from X windows and LyX crashes without saving.
170 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
172 && outer_form->visible) {
173 fl_hide_form(outer_form);
175 FormBaseDeprecated::hide();
179 void FormPreferences::build()
181 dialog_.reset(build_preferences());
183 // Manage the restore, save, apply and cancel/close buttons
184 bc().setOK(dialog_->button_ok);
185 bc().setApply(dialog_->button_apply);
186 bc().setCancel(dialog_->button_cancel);
187 bc().setRestore(dialog_->button_restore);
189 // build the tab folders
190 converters_tab_.reset(build_outer_tab());
191 look_n_feel_tab_.reset(build_outer_tab());
192 inputs_tab_.reset(build_outer_tab());
193 outputs_tab_.reset(build_outer_tab());
194 lang_opts_tab_.reset(build_outer_tab());
196 // build actual tabfolder contents
197 // these will become nested tabfolders
201 inputs_misc_.build();
205 outputs_misc_.build();
208 screen_fonts_.build();
209 spelloptions_.build();
211 // Now add them to the tabfolder
212 fl_addto_tabfolder(dialog_->tabfolder_prefs,
214 look_n_feel_tab_->form);
215 fl_addto_tabfolder(dialog_->tabfolder_prefs,
217 lang_opts_tab_->form);
218 fl_addto_tabfolder(dialog_->tabfolder_prefs,
220 converters_tab_->form);
221 fl_addto_tabfolder(dialog_->tabfolder_prefs,
224 fl_addto_tabfolder(dialog_->tabfolder_prefs,
228 // now build the nested tabfolders
229 // Starting with look and feel
230 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
232 screen_fonts_.dialog()->form);
233 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
235 interface_.dialog()->form);
236 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
238 colors_.dialog()->form);
239 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
241 lnf_misc_.dialog()->form);
243 // then build converters
244 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
246 formats_.dialog()->form);
247 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
249 converters_.dialog()->form);
252 // Paths should probably go in a few outer_tab called Files
253 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
255 paths_.dialog()->form);
256 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
258 inputs_misc_.dialog()->form);
260 // then building outputs
261 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
263 printer_.dialog()->form);
264 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
266 outputs_misc_.dialog()->form);
268 // then building usage
269 fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
271 spelloptions_.dialog()->form);
272 fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
274 language_.dialog()->form);
278 void FormPreferences::apply()
280 // set the new lyxrc entries
281 // many of these need to trigger other functions when the assignment
282 // is made. For example, screen zoom and font types. These could be
283 // handled either by signals/slots in lyxrc or just directly call the
284 // associated functions here.
285 // There are other problems with this scheme. We really should check
286 // what we copy to make sure that it really is necessary to do things
287 // like update the screen fonts because that flushes the textcache
288 // and other stuff which may cost us a lot on slower/high-load
292 formats_.apply(); // Must be before converters_.apply()
294 inputs_misc_.apply();
298 outputs_misc_.apply();
301 screen_fonts_.apply();
302 spelloptions_.apply();
306 void FormPreferences::feedback(FL_OBJECT * ob)
312 if (ob->form->fdui == colors_.dialog()) {
313 str = colors_.feedback(ob);
314 } else if (ob->form->fdui == converters_.dialog()) {
315 str = converters_.feedback(ob);
316 } else if (ob->form->fdui == formats_.dialog()) {
317 str = formats_.feedback(ob);
318 } else if (ob->form->fdui == inputs_misc_.dialog()) {
319 str = inputs_misc_.feedback(ob);
320 } else if (ob->form->fdui == interface_.dialog()) {
321 str = interface_.feedback(ob);
322 } else if (ob->form->fdui == language_.dialog()) {
323 str = language_.feedback(ob);
324 } else if (ob->form->fdui == lnf_misc_.dialog()) {
325 str = lnf_misc_.feedback(ob);
326 } else if (ob->form->fdui == outputs_misc_.dialog()) {
327 str = outputs_misc_.feedback(ob);
328 } else if (ob->form->fdui == paths_.dialog()) {
329 str = paths_.feedback(ob);
330 } else if (ob->form->fdui == printer_.dialog()) {
331 str = printer_.feedback(ob);
332 } else if (ob->form->fdui == screen_fonts_.dialog()) {
333 str = screen_fonts_.feedback(ob);
334 } else if (ob->form->fdui == spelloptions_.dialog()) {
335 str = spelloptions_.feedback(ob);
338 str = formatted(_(str), dialog_->text_warning->w-10, FL_SMALL_SIZE);
340 fl_set_object_label(dialog_->text_warning, str.c_str());
341 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
345 bool FormPreferences::input(FL_OBJECT * ob, long)
349 // whatever checks you need to ensure the user hasn't entered
350 // some totally ridiculous value somewhere. Change activate to suit.
351 // comments before each test describe what is _valid_
353 if (ob->form->fdui == colors_.dialog()) {
356 } else if (ob->form->fdui == converters_.dialog())
357 return converters_.input(ob);
358 else if (ob->form->fdui == formats_.dialog())
359 return formats_.input(ob);
360 else if (ob->form->fdui == interface_.dialog())
361 return interface_.input(ob);
362 else if (ob->form->fdui == language_.dialog())
363 return language_.input(ob);
364 else if (ob->form->fdui == paths_.dialog())
365 return paths_.input(ob);
366 else if (ob->form->fdui == screen_fonts_.dialog())
367 return screen_fonts_.input();
368 else if (ob->form->fdui == spelloptions_.dialog())
369 return spelloptions_.input(ob);
375 void FormPreferences::update()
377 if (!dialog_.get()) return;
379 // read lyxrc entries
381 formats_.update(); // Must be before converters_.update()
382 converters_.update();
383 inputs_misc_.update();
387 outputs_misc_.update();
390 screen_fonts_.update();
391 spelloptions_.update();
395 FormPreferences::Colors::Colors(FormPreferences & p)
396 : modifiedXformsPrefs(false), parent_(p)
400 FD_form_colors const * FormPreferences::Colors::dialog()
402 return dialog_.get();
406 void FormPreferences::Colors::apply()
408 bool modifiedText = false;
409 bool modifiedBackground = false;
411 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
412 cit != xformsColorDB.end(); ++cit) {
414 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
415 if (col != cit->color()) {
416 modifiedXformsPrefs = true;
417 if (cit->colorID == FL_BLACK)
419 if (cit->colorID == FL_COL1)
420 modifiedBackground = true;
424 if (modifiedXformsPrefs) {
425 for (vector<XformsColor>::const_iterator cit =
426 xformsColorDB.begin();
427 cit != xformsColorDB.end(); ++cit) {
428 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
430 if (modifiedText && cit->colorID == FL_BLACK) {
431 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
434 if (modifiedBackground && cit->colorID == FL_COL1) {
435 AdjustVal(FL_MCOL, FL_COL1, 0.1);
436 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
437 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
439 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
440 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
443 if (cit->colorID == GUI_COLOR_CURSOR) {
444 fl_mapcolor(GUI_COLOR_CURSOR,
445 cit->r, cit->g, cit->b);
446 fl_set_cursor_color(FL_DEFAULT_CURSOR,
447 GUI_COLOR_CURSOR, FL_WHITE);
450 Dialogs::redrawGUI();
453 // Now do the same for the LyX LColors...
454 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
455 cit != lyxColorDB.end(); ++cit) {
456 LColor::color lc = lcolor.getFromGUIName(cit->getname());
457 if (lc == LColor::inherit) continue;
459 // Create a valid X11 name of the form "#rrggbb"
460 string const hexname = X11hexname(cit->color());
462 if (lcolor.getX11Name(lc) != hexname) {
464 << "FormPreferences::Colors::apply: "
465 << "resetting LColor " << lcolor.getGUIName(lc)
466 << " from \"" << lcolor.getX11Name(lc)
467 << "\" to \"" << hexname << "\"."
470 string const s = lcolor.getLyXName(lc) + string(" ") +
472 parent_.lv_->getLyXFunc()->dispatch(LFUN_SET_COLOR, s);
478 void FormPreferences::Colors::build()
480 dialog_.reset(parent_.build_colors());
482 fl_set_object_color(dialog_->button_color,
483 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
485 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
486 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
487 fl_set_dial_step(dialog_->dial_hue, 1.0);
488 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
490 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
491 fl_set_slider_step(dialog_->slider_saturation, 0.01);
492 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
494 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
495 fl_set_slider_step(dialog_->slider_value, 0.01);
496 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
498 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
499 fl_set_slider_step(dialog_->slider_red, 1.0);
500 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
502 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
503 fl_set_slider_step(dialog_->slider_green, 1.0);
504 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
506 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
507 fl_set_slider_step(dialog_->slider_blue, 1.0);
508 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
510 // set up the feedback mechanism
511 setPreHandler(dialog_->browser_lyx_objs);
512 setPreHandler(dialog_->button_color);
513 setPreHandler(dialog_->button_modify);
514 setPreHandler(dialog_->dial_hue);
515 setPreHandler(dialog_->slider_saturation);
516 setPreHandler(dialog_->slider_value);
517 setPreHandler(dialog_->slider_red);
518 setPreHandler(dialog_->slider_green);
519 setPreHandler(dialog_->slider_blue);
520 setPreHandler(dialog_->button_colorspace);
524 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
528 if (ob == dialog_->browser_lyx_objs) {
529 str = N_("LyX objects that can be assigned a color.");
531 } else if (ob == dialog_->button_modify) {
532 str = N_("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
534 } else if (ob == dialog_->dial_hue ||
535 ob == dialog_->slider_saturation ||
536 ob == dialog_->slider_value ||
537 ob == dialog_->slider_red ||
538 ob == dialog_->slider_green ||
539 ob == dialog_->slider_blue) {
540 str = N_("Find a new color.");
542 } else if (ob == dialog_->button_colorspace) {
543 str = N_("Toggle between RGB and HSV color spaces.");
550 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
552 if (ob == dialog_->browser_lyx_objs) {
555 } else if (ob == dialog_->dial_hue ||
556 ob == dialog_->slider_saturation ||
557 ob == dialog_->slider_value) {
560 } else if (ob == dialog_->slider_red ||
561 ob == dialog_->slider_green ||
562 ob == dialog_->slider_blue) {
565 } else if (ob == dialog_->button_colorspace) {
568 } else if (ob == dialog_->button_modify) {
574 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
578 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
582 hsv.v = min( 1.0, max(0.0, hsv.v) );
585 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
589 void FormPreferences::Colors::InputBrowserLyX() const
591 vector<NamedColor>::size_type const selLyX =
592 fl_get_browser(dialog_->browser_lyx_objs);
593 if (selLyX < 1) return;
595 // Is the choice an Xforms color...
598 if( selLyX-1 < xformsColorDB.size() ) {
599 vector<XformsColor>::size_type const i = selLyX - 1;
600 col = xformsColorDB[i].color();
602 // or a LyX Logical color?
604 vector<NamedColor>::size_type const i = selLyX - 1 -
605 xformsColorDB.size();
606 col = lyxColorDB[i].color();
609 fl_freeze_form(dialog_->form);
611 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
612 fl_redraw_object(dialog_->button_color);
614 // Display either RGB or HSV but not both!
617 // Deactivate the modify button to begin with...
618 setEnabled(dialog_->button_modify, false);
620 fl_unfreeze_form(dialog_->form);
624 void FormPreferences::Colors::InputHSV()
626 double const hue = fl_get_dial_value(dialog_->dial_hue);
627 double const sat = fl_get_slider_value(dialog_->slider_saturation);
628 double const val = fl_get_slider_value(dialog_->slider_value);
630 int const h = int(hue);
631 int const s = int(100.0 * sat);
632 int const v = int(100.0 * val);
634 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
636 fl_set_object_label(dialog_->text_color_values, label.c_str());
638 RGBColor col = HSVColor(hue, sat, val);
640 fl_freeze_form(dialog_->form);
642 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
643 fl_redraw_object(dialog_->button_color);
645 col = HSVColor(hue, 1.0, 1.0);
646 col.r = max(col.r, 0);
647 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
648 fl_redraw_object(dialog_->dial_hue);
650 // Ascertain whether to activate the Modify button.
651 vector<NamedColor>::size_type const selLyX =
652 fl_get_browser(dialog_->browser_lyx_objs);
654 fl_unfreeze_form(dialog_->form);
655 if (selLyX < 1) return;
657 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
660 // Is the choice an Xforms color...
661 if( selLyX-1 < xformsColorDB.size() ) {
662 vector<XformsColor>::size_type const i = selLyX - 1;
663 modify = (xformsColorDB[i].color() != col);
665 // or a LyX Logical color?
667 vector<NamedColor>::size_type const i = selLyX - 1 -
668 xformsColorDB.size();
669 modify = (lyxColorDB[i].color() != col);
672 setEnabled(dialog_->button_modify, modify);
676 void FormPreferences::Colors::InputRGB()
678 int const red = int(fl_get_slider_value(dialog_->slider_red));
679 int const green = int(fl_get_slider_value(dialog_->slider_green));
680 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
682 string const label = tostr(red) + string(", ") + tostr(green) +
683 string(", ") + tostr(blue);
684 fl_set_object_label(dialog_->text_color_values, label.c_str());
686 fl_freeze_form(dialog_->form);
688 RGBColor col = RGBColor(red, green, blue);
689 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
690 fl_redraw_object(dialog_->button_color);
692 // Ascertain whether to activate the Modify button.
693 vector<NamedColor>::size_type const selLyX =
694 fl_get_browser(dialog_->browser_lyx_objs);
696 fl_unfreeze_form(dialog_->form);
697 if (selLyX < 1) return;
701 // Is the choice an Xforms color...
702 if( selLyX-1 < xformsColorDB.size() ) {
703 vector<XformsColor>::size_type const i = selLyX - 1;
704 modify = (xformsColorDB[i].color() != col);
706 // or a LyX Logical color?
708 vector<NamedColor>::size_type const i = selLyX - 1 -
709 xformsColorDB.size();
710 modify = (lyxColorDB[i].color() != col);
713 setEnabled(dialog_->button_modify, modify);
717 void FormPreferences::Colors::LoadBrowserLyX()
719 if (!dialog_->browser_lyx_objs->visible) return;
721 // First, define the modifiable xforms colors
722 xformsColorDB.clear();
725 xcol.name = _("GUI background");
726 xcol.colorID = FL_COL1;
727 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
729 xformsColorDB.push_back(xcol);
731 xcol.name = _("GUI text");
732 xcol.colorID = FL_BLACK;
733 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
735 fl_mapcolor(GUI_COLOR_CURSOR, xcol.r, xcol.g, xcol.b);
736 fl_set_cursor_color(FL_DEFAULT_CURSOR, GUI_COLOR_CURSOR, FL_WHITE);
738 xformsColorDB.push_back(xcol);
740 xcol.name = _("GUI selection");
741 xcol.colorID = FL_YELLOW;
742 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
744 xformsColorDB.push_back(xcol);
746 xcol.name = _("GUI pointer");
747 xcol.colorID = GUI_COLOR_CURSOR;
748 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
750 xformsColorDB.push_back(xcol);
752 // Now create the the LyX LColors database
754 for (int i=0; i<LColor::ignore; ++i) {
755 LColor::color lc = static_cast<LColor::color>(i);
756 if (lc == LColor::none
757 || lc == LColor::black
758 || lc == LColor::white
760 || lc == LColor::green
761 || lc == LColor::blue
762 || lc == LColor::cyan
763 || lc == LColor::magenta
764 || lc == LColor::yellow
765 || lc == LColor::inherit
766 || lc == LColor::ignore) continue;
768 string const name = lcolor.getX11Name(lc);
769 Display * display = fl_get_display();;
770 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
773 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
775 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
776 << "LColor " << lcolor.getLyXName(lc)
777 << ": X can't find color \"" << name
778 << "\". Set to \"black\"!" << endl;
780 string const arg = lcolor.getLyXName(lc) + " black";
781 parent_.lv_->getLyXFunc()->
782 dispatch(LFUN_SET_COLOR, arg);
786 // X has found the color. Now find the "appropriate" X11 name
789 // Note that X stores the RGB values in the range 0 - 65535
790 // whilst we require them in the range 0 - 255.
792 col.r = xcol.red / 256;
793 col.g = xcol.green / 256;
794 col.b = xcol.blue / 256;
796 // Create a valid X11 name of the form "#rrggbb" and change the
797 // LColor X11name to this. Don't want to trigger a redraw,
798 // as we're just changing the name not the RGB values.
799 // Also reset the system_lcolor names, so that we don't output
800 // unnecessary changes.
801 string const hexname = X11hexname(col);
803 if (lcolor.getX11Name(lc) != hexname) {
804 lcolor.setColor(lc, hexname);
805 system_lcolor.setColor(lc, hexname);
808 // Finally, push the color onto the database
809 NamedColor ncol(lcolor.getGUIName(lc), col);
810 lyxColorDB.push_back(ncol);
813 // Now construct the browser
814 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
815 fl_freeze_form(dialog_->form);
816 fl_clear_browser(colbr);
817 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
818 cit != xformsColorDB.end(); ++cit) {
819 fl_addto_browser(colbr, cit->getname().c_str());
821 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
822 cit != lyxColorDB.end(); ++cit) {
823 fl_addto_browser(colbr, cit->getname().c_str());
826 // just to be safe...
827 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
828 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
829 fl_unfreeze_form(dialog_->form);
835 void FormPreferences::Colors::Modify()
837 vector<NamedColor>::size_type const selLyX =
838 fl_get_browser(dialog_->browser_lyx_objs);
839 if (selLyX < 1) return;
842 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
844 // Is the choice an Xforms color...
845 if( selLyX-1 < xformsColorDB.size() ) {
846 vector<XformsColor>::size_type const i = selLyX - 1;
847 xformsColorDB[i].r = col.r;
848 xformsColorDB[i].g = col.g;
849 xformsColorDB[i].b = col.b;
851 // or a LyX Logical color?
853 vector<NamedColor>::size_type const i = selLyX - 1 -
854 xformsColorDB.size();
855 lyxColorDB[i].r = col.r;
856 lyxColorDB[i].g = col.g;
857 lyxColorDB[i].b = col.b;
860 fl_freeze_form(dialog_->form);
861 setEnabled(dialog_->button_modify, false);
862 fl_unfreeze_form(dialog_->form);
866 void FormPreferences::Colors::SwitchColorSpace() const
868 bool const pressed = fl_get_button(dialog_->button_colorspace);
871 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
873 fl_freeze_form(dialog_->form);
876 fl_set_object_label(dialog_->button_colorspace, _("HSV"));
878 fl_hide_object(dialog_->slider_red);
879 fl_hide_object(dialog_->slider_blue);
880 fl_hide_object(dialog_->slider_green);
881 fl_show_object(dialog_->dial_hue);
882 fl_show_object(dialog_->slider_saturation);
883 fl_show_object(dialog_->slider_value);
885 HSVColor hsv = HSVColor(col);
886 hsv.h = max(hsv.h, 0.0);
888 fl_set_dial_value(dialog_->dial_hue, hsv.h);
889 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
890 fl_set_slider_value(dialog_->slider_value, hsv.v);
892 col = HSVColor(hsv.h, 1.0, 1.0);
893 col.r = max(col.r,0);
894 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
895 fl_redraw_object(dialog_->dial_hue);
897 // Adjust the label a bit, but not the actual values.
898 // Means that toggling from one space to the other has no
899 // effect on the final color.
900 int const h = int(hsv.h);
901 int const s = int(100*hsv.s);
902 int const v = int(100*hsv.v);
903 string const label = tostr(h) + string(", ") + tostr(s) +
904 string(", ") + tostr(v);
905 fl_set_object_label(dialog_->text_color_values, label.c_str());
908 fl_set_object_label(dialog_->button_colorspace, _("RGB"));
910 fl_show_object(dialog_->slider_red);
911 fl_show_object(dialog_->slider_blue);
912 fl_show_object(dialog_->slider_green);
913 fl_hide_object(dialog_->dial_hue);
914 fl_hide_object(dialog_->slider_saturation);
915 fl_hide_object(dialog_->slider_value);
917 fl_set_slider_value(dialog_->slider_red, col.r);
918 fl_set_slider_value(dialog_->slider_green, col.g);
919 fl_set_slider_value(dialog_->slider_blue, col.b);
921 // Adjust the label a bit. Same reasoning as above.
922 int const r = int(col.r);
923 int const g = int(col.g);
924 int const b = int(col.b);
925 string const label = tostr(r) + string(", ") + tostr(g) +
926 string(", ") + tostr(b);
927 fl_set_object_label(dialog_->text_color_values, label.c_str());
930 fl_unfreeze_form(dialog_->form);
933 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
937 ostr << "#" << std::setbase(16) << std::setfill('0')
938 << std::setw(2) << col.r
939 << std::setw(2) << col.g
940 << std::setw(2) << col.b;
942 return ostr.str().c_str();
946 FormPreferences::Converters::Converters(FormPreferences & p)
951 FD_form_converters const * FormPreferences::Converters::dialog()
953 return dialog_.get();
957 void FormPreferences::Converters::apply() const
959 converters = local_converters;
960 converters.update(formats);
961 converters.buildGraph();
965 void FormPreferences::Converters::build()
967 dialog_.reset(parent_.build_converters());
969 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
970 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
972 // set up the feedback mechanism
973 setPreHandler(dialog_->browser_all);
974 setPreHandler(dialog_->button_delete);
975 setPreHandler(dialog_->button_add);
976 setPreHandler(dialog_->input_converter);
977 setPreHandler(dialog_->choice_from);
978 setPreHandler(dialog_->choice_to);
979 setPreHandler(dialog_->input_flags);
984 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
988 if (ob == dialog_->browser_all) {
989 str = N_("All the currently defined converters known to LyX.");
990 } else if (ob == dialog_->choice_from) {
991 str = N_("Convert \"from\" this format");
992 } else if (ob == dialog_->choice_to) {
993 str = N_("Convert \"to\" this format");
994 } else if (ob == dialog_->input_converter) {
995 str = N_("The conversion command. $$i is the input file name, $$b is the file name without its extension and $$o is the name of the output file.");
996 } else if (ob == dialog_->input_flags) {
997 str = N_("Flags that control the converter behavior");
998 } else if (ob == dialog_->button_delete) {
999 str = N_("Remove the current converter from the list of available converters. Note: you must then \"Apply\" the change.");
1000 } else if (ob == dialog_->button_add) {
1001 if (string(ob->label) == _("Add"))
1002 str = N_("Add the current converter to the list of available converters. Note: you must then \"Apply\" the change.");
1004 str = N_("Modify the contents of the current converter. Note: you must then \"Apply\" the change.");
1011 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
1013 if (ob == dialog_->browser_all) {
1016 } else if (ob == dialog_->choice_from
1017 || ob == dialog_->choice_to
1018 || ob == dialog_->input_converter
1019 || ob == dialog_->input_flags) {
1022 } else if (ob == dialog_->button_add) {
1025 } else if (ob == dialog_->button_delete) {
1033 void FormPreferences::Converters::update()
1035 local_converters = converters;
1036 local_converters.update(local_formats);
1041 void FormPreferences::Converters::UpdateBrowser()
1043 local_converters.sort();
1045 fl_freeze_form(dialog_->form);
1046 fl_clear_browser(dialog_->browser_all);
1047 for (::Converters::const_iterator cit = local_converters.begin();
1048 cit != local_converters.end(); ++cit) {
1049 string const name = cit->From->prettyname() + " -> "
1050 + cit->To->prettyname();
1051 fl_addto_browser(dialog_->browser_all, name.c_str());
1054 fl_unfreeze_form(dialog_->form);
1058 bool FormPreferences::Converters::Add()
1060 string const from = GetFrom();
1061 string const to = GetTo();
1062 string const command = fl_get_input(dialog_->input_converter);
1063 string const flags = fl_get_input(dialog_->input_flags);
1065 Converter const * old = local_converters.getConverter(from, to);
1066 local_converters.add(from, to, command, flags);
1068 local_converters.updateLast(local_formats);
1071 setEnabled(dialog_->button_add, false);
1077 bool FormPreferences::Converters::Browser()
1079 int const i = fl_get_browser(dialog_->browser_all);
1080 if (i <= 0) return false;
1082 fl_freeze_form(dialog_->form);
1084 Converter const & c = local_converters.get(i - 1);
1085 int j = local_formats.getNumber(c.from);
1087 fl_set_choice(dialog_->choice_from, j + 1);
1089 j = local_formats.getNumber(c.to);
1091 fl_set_choice(dialog_->choice_to, j + 1);
1093 fl_set_input(dialog_->input_converter, c.command.c_str());
1094 fl_set_input(dialog_->input_flags, c.flags.c_str());
1096 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1097 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1099 setEnabled(dialog_->button_add, false);
1100 setEnabled(dialog_->button_delete, true);
1102 fl_unfreeze_form(dialog_->form);
1107 bool FormPreferences::Converters::erase()
1109 string const from = GetFrom();
1110 string const to = GetTo();
1112 local_converters.erase(from, to);
1118 bool FormPreferences::Converters::Input()
1120 string const from = GetFrom();
1121 string const to = GetTo();
1122 int const sel = local_converters.getNumber(from, to);
1124 fl_freeze_form(dialog_->form);
1127 fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
1128 fl_set_button_shortcut(dialog_->button_add,
1129 scex(_("Add|#A")), 1);
1131 fl_deselect_browser(dialog_->browser_all);
1132 setEnabled(dialog_->button_delete, false);
1135 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1136 fl_set_button_shortcut(dialog_->button_add,
1137 scex(_("Modify|#M")), 1);
1139 int top = max(sel-5, 0);
1140 fl_set_browser_topline(dialog_->browser_all, top);
1141 fl_select_browser_line(dialog_->browser_all, sel+1);
1142 setEnabled(dialog_->button_delete, true);
1145 string const command = strip(fl_get_input(dialog_->input_converter));
1146 bool const enable = !(command.empty() || from == to);
1147 setEnabled(dialog_->button_add, enable);
1149 fl_unfreeze_form(dialog_->form);
1154 string const FormPreferences::Converters::GetFrom() const
1156 ::Formats::FormatList::size_type const i =
1157 fl_get_choice(dialog_->choice_from);
1159 if (i > 0 && i <= local_formats.size())
1160 return local_formats.get(i - 1).name();
1162 lyxerr << "FormPreferences::Converters::GetFrom: No choice!"
1169 string const FormPreferences::Converters::GetTo() const
1171 ::Formats::FormatList::size_type const i =
1172 fl_get_choice(dialog_->choice_to);
1174 if (i > 0 && i <= local_formats.size())
1175 return local_formats.get(i - 1).name();
1177 lyxerr << "FormPreferences::Converters::GetTo: No choice!"
1184 void FormPreferences::Converters::UpdateChoices() const
1187 for (::Formats::const_iterator cit = local_formats.begin();
1188 cit != local_formats.end(); ++cit) {
1189 if (!choice.empty())
1193 choice += cit->prettyname();
1197 fl_clear_choice(dialog_->choice_from);
1198 fl_addto_choice(dialog_->choice_from, choice.c_str());
1200 fl_clear_choice(dialog_->choice_to);
1201 fl_addto_choice(dialog_->choice_to, choice.c_str());
1205 FormPreferences::Formats::Formats( FormPreferences & p )
1210 FD_form_formats const * FormPreferences::Formats::dialog()
1212 return dialog_.get();
1216 void FormPreferences::Formats::apply() const
1218 formats = local_formats;
1222 void FormPreferences::Formats::build()
1224 dialog_.reset(parent_.build_formats());
1226 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1227 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1228 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1229 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1230 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1232 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1234 // set up the feedback mechanism
1235 setPreHandler(dialog_->browser_all);
1236 setPreHandler(dialog_->input_format);
1237 setPreHandler(dialog_->input_gui_name);
1238 setPreHandler(dialog_->button_delete);
1239 setPreHandler(dialog_->button_add);
1240 setPreHandler(dialog_->input_extension);
1241 setPreHandler(dialog_->input_viewer);
1242 setPreHandler(dialog_->input_shrtcut);
1247 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1251 if (ob == dialog_->browser_all) {
1252 str = N_("All the currently defined formats known to LyX.");
1253 } else if (ob == dialog_->input_format) {
1254 str = N_("The format identifier.");
1255 } else if (ob == dialog_->input_gui_name) {
1256 str = N_("The format name as it will appear in the menus.");
1257 } else if (ob == dialog_->input_shrtcut) {
1258 str = N_("The keyboard accelerator. Use a letter in the GUI name. Case sensitive.");
1259 } else if (ob == dialog_->input_extension) {
1260 str = N_("Used to recognize the file. E.g., ps, pdf, tex.");
1261 } else if (ob == dialog_->input_viewer) {
1262 str = N_("The command used to launch the viewer application.");
1263 } else if (ob == dialog_->button_delete) {
1264 str = N_("Remove the current format from the list of available formats. Note: you must then \"Apply\" the change.");
1265 } else if (ob == dialog_->button_add) {
1266 if (string(ob->label) == _("Add"))
1267 str = N_("Add the current format to the list of available formats. Note: you must then \"Apply\" the change.");
1269 str = N_("Modify the contents of the current format. Note: you must then \"Apply\" the change.");
1276 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1278 if (ob == dialog_->browser_all) {
1281 } else if (ob == dialog_->input_format
1282 || ob == dialog_->input_gui_name
1283 || ob == dialog_->input_shrtcut
1284 || ob == dialog_->input_extension
1285 || ob == dialog_->input_viewer) {
1288 } else if (ob == dialog_->button_add) {
1291 } else if (ob == dialog_->button_delete) {
1299 void FormPreferences::Formats::update()
1301 local_formats = formats;
1306 void FormPreferences::Formats::UpdateBrowser()
1308 local_formats.sort();
1310 fl_freeze_form(dialog_->form);
1311 fl_deselect_browser(dialog_->browser_all);
1312 fl_clear_browser(dialog_->browser_all);
1313 for (::Formats::const_iterator cit = local_formats.begin();
1314 cit != local_formats.end(); ++cit)
1315 fl_addto_browser(dialog_->browser_all,
1316 cit->prettyname().c_str());
1319 fl_unfreeze_form(dialog_->form);
1321 // Mustn't forget to update the Formats available to the converters_
1322 parent_.converters_.UpdateChoices();
1323 local_converters.update(local_formats);
1327 bool FormPreferences::Formats::Add()
1329 string const name = fl_get_input(dialog_->input_format);
1330 string const prettyname = fl_get_input(dialog_->input_gui_name);
1331 string const extension = fl_get_input(dialog_->input_extension);
1332 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1333 string const viewer = fl_get_input(dialog_->input_viewer);
1335 Format const * old = local_formats.getFormat(name);
1336 string const old_prettyname = old ? old->prettyname() : string();
1337 local_formats.add(name, extension, prettyname, shortcut);
1338 local_formats.setViewer(name, viewer);
1339 if (!old || prettyname != old_prettyname) {
1342 parent_.converters_.UpdateBrowser();
1344 setEnabled(dialog_->button_add, false);
1350 bool FormPreferences::Formats::Browser()
1352 int const i = fl_get_browser(dialog_->browser_all);
1353 if (i <= 0) return false;
1355 fl_freeze_form(dialog_->form);
1357 Format const & f = local_formats.get(i - 1);
1359 fl_set_input(dialog_->input_format, f.name().c_str());
1360 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1361 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1362 fl_set_input(dialog_->input_extension, f.extension().c_str());
1363 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1365 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1366 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1368 setEnabled(dialog_->button_add, false);
1369 setEnabled(dialog_->button_delete, true);
1371 fl_unfreeze_form(dialog_->form);
1376 bool FormPreferences::Formats::erase()
1378 string const name = fl_get_input(dialog_->input_format);
1380 if (local_converters.formatIsUsed(name)) {
1381 parent_.printWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
1382 setEnabled(dialog_->button_delete, false);
1386 local_formats.erase(name);
1392 bool FormPreferences::Formats::Input()
1394 string const name = fl_get_input(dialog_->input_format);
1395 int const sel = local_formats.getNumber(name);
1396 fl_freeze_form(dialog_->form);
1399 fl_set_object_label(dialog_->button_add,
1401 fl_set_button_shortcut(dialog_->button_add,
1402 scex(_("Add|#A")), 1);
1404 fl_deselect_browser(dialog_->browser_all);
1405 setEnabled(dialog_->button_delete, false);
1408 fl_set_object_label(dialog_->button_add,
1409 idex(_("Modify|#M")));
1410 fl_set_button_shortcut(dialog_->button_add,
1411 scex(_("Modify|#M")), 1);
1413 int const top = max(sel-5, 0);
1414 fl_set_browser_topline(dialog_->browser_all, top);
1415 fl_select_browser_line(dialog_->browser_all, sel+1);
1417 setEnabled(dialog_->button_add, true);
1418 setEnabled(dialog_->button_delete, true);
1421 string const prettyname = fl_get_input(dialog_->input_gui_name);
1422 bool const enable = !(name.empty() || prettyname.empty());
1423 setEnabled(dialog_->button_add, enable);
1425 fl_unfreeze_form(dialog_->form);
1430 FormPreferences::InputsMisc::InputsMisc( FormPreferences & p )
1435 FD_form_inputs_misc const * FormPreferences::InputsMisc::dialog()
1437 return dialog_.get();
1441 void FormPreferences::InputsMisc::apply() const
1443 lyxrc.date_insert_format =
1444 fl_get_input(dialog_->input_date_format);
1448 void FormPreferences::InputsMisc::build()
1450 dialog_.reset(parent_.build_inputs_misc());
1452 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1454 // set up the feedback mechanism
1455 setPreHandler(dialog_->input_date_format);
1460 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1464 if (ob == dialog_->input_date_format)
1465 str = lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1471 void FormPreferences::InputsMisc::update()
1473 fl_set_input(dialog_->input_date_format,
1474 lyxrc.date_insert_format.c_str());
1478 FormPreferences::Interface::Interface( FormPreferences & p )
1483 FD_form_interface const * FormPreferences::Interface::dialog()
1485 return dialog_.get();
1489 void FormPreferences::Interface::apply() const
1491 lyxrc.popup_font_name =
1492 fl_get_input(dialog_->input_popup_font);
1493 lyxrc.menu_font_name = fl_get_input(dialog_->input_menu_font);
1494 lyxrc.font_norm_menu =
1495 fl_get_input(dialog_->input_popup_encoding);
1496 lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
1497 lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
1498 lyxrc.override_x_deadkeys =
1499 fl_get_button(dialog_->check_override_x_dead_keys);
1503 void FormPreferences::Interface::build()
1505 dialog_.reset(parent_.build_interface());
1507 fl_set_input_return(dialog_->input_popup_font, FL_RETURN_CHANGED);
1508 fl_set_input_return(dialog_->input_menu_font, FL_RETURN_CHANGED);
1509 fl_set_input_return(dialog_->input_popup_encoding, FL_RETURN_CHANGED);
1510 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1511 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1513 // set up the feedback mechanism
1514 setPreHandler(dialog_->input_popup_font);
1515 setPreHandler(dialog_->input_menu_font);
1516 setPreHandler(dialog_->input_popup_encoding);
1517 setPreHandler(dialog_->input_bind_file);
1518 setPreHandler(dialog_->button_bind_file_browse);
1519 setPreHandler(dialog_->input_ui_file);
1520 setPreHandler(dialog_->button_ui_file_browse);
1521 setPreHandler(dialog_->check_override_x_dead_keys);
1526 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1530 if (ob == dialog_->input_popup_font)
1531 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_POPUP);
1532 else if (ob == dialog_->input_menu_font)
1533 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_MENU);
1534 else if (ob == dialog_->input_popup_encoding)
1535 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING_MENU);
1536 else if (ob == dialog_->input_bind_file)
1537 str = lyxrc.getDescription(LyXRC::RC_BINDFILE);
1538 else if (ob == dialog_->input_ui_file)
1539 str = lyxrc.getDescription(LyXRC::RC_UIFILE);
1540 else if (ob == dialog_->check_override_x_dead_keys)
1541 str = lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1547 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1549 if (ob == dialog_->button_bind_file_browse) {
1550 string dir = AddName(system_lyxdir, "bind");
1551 string name = N_("Sys Bind");
1552 pair<string,string> dir1(name, dir);
1554 dir = AddName(user_lyxdir, "bind");
1555 name = N_("User Bind");
1556 pair<string,string> dir2(name, dir);
1558 parent_.browse(dialog_->input_bind_file,
1559 N_("Bind file"), "*.bind", dir1, dir2);
1561 } else if (ob == dialog_->button_ui_file_browse) {
1562 string dir = AddName(system_lyxdir, "ui");
1563 string name = N_("Sys UI");
1564 pair<string,string> dir1(name, dir);
1566 dir = AddName(user_lyxdir, "ui");
1567 name = N_("User UI");
1568 pair<string,string> dir2(name, dir);
1570 parent_.browse(dialog_->input_ui_file,
1571 N_("UI file"), "*.ui", dir1, dir2);
1578 void FormPreferences::Interface::update()
1580 fl_set_input(dialog_->input_popup_font,
1581 lyxrc.popup_font_name.c_str());
1582 fl_set_input(dialog_->input_menu_font,
1583 lyxrc.menu_font_name.c_str());
1584 fl_set_input(dialog_->input_popup_encoding,
1585 lyxrc.font_norm_menu.c_str());
1586 fl_set_input(dialog_->input_bind_file,
1587 lyxrc.bind_file.c_str());
1588 fl_set_input(dialog_->input_ui_file,
1589 lyxrc.ui_file.c_str());
1590 fl_set_button(dialog_->check_override_x_dead_keys,
1591 lyxrc.override_x_deadkeys);
1595 FormPreferences::Language::Language( FormPreferences & p )
1600 FD_form_language const * FormPreferences::Language::dialog()
1602 return dialog_.get();
1606 void FormPreferences::Language::apply()
1608 lyxrc.default_language = combo_default_lang->getline();
1610 int button = fl_get_button(dialog_->check_use_kbmap);
1611 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1612 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1614 button = !(name_1.empty() && name_2.empty());
1615 lyxrc.use_kbmap = static_cast<bool>(button);
1617 if (lyxrc.use_kbmap) {
1618 lyxrc.primary_kbmap = name_1;
1619 lyxrc.secondary_kbmap = name_2;
1622 button = fl_get_button(dialog_->check_rtl_support);
1623 lyxrc.rtl_support = static_cast<bool>(button);
1625 button = fl_get_button(dialog_->check_mark_foreign);
1626 lyxrc.mark_foreign_language = static_cast<bool>(button);
1628 button = fl_get_button(dialog_->check_auto_begin);
1629 lyxrc.language_auto_begin = static_cast<bool>(button);
1631 button = fl_get_button(dialog_->check_auto_end);
1632 lyxrc.language_auto_end = static_cast<bool>(button);
1634 button = fl_get_button(dialog_->check_use_babel);
1635 lyxrc.language_use_babel = static_cast<bool>(button);
1637 button = fl_get_button(dialog_->check_global_options);
1638 lyxrc.language_global_options = static_cast<bool>(button);
1640 lyxrc.language_package = fl_get_input(dialog_->input_package);
1641 lyxrc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1642 lyxrc.language_command_end = fl_get_input(dialog_->input_command_end);
1644 // Ensure that all is self-consistent.
1649 void FormPreferences::Language::build()
1651 dialog_.reset(parent_.build_language());
1653 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1654 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1655 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1657 // The default_language is a combo-box and has to be inserted manually
1658 fl_freeze_form(dialog_->form);
1659 fl_addto_form(dialog_->form);
1661 FL_OBJECT * obj = dialog_->choice_default_lang;
1662 fl_deactivate_object(dialog_->choice_default_lang);
1663 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1664 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
1665 parent_.lang_opts_tab_->tabfolder_outer,
1666 parent_.dialog_->tabfolder_prefs);
1667 combo_default_lang->shortcut("#L",1);
1668 combo_default_lang->setcallback(ComboCB, &parent_);
1670 for (Languages::const_iterator cit = languages.begin();
1671 cit != languages.end(); ++cit) {
1672 combo_default_lang->addto(cit->second.lang());
1676 fl_unfreeze_form(dialog_->form);
1678 // set up the feedback mechanism
1679 setPreHandler(dialog_->input_package);
1680 setPreHandler(dialog_->check_use_kbmap);
1682 // This is safe, as nothing is done to the pointer, other than
1683 // to use its address in a block-if statement.
1684 // No it's not! Leads to crash.
1686 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1687 // C_FormPreferencesFeedbackCB);
1689 setPreHandler(dialog_->input_kbmap1);
1690 setPreHandler(dialog_->input_kbmap2);
1691 setPreHandler(dialog_->check_rtl_support);
1692 setPreHandler(dialog_->check_mark_foreign);
1693 setPreHandler(dialog_->check_auto_begin);
1694 setPreHandler(dialog_->check_auto_end);
1695 setPreHandler(dialog_->check_use_babel);
1696 setPreHandler(dialog_->check_global_options);
1697 setPreHandler(dialog_->input_command_begin);
1698 setPreHandler(dialog_->input_command_end);
1700 // Activate/Deactivate the input fields dependent on the state of the
1707 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1711 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1712 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1713 else if (ob == dialog_->check_use_kbmap)
1714 str = lyxrc.getDescription(LyXRC::RC_KBMAP);
1715 else if (ob == dialog_->input_kbmap1)
1716 str = lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1717 else if (ob == dialog_->input_kbmap2)
1718 str = lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1719 else if (ob == dialog_->check_rtl_support)
1720 str = lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1721 else if (ob == dialog_->check_mark_foreign)
1722 str = lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1723 else if (ob == dialog_->check_auto_begin)
1724 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1725 else if (ob == dialog_->check_auto_end)
1726 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1727 else if (ob == dialog_->check_use_babel)
1728 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1729 else if (ob == dialog_->check_global_options)
1730 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1731 else if (ob == dialog_->input_package)
1732 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1733 else if (ob == dialog_->input_command_begin)
1734 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1735 else if (ob == dialog_->input_command_end)
1736 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1742 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1744 bool activate = true;
1746 // !ob if function is called from Language::build() to de/activate
1748 // otherwise the function is called by an xforms CB via input().
1749 if (!ob || ob == dialog_->check_use_kbmap) {
1750 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1751 setEnabled(dialog_->button_kbmap1_browse, enable);
1752 setEnabled(dialog_->button_kbmap2_browse, enable);
1753 setEnabled(dialog_->input_kbmap1, enable);
1754 setEnabled(dialog_->input_kbmap2, enable);
1757 if (ob == dialog_->button_kbmap1_browse) {
1758 string const dir = AddName(system_lyxdir, "kbd");
1759 string const name = N_("Key maps");
1760 pair<string, string> dir1(name, dir);
1762 parent_.browse(dialog_->input_kbmap1,
1763 N_("Keyboard map"), "*.kmap", dir1,
1764 make_pair(string(), string()));
1765 } else if (ob == dialog_->button_kbmap2_browse) {
1766 string const dir = AddName(system_lyxdir, "kbd");
1767 string const name = N_("Key maps");
1768 pair<string, string> dir1(name, dir);
1770 parent_.browse(dialog_->input_kbmap2,
1771 N_("Keyboard map"), "*.kmap", dir1,
1772 make_pair(string(), string()));
1779 void FormPreferences::Language::update()
1781 fl_set_button(dialog_->check_use_kbmap,
1784 combo_default_lang->select(lyxrc.default_language);
1786 if (lyxrc.use_kbmap) {
1787 fl_set_input(dialog_->input_kbmap1,
1788 lyxrc.primary_kbmap.c_str());
1789 fl_set_input(dialog_->input_kbmap2,
1790 lyxrc.secondary_kbmap.c_str());
1792 fl_set_input(dialog_->input_kbmap1, "");
1793 fl_set_input(dialog_->input_kbmap2, "");
1796 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1797 fl_set_button(dialog_->check_mark_foreign,
1798 lyxrc.mark_foreign_language);
1799 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1800 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1801 fl_set_button(dialog_->check_use_babel, lyxrc.language_use_babel);
1802 fl_set_button(dialog_->check_global_options,
1803 lyxrc.language_global_options);
1805 fl_set_input(dialog_->input_package,
1806 lyxrc.language_package.c_str());
1807 fl_set_input(dialog_->input_command_begin,
1808 lyxrc.language_command_begin.c_str());
1809 fl_set_input(dialog_->input_command_end,
1810 lyxrc.language_command_end.c_str());
1812 // Activate/Deactivate the input fields dependent on the state of the
1818 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1820 FormPreferences * pre = static_cast<FormPreferences*>(v);
1821 // This is safe, as nothing is done to the pointer, other than
1822 // to use its address in a block-if statement.
1823 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1827 FormPreferences::LnFmisc::LnFmisc( FormPreferences & p )
1832 FD_form_lnf_misc const * FormPreferences::LnFmisc::dialog()
1834 return dialog_.get();
1838 void FormPreferences::LnFmisc::apply() const
1840 lyxrc.show_banner = fl_get_button(dialog_->check_banner);
1841 lyxrc.auto_region_delete =
1842 fl_get_button(dialog_->check_auto_region_delete);
1843 lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm);
1844 lyxrc.display_shortcuts =
1845 fl_get_button(dialog_->check_display_shrtcuts);
1846 lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
1847 lyxrc.cursor_follows_scrollbar =
1848 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1849 lyxrc.autosave = static_cast<unsigned int>
1850 (fl_get_counter_value(dialog_->counter_autosave));
1851 lyxrc.wheel_jump = static_cast<unsigned int>
1852 (fl_get_counter_value(dialog_->counter_wm_jump));
1856 void FormPreferences::LnFmisc::build()
1858 dialog_.reset(parent_.build_lnf_misc());
1860 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1861 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1863 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1864 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1866 // set up the feedback mechanism
1867 setPreHandler(dialog_->check_banner);
1868 setPreHandler(dialog_->check_auto_region_delete);
1869 setPreHandler(dialog_->check_exit_confirm);
1870 setPreHandler(dialog_->check_display_shrtcuts);
1871 setPreHandler(dialog_->counter_autosave);
1872 setPreHandler(dialog_->check_ask_new_file);
1873 setPreHandler(dialog_->check_cursor_follows_scrollbar);
1874 setPreHandler(dialog_->counter_wm_jump);
1879 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1883 if (ob == dialog_->check_banner)
1884 str = lyxrc.getDescription(LyXRC::RC_SHOW_BANNER);
1885 else if (ob == dialog_->check_auto_region_delete)
1886 str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1887 else if (ob == dialog_->check_exit_confirm)
1888 str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION);
1889 else if (ob == dialog_->check_display_shrtcuts)
1890 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_SHORTCUTS);
1891 else if (ob == dialog_->check_ask_new_file)
1892 str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
1893 else if (ob == dialog_->check_cursor_follows_scrollbar)
1894 str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1895 else if (ob == dialog_->counter_autosave)
1896 str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1897 else if (ob == dialog_->counter_wm_jump)
1898 str = lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1904 void FormPreferences::LnFmisc::update()
1906 fl_set_button(dialog_->check_banner, lyxrc.show_banner);
1907 fl_set_button(dialog_->check_auto_region_delete,
1908 lyxrc.auto_region_delete);
1909 fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
1910 fl_set_button(dialog_->check_display_shrtcuts, lyxrc.display_shortcuts);
1911 fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
1912 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1913 lyxrc.cursor_follows_scrollbar);
1914 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1915 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1919 FormPreferences::OutputsMisc::OutputsMisc( FormPreferences & p )
1924 FD_form_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1926 return dialog_.get();
1930 void FormPreferences::OutputsMisc::apply() const
1932 lyxrc.ascii_linelen = static_cast<unsigned int>
1933 (fl_get_counter_value(dialog_->counter_line_len));
1934 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1937 fl_get_choice(dialog_->choice_default_papersize) - 1;
1938 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1940 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1941 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1942 lyxrc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1946 void FormPreferences::OutputsMisc::build()
1948 dialog_.reset(parent_.build_outputs_misc());
1950 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1952 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1953 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1954 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1955 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1956 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1958 fl_addto_choice(dialog_->choice_default_papersize,
1959 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
1961 // set up the feedback mechanism
1962 setPreHandler(dialog_->counter_line_len);
1963 setPreHandler(dialog_->input_tex_encoding);
1964 setPreHandler(dialog_->choice_default_papersize);
1965 setPreHandler(dialog_->input_ascii_roff);
1966 setPreHandler(dialog_->input_checktex);
1967 setPreHandler(dialog_->input_paperoption);
1972 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1976 if (ob == dialog_->counter_line_len)
1977 str = lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
1978 else if (ob == dialog_->input_tex_encoding)
1979 str = lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
1980 else if (ob == dialog_->input_ascii_roff)
1981 str = lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1982 else if (ob == dialog_->input_checktex)
1983 str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
1984 else if (ob == dialog_->choice_default_papersize)
1985 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1986 else if (ob == dialog_->input_paperoption)
1987 str = lyxrc.getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
1993 void FormPreferences::OutputsMisc::update()
1995 fl_set_counter_value(dialog_->counter_line_len,
1996 lyxrc.ascii_linelen);
1997 fl_set_input(dialog_->input_tex_encoding,
1998 lyxrc.fontenc.c_str());
1999 fl_set_choice(dialog_->choice_default_papersize,
2000 lyxrc.default_papersize+1);
2001 fl_set_input(dialog_->input_ascii_roff,
2002 lyxrc.ascii_roff_command.c_str());
2003 fl_set_input(dialog_->input_checktex,
2004 lyxrc.chktex_command.c_str());
2005 fl_set_input(dialog_->input_paperoption,
2006 lyxrc.view_dvi_paper_option.c_str());
2010 FormPreferences::Paths::Paths( FormPreferences & p )
2015 FD_form_paths const * FormPreferences::Paths::dialog()
2017 return dialog_.get();
2021 void FormPreferences::Paths::apply()
2023 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2024 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2026 int button = fl_get_button(dialog_->check_use_temp_dir);
2027 string str = fl_get_input(dialog_->input_temp_dir);
2028 if (!button) str.erase();
2030 lyxrc.use_tempdir = button;
2031 lyxrc.tempdir_path = str;
2033 button = fl_get_button(dialog_->check_last_files);
2034 str = fl_get_input(dialog_->input_lastfiles);
2035 if (!button) str.erase();
2037 lyxrc.check_lastfiles = button;
2038 lyxrc.lastfiles = str;
2039 lyxrc.num_lastfiles = static_cast<unsigned int>
2040 (fl_get_counter_value(dialog_->counter_lastfiles));
2042 button = fl_get_button(dialog_->check_make_backups);
2043 str = fl_get_input(dialog_->input_backup_path);
2044 if (!button) str.erase();
2046 lyxrc.make_backup = button;
2047 lyxrc.backupdir_path = str;
2049 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2056 void FormPreferences::Paths::build()
2058 dialog_.reset(parent_.build_paths());
2060 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2061 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2062 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2063 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2064 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2065 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2066 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2068 // set up the feedback mechanism
2069 setPreHandler(dialog_->input_default_path);
2070 setPreHandler(dialog_->counter_lastfiles);
2071 setPreHandler(dialog_->input_template_path);
2072 setPreHandler(dialog_->check_last_files);
2073 setPreHandler(dialog_->input_lastfiles);
2074 setPreHandler(dialog_->check_make_backups);
2075 setPreHandler(dialog_->input_backup_path);
2076 setPreHandler(dialog_->input_serverpipe);
2077 setPreHandler(dialog_->input_temp_dir);
2078 setPreHandler(dialog_->check_use_temp_dir);
2083 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2087 if (ob == dialog_->input_default_path)
2088 str = lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2089 else if (ob == dialog_->input_template_path)
2090 str = lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2091 else if (ob == dialog_->check_use_temp_dir)
2092 str = lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2093 else if (ob == dialog_->input_temp_dir)
2094 str = lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2095 else if (ob == dialog_->check_last_files)
2096 str = lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2097 else if (ob == dialog_->input_lastfiles)
2098 str = lyxrc.getDescription(LyXRC::RC_LASTFILES);
2099 else if (ob == dialog_->counter_lastfiles)
2100 str = lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2101 else if (ob == dialog_->check_make_backups)
2102 str = lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2103 else if (ob == dialog_->input_backup_path)
2104 str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2105 else if (ob == dialog_->input_serverpipe) {
2106 str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2113 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2115 bool activate = true;
2117 // !ob if function is called from Paths::update() to de/activate
2119 // otherwise the function is called by an xforms CB via input().
2120 if (!ob || ob == dialog_->check_use_temp_dir) {
2121 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2122 setEnabled(dialog_->input_temp_dir, enable);
2125 if (!ob || ob == dialog_->check_last_files) {
2126 bool const enable = fl_get_button(dialog_->check_last_files);
2127 setEnabled(dialog_->input_lastfiles, enable);
2130 if (!ob || ob == dialog_->check_make_backups) {
2131 bool const enable = fl_get_button(dialog_->check_make_backups);
2132 setEnabled(dialog_->input_backup_path, enable);
2135 if (!ob || ob == dialog_->input_default_path) {
2136 string const name = fl_get_input(dialog_->input_default_path);
2137 if (!RWInfo::WriteableDir(name)) {
2138 parent_.printWarning(RWInfo::ErrorMessage());
2143 if (!ob || ob == dialog_->input_template_path) {
2144 string const name = fl_get_input(dialog_->input_template_path);
2145 if (!RWInfo::ReadableDir(name)) {
2146 parent_.printWarning(RWInfo::ErrorMessage());
2151 if (!ob || ob == dialog_->input_temp_dir) {
2152 string const name = fl_get_input(dialog_->input_temp_dir);
2153 if (fl_get_button(dialog_->check_make_backups)
2155 && !RWInfo::WriteableDir(name)) {
2156 parent_.printWarning(RWInfo::ErrorMessage());
2161 if (!ob || ob == dialog_->input_backup_path) {
2162 string const name = fl_get_input(dialog_->input_backup_path);
2163 if (fl_get_button(dialog_->check_make_backups)
2165 && !RWInfo::WriteableDir(name)) {
2166 parent_.printWarning(RWInfo::ErrorMessage());
2171 if (!ob || ob == dialog_->input_lastfiles) {
2172 string const name = fl_get_input(dialog_->input_lastfiles);
2173 if (fl_get_button(dialog_->check_last_files)
2175 && !RWInfo::WriteableFile(name)) {
2176 parent_.printWarning(RWInfo::ErrorMessage());
2181 if (!ob || ob == dialog_->input_serverpipe) {
2182 string const name = fl_get_input(dialog_->input_serverpipe);
2183 if (!name.empty()) {
2184 // strip off the extension
2185 string const str = ChangeExtension(name, "");
2186 if (!RWInfo::WriteableFile(str + ".in")) {
2187 parent_.printWarning(RWInfo::ErrorMessage());
2190 if (!RWInfo::WriteableFile(str + ".out")) {
2191 parent_.printWarning(RWInfo::ErrorMessage());
2197 if (ob == dialog_->button_default_path_browse) {
2198 parent_.browse(dialog_->input_default_path,
2199 N_("Default path"), string(),
2200 make_pair(string(), string()),
2201 make_pair(string(), string()));
2202 } else if (ob == dialog_->button_template_path_browse) {
2203 parent_.browse(dialog_->input_template_path,
2204 N_("Template path"), string(),
2205 make_pair(string(), string()),
2206 make_pair(string(), string()));
2207 } else if (ob == dialog_->button_temp_dir_browse) {
2208 parent_.browse(dialog_->input_temp_dir,
2209 N_("Temp dir"), string(),
2210 make_pair(string(), string()),
2211 make_pair(string(), string()));
2212 } else if (ob == dialog_->button_lastfiles_browse) {
2213 pair<string, string> dir(_("User"), user_lyxdir);
2215 parent_.browse(dialog_->input_lastfiles,
2216 N_("Lastfiles"), string(), dir,
2217 make_pair(string(), string()));
2218 } else if (ob == dialog_->button_backup_path_browse) {
2219 parent_.browse(dialog_->input_backup_path,
2220 N_("Backup path"), string(),
2221 make_pair(string(), string()),
2222 make_pair(string(), string()));
2223 } else if (ob == dialog_->button_serverpipe_browse) {
2224 parent_.browse(dialog_->input_serverpipe,
2225 N_("LyX Server pipes"), string(),
2226 make_pair(string(), string()),
2227 make_pair(string(), string()));
2234 void FormPreferences::Paths::update()
2236 fl_set_input(dialog_->input_default_path,
2237 lyxrc.document_path.c_str());
2238 fl_set_input(dialog_->input_template_path,
2239 lyxrc.template_path.c_str());
2242 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
2244 fl_set_button(dialog_->check_make_backups,
2246 fl_set_input(dialog_->input_backup_path, str.c_str());
2249 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
2251 fl_set_button(dialog_->check_use_temp_dir,
2253 fl_set_input(dialog_->input_temp_dir, str.c_str());
2256 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
2258 fl_set_button(dialog_->check_last_files,
2259 lyxrc.check_lastfiles);
2260 fl_set_input(dialog_->input_lastfiles, str.c_str());
2261 fl_set_counter_value(dialog_->counter_lastfiles,
2262 lyxrc.num_lastfiles);
2264 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2266 // Activate/Deactivate the input fields dependent on the state of the
2272 FormPreferences::Printer::Printer(FormPreferences & p)
2277 FD_form_printer const * FormPreferences::Printer::dialog()
2279 return dialog_.get();
2283 void FormPreferences::Printer::apply() const
2285 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2286 lyxrc.print_command = fl_get_input(dialog_->input_command);
2287 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2288 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2289 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2290 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2291 lyxrc.print_file_extension =
2292 fl_get_input(dialog_->input_file_extension);
2293 lyxrc.print_spool_command =
2294 fl_get_input(dialog_->input_spool_command);
2295 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2296 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2297 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2298 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2299 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2300 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2301 lyxrc.print_extra_options =
2302 fl_get_input(dialog_->input_extra_options);
2303 lyxrc.print_spool_printerprefix =
2304 fl_get_input(dialog_->input_spool_prefix);
2305 lyxrc.print_paper_dimension_flag =
2306 fl_get_input(dialog_->input_paper_size);
2307 lyxrc.printer = fl_get_input(dialog_->input_name);
2312 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2316 if (ob == dialog_->input_command)
2317 str = lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2318 else if (ob == dialog_->check_adapt_output)
2319 str = lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2320 else if (ob == dialog_->input_to_printer)
2321 str = lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2322 else if (ob == dialog_->input_to_file)
2323 str = lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2324 else if (ob == dialog_->input_file_extension)
2325 str = lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2326 else if (ob == dialog_->input_extra_options)
2327 str = lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2328 else if (ob == dialog_->input_spool_command)
2329 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2330 else if (ob == dialog_->input_spool_prefix)
2331 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2332 else if (ob == dialog_->input_name)
2333 str = lyxrc.getDescription(LyXRC::RC_PRINTER);
2334 else if (ob == dialog_->input_even_pages)
2335 str = lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2336 else if (ob == dialog_->input_odd_pages)
2337 str = lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2338 else if (ob == dialog_->input_page_range)
2339 str = lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2340 else if (ob == dialog_->input_reverse)
2341 str = lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2342 else if (ob == dialog_->input_landscape)
2343 str = lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2344 else if (ob == dialog_->input_copies)
2345 str = lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2346 else if (ob == dialog_->input_collated)
2347 str = lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2348 else if (ob == dialog_->input_paper_type)
2349 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2350 else if (ob == dialog_->input_paper_size)
2351 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2357 void FormPreferences::Printer::build()
2359 dialog_.reset(parent_.build_printer());
2361 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2362 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2363 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2364 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2365 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2366 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2367 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2368 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2369 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2370 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2371 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2372 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2373 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2374 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2375 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2376 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2377 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2379 // set up the feedback mechanism
2380 setPreHandler(dialog_->input_command);
2381 setPreHandler(dialog_->input_page_range);
2382 setPreHandler(dialog_->input_copies);
2383 setPreHandler(dialog_->input_reverse);
2384 setPreHandler(dialog_->input_to_printer);
2385 setPreHandler(dialog_->input_file_extension);
2386 setPreHandler(dialog_->input_spool_command);
2387 setPreHandler(dialog_->input_paper_type);
2388 setPreHandler(dialog_->input_even_pages);
2389 setPreHandler(dialog_->input_odd_pages);
2390 setPreHandler(dialog_->input_collated);
2391 setPreHandler(dialog_->input_landscape);
2392 setPreHandler(dialog_->input_to_file);
2393 setPreHandler(dialog_->input_extra_options);
2394 setPreHandler(dialog_->input_spool_prefix);
2395 setPreHandler(dialog_->input_paper_size);
2396 setPreHandler(dialog_->input_name);
2397 setPreHandler(dialog_->check_adapt_output);
2401 void FormPreferences::Printer::update()
2403 fl_set_button(dialog_->check_adapt_output,
2404 lyxrc.print_adapt_output);
2405 fl_set_input(dialog_->input_command,
2406 lyxrc.print_command.c_str());
2407 fl_set_input(dialog_->input_page_range,
2408 lyxrc.print_pagerange_flag.c_str());
2409 fl_set_input(dialog_->input_copies,
2410 lyxrc.print_copies_flag.c_str());
2411 fl_set_input(dialog_->input_reverse,
2412 lyxrc.print_reverse_flag.c_str());
2413 fl_set_input(dialog_->input_to_printer,
2414 lyxrc.print_to_printer.c_str());
2415 fl_set_input(dialog_->input_file_extension,
2416 lyxrc.print_file_extension.c_str());
2417 fl_set_input(dialog_->input_spool_command,
2418 lyxrc.print_spool_command.c_str());
2419 fl_set_input(dialog_->input_paper_type,
2420 lyxrc.print_paper_flag.c_str());
2421 fl_set_input(dialog_->input_even_pages,
2422 lyxrc.print_evenpage_flag.c_str());
2423 fl_set_input(dialog_->input_odd_pages,
2424 lyxrc.print_oddpage_flag.c_str());
2425 fl_set_input(dialog_->input_collated,
2426 lyxrc.print_collcopies_flag.c_str());
2427 fl_set_input(dialog_->input_landscape,
2428 lyxrc.print_landscape_flag.c_str());
2429 fl_set_input(dialog_->input_to_file,
2430 lyxrc.print_to_file.c_str());
2431 fl_set_input(dialog_->input_extra_options,
2432 lyxrc.print_extra_options.c_str());
2433 fl_set_input(dialog_->input_spool_prefix,
2434 lyxrc.print_spool_printerprefix.c_str());
2435 fl_set_input(dialog_->input_paper_size,
2436 lyxrc.print_paper_dimension_flag.c_str());
2437 fl_set_input(dialog_->input_name,
2438 lyxrc.printer.c_str());
2442 FormPreferences::ScreenFonts::ScreenFonts( FormPreferences & p )
2447 FD_form_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2449 return dialog_.get();
2453 void FormPreferences::ScreenFonts::apply() const
2455 bool changed = false;
2457 string str = fl_get_input(dialog_->input_roman);
2458 if (lyxrc.roman_font_name != str) {
2460 lyxrc.roman_font_name = str;
2463 str = fl_get_input(dialog_->input_sans);
2464 if (lyxrc.sans_font_name != str) {
2466 lyxrc.sans_font_name = str;
2469 str = fl_get_input(dialog_->input_typewriter);
2470 if (lyxrc.typewriter_font_name != str) {
2472 lyxrc.typewriter_font_name = str;
2475 str = fl_get_input(dialog_->input_screen_encoding);
2476 if (lyxrc.font_norm != str) {
2478 lyxrc.font_norm = str;
2481 bool button = fl_get_button(dialog_->check_scalable);
2482 if (lyxrc.use_scalable_fonts != button) {
2484 lyxrc.use_scalable_fonts = button;
2487 unsigned int ivalue = static_cast<unsigned int>
2488 (fl_get_counter_value(dialog_->counter_zoom));
2489 if (lyxrc.zoom != ivalue) {
2491 lyxrc.zoom = ivalue;
2494 ivalue = static_cast<unsigned int>
2495 (fl_get_counter_value(dialog_->counter_dpi));
2496 if (lyxrc.dpi != ivalue) {
2501 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2502 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2504 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2507 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2508 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2510 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2513 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2514 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2516 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2519 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2520 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2522 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2525 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2526 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2528 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2531 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2532 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2534 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2537 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2538 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2540 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2543 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2544 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2546 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2549 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2550 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2552 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2555 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2556 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2558 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2562 // Now update the buffers
2563 // Can anything below here affect the redraw process?
2564 parent_.lv_->getLyXFunc()->dispatch(LFUN_SCREEN_FONT_UPDATE);
2569 void FormPreferences::ScreenFonts::build()
2571 dialog_.reset(parent_.build_screen_fonts());
2573 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2574 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2576 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2577 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2578 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2579 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2580 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2581 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2582 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2583 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2584 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2585 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2586 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2587 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2588 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2589 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2590 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2591 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2593 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2594 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2595 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2596 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2597 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2598 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2599 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2600 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2601 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2602 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2604 // set up the feedback mechanism
2605 setPreHandler(dialog_->input_roman);
2606 setPreHandler(dialog_->input_sans);
2607 setPreHandler(dialog_->input_typewriter);
2608 setPreHandler(dialog_->counter_zoom);
2609 setPreHandler(dialog_->counter_dpi);
2610 setPreHandler(dialog_->check_scalable);
2611 setPreHandler(dialog_->input_screen_encoding);
2612 setPreHandler(dialog_->input_tiny);
2613 setPreHandler(dialog_->input_script);
2614 setPreHandler(dialog_->input_footnote);
2615 setPreHandler(dialog_->input_small);
2616 setPreHandler(dialog_->input_large);
2617 setPreHandler(dialog_->input_larger);
2618 setPreHandler(dialog_->input_largest);
2619 setPreHandler(dialog_->input_normal);
2620 setPreHandler(dialog_->input_huge);
2621 setPreHandler(dialog_->input_huger);
2626 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2630 if (ob == dialog_->input_roman)
2631 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2632 else if (ob == dialog_->input_sans)
2633 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2634 else if (ob == dialog_->input_typewriter)
2635 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2636 else if (ob == dialog_->check_scalable)
2637 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2638 else if (ob == dialog_->input_screen_encoding)
2639 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2640 else if (ob == dialog_->counter_zoom)
2641 str = lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2642 else if (ob == dialog_->counter_dpi)
2643 str = lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2644 else if (ob == dialog_->input_tiny
2645 || ob == dialog_->input_script
2646 || ob == dialog_->input_footnote
2647 || ob == dialog_->input_small
2648 || ob == dialog_->input_large
2649 || ob == dialog_->input_larger
2650 || ob == dialog_->input_larger
2651 || ob == dialog_->input_largest
2652 || ob == dialog_->input_normal
2653 || ob == dialog_->input_huge
2654 || ob == dialog_->input_huger)
2655 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2661 bool FormPreferences::ScreenFonts::input()
2663 bool activate = true;
2666 // Make sure that all fonts all have positive entries
2667 // Also note that an empty entry is returned as 0.0 by strToDbl
2668 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2669 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2670 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2671 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2672 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2673 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2674 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2675 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2676 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2677 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2679 str = N_("Fonts must be positive!");
2681 // Fontsizes -- tiny < script < footnote etc.
2682 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2683 strToDbl(fl_get_input(dialog_->input_script)) ||
2684 strToDbl(fl_get_input(dialog_->input_script)) >
2685 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2686 strToDbl(fl_get_input(dialog_->input_footnote)) >
2687 strToDbl(fl_get_input(dialog_->input_small)) ||
2688 strToDbl(fl_get_input(dialog_->input_small)) >
2689 strToDbl(fl_get_input(dialog_->input_normal)) ||
2690 strToDbl(fl_get_input(dialog_->input_normal)) >
2691 strToDbl(fl_get_input(dialog_->input_large)) ||
2692 strToDbl(fl_get_input(dialog_->input_large)) >
2693 strToDbl(fl_get_input(dialog_->input_larger)) ||
2694 strToDbl(fl_get_input(dialog_->input_larger)) >
2695 strToDbl(fl_get_input(dialog_->input_largest)) ||
2696 strToDbl(fl_get_input(dialog_->input_largest)) >
2697 strToDbl(fl_get_input(dialog_->input_huge)) ||
2698 strToDbl(fl_get_input(dialog_->input_huge)) >
2699 strToDbl(fl_get_input(dialog_->input_huger))) {
2702 str = N_("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2706 parent_.printWarning(str);
2712 void FormPreferences::ScreenFonts::update()
2714 fl_set_input(dialog_->input_roman,
2715 lyxrc.roman_font_name.c_str());
2716 fl_set_input(dialog_->input_sans,
2717 lyxrc.sans_font_name.c_str());
2718 fl_set_input(dialog_->input_typewriter,
2719 lyxrc.typewriter_font_name.c_str());
2720 fl_set_input(dialog_->input_screen_encoding,
2721 lyxrc.font_norm.c_str());
2722 fl_set_button(dialog_->check_scalable,
2723 lyxrc.use_scalable_fonts);
2724 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2725 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2726 fl_set_input(dialog_->input_tiny,
2727 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2728 fl_set_input(dialog_->input_script,
2729 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2730 fl_set_input(dialog_->input_footnote,
2731 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2732 fl_set_input(dialog_->input_small,
2733 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2734 fl_set_input(dialog_->input_normal,
2735 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2736 fl_set_input(dialog_->input_large,
2737 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2738 fl_set_input(dialog_->input_larger,
2739 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2740 fl_set_input(dialog_->input_largest,
2741 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2742 fl_set_input(dialog_->input_huge,
2743 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2744 fl_set_input(dialog_->input_huger,
2745 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2750 FormPreferences::SpellOptions::SpellOptions( FormPreferences & p )
2755 FD_form_spelloptions const * FormPreferences::SpellOptions::dialog()
2757 return dialog_.get();
2761 void FormPreferences::SpellOptions::apply()
2764 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2765 choice = strip(frontStrip(choice));
2767 lyxrc.isp_command = choice;
2770 // If spell checker == "none", all other input set to off.
2771 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2772 lyxrc.isp_use_alt_lang = false;
2773 lyxrc.isp_alt_lang.erase();
2775 lyxrc.isp_use_esc_chars = false;
2776 lyxrc.isp_esc_chars.erase();
2778 lyxrc.isp_use_pers_dict = false;
2779 lyxrc.isp_pers_dict.erase();
2781 lyxrc.isp_accept_compound = false;
2782 lyxrc.isp_use_input_encoding = false;
2785 int button = fl_get_button(dialog_->check_alt_lang);
2786 choice = fl_get_input(dialog_->input_alt_lang);
2787 if (button && choice.empty()) button = 0;
2788 if (!button) choice.erase();
2790 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2791 lyxrc.isp_alt_lang = choice;
2793 button = fl_get_button(dialog_->check_escape_chars);
2794 choice = fl_get_input(dialog_->input_escape_chars);
2795 if (button && choice.empty()) button = 0;
2796 if (!button) choice.erase();
2798 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2799 lyxrc.isp_esc_chars = choice;
2801 button = fl_get_button(dialog_->check_personal_dict);
2802 choice = fl_get_input(dialog_->input_personal_dict);
2803 if (button && choice.empty()) button = 0;
2804 if (!button) choice.erase();
2806 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2807 lyxrc.isp_pers_dict = choice;
2809 button = fl_get_button(dialog_->check_compound_words);
2810 lyxrc.isp_accept_compound = static_cast<bool>(button);
2812 button = fl_get_button(dialog_->check_input_enc);
2813 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2824 void FormPreferences::SpellOptions::build()
2826 dialog_.reset(parent_.build_spelloptions());
2828 fl_addto_choice(dialog_->choice_spell_command,
2830 _(" none | ispell | aspell "));
2832 _(" ispell | aspell "));
2834 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2835 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2836 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2838 // set up the feedback mechanism
2839 setPreHandler(dialog_->choice_spell_command);
2840 setPreHandler(dialog_->check_alt_lang);
2841 setPreHandler(dialog_->input_alt_lang);
2842 setPreHandler(dialog_->check_escape_chars);
2843 setPreHandler(dialog_->input_escape_chars);
2844 setPreHandler(dialog_->check_personal_dict);
2845 setPreHandler(dialog_->input_personal_dict);
2846 setPreHandler(dialog_->button_personal_dict);
2847 setPreHandler(dialog_->check_compound_words);
2848 setPreHandler(dialog_->check_input_enc);
2853 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2857 if (ob == dialog_->choice_spell_command)
2858 str = lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2859 else if (ob == dialog_->check_alt_lang)
2860 str = lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2861 else if (ob == dialog_->input_alt_lang)
2862 str = lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2863 else if (ob == dialog_->check_escape_chars)
2864 str = lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2865 else if (ob == dialog_->input_escape_chars)
2866 str = lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2867 else if (ob == dialog_->check_personal_dict)
2868 str = lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2869 else if (ob == dialog_->input_personal_dict)
2870 str = lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2871 else if (ob == dialog_->check_compound_words)
2872 str = lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2873 else if (ob == dialog_->check_input_enc)
2874 str = lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2880 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2882 // !ob if function is called from updateSpellOptions() to de/activate
2884 // otherwise the function is called by an xforms CB via input().
2887 // If spell checker == "none", disable all input.
2888 if (!ob || ob == dialog_->choice_spell_command) {
2889 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2890 fl_deactivate_object(dialog_->check_alt_lang);
2891 fl_deactivate_object(dialog_->input_alt_lang);
2892 fl_deactivate_object(dialog_->check_escape_chars);
2893 fl_deactivate_object(dialog_->input_escape_chars);
2894 fl_deactivate_object(dialog_->check_personal_dict);
2895 fl_deactivate_object(dialog_->input_personal_dict);
2896 fl_deactivate_object(dialog_->check_compound_words);
2897 fl_deactivate_object(dialog_->check_input_enc);
2900 fl_activate_object(dialog_->check_alt_lang);
2901 fl_activate_object(dialog_->check_escape_chars);
2902 fl_activate_object(dialog_->check_personal_dict);
2903 fl_activate_object(dialog_->check_compound_words);
2904 fl_activate_object(dialog_->check_input_enc);
2909 if (!ob || ob == dialog_->check_alt_lang) {
2910 bool const enable = fl_get_button(dialog_->check_alt_lang);
2911 setEnabled(dialog_->input_alt_lang, enable);
2914 if (!ob || ob == dialog_->check_escape_chars) {
2915 bool const enable = fl_get_button(dialog_->check_escape_chars);
2916 setEnabled(dialog_->input_escape_chars, enable);
2919 if (!ob || ob == dialog_->check_personal_dict) {
2920 bool const enable = fl_get_button(dialog_->check_personal_dict);
2921 setEnabled(dialog_->input_personal_dict, enable);
2924 if (ob == dialog_->button_personal_dict) {
2925 parent_.browse(dialog_->input_personal_dict,
2926 N_("Personal dictionary"), "*.ispell",
2927 make_pair(string(), string()),
2928 make_pair(string(), string()));
2931 return true; // All input is valid!
2935 void FormPreferences::SpellOptions::update()
2939 if (lyxrc.isp_command == "none")
2941 else if (lyxrc.isp_command == "ispell")
2943 else if (lyxrc.isp_command == "aspell")
2946 if (lyxrc.isp_command == "ispell")
2948 else if (lyxrc.isp_command == "aspell")
2951 fl_set_choice(dialog_->choice_spell_command, choice);
2954 if (lyxrc.isp_use_alt_lang) str = lyxrc.isp_alt_lang;
2956 fl_set_button(dialog_->check_alt_lang,
2957 lyxrc.isp_use_alt_lang);
2958 fl_set_input(dialog_->input_alt_lang, str.c_str());
2961 if (lyxrc.isp_use_esc_chars) str = lyxrc.isp_esc_chars;
2963 fl_set_button(dialog_->check_escape_chars,
2964 lyxrc.isp_use_esc_chars);
2965 fl_set_input(dialog_->input_escape_chars, str.c_str());
2968 if (lyxrc.isp_use_pers_dict) str = lyxrc.isp_pers_dict;
2970 fl_set_button(dialog_->check_personal_dict,
2971 lyxrc.isp_use_pers_dict);
2972 fl_set_input(dialog_->input_personal_dict, str.c_str());
2974 fl_set_button(dialog_->check_compound_words,
2975 lyxrc.isp_accept_compound);
2976 fl_set_button(dialog_->check_input_enc,
2977 lyxrc.isp_use_input_encoding);
2979 // Activate/Deactivate the input fields dependent on the state of the
2985 void FormPreferences::printWarning(string const & warning)
2987 warningPosted = true;
2989 string str = _("WARNING!") + string(" ") + warning;
2990 str = formatted(str, dialog_->text_warning->w-10, FL_SMALL_SIZE);
2992 fl_set_object_label(dialog_->text_warning, str.c_str());
2993 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2997 void FormPreferences::browse(FL_OBJECT * inpt,
2998 string const & title,
2999 string const & pattern,
3000 pair<string,string> const & dir1,
3001 pair<string,string> const & dir2)
3003 // Get the filename from the dialog
3004 string const filename = fl_get_input(inpt);
3006 // Show the file browser dialog
3007 string const new_filename =
3008 browseFile(lv_, filename, title, pattern, dir1, dir2);
3010 // Save the filename to the dialog
3011 if (new_filename != filename && !new_filename.empty()) {
3012 fl_set_input(inpt, new_filename.c_str());
3018 // C function wrapper, required by xforms.
3019 extern "C" int C_FormPreferencesFeedbackCB(FL_OBJECT * ob, int event,
3020 FL_Coord mx, FL_Coord my,
3021 int key, void * xev)
3023 return FormPreferences::FeedbackCB(ob, event, mx, my, key, xev);
3026 int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event,
3027 FL_Coord, FL_Coord, int, void *)
3029 // Note that the return value is important in the pre-emptive handler.
3030 // Don't return anything other than 0.
3033 // Don't Assert this one, as it can happen quite reasonably when things
3034 // are being deleted in the d-tor.
3036 if (!ob->form) return 0;
3038 FormPreferences * pre =
3039 static_cast<FormPreferences*>(ob->form->u_vdata);
3040 pre->Feedback(ob, event);
3045 // preemptive handler for feedback messages
3046 void FormPreferences::Feedback(FL_OBJECT * ob, int event)
3052 warningPosted = false;
3058 fl_set_object_label(dialog_->text_warning, "");
3067 void FormPreferences::setPreHandler(FL_OBJECT * ob)
3070 fl_set_object_prehandler(ob, C_FormPreferencesFeedbackCB);