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 "ButtonController.tmpl"
32 #include "input_validators.h"
41 #include "input_validators.h"
42 #include "xforms_helpers.h"
43 #include "helper_funcs.h"
44 #include "converter.h"
46 #include "support/lyxfunctional.h"
47 #include "support/lyxmanip.h"
48 #include "support/filetools.h"
49 #include "support/LAssert.h"
51 #include "graphics/GraphicsCache.h"
64 extern string system_lyxdir;
65 extern string user_lyxdir;
66 extern Languages languages;
70 // These should probably go inside the class definition...
71 Formats local_formats;
72 Converters local_converters;
77 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
78 : FormBaseBI(lv, d, _("Preferences"), false),
80 colors_(*this), converters_(*this), inputs_misc_(*this),
81 formats_(*this), interface_(*this), language_(*this),
82 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
83 printer_(*this), screen_fonts_(*this), spelloptions_(*this)
85 // let the dialog be shown
86 // This is a permanent connection so we won't bother
87 // storing a copy because we won't be disconnecting.
88 d->showPreferences.connect(slot(this, &FormPreferences::show));
89 d->showSpellcheckerPreferences.connect(slot(this, &FormPreferences::showSpellPref));
93 void FormPreferences::redraw()
95 if (!(form() && form()->visible))
97 fl_redraw_form(form());
99 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
100 if (!(form2 && form2->visible))
102 fl_redraw_form(form2);
105 if (form2 == converters_tab_->form)
106 form3 = fl_get_active_folder(converters_tab_->tabfolder_inner);
108 else if (form2 == look_n_feel_tab_->form)
109 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_inner);
111 else if (form2 == inputs_tab_->form)
112 form3 = fl_get_active_folder(inputs_tab_->tabfolder_inner);
114 else if (form2 == outputs_tab_->form)
115 form3 = fl_get_active_folder(outputs_tab_->tabfolder_inner);
117 else if (form2 == lang_opts_tab_->form)
118 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_inner);
120 if (form3 && form3->visible)
121 fl_redraw_form(form3);
125 FL_FORM * FormPreferences::form() const
127 if (dialog_.get()) return dialog_->form;
132 void FormPreferences::showSpellPref()
135 fl_set_folder(dialog_->tabfolder_prefs, lang_opts_tab_->form);
136 fl_set_folder(lang_opts_tab_->tabfolder_inner, spelloptions_.dialog()->form);
140 void FormPreferences::ok()
142 FormBaseDeprecated::ok();
144 if (colors_.modifiedXformsPrefs) {
145 string const filename =
146 AddName(user_lyxdir, "preferences.xform");
147 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
150 lv_->getLyXFunc()->dispatch(LFUN_SAVEPREFERENCES);
154 void FormPreferences::hide()
156 // We need to hide the active tabfolder otherwise we get a
157 // BadDrawable error from X window and LyX crashes without saving.
158 FL_FORM * inner_form = fl_get_active_folder(dialog_->tabfolder_prefs);
160 && inner_form->visible) {
161 fl_hide_form(inner_form);
163 FormBaseDeprecated::hide();
167 void FormPreferences::build()
169 dialog_.reset(build_preferences());
171 // Manage the restore, save, apply and cancel/close buttons
172 bc().setOK(dialog_->button_ok);
173 bc().setApply(dialog_->button_apply);
174 bc().setCancel(dialog_->button_cancel);
175 bc().setRestore(dialog_->button_restore);
177 // build the tab folders
178 converters_tab_.reset(build_inner_tab());
179 look_n_feel_tab_.reset(build_inner_tab());
180 inputs_tab_.reset(build_inner_tab());
181 outputs_tab_.reset(build_inner_tab());
182 lang_opts_tab_.reset(build_inner_tab());
184 // build actual tabfolder contents
185 // these will become nested tabfolders
189 inputs_misc_.build();
193 outputs_misc_.build();
196 screen_fonts_.build();
197 spelloptions_.build();
199 // Now add them to the tabfolder
200 fl_addto_tabfolder(dialog_->tabfolder_prefs,
202 look_n_feel_tab_->form);
203 fl_addto_tabfolder(dialog_->tabfolder_prefs,
205 lang_opts_tab_->form);
206 fl_addto_tabfolder(dialog_->tabfolder_prefs,
208 converters_tab_->form);
209 fl_addto_tabfolder(dialog_->tabfolder_prefs,
212 fl_addto_tabfolder(dialog_->tabfolder_prefs,
216 // now build the nested tabfolders
217 // Starting with look and feel
218 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
220 screen_fonts_.dialog()->form);
221 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
223 interface_.dialog()->form);
224 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
226 colors_.dialog()->form);
227 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_inner,
229 lnf_misc_.dialog()->form);
231 // then build converters
232 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
234 formats_.dialog()->form);
235 fl_addto_tabfolder(converters_tab_->tabfolder_inner,
237 converters_.dialog()->form);
240 // Paths should probably go in a few inner_tab called Files
241 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
243 paths_.dialog()->form);
244 fl_addto_tabfolder(inputs_tab_->tabfolder_inner,
246 inputs_misc_.dialog()->form);
248 // then building outputs
249 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
251 printer_.dialog()->form);
252 fl_addto_tabfolder(outputs_tab_->tabfolder_inner,
254 outputs_misc_.dialog()->form);
256 // then building usage
257 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
259 spelloptions_.dialog()->form);
260 fl_addto_tabfolder(lang_opts_tab_->tabfolder_inner,
262 language_.dialog()->form);
266 void FormPreferences::apply()
268 // set the new lyxrc entries
269 // many of these need to trigger other functions when the assignment
270 // is made. For example, screen zoom and font types. These could be
271 // handled either by signals/slots in lyxrc or just directly call the
272 // associated functions here.
273 // There are other problems with this scheme. We really should check
274 // what we copy to make sure that it really is necessary to do things
275 // like update the screen fonts because that flushes the textcache
276 // and other stuff which may cost us a lot on slower/high-load
280 formats_.apply(); // Must be before converters_.apply()
282 inputs_misc_.apply();
286 outputs_misc_.apply();
289 screen_fonts_.apply();
290 spelloptions_.apply();
294 void FormPreferences::feedback(FL_OBJECT * ob)
300 if (ob->form->fdui == colors_.dialog()) {
301 str = colors_.feedback(ob);
302 } else if (ob->form->fdui == converters_.dialog()) {
303 str = converters_.feedback(ob);
304 } else if (ob->form->fdui == formats_.dialog()) {
305 str = formats_.feedback(ob);
306 } else if (ob->form->fdui == inputs_misc_.dialog()) {
307 str = inputs_misc_.feedback(ob);
308 } else if (ob->form->fdui == interface_.dialog()) {
309 str = interface_.feedback(ob);
310 } else if (ob->form->fdui == language_.dialog()) {
311 str = language_.feedback(ob);
312 } else if (ob->form->fdui == lnf_misc_.dialog()) {
313 str = lnf_misc_.feedback(ob);
314 } else if (ob->form->fdui == outputs_misc_.dialog()) {
315 str = outputs_misc_.feedback(ob);
316 } else if (ob->form->fdui == paths_.dialog()) {
317 str = paths_.feedback(ob);
318 } else if (ob->form->fdui == printer_.dialog()) {
319 str = printer_.feedback(ob);
320 } else if (ob->form->fdui == screen_fonts_.dialog()) {
321 str = screen_fonts_.feedback(ob);
322 } else if (ob->form->fdui == spelloptions_.dialog()) {
323 str = spelloptions_.feedback(ob);
326 str = formatted(_(str), dialog_->text_warning->w-10, FL_SMALL_SIZE);
328 fl_set_object_label(dialog_->text_warning, str.c_str());
329 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
333 bool FormPreferences::input(FL_OBJECT * ob, long)
337 // whatever checks you need to ensure the user hasn't entered
338 // some totally ridiculous value somewhere. Change activate to suit.
339 // comments before each test describe what is _valid_
341 if (ob->form->fdui == colors_.dialog()) {
344 } else if (ob->form->fdui == converters_.dialog())
345 return converters_.input(ob);
346 else if (ob->form->fdui == formats_.dialog())
347 return formats_.input(ob);
348 else if (ob->form->fdui == interface_.dialog())
349 return interface_.input(ob);
350 else if (ob->form->fdui == language_.dialog())
351 return language_.input(ob);
352 else if (ob->form->fdui == paths_.dialog())
353 return paths_.input(ob);
354 else if (ob->form->fdui == screen_fonts_.dialog())
355 return screen_fonts_.input();
356 else if (ob->form->fdui == spelloptions_.dialog())
357 return spelloptions_.input(ob);
363 void FormPreferences::update()
365 if (!dialog_.get()) return;
367 // read lyxrc entries
369 formats_.update(); // Must be before converters_.update()
370 converters_.update();
371 inputs_misc_.update();
375 outputs_misc_.update();
378 screen_fonts_.update();
379 spelloptions_.update();
383 FormPreferences::Colors::Colors(FormPreferences & p)
384 : modifiedXformsPrefs(false), parent_(p)
388 FD_form_colors const * FormPreferences::Colors::dialog()
390 return dialog_.get();
394 void FormPreferences::Colors::apply()
396 bool modifiedText = false;
397 bool modifiedBackground = false;
399 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
400 cit != xformsColorDB.end(); ++cit) {
402 fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
403 if (col != cit->color()) {
404 modifiedXformsPrefs = true;
405 if (cit->colorID == FL_BLACK)
407 if (cit->colorID == FL_COL1)
408 modifiedBackground = true;
412 if (modifiedXformsPrefs) {
413 for (vector<XformsColor>::const_iterator cit =
414 xformsColorDB.begin();
415 cit != xformsColorDB.end(); ++cit) {
416 fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
418 if (modifiedText && cit->colorID == FL_BLACK) {
419 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
422 if (modifiedBackground && cit->colorID == FL_COL1) {
423 AdjustVal(FL_MCOL, FL_COL1, 0.1);
424 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
425 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
427 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
428 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
431 if (cit->colorID == GUI_COLOR_CURSOR) {
432 fl_mapcolor(GUI_COLOR_CURSOR,
433 cit->r, cit->g, cit->b);
434 fl_set_cursor_color(FL_DEFAULT_CURSOR,
435 GUI_COLOR_CURSOR, FL_WHITE);
438 Dialogs::redrawGUI();
441 // Now do the same for the LyX LColors...
442 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
443 cit != lyxColorDB.end(); ++cit) {
444 LColor::color lc = lcolor.getFromGUIName(cit->getname());
445 if (lc == LColor::inherit) continue;
447 // Create a valid X11 name of the form "#rrggbb"
448 string const hexname = X11hexname(cit->color());
450 if (lcolor.getX11Name(lc) != hexname) {
452 << "FormPreferences::Colors::apply: "
453 << "resetting LColor " << lcolor.getGUIName(lc)
454 << " from \"" << lcolor.getX11Name(lc)
455 << "\" to \"" << hexname << "\"."
458 string const s = lcolor.getLyXName(lc) + string(" ") +
460 parent_.lv_->getLyXFunc()->dispatch(LFUN_SET_COLOR, s);
466 void FormPreferences::Colors::build()
468 dialog_.reset(parent_.build_colors());
470 fl_set_object_color(dialog_->button_color,
471 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
473 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
474 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
475 fl_set_dial_step(dialog_->dial_hue, 1.0);
476 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
478 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
479 fl_set_slider_step(dialog_->slider_saturation, 0.01);
480 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
482 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
483 fl_set_slider_step(dialog_->slider_value, 0.01);
484 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
486 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
487 fl_set_slider_step(dialog_->slider_red, 1.0);
488 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
490 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
491 fl_set_slider_step(dialog_->slider_green, 1.0);
492 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
494 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
495 fl_set_slider_step(dialog_->slider_blue, 1.0);
496 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
498 // set up the feedback mechanism
499 setPreHandler(dialog_->browser_lyx_objs);
500 setPreHandler(dialog_->button_color);
501 setPreHandler(dialog_->button_modify);
502 setPreHandler(dialog_->dial_hue);
503 setPreHandler(dialog_->slider_saturation);
504 setPreHandler(dialog_->slider_value);
505 setPreHandler(dialog_->slider_red);
506 setPreHandler(dialog_->slider_green);
507 setPreHandler(dialog_->slider_blue);
508 setPreHandler(dialog_->radio_rgb);
509 setPreHandler(dialog_->radio_hsv);
513 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
517 if (ob == dialog_->browser_lyx_objs) {
518 str = N_("LyX objects that can be assigned a color.");
520 } else if (ob == dialog_->button_modify) {
521 str = N_("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
523 } else if (ob == dialog_->dial_hue ||
524 ob == dialog_->slider_saturation ||
525 ob == dialog_->slider_value ||
526 ob == dialog_->slider_red ||
527 ob == dialog_->slider_green ||
528 ob == dialog_->slider_blue) {
529 str = N_("Find a new color.");
531 } else if (ob == dialog_->radio_rgb ||
532 ob == dialog_->radio_hsv) {
533 str = N_("Toggle between RGB and HSV color spaces.");
540 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
542 if (ob == dialog_->browser_lyx_objs) {
545 } else if (ob == dialog_->dial_hue ||
546 ob == dialog_->slider_saturation ||
547 ob == dialog_->slider_value) {
550 } else if (ob == dialog_->slider_red ||
551 ob == dialog_->slider_green ||
552 ob == dialog_->slider_blue) {
555 } else if (ob == dialog_->radio_rgb ||
556 ob == dialog_->radio_hsv) {
559 } else if (ob == dialog_->button_modify) {
565 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
569 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
573 hsv.v = min(1.0, max(0.0, hsv.v));
576 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
580 void FormPreferences::Colors::InputBrowserLyX() const
582 vector<NamedColor>::size_type const selLyX =
583 fl_get_browser(dialog_->browser_lyx_objs);
584 if (selLyX < 1) return;
586 // Is the choice an Xforms color...
589 if (selLyX - 1 < xformsColorDB.size()) {
590 vector<XformsColor>::size_type const i = selLyX - 1;
591 col = xformsColorDB[i].color();
593 // or a LyX Logical color?
595 vector<NamedColor>::size_type const i = selLyX - 1 -
596 xformsColorDB.size();
597 col = lyxColorDB[i].color();
600 fl_freeze_form(dialog_->form);
602 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
603 fl_redraw_object(dialog_->button_color);
605 // Display either RGB or HSV but not both!
608 // Deactivate the modify button to begin with...
609 setEnabled(dialog_->button_modify, false);
611 fl_unfreeze_form(dialog_->form);
615 void FormPreferences::Colors::InputHSV()
617 double const hue = fl_get_dial_value(dialog_->dial_hue);
618 double const sat = fl_get_slider_value(dialog_->slider_saturation);
619 double const val = fl_get_slider_value(dialog_->slider_value);
621 int const h = int(hue);
622 int const s = int(100.0 * sat);
623 int const v = int(100.0 * val);
625 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
627 fl_set_object_label(dialog_->text_color_values, label.c_str());
629 RGBColor col = HSVColor(hue, sat, val);
631 fl_freeze_form(dialog_->form);
633 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
634 fl_redraw_object(dialog_->button_color);
636 col = HSVColor(hue, 1.0, 1.0);
637 col.r = max(col.r, 0);
638 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
639 fl_redraw_object(dialog_->dial_hue);
641 // Ascertain whether to activate the Modify button.
642 vector<NamedColor>::size_type const selLyX =
643 fl_get_browser(dialog_->browser_lyx_objs);
645 fl_unfreeze_form(dialog_->form);
646 if (selLyX < 1) return;
648 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
651 // Is the choice an Xforms color...
652 if (selLyX - 1 < xformsColorDB.size()) {
653 vector<XformsColor>::size_type const i = selLyX - 1;
654 modify = (xformsColorDB[i].color() != col);
656 // or a LyX Logical color?
658 vector<NamedColor>::size_type const i = selLyX - 1 -
659 xformsColorDB.size();
660 modify = (lyxColorDB[i].color() != col);
663 setEnabled(dialog_->button_modify, modify);
667 void FormPreferences::Colors::InputRGB()
669 int const red = int(fl_get_slider_value(dialog_->slider_red));
670 int const green = int(fl_get_slider_value(dialog_->slider_green));
671 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
673 string const label = tostr(red) + string(", ") + tostr(green) +
674 string(", ") + tostr(blue);
675 fl_set_object_label(dialog_->text_color_values, label.c_str());
677 fl_freeze_form(dialog_->form);
679 RGBColor col = RGBColor(red, green, blue);
680 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
681 fl_redraw_object(dialog_->button_color);
683 // Ascertain whether to activate the Modify button.
684 vector<NamedColor>::size_type const selLyX =
685 fl_get_browser(dialog_->browser_lyx_objs);
687 fl_unfreeze_form(dialog_->form);
688 if (selLyX < 1) return;
692 // Is the choice an Xforms color...
693 if (selLyX - 1 < xformsColorDB.size()) {
694 vector<XformsColor>::size_type const i = selLyX - 1;
695 modify = (xformsColorDB[i].color() != col);
697 // or a LyX Logical color?
699 vector<NamedColor>::size_type const i = selLyX - 1 -
700 xformsColorDB.size();
701 modify = (lyxColorDB[i].color() != col);
704 setEnabled(dialog_->button_modify, modify);
708 void FormPreferences::Colors::LoadBrowserLyX()
710 if (!dialog_->browser_lyx_objs->visible) return;
712 // First, define the modifiable xforms colors
713 xformsColorDB.clear();
716 xcol.name = _("GUI background");
717 xcol.colorID = FL_COL1;
718 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
720 xformsColorDB.push_back(xcol);
722 xcol.name = _("GUI text");
723 xcol.colorID = FL_BLACK;
724 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
726 fl_mapcolor(GUI_COLOR_CURSOR, xcol.r, xcol.g, xcol.b);
727 fl_set_cursor_color(FL_DEFAULT_CURSOR, GUI_COLOR_CURSOR, FL_WHITE);
729 xformsColorDB.push_back(xcol);
731 xcol.name = _("GUI selection");
732 xcol.colorID = FL_YELLOW;
733 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
735 xformsColorDB.push_back(xcol);
737 xcol.name = _("GUI pointer");
738 xcol.colorID = GUI_COLOR_CURSOR;
739 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
741 xformsColorDB.push_back(xcol);
743 // Now create the the LyX LColors database
745 for (int i=0; i<LColor::ignore; ++i) {
746 LColor::color lc = static_cast<LColor::color>(i);
747 if (lc == LColor::none
748 || lc == LColor::black
749 || lc == LColor::white
751 || lc == LColor::green
752 || lc == LColor::blue
753 || lc == LColor::cyan
754 || lc == LColor::magenta
755 || lc == LColor::yellow
756 || lc == LColor::inherit
757 || lc == LColor::ignore) continue;
759 string const name = lcolor.getX11Name(lc);
760 Display * display = fl_get_display();;
761 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
764 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
766 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
767 << "LColor " << lcolor.getLyXName(lc)
768 << ": X can't find color \"" << name
769 << "\". Set to \"black\"!" << endl;
771 string const arg = lcolor.getLyXName(lc) + " black";
772 parent_.lv_->getLyXFunc()->
773 dispatch(LFUN_SET_COLOR, arg);
777 // X has found the color. Now find the "appropriate" X11 name
780 // Note that X stores the RGB values in the range 0 - 65535
781 // whilst we require them in the range 0 - 255.
783 col.r = xcol.red / 256;
784 col.g = xcol.green / 256;
785 col.b = xcol.blue / 256;
787 // Create a valid X11 name of the form "#rrggbb" and change the
788 // LColor X11name to this. Don't want to trigger a redraw,
789 // as we're just changing the name not the RGB values.
790 // Also reset the system_lcolor names, so that we don't output
791 // unnecessary changes.
792 string const hexname = X11hexname(col);
794 if (lcolor.getX11Name(lc) != hexname) {
795 lcolor.setColor(lc, hexname);
796 system_lcolor.setColor(lc, hexname);
799 // Finally, push the color onto the database
800 NamedColor ncol(lcolor.getGUIName(lc), col);
801 lyxColorDB.push_back(ncol);
804 // Now construct the browser
805 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
806 fl_freeze_form(dialog_->form);
807 fl_clear_browser(colbr);
808 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
809 cit != xformsColorDB.end(); ++cit) {
810 fl_addto_browser(colbr, cit->getname().c_str());
812 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
813 cit != lyxColorDB.end(); ++cit) {
814 fl_addto_browser(colbr, cit->getname().c_str());
817 // just to be safe...
818 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
819 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
820 fl_unfreeze_form(dialog_->form);
826 void FormPreferences::Colors::Modify()
828 vector<NamedColor>::size_type const selLyX =
829 fl_get_browser(dialog_->browser_lyx_objs);
830 if (selLyX < 1) return;
833 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
835 // Is the choice an Xforms color...
836 if (selLyX - 1 < xformsColorDB.size()) {
837 vector<XformsColor>::size_type const i = selLyX - 1;
838 xformsColorDB[i].r = col.r;
839 xformsColorDB[i].g = col.g;
840 xformsColorDB[i].b = col.b;
842 // or a LyX Logical color?
844 vector<NamedColor>::size_type const i = selLyX - 1 -
845 xformsColorDB.size();
846 lyxColorDB[i].r = col.r;
847 lyxColorDB[i].g = col.g;
848 lyxColorDB[i].b = col.b;
851 fl_freeze_form(dialog_->form);
852 setEnabled(dialog_->button_modify, false);
853 fl_unfreeze_form(dialog_->form);
857 void FormPreferences::Colors::SwitchColorSpace() const
859 bool const hsv = fl_get_button(dialog_->radio_hsv);
862 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
864 fl_freeze_form(dialog_->form);
867 fl_hide_object(dialog_->slider_red);
868 fl_hide_object(dialog_->slider_blue);
869 fl_hide_object(dialog_->slider_green);
870 fl_show_object(dialog_->dial_hue);
871 fl_show_object(dialog_->slider_saturation);
872 fl_show_object(dialog_->slider_value);
874 HSVColor hsv = HSVColor(col);
875 hsv.h = max(hsv.h, 0.0);
877 fl_set_dial_value(dialog_->dial_hue, hsv.h);
878 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
879 fl_set_slider_value(dialog_->slider_value, hsv.v);
881 col = HSVColor(hsv.h, 1.0, 1.0);
882 col.r = max(col.r,0);
883 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
884 fl_redraw_object(dialog_->dial_hue);
886 // Adjust the label a bit, but not the actual values.
887 // Means that toggling from one space to the other has no
888 // effect on the final color.
889 int const h = int(hsv.h);
890 int const s = int(100*hsv.s);
891 int const v = int(100*hsv.v);
892 string const label = tostr(h) + string(", ") + tostr(s) +
893 string(", ") + tostr(v);
894 fl_set_object_label(dialog_->text_color_values, label.c_str());
897 fl_show_object(dialog_->slider_red);
898 fl_show_object(dialog_->slider_blue);
899 fl_show_object(dialog_->slider_green);
900 fl_hide_object(dialog_->dial_hue);
901 fl_hide_object(dialog_->slider_saturation);
902 fl_hide_object(dialog_->slider_value);
904 fl_set_slider_value(dialog_->slider_red, col.r);
905 fl_set_slider_value(dialog_->slider_green, col.g);
906 fl_set_slider_value(dialog_->slider_blue, col.b);
908 // Adjust the label a bit. Same reasoning as above.
909 int const r = int(col.r);
910 int const g = int(col.g);
911 int const b = int(col.b);
912 string const label = tostr(r) + string(", ") + tostr(g) +
913 string(", ") + tostr(b);
914 fl_set_object_label(dialog_->text_color_values, label.c_str());
917 fl_unfreeze_form(dialog_->form);
920 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
924 ostr << "#" << std::setbase(16) << setfill('0')
929 return ostr.str().c_str();
933 FormPreferences::Converters::Converters(FormPreferences & p)
938 FD_form_converters const * FormPreferences::Converters::dialog()
940 return dialog_.get();
944 void FormPreferences::Converters::apply() const
946 converters = local_converters;
947 converters.update(formats);
948 converters.buildGraph();
952 void FormPreferences::Converters::build()
954 dialog_.reset(parent_.build_converters());
956 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
957 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
959 // set up the feedback mechanism
960 setPreHandler(dialog_->browser_all);
961 setPreHandler(dialog_->button_delete);
962 setPreHandler(dialog_->button_add);
963 setPreHandler(dialog_->input_converter);
964 setPreHandler(dialog_->choice_from);
965 setPreHandler(dialog_->choice_to);
966 setPreHandler(dialog_->input_flags);
971 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
975 if (ob == dialog_->browser_all) {
976 str = N_("All the currently defined converters known to LyX.");
977 } else if (ob == dialog_->choice_from) {
978 str = N_("Convert \"from\" this format");
979 } else if (ob == dialog_->choice_to) {
980 str = N_("Convert \"to\" this format");
981 } else if (ob == dialog_->input_converter) {
982 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.");
983 } else if (ob == dialog_->input_flags) {
984 str = N_("Flags that control the converter behavior");
985 } else if (ob == dialog_->button_delete) {
986 str = N_("Remove the current converter from the list of available converters. Note: you must then \"Apply\" the change.");
987 } else if (ob == dialog_->button_add) {
988 if (string(ob->label) == _("Add"))
989 str = N_("Add the current converter to the list of available converters. Note: you must then \"Apply\" the change.");
991 str = N_("Modify the contents of the current converter. Note: you must then \"Apply\" the change.");
998 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
1000 if (ob == dialog_->browser_all) {
1003 } else if (ob == dialog_->choice_from
1004 || ob == dialog_->choice_to
1005 || ob == dialog_->input_converter
1006 || ob == dialog_->input_flags) {
1009 } else if (ob == dialog_->button_add) {
1012 } else if (ob == dialog_->button_delete) {
1020 void FormPreferences::Converters::update()
1022 local_converters = converters;
1023 local_converters.update(local_formats);
1028 void FormPreferences::Converters::UpdateBrowser()
1030 local_converters.sort();
1032 fl_freeze_form(dialog_->form);
1033 fl_clear_browser(dialog_->browser_all);
1034 for (::Converters::const_iterator cit = local_converters.begin();
1035 cit != local_converters.end(); ++cit) {
1036 string const name = cit->From->prettyname() + " -> "
1037 + cit->To->prettyname();
1038 fl_addto_browser(dialog_->browser_all, name.c_str());
1041 fl_unfreeze_form(dialog_->form);
1045 bool FormPreferences::Converters::Add()
1047 string const from = GetFrom();
1048 string const to = GetTo();
1049 string const command = fl_get_input(dialog_->input_converter);
1050 string const flags = fl_get_input(dialog_->input_flags);
1052 Converter const * old = local_converters.getConverter(from, to);
1053 local_converters.add(from, to, command, flags);
1055 local_converters.updateLast(local_formats);
1058 setEnabled(dialog_->button_add, false);
1064 bool FormPreferences::Converters::Browser()
1066 int const i = fl_get_browser(dialog_->browser_all);
1067 if (i <= 0) return false;
1069 fl_freeze_form(dialog_->form);
1071 Converter const & c = local_converters.get(i - 1);
1072 int j = local_formats.getNumber(c.from);
1074 fl_set_choice(dialog_->choice_from, j + 1);
1076 j = local_formats.getNumber(c.to);
1078 fl_set_choice(dialog_->choice_to, j + 1);
1080 fl_set_input(dialog_->input_converter, c.command.c_str());
1081 fl_set_input(dialog_->input_flags, c.flags.c_str());
1083 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1084 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1086 setEnabled(dialog_->button_add, false);
1087 setEnabled(dialog_->button_delete, true);
1089 fl_unfreeze_form(dialog_->form);
1094 bool FormPreferences::Converters::erase()
1096 string const from = GetFrom();
1097 string const to = GetTo();
1099 local_converters.erase(from, to);
1105 bool FormPreferences::Converters::Input()
1107 string const from = GetFrom();
1108 string const to = GetTo();
1109 int const sel = local_converters.getNumber(from, to);
1111 fl_freeze_form(dialog_->form);
1114 fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
1115 fl_set_button_shortcut(dialog_->button_add,
1116 scex(_("Add|#A")), 1);
1118 fl_deselect_browser(dialog_->browser_all);
1119 setEnabled(dialog_->button_delete, false);
1122 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1123 fl_set_button_shortcut(dialog_->button_add,
1124 scex(_("Modify|#M")), 1);
1126 int top = max(sel-5, 0);
1127 fl_set_browser_topline(dialog_->browser_all, top);
1128 fl_select_browser_line(dialog_->browser_all, sel+1);
1129 setEnabled(dialog_->button_delete, true);
1132 string const command = strip(fl_get_input(dialog_->input_converter));
1133 bool const enable = !(command.empty() || from == to);
1134 setEnabled(dialog_->button_add, enable);
1136 fl_unfreeze_form(dialog_->form);
1141 string const FormPreferences::Converters::GetFrom() const
1143 ::Formats::FormatList::size_type const i =
1144 fl_get_choice(dialog_->choice_from);
1146 if (i > 0 && i <= local_formats.size())
1147 return local_formats.get(i - 1).name();
1149 lyxerr << "FormPreferences::Converters::GetFrom: No choice!"
1156 string const FormPreferences::Converters::GetTo() const
1158 ::Formats::FormatList::size_type const i =
1159 fl_get_choice(dialog_->choice_to);
1161 if (i > 0 && i <= local_formats.size())
1162 return local_formats.get(i - 1).name();
1164 lyxerr << "FormPreferences::Converters::GetTo: No choice!"
1171 void FormPreferences::Converters::UpdateChoices() const
1174 for (::Formats::const_iterator cit = local_formats.begin();
1175 cit != local_formats.end(); ++cit) {
1176 if (!choice.empty())
1180 choice += cit->prettyname();
1184 fl_clear_choice(dialog_->choice_from);
1185 fl_addto_choice(dialog_->choice_from, choice.c_str());
1187 fl_clear_choice(dialog_->choice_to);
1188 fl_addto_choice(dialog_->choice_to, choice.c_str());
1192 FormPreferences::Formats::Formats(FormPreferences & p)
1197 FD_form_formats const * FormPreferences::Formats::dialog()
1199 return dialog_.get();
1203 void FormPreferences::Formats::apply() const
1205 formats = local_formats;
1209 void FormPreferences::Formats::build()
1211 dialog_.reset(parent_.build_formats());
1213 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1214 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1215 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1216 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1217 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1219 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1221 // set up the feedback mechanism
1222 setPreHandler(dialog_->browser_all);
1223 setPreHandler(dialog_->input_format);
1224 setPreHandler(dialog_->input_gui_name);
1225 setPreHandler(dialog_->button_delete);
1226 setPreHandler(dialog_->button_add);
1227 setPreHandler(dialog_->input_extension);
1228 setPreHandler(dialog_->input_viewer);
1229 setPreHandler(dialog_->input_shrtcut);
1234 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1238 if (ob == dialog_->browser_all) {
1239 str = N_("All the currently defined formats known to LyX.");
1240 } else if (ob == dialog_->input_format) {
1241 str = N_("The format identifier.");
1242 } else if (ob == dialog_->input_gui_name) {
1243 str = N_("The format name as it will appear in the menus.");
1244 } else if (ob == dialog_->input_shrtcut) {
1245 str = N_("The keyboard accelerator. Use a letter in the GUI name. Case sensitive.");
1246 } else if (ob == dialog_->input_extension) {
1247 str = N_("Used to recognize the file. E.g., ps, pdf, tex.");
1248 } else if (ob == dialog_->input_viewer) {
1249 str = N_("The command used to launch the viewer application.");
1250 } else if (ob == dialog_->button_delete) {
1251 str = N_("Remove the current format from the list of available formats. Note: you must then \"Apply\" the change.");
1252 } else if (ob == dialog_->button_add) {
1253 if (string(ob->label) == _("Add"))
1254 str = N_("Add the current format to the list of available formats. Note: you must then \"Apply\" the change.");
1256 str = N_("Modify the contents of the current format. Note: you must then \"Apply\" the change.");
1263 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1265 if (ob == dialog_->browser_all) {
1268 } else if (ob == dialog_->input_format
1269 || ob == dialog_->input_gui_name
1270 || ob == dialog_->input_shrtcut
1271 || ob == dialog_->input_extension
1272 || ob == dialog_->input_viewer) {
1275 } else if (ob == dialog_->button_add) {
1278 } else if (ob == dialog_->button_delete) {
1286 void FormPreferences::Formats::update()
1288 local_formats = formats;
1293 void FormPreferences::Formats::UpdateBrowser()
1295 local_formats.sort();
1297 fl_freeze_form(dialog_->form);
1298 fl_deselect_browser(dialog_->browser_all);
1299 fl_clear_browser(dialog_->browser_all);
1300 for (::Formats::const_iterator cit = local_formats.begin();
1301 cit != local_formats.end(); ++cit)
1302 fl_addto_browser(dialog_->browser_all,
1303 cit->prettyname().c_str());
1306 fl_unfreeze_form(dialog_->form);
1308 // Mustn't forget to update the Formats available to the converters_
1309 parent_.converters_.UpdateChoices();
1310 local_converters.update(local_formats);
1314 bool FormPreferences::Formats::Add()
1316 string const name = fl_get_input(dialog_->input_format);
1317 string const prettyname = fl_get_input(dialog_->input_gui_name);
1318 string const extension = fl_get_input(dialog_->input_extension);
1319 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1320 string const viewer = fl_get_input(dialog_->input_viewer);
1322 Format const * old = local_formats.getFormat(name);
1323 string const old_prettyname = old ? old->prettyname() : string();
1324 local_formats.add(name, extension, prettyname, shortcut);
1325 local_formats.setViewer(name, viewer);
1326 if (!old || prettyname != old_prettyname) {
1329 parent_.converters_.UpdateBrowser();
1331 setEnabled(dialog_->button_add, false);
1337 bool FormPreferences::Formats::Browser()
1339 int const i = fl_get_browser(dialog_->browser_all);
1340 if (i <= 0) return false;
1342 fl_freeze_form(dialog_->form);
1344 Format const & f = local_formats.get(i - 1);
1346 fl_set_input(dialog_->input_format, f.name().c_str());
1347 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1348 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1349 fl_set_input(dialog_->input_extension, f.extension().c_str());
1350 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1352 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1353 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1355 setEnabled(dialog_->button_add, false);
1356 setEnabled(dialog_->button_delete, true);
1358 fl_unfreeze_form(dialog_->form);
1363 bool FormPreferences::Formats::erase()
1365 string const name = fl_get_input(dialog_->input_format);
1367 if (local_converters.formatIsUsed(name)) {
1368 parent_.printWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
1369 setEnabled(dialog_->button_delete, false);
1373 local_formats.erase(name);
1379 bool FormPreferences::Formats::Input()
1381 string const name = fl_get_input(dialog_->input_format);
1382 int const sel = local_formats.getNumber(name);
1383 fl_freeze_form(dialog_->form);
1386 fl_set_object_label(dialog_->button_add,
1388 fl_set_button_shortcut(dialog_->button_add,
1389 scex(_("Add|#A")), 1);
1391 fl_deselect_browser(dialog_->browser_all);
1392 setEnabled(dialog_->button_delete, false);
1395 fl_set_object_label(dialog_->button_add,
1396 idex(_("Modify|#M")));
1397 fl_set_button_shortcut(dialog_->button_add,
1398 scex(_("Modify|#M")), 1);
1400 int const top = max(sel-5, 0);
1401 fl_set_browser_topline(dialog_->browser_all, top);
1402 fl_select_browser_line(dialog_->browser_all, sel+1);
1404 setEnabled(dialog_->button_add, true);
1405 setEnabled(dialog_->button_delete, true);
1408 string const prettyname = fl_get_input(dialog_->input_gui_name);
1409 bool const enable = !(name.empty() || prettyname.empty());
1410 setEnabled(dialog_->button_add, enable);
1412 fl_unfreeze_form(dialog_->form);
1417 FormPreferences::InputsMisc::InputsMisc(FormPreferences & p)
1422 FD_form_inputs_misc const * FormPreferences::InputsMisc::dialog()
1424 return dialog_.get();
1428 void FormPreferences::InputsMisc::apply() const
1430 lyxrc.date_insert_format =
1431 fl_get_input(dialog_->input_date_format);
1435 void FormPreferences::InputsMisc::build()
1437 dialog_.reset(parent_.build_inputs_misc());
1439 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1441 // set up the feedback mechanism
1442 setPreHandler(dialog_->input_date_format);
1447 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1451 if (ob == dialog_->input_date_format)
1452 str = lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1458 void FormPreferences::InputsMisc::update()
1460 fl_set_input(dialog_->input_date_format,
1461 lyxrc.date_insert_format.c_str());
1465 FormPreferences::Interface::Interface(FormPreferences & p)
1470 FD_form_interface const * FormPreferences::Interface::dialog()
1472 return dialog_.get();
1476 void FormPreferences::Interface::apply() const
1478 lyxrc.popup_normal_font =
1479 fl_get_input(dialog_->input_popup_normal_font);
1480 lyxrc.popup_bold_font = fl_get_input(dialog_->input_popup_bold_font);
1481 lyxrc.popup_font_encoding =
1482 fl_get_input(dialog_->input_popup_font_encoding);
1483 lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
1484 lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
1485 lyxrc.override_x_deadkeys =
1486 fl_get_button(dialog_->check_override_x_dead_keys);
1490 void FormPreferences::Interface::build()
1492 dialog_.reset(parent_.build_interface());
1494 fl_set_input_return(dialog_->input_popup_normal_font, FL_RETURN_CHANGED);
1495 fl_set_input_return(dialog_->input_popup_bold_font, FL_RETURN_CHANGED);
1496 fl_set_input_return(dialog_->input_popup_font_encoding, FL_RETURN_CHANGED);
1497 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1498 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1500 // set up the feedback mechanism
1501 setPreHandler(dialog_->input_popup_normal_font);
1502 setPreHandler(dialog_->input_popup_bold_font);
1503 setPreHandler(dialog_->input_popup_font_encoding);
1504 setPreHandler(dialog_->input_bind_file);
1505 setPreHandler(dialog_->button_bind_file_browse);
1506 setPreHandler(dialog_->input_ui_file);
1507 setPreHandler(dialog_->button_ui_file_browse);
1508 setPreHandler(dialog_->check_override_x_dead_keys);
1513 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1517 if (ob == dialog_->input_popup_normal_font)
1518 str = lyxrc.getDescription(LyXRC::RC_POPUP_NORMAL_FONT);
1519 else if (ob == dialog_->input_popup_bold_font)
1520 str = lyxrc.getDescription(LyXRC::RC_POPUP_BOLD_FONT);
1521 else if (ob == dialog_->input_popup_font_encoding)
1522 str = lyxrc.getDescription(LyXRC::RC_POPUP_FONT_ENCODING);
1523 else if (ob == dialog_->input_bind_file)
1524 str = lyxrc.getDescription(LyXRC::RC_BINDFILE);
1525 else if (ob == dialog_->input_ui_file)
1526 str = lyxrc.getDescription(LyXRC::RC_UIFILE);
1527 else if (ob == dialog_->check_override_x_dead_keys)
1528 str = lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1534 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1536 if (ob == dialog_->button_bind_file_browse) {
1537 string dir = AddName(system_lyxdir, "bind");
1538 string name = N_("Sys Bind|#S#s");
1539 pair<string,string> dir1(name, dir);
1541 dir = AddName(user_lyxdir, "bind");
1542 name = N_("User Bind|#U#u");
1543 pair<string,string> dir2(name, dir);
1545 parent_.browse(dialog_->input_bind_file,
1546 N_("Bind file"), "*.bind", dir1, dir2);
1548 } else if (ob == dialog_->button_ui_file_browse) {
1549 string dir = AddName(system_lyxdir, "ui");
1550 string name = N_("Sys UI|#S#s");
1551 pair<string,string> dir1(name, dir);
1553 dir = AddName(user_lyxdir, "ui");
1554 name = N_("User UI|#U#u");
1555 pair<string,string> dir2(name, dir);
1557 parent_.browse(dialog_->input_ui_file,
1558 N_("UI file"), "*.ui", dir1, dir2);
1565 void FormPreferences::Interface::update()
1567 fl_set_input(dialog_->input_popup_normal_font,
1568 lyxrc.popup_normal_font.c_str());
1569 fl_set_input(dialog_->input_popup_bold_font,
1570 lyxrc.popup_bold_font.c_str());
1571 fl_set_input(dialog_->input_popup_font_encoding,
1572 lyxrc.popup_font_encoding.c_str());
1573 fl_set_input(dialog_->input_bind_file,
1574 lyxrc.bind_file.c_str());
1575 fl_set_input(dialog_->input_ui_file,
1576 lyxrc.ui_file.c_str());
1577 fl_set_button(dialog_->check_override_x_dead_keys,
1578 lyxrc.override_x_deadkeys);
1582 FormPreferences::Language::Language(FormPreferences & p)
1587 FD_form_language const * FormPreferences::Language::dialog()
1589 return dialog_.get();
1593 void FormPreferences::Language::apply()
1595 lyxrc.default_language = combo_default_lang->getline();
1597 int button = fl_get_button(dialog_->check_use_kbmap);
1598 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1599 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1601 button = !(name_1.empty() && name_2.empty());
1602 lyxrc.use_kbmap = static_cast<bool>(button);
1604 if (lyxrc.use_kbmap) {
1605 lyxrc.primary_kbmap = name_1;
1606 lyxrc.secondary_kbmap = name_2;
1609 button = fl_get_button(dialog_->check_rtl_support);
1610 lyxrc.rtl_support = static_cast<bool>(button);
1612 button = fl_get_button(dialog_->check_mark_foreign);
1613 lyxrc.mark_foreign_language = static_cast<bool>(button);
1615 button = fl_get_button(dialog_->check_auto_begin);
1616 lyxrc.language_auto_begin = static_cast<bool>(button);
1618 button = fl_get_button(dialog_->check_auto_end);
1619 lyxrc.language_auto_end = static_cast<bool>(button);
1621 button = fl_get_button(dialog_->check_use_babel);
1622 lyxrc.language_use_babel = static_cast<bool>(button);
1624 button = fl_get_button(dialog_->check_global_options);
1625 lyxrc.language_global_options = static_cast<bool>(button);
1627 lyxrc.language_package = fl_get_input(dialog_->input_package);
1628 lyxrc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1629 lyxrc.language_command_end = fl_get_input(dialog_->input_command_end);
1631 // Ensure that all is self-consistent.
1636 void FormPreferences::Language::build()
1638 dialog_.reset(parent_.build_language());
1640 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1641 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1642 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1644 // The default_language is a combo-box and has to be inserted manually
1645 fl_freeze_form(dialog_->form);
1646 fl_addto_form(dialog_->form);
1648 FL_OBJECT * obj = dialog_->choice_default_lang;
1649 fl_deactivate_object(dialog_->choice_default_lang);
1650 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1651 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
1652 parent_.lang_opts_tab_->tabfolder_inner,
1653 parent_.dialog_->tabfolder_prefs);
1654 combo_default_lang->shortcut("#L",1);
1655 combo_default_lang->setcallback(ComboCB, &parent_);
1657 for (Languages::const_iterator cit = languages.begin();
1658 cit != languages.end(); ++cit) {
1659 combo_default_lang->addto(cit->second.lang());
1663 fl_unfreeze_form(dialog_->form);
1665 // set up the feedback mechanism
1666 setPreHandler(dialog_->input_package);
1667 setPreHandler(dialog_->check_use_kbmap);
1669 // This is safe, as nothing is done to the pointer, other than
1670 // to use its address in a block-if statement.
1671 // No it's not! Leads to crash.
1673 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1674 // C_FormPreferencesFeedbackCB);
1676 setPreHandler(dialog_->input_kbmap1);
1677 setPreHandler(dialog_->input_kbmap2);
1678 setPreHandler(dialog_->check_rtl_support);
1679 setPreHandler(dialog_->check_mark_foreign);
1680 setPreHandler(dialog_->check_auto_begin);
1681 setPreHandler(dialog_->check_auto_end);
1682 setPreHandler(dialog_->check_use_babel);
1683 setPreHandler(dialog_->check_global_options);
1684 setPreHandler(dialog_->input_command_begin);
1685 setPreHandler(dialog_->input_command_end);
1687 // Activate/Deactivate the input fields dependent on the state of the
1694 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1698 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1699 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1700 else if (ob == dialog_->check_use_kbmap)
1701 str = lyxrc.getDescription(LyXRC::RC_KBMAP);
1702 else if (ob == dialog_->input_kbmap1)
1703 str = lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1704 else if (ob == dialog_->input_kbmap2)
1705 str = lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1706 else if (ob == dialog_->check_rtl_support)
1707 str = lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1708 else if (ob == dialog_->check_mark_foreign)
1709 str = lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1710 else if (ob == dialog_->check_auto_begin)
1711 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1712 else if (ob == dialog_->check_auto_end)
1713 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1714 else if (ob == dialog_->check_use_babel)
1715 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1716 else if (ob == dialog_->check_global_options)
1717 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1718 else if (ob == dialog_->input_package)
1719 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1720 else if (ob == dialog_->input_command_begin)
1721 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1722 else if (ob == dialog_->input_command_end)
1723 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1729 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1731 bool activate = true;
1733 // !ob if function is called from Language::build() to de/activate
1735 // otherwise the function is called by an xforms CB via input().
1736 if (!ob || ob == dialog_->check_use_kbmap) {
1737 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1738 setEnabled(dialog_->button_kbmap1_browse, enable);
1739 setEnabled(dialog_->button_kbmap2_browse, enable);
1740 setEnabled(dialog_->input_kbmap1, enable);
1741 setEnabled(dialog_->input_kbmap2, enable);
1744 if (ob == dialog_->button_kbmap1_browse) {
1745 string const dir = AddName(system_lyxdir, "kbd");
1746 string const name = N_("Key maps|#K#k");
1747 pair<string, string> dir1(name, dir);
1749 parent_.browse(dialog_->input_kbmap1,
1750 N_("Keyboard map"), "*.kmap", dir1);
1751 } else if (ob == dialog_->button_kbmap2_browse) {
1752 string const dir = AddName(system_lyxdir, "kbd");
1753 string const name = N_("Key maps|#K#k");
1754 pair<string, string> dir1(name, dir);
1756 parent_.browse(dialog_->input_kbmap2,
1757 N_("Keyboard map"), "*.kmap", dir1);
1764 void FormPreferences::Language::update()
1766 fl_set_button(dialog_->check_use_kbmap,
1769 combo_default_lang->select(lyxrc.default_language);
1771 if (lyxrc.use_kbmap) {
1772 fl_set_input(dialog_->input_kbmap1,
1773 lyxrc.primary_kbmap.c_str());
1774 fl_set_input(dialog_->input_kbmap2,
1775 lyxrc.secondary_kbmap.c_str());
1777 fl_set_input(dialog_->input_kbmap1, "");
1778 fl_set_input(dialog_->input_kbmap2, "");
1781 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1782 fl_set_button(dialog_->check_mark_foreign,
1783 lyxrc.mark_foreign_language);
1784 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1785 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1786 fl_set_button(dialog_->check_use_babel, lyxrc.language_use_babel);
1787 fl_set_button(dialog_->check_global_options,
1788 lyxrc.language_global_options);
1790 fl_set_input(dialog_->input_package,
1791 lyxrc.language_package.c_str());
1792 fl_set_input(dialog_->input_command_begin,
1793 lyxrc.language_command_begin.c_str());
1794 fl_set_input(dialog_->input_command_end,
1795 lyxrc.language_command_end.c_str());
1797 // Activate/Deactivate the input fields dependent on the state of the
1803 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1805 FormPreferences * pre = static_cast<FormPreferences*>(v);
1806 // This is safe, as nothing is done to the pointer, other than
1807 // to use its address in a block-if statement.
1808 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1812 FormPreferences::LnFmisc::LnFmisc(FormPreferences & p)
1817 FD_form_lnf_misc const * FormPreferences::LnFmisc::dialog()
1819 return dialog_.get();
1823 void FormPreferences::LnFmisc::apply() const
1825 lyxrc.show_banner = fl_get_button(dialog_->check_banner);
1826 lyxrc.auto_region_delete =
1827 fl_get_button(dialog_->check_auto_region_delete);
1828 lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm);
1829 lyxrc.display_shortcuts =
1830 fl_get_button(dialog_->check_display_shrtcuts);
1831 lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
1832 lyxrc.cursor_follows_scrollbar =
1833 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1834 lyxrc.dialogs_iconify_with_main =
1835 fl_get_button(dialog_->check_dialogs_iconify_with_main);
1836 lyxrc.autosave = static_cast<unsigned int>
1837 (fl_get_counter_value(dialog_->counter_autosave));
1838 lyxrc.wheel_jump = static_cast<unsigned int>
1839 (fl_get_counter_value(dialog_->counter_wm_jump));
1841 string const old_value = lyxrc.display_graphics;
1842 if (fl_get_button(dialog_->radio_display_monochrome)) {
1843 lyxrc.display_graphics = "mono";
1844 } else if (fl_get_button(dialog_->radio_display_grayscale)) {
1845 lyxrc.display_graphics = "gray";
1846 } else if (fl_get_button(dialog_->radio_display_color)) {
1847 lyxrc.display_graphics = "color";
1849 lyxrc.display_graphics = "no";
1851 if (old_value != lyxrc.display_graphics) {
1852 grfx::GCache & gc = grfx::GCache::get();
1858 void FormPreferences::LnFmisc::build()
1860 dialog_.reset(parent_.build_lnf_misc());
1862 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1863 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1865 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1866 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1868 // set up the feedback mechanism
1869 setPreHandler(dialog_->check_banner);
1870 setPreHandler(dialog_->check_auto_region_delete);
1871 setPreHandler(dialog_->check_exit_confirm);
1872 setPreHandler(dialog_->check_display_shrtcuts);
1873 setPreHandler(dialog_->counter_autosave);
1874 setPreHandler(dialog_->check_ask_new_file);
1875 setPreHandler(dialog_->check_cursor_follows_scrollbar);
1876 setPreHandler(dialog_->check_dialogs_iconify_with_main);
1877 setPreHandler(dialog_->counter_wm_jump);
1878 setPreHandler(dialog_->radio_display_monochrome);
1879 setPreHandler(dialog_->radio_display_grayscale);
1880 setPreHandler(dialog_->radio_display_color);
1881 setPreHandler(dialog_->radio_no_display);
1886 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1890 if (ob == dialog_->check_banner)
1891 str = lyxrc.getDescription(LyXRC::RC_SHOW_BANNER);
1892 else if (ob == dialog_->check_auto_region_delete)
1893 str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1894 else if (ob == dialog_->check_exit_confirm)
1895 str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION);
1896 else if (ob == dialog_->check_display_shrtcuts)
1897 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_SHORTCUTS);
1898 else if (ob == dialog_->check_ask_new_file)
1899 str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
1900 else if (ob == dialog_->check_cursor_follows_scrollbar)
1901 str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1902 else if (ob == dialog_->check_dialogs_iconify_with_main)
1903 str = lyxrc.getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
1904 else if (ob == dialog_->counter_autosave)
1905 str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1906 else if (ob == dialog_->counter_wm_jump)
1907 str = lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1908 else if (ob == dialog_->radio_display_monochrome ||
1909 ob == dialog_->radio_display_grayscale ||
1910 ob == dialog_->radio_display_color ||
1911 ob == dialog_->radio_no_display)
1912 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
1918 void FormPreferences::LnFmisc::update()
1920 fl_set_button(dialog_->check_banner, lyxrc.show_banner);
1921 fl_set_button(dialog_->check_auto_region_delete,
1922 lyxrc.auto_region_delete);
1923 fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
1924 fl_set_button(dialog_->check_display_shrtcuts, lyxrc.display_shortcuts);
1925 fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
1926 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1927 lyxrc.cursor_follows_scrollbar);
1928 fl_set_button(dialog_->check_dialogs_iconify_with_main,
1929 lyxrc.dialogs_iconify_with_main);
1930 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1931 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1933 if (lyxrc.display_graphics == "mono") {
1934 fl_set_button(dialog_->radio_display_monochrome, 1);
1935 } else if (lyxrc.display_graphics == "gray") {
1936 fl_set_button(dialog_->radio_display_grayscale, 1);
1937 } else if (lyxrc.display_graphics == "color") {
1938 fl_set_button(dialog_->radio_display_color, 1);
1940 fl_set_button(dialog_->radio_no_display, 1);
1945 FormPreferences::OutputsMisc::OutputsMisc(FormPreferences & p)
1950 FD_form_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1952 return dialog_.get();
1956 void FormPreferences::OutputsMisc::apply() const
1958 lyxrc.ascii_linelen = static_cast<unsigned int>
1959 (fl_get_counter_value(dialog_->counter_line_len));
1960 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1963 fl_get_choice(dialog_->choice_default_papersize) - 1;
1964 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1966 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1967 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1968 lyxrc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
1969 lyxrc.auto_reset_options = fl_get_button(dialog_->check_autoreset_classopt);
1973 void FormPreferences::OutputsMisc::build()
1975 dialog_.reset(parent_.build_outputs_misc());
1977 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1979 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1980 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1981 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1982 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1983 fl_set_input_return(dialog_->input_paperoption, FL_RETURN_CHANGED);
1985 fl_addto_choice(dialog_->choice_default_papersize,
1986 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
1988 // set up the feedback mechanism
1989 setPreHandler(dialog_->counter_line_len);
1990 setPreHandler(dialog_->input_tex_encoding);
1991 setPreHandler(dialog_->choice_default_papersize);
1992 setPreHandler(dialog_->input_ascii_roff);
1993 setPreHandler(dialog_->input_checktex);
1994 setPreHandler(dialog_->input_paperoption);
1995 setPreHandler(dialog_->check_autoreset_classopt);
2000 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
2004 if (ob == dialog_->counter_line_len)
2005 str = lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
2006 else if (ob == dialog_->input_tex_encoding)
2007 str = lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
2008 else if (ob == dialog_->input_ascii_roff)
2009 str = lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
2010 else if (ob == dialog_->input_checktex)
2011 str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
2012 else if (ob == dialog_->choice_default_papersize)
2013 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2014 else if (ob == dialog_->input_paperoption)
2015 str = lyxrc.getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
2016 else if (ob == dialog_->check_autoreset_classopt)
2017 str = lyxrc.getDescription(LyXRC::RC_AUTORESET_OPTIONS);
2023 void FormPreferences::OutputsMisc::update()
2025 fl_set_counter_value(dialog_->counter_line_len,
2026 lyxrc.ascii_linelen);
2027 fl_set_input(dialog_->input_tex_encoding,
2028 lyxrc.fontenc.c_str());
2029 fl_set_choice(dialog_->choice_default_papersize,
2030 lyxrc.default_papersize+1);
2031 fl_set_input(dialog_->input_ascii_roff,
2032 lyxrc.ascii_roff_command.c_str());
2033 fl_set_input(dialog_->input_checktex,
2034 lyxrc.chktex_command.c_str());
2035 fl_set_input(dialog_->input_paperoption,
2036 lyxrc.view_dvi_paper_option.c_str());
2037 fl_set_button(dialog_->check_autoreset_classopt,
2038 lyxrc.auto_reset_options);
2043 FormPreferences::Paths::Paths(FormPreferences & p)
2048 FD_form_paths const * FormPreferences::Paths::dialog()
2050 return dialog_.get();
2054 void FormPreferences::Paths::apply()
2056 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2057 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2059 int button = fl_get_button(dialog_->check_use_temp_dir);
2060 string str = fl_get_input(dialog_->input_temp_dir);
2061 if (!button) str.erase();
2063 lyxrc.use_tempdir = button;
2064 lyxrc.tempdir_path = str;
2066 button = fl_get_button(dialog_->check_last_files);
2067 str = fl_get_input(dialog_->input_lastfiles);
2068 if (!button) str.erase();
2070 lyxrc.check_lastfiles = button;
2071 lyxrc.lastfiles = str;
2072 lyxrc.num_lastfiles = static_cast<unsigned int>
2073 (fl_get_counter_value(dialog_->counter_lastfiles));
2075 button = fl_get_button(dialog_->check_make_backups);
2076 str = fl_get_input(dialog_->input_backup_path);
2077 if (!button) str.erase();
2079 lyxrc.make_backup = button;
2080 lyxrc.backupdir_path = str;
2082 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2089 void FormPreferences::Paths::build()
2091 dialog_.reset(parent_.build_paths());
2093 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2094 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2095 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2096 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2097 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2098 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2099 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2101 // set up the feedback mechanism
2102 setPreHandler(dialog_->input_default_path);
2103 setPreHandler(dialog_->counter_lastfiles);
2104 setPreHandler(dialog_->input_template_path);
2105 setPreHandler(dialog_->check_last_files);
2106 setPreHandler(dialog_->input_lastfiles);
2107 setPreHandler(dialog_->check_make_backups);
2108 setPreHandler(dialog_->input_backup_path);
2109 setPreHandler(dialog_->input_serverpipe);
2110 setPreHandler(dialog_->input_temp_dir);
2111 setPreHandler(dialog_->check_use_temp_dir);
2116 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2120 if (ob == dialog_->input_default_path)
2121 str = lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2122 else if (ob == dialog_->input_template_path)
2123 str = lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2124 else if (ob == dialog_->check_use_temp_dir)
2125 str = lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2126 else if (ob == dialog_->input_temp_dir)
2127 str = lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2128 else if (ob == dialog_->check_last_files)
2129 str = lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2130 else if (ob == dialog_->input_lastfiles)
2131 str = lyxrc.getDescription(LyXRC::RC_LASTFILES);
2132 else if (ob == dialog_->counter_lastfiles)
2133 str = lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2134 else if (ob == dialog_->check_make_backups)
2135 str = lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2136 else if (ob == dialog_->input_backup_path)
2137 str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2138 else if (ob == dialog_->input_serverpipe) {
2139 str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2146 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2148 bool activate = true;
2150 // !ob if function is called from Paths::update() to de/activate
2152 // otherwise the function is called by an xforms CB via input().
2153 if (!ob || ob == dialog_->check_use_temp_dir) {
2154 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2155 setEnabled(dialog_->input_temp_dir, enable);
2158 if (!ob || ob == dialog_->check_last_files) {
2159 bool const enable = fl_get_button(dialog_->check_last_files);
2160 setEnabled(dialog_->input_lastfiles, enable);
2163 if (!ob || ob == dialog_->check_make_backups) {
2164 bool const enable = fl_get_button(dialog_->check_make_backups);
2165 setEnabled(dialog_->input_backup_path, enable);
2168 if (!ob || ob == dialog_->input_default_path) {
2169 string const name = fl_get_input(dialog_->input_default_path);
2170 if (!name.empty() && !RWInfo::WriteableDir(name)) {
2171 parent_.printWarning(RWInfo::ErrorMessage());
2176 if (!ob || ob == dialog_->input_template_path) {
2177 string const name = fl_get_input(dialog_->input_template_path);
2178 if (!name.empty() && !RWInfo::ReadableDir(name)) {
2179 parent_.printWarning(RWInfo::ErrorMessage());
2184 if (!ob || ob == dialog_->input_temp_dir) {
2185 string const name = fl_get_input(dialog_->input_temp_dir);
2186 if (fl_get_button(dialog_->check_make_backups)
2188 && !RWInfo::WriteableDir(name)) {
2189 parent_.printWarning(RWInfo::ErrorMessage());
2194 if (!ob || ob == dialog_->input_backup_path) {
2195 string const name = fl_get_input(dialog_->input_backup_path);
2196 if (fl_get_button(dialog_->check_make_backups)
2198 && !RWInfo::WriteableDir(name)) {
2199 parent_.printWarning(RWInfo::ErrorMessage());
2204 if (!ob || ob == dialog_->input_lastfiles) {
2205 string const name = fl_get_input(dialog_->input_lastfiles);
2206 if (fl_get_button(dialog_->check_last_files)
2208 && !RWInfo::WriteableFile(name)) {
2209 parent_.printWarning(RWInfo::ErrorMessage());
2214 if (!ob || ob == dialog_->input_serverpipe) {
2215 string const name = fl_get_input(dialog_->input_serverpipe);
2216 if (!name.empty()) {
2217 // strip off the extension
2218 string const str = ChangeExtension(name, "");
2219 if (!RWInfo::WriteableFile(str + ".in")) {
2220 parent_.printWarning(RWInfo::ErrorMessage());
2223 if (!RWInfo::WriteableFile(str + ".out")) {
2224 parent_.printWarning(RWInfo::ErrorMessage());
2230 if (ob == dialog_->button_default_path_browse) {
2231 parent_.browse(dialog_->input_default_path,
2232 N_("Default path"), string());
2233 } else if (ob == dialog_->button_template_path_browse) {
2234 parent_.browse(dialog_->input_template_path,
2235 N_("Template path"), string());
2236 } else if (ob == dialog_->button_temp_dir_browse) {
2237 parent_.browse(dialog_->input_temp_dir,
2238 N_("Temp dir"), string());
2239 } else if (ob == dialog_->button_lastfiles_browse) {
2240 pair<string, string> dir(_("User|#U#u"), user_lyxdir);
2242 parent_.browse(dialog_->input_lastfiles,
2243 N_("Lastfiles"), string(), dir);
2244 } else if (ob == dialog_->button_backup_path_browse) {
2245 parent_.browse(dialog_->input_backup_path,
2246 N_("Backup path"), string());
2247 } else if (ob == dialog_->button_serverpipe_browse) {
2248 parent_.browse(dialog_->input_serverpipe,
2249 N_("LyX Server pipes"), string());
2256 void FormPreferences::Paths::update()
2258 fl_set_input(dialog_->input_default_path,
2259 lyxrc.document_path.c_str());
2260 fl_set_input(dialog_->input_template_path,
2261 lyxrc.template_path.c_str());
2264 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
2266 fl_set_button(dialog_->check_make_backups,
2268 fl_set_input(dialog_->input_backup_path, str.c_str());
2271 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
2273 fl_set_button(dialog_->check_use_temp_dir,
2275 fl_set_input(dialog_->input_temp_dir, str.c_str());
2278 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
2280 fl_set_button(dialog_->check_last_files,
2281 lyxrc.check_lastfiles);
2282 fl_set_input(dialog_->input_lastfiles, str.c_str());
2283 fl_set_counter_value(dialog_->counter_lastfiles,
2284 lyxrc.num_lastfiles);
2286 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2288 // Activate/Deactivate the input fields dependent on the state of the
2294 FormPreferences::Printer::Printer(FormPreferences & p)
2299 FD_form_printer const * FormPreferences::Printer::dialog()
2301 return dialog_.get();
2305 void FormPreferences::Printer::apply() const
2307 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2308 lyxrc.print_command = fl_get_input(dialog_->input_command);
2309 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2310 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2311 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2312 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2313 lyxrc.print_file_extension =
2314 fl_get_input(dialog_->input_file_extension);
2315 lyxrc.print_spool_command =
2316 fl_get_input(dialog_->input_spool_command);
2317 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2318 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2319 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2320 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2321 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2322 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2323 lyxrc.print_extra_options =
2324 fl_get_input(dialog_->input_extra_options);
2325 lyxrc.print_spool_printerprefix =
2326 fl_get_input(dialog_->input_spool_prefix);
2327 lyxrc.print_paper_dimension_flag =
2328 fl_get_input(dialog_->input_paper_size);
2329 lyxrc.printer = fl_get_input(dialog_->input_name);
2334 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2338 if (ob == dialog_->input_command)
2339 str = lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2340 else if (ob == dialog_->check_adapt_output)
2341 str = lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2342 else if (ob == dialog_->input_to_printer)
2343 str = lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2344 else if (ob == dialog_->input_to_file)
2345 str = lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2346 else if (ob == dialog_->input_file_extension)
2347 str = lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2348 else if (ob == dialog_->input_extra_options)
2349 str = lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2350 else if (ob == dialog_->input_spool_command)
2351 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2352 else if (ob == dialog_->input_spool_prefix)
2353 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2354 else if (ob == dialog_->input_name)
2355 str = lyxrc.getDescription(LyXRC::RC_PRINTER);
2356 else if (ob == dialog_->input_even_pages)
2357 str = lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2358 else if (ob == dialog_->input_odd_pages)
2359 str = lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2360 else if (ob == dialog_->input_page_range)
2361 str = lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2362 else if (ob == dialog_->input_reverse)
2363 str = lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2364 else if (ob == dialog_->input_landscape)
2365 str = lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2366 else if (ob == dialog_->input_copies)
2367 str = lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2368 else if (ob == dialog_->input_collated)
2369 str = lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2370 else if (ob == dialog_->input_paper_type)
2371 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2372 else if (ob == dialog_->input_paper_size)
2373 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2379 void FormPreferences::Printer::build()
2381 dialog_.reset(parent_.build_printer());
2383 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2384 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2385 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2386 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2387 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2388 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2389 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2390 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2391 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2392 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2393 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2394 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2395 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2396 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2397 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2398 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2399 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2401 // set up the feedback mechanism
2402 setPreHandler(dialog_->input_command);
2403 setPreHandler(dialog_->input_page_range);
2404 setPreHandler(dialog_->input_copies);
2405 setPreHandler(dialog_->input_reverse);
2406 setPreHandler(dialog_->input_to_printer);
2407 setPreHandler(dialog_->input_file_extension);
2408 setPreHandler(dialog_->input_spool_command);
2409 setPreHandler(dialog_->input_paper_type);
2410 setPreHandler(dialog_->input_even_pages);
2411 setPreHandler(dialog_->input_odd_pages);
2412 setPreHandler(dialog_->input_collated);
2413 setPreHandler(dialog_->input_landscape);
2414 setPreHandler(dialog_->input_to_file);
2415 setPreHandler(dialog_->input_extra_options);
2416 setPreHandler(dialog_->input_spool_prefix);
2417 setPreHandler(dialog_->input_paper_size);
2418 setPreHandler(dialog_->input_name);
2419 setPreHandler(dialog_->check_adapt_output);
2423 void FormPreferences::Printer::update()
2425 fl_set_button(dialog_->check_adapt_output,
2426 lyxrc.print_adapt_output);
2427 fl_set_input(dialog_->input_command,
2428 lyxrc.print_command.c_str());
2429 fl_set_input(dialog_->input_page_range,
2430 lyxrc.print_pagerange_flag.c_str());
2431 fl_set_input(dialog_->input_copies,
2432 lyxrc.print_copies_flag.c_str());
2433 fl_set_input(dialog_->input_reverse,
2434 lyxrc.print_reverse_flag.c_str());
2435 fl_set_input(dialog_->input_to_printer,
2436 lyxrc.print_to_printer.c_str());
2437 fl_set_input(dialog_->input_file_extension,
2438 lyxrc.print_file_extension.c_str());
2439 fl_set_input(dialog_->input_spool_command,
2440 lyxrc.print_spool_command.c_str());
2441 fl_set_input(dialog_->input_paper_type,
2442 lyxrc.print_paper_flag.c_str());
2443 fl_set_input(dialog_->input_even_pages,
2444 lyxrc.print_evenpage_flag.c_str());
2445 fl_set_input(dialog_->input_odd_pages,
2446 lyxrc.print_oddpage_flag.c_str());
2447 fl_set_input(dialog_->input_collated,
2448 lyxrc.print_collcopies_flag.c_str());
2449 fl_set_input(dialog_->input_landscape,
2450 lyxrc.print_landscape_flag.c_str());
2451 fl_set_input(dialog_->input_to_file,
2452 lyxrc.print_to_file.c_str());
2453 fl_set_input(dialog_->input_extra_options,
2454 lyxrc.print_extra_options.c_str());
2455 fl_set_input(dialog_->input_spool_prefix,
2456 lyxrc.print_spool_printerprefix.c_str());
2457 fl_set_input(dialog_->input_paper_size,
2458 lyxrc.print_paper_dimension_flag.c_str());
2459 fl_set_input(dialog_->input_name,
2460 lyxrc.printer.c_str());
2464 FormPreferences::ScreenFonts::ScreenFonts(FormPreferences & p)
2469 FD_form_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2471 return dialog_.get();
2475 void FormPreferences::ScreenFonts::apply() const
2477 bool changed = false;
2479 string str = fl_get_input(dialog_->input_roman);
2480 if (lyxrc.roman_font_name != str) {
2482 lyxrc.roman_font_name = str;
2485 str = fl_get_input(dialog_->input_sans);
2486 if (lyxrc.sans_font_name != str) {
2488 lyxrc.sans_font_name = str;
2491 str = fl_get_input(dialog_->input_typewriter);
2492 if (lyxrc.typewriter_font_name != str) {
2494 lyxrc.typewriter_font_name = str;
2497 str = fl_get_input(dialog_->input_screen_encoding);
2498 if (lyxrc.font_norm != str) {
2500 lyxrc.font_norm = str;
2503 bool button = fl_get_button(dialog_->check_scalable);
2504 if (lyxrc.use_scalable_fonts != button) {
2506 lyxrc.use_scalable_fonts = button;
2509 unsigned int ivalue = static_cast<unsigned int>
2510 (fl_get_counter_value(dialog_->counter_zoom));
2511 if (lyxrc.zoom != ivalue) {
2513 lyxrc.zoom = ivalue;
2516 ivalue = static_cast<unsigned int>
2517 (fl_get_counter_value(dialog_->counter_dpi));
2518 if (lyxrc.dpi != ivalue) {
2523 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2524 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2526 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2529 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2530 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2532 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2535 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2536 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2538 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2541 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2542 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2544 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2547 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2548 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2550 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2553 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2554 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2556 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2559 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2560 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2562 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2565 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2566 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2568 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2571 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2572 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2574 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2577 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2578 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2580 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2584 // Now update the buffers
2585 // Can anything below here affect the redraw process?
2586 parent_.lv_->getLyXFunc()->dispatch(LFUN_SCREEN_FONT_UPDATE);
2591 void FormPreferences::ScreenFonts::build()
2593 dialog_.reset(parent_.build_screen_fonts());
2595 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2596 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2598 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2599 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2600 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2601 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2602 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2603 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2604 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2605 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2606 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2607 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2608 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2609 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2610 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2611 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2612 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2613 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2615 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2616 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2617 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2618 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2619 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2620 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2621 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2622 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2623 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2624 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2626 // set up the feedback mechanism
2627 setPreHandler(dialog_->input_roman);
2628 setPreHandler(dialog_->input_sans);
2629 setPreHandler(dialog_->input_typewriter);
2630 setPreHandler(dialog_->counter_zoom);
2631 setPreHandler(dialog_->counter_dpi);
2632 setPreHandler(dialog_->check_scalable);
2633 setPreHandler(dialog_->input_screen_encoding);
2634 setPreHandler(dialog_->input_tiny);
2635 setPreHandler(dialog_->input_script);
2636 setPreHandler(dialog_->input_footnote);
2637 setPreHandler(dialog_->input_small);
2638 setPreHandler(dialog_->input_large);
2639 setPreHandler(dialog_->input_larger);
2640 setPreHandler(dialog_->input_largest);
2641 setPreHandler(dialog_->input_normal);
2642 setPreHandler(dialog_->input_huge);
2643 setPreHandler(dialog_->input_huger);
2648 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2652 if (ob == dialog_->input_roman)
2653 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2654 else if (ob == dialog_->input_sans)
2655 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2656 else if (ob == dialog_->input_typewriter)
2657 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2658 else if (ob == dialog_->check_scalable)
2659 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2660 else if (ob == dialog_->input_screen_encoding)
2661 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2662 else if (ob == dialog_->counter_zoom)
2663 str = lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2664 else if (ob == dialog_->counter_dpi)
2665 str = lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2666 else if (ob == dialog_->input_tiny
2667 || ob == dialog_->input_script
2668 || ob == dialog_->input_footnote
2669 || ob == dialog_->input_small
2670 || ob == dialog_->input_large
2671 || ob == dialog_->input_larger
2672 || ob == dialog_->input_larger
2673 || ob == dialog_->input_largest
2674 || ob == dialog_->input_normal
2675 || ob == dialog_->input_huge
2676 || ob == dialog_->input_huger)
2677 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2683 bool FormPreferences::ScreenFonts::input()
2685 bool activate = true;
2688 // Make sure that all fonts all have positive entries
2689 // Also note that an empty entry is returned as 0.0 by strToDbl
2690 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2691 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2692 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2693 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2694 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2695 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2696 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2697 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2698 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2699 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2701 str = N_("Fonts must be positive!");
2703 // Fontsizes -- tiny < script < footnote etc.
2704 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2705 strToDbl(fl_get_input(dialog_->input_script)) ||
2706 strToDbl(fl_get_input(dialog_->input_script)) >
2707 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2708 strToDbl(fl_get_input(dialog_->input_footnote)) >
2709 strToDbl(fl_get_input(dialog_->input_small)) ||
2710 strToDbl(fl_get_input(dialog_->input_small)) >
2711 strToDbl(fl_get_input(dialog_->input_normal)) ||
2712 strToDbl(fl_get_input(dialog_->input_normal)) >
2713 strToDbl(fl_get_input(dialog_->input_large)) ||
2714 strToDbl(fl_get_input(dialog_->input_large)) >
2715 strToDbl(fl_get_input(dialog_->input_larger)) ||
2716 strToDbl(fl_get_input(dialog_->input_larger)) >
2717 strToDbl(fl_get_input(dialog_->input_largest)) ||
2718 strToDbl(fl_get_input(dialog_->input_largest)) >
2719 strToDbl(fl_get_input(dialog_->input_huge)) ||
2720 strToDbl(fl_get_input(dialog_->input_huge)) >
2721 strToDbl(fl_get_input(dialog_->input_huger))) {
2724 str = N_("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2728 parent_.printWarning(str);
2734 void FormPreferences::ScreenFonts::update()
2736 fl_set_input(dialog_->input_roman,
2737 lyxrc.roman_font_name.c_str());
2738 fl_set_input(dialog_->input_sans,
2739 lyxrc.sans_font_name.c_str());
2740 fl_set_input(dialog_->input_typewriter,
2741 lyxrc.typewriter_font_name.c_str());
2742 fl_set_input(dialog_->input_screen_encoding,
2743 lyxrc.font_norm.c_str());
2744 fl_set_button(dialog_->check_scalable,
2745 lyxrc.use_scalable_fonts);
2746 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2747 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2748 fl_set_input(dialog_->input_tiny,
2749 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2750 fl_set_input(dialog_->input_script,
2751 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2752 fl_set_input(dialog_->input_footnote,
2753 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2754 fl_set_input(dialog_->input_small,
2755 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2756 fl_set_input(dialog_->input_normal,
2757 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2758 fl_set_input(dialog_->input_large,
2759 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2760 fl_set_input(dialog_->input_larger,
2761 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2762 fl_set_input(dialog_->input_largest,
2763 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2764 fl_set_input(dialog_->input_huge,
2765 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2766 fl_set_input(dialog_->input_huger,
2767 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2772 FormPreferences::SpellOptions::SpellOptions(FormPreferences & p)
2777 FD_form_spelloptions const * FormPreferences::SpellOptions::dialog()
2779 return dialog_.get();
2783 void FormPreferences::SpellOptions::apply()
2786 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2787 choice = strip(frontStrip(choice));
2789 lyxrc.isp_command = choice;
2792 // If spell checker == "none", all other input set to off.
2793 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2794 lyxrc.isp_use_alt_lang = false;
2795 lyxrc.isp_alt_lang.erase();
2797 lyxrc.isp_use_esc_chars = false;
2798 lyxrc.isp_esc_chars.erase();
2800 lyxrc.isp_use_pers_dict = false;
2801 lyxrc.isp_pers_dict.erase();
2803 lyxrc.isp_accept_compound = false;
2804 lyxrc.isp_use_input_encoding = false;
2807 int button = fl_get_button(dialog_->check_alt_lang);
2808 choice = fl_get_input(dialog_->input_alt_lang);
2809 if (button && choice.empty()) button = 0;
2810 if (!button) choice.erase();
2812 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2813 lyxrc.isp_alt_lang = choice;
2815 button = fl_get_button(dialog_->check_escape_chars);
2816 choice = fl_get_input(dialog_->input_escape_chars);
2817 if (button && choice.empty()) button = 0;
2818 if (!button) choice.erase();
2820 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2821 lyxrc.isp_esc_chars = choice;
2823 button = fl_get_button(dialog_->check_personal_dict);
2824 choice = fl_get_input(dialog_->input_personal_dict);
2825 if (button && choice.empty()) button = 0;
2826 if (!button) choice.erase();
2828 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2829 lyxrc.isp_pers_dict = choice;
2831 button = fl_get_button(dialog_->check_compound_words);
2832 lyxrc.isp_accept_compound = static_cast<bool>(button);
2834 button = fl_get_button(dialog_->check_input_enc);
2835 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2846 void FormPreferences::SpellOptions::build()
2848 dialog_.reset(parent_.build_spelloptions());
2850 fl_addto_choice(dialog_->choice_spell_command,
2852 _(" none | ispell | aspell "));
2854 _(" ispell | aspell "));
2856 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2857 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2858 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2860 // set up the feedback mechanism
2861 setPreHandler(dialog_->choice_spell_command);
2862 setPreHandler(dialog_->check_alt_lang);
2863 setPreHandler(dialog_->input_alt_lang);
2864 setPreHandler(dialog_->check_escape_chars);
2865 setPreHandler(dialog_->input_escape_chars);
2866 setPreHandler(dialog_->check_personal_dict);
2867 setPreHandler(dialog_->input_personal_dict);
2868 setPreHandler(dialog_->button_personal_dict);
2869 setPreHandler(dialog_->check_compound_words);
2870 setPreHandler(dialog_->check_input_enc);
2875 FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
2879 if (ob == dialog_->choice_spell_command)
2880 str = lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2881 else if (ob == dialog_->check_alt_lang)
2882 str = lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2883 else if (ob == dialog_->input_alt_lang)
2884 str = lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2885 else if (ob == dialog_->check_escape_chars)
2886 str = lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2887 else if (ob == dialog_->input_escape_chars)
2888 str = lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2889 else if (ob == dialog_->check_personal_dict)
2890 str = lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2891 else if (ob == dialog_->input_personal_dict)
2892 str = lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2893 else if (ob == dialog_->check_compound_words)
2894 str = lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2895 else if (ob == dialog_->check_input_enc)
2896 str = lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2902 bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
2904 // !ob if function is called from updateSpellOptions() to de/activate
2906 // otherwise the function is called by an xforms CB via input().
2909 // If spell checker == "none", disable all input.
2910 if (!ob || ob == dialog_->choice_spell_command) {
2911 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2912 fl_deactivate_object(dialog_->check_alt_lang);
2913 fl_deactivate_object(dialog_->input_alt_lang);
2914 fl_deactivate_object(dialog_->check_escape_chars);
2915 fl_deactivate_object(dialog_->input_escape_chars);
2916 fl_deactivate_object(dialog_->check_personal_dict);
2917 fl_deactivate_object(dialog_->input_personal_dict);
2918 fl_deactivate_object(dialog_->check_compound_words);
2919 fl_deactivate_object(dialog_->check_input_enc);
2922 fl_activate_object(dialog_->check_alt_lang);
2923 fl_activate_object(dialog_->check_escape_chars);
2924 fl_activate_object(dialog_->check_personal_dict);
2925 fl_activate_object(dialog_->check_compound_words);
2926 fl_activate_object(dialog_->check_input_enc);
2931 if (!ob || ob == dialog_->check_alt_lang) {
2932 bool const enable = fl_get_button(dialog_->check_alt_lang);
2933 setEnabled(dialog_->input_alt_lang, enable);
2936 if (!ob || ob == dialog_->check_escape_chars) {
2937 bool const enable = fl_get_button(dialog_->check_escape_chars);
2938 setEnabled(dialog_->input_escape_chars, enable);
2941 if (!ob || ob == dialog_->check_personal_dict) {
2942 bool const enable = fl_get_button(dialog_->check_personal_dict);
2943 setEnabled(dialog_->input_personal_dict, enable);
2946 if (ob == dialog_->button_personal_dict) {
2947 parent_.browse(dialog_->input_personal_dict,
2948 N_("Personal dictionary"), "*.ispell");
2951 return true; // All input is valid!
2955 void FormPreferences::SpellOptions::update()
2959 if (lyxrc.isp_command == "none")
2961 else if (lyxrc.isp_command == "ispell")
2963 else if (lyxrc.isp_command == "aspell")
2966 if (lyxrc.isp_command == "ispell")
2968 else if (lyxrc.isp_command == "aspell")
2971 fl_set_choice(dialog_->choice_spell_command, choice);
2974 if (lyxrc.isp_use_alt_lang) str = lyxrc.isp_alt_lang;
2976 fl_set_button(dialog_->check_alt_lang,
2977 lyxrc.isp_use_alt_lang);
2978 fl_set_input(dialog_->input_alt_lang, str.c_str());
2981 if (lyxrc.isp_use_esc_chars) str = lyxrc.isp_esc_chars;
2983 fl_set_button(dialog_->check_escape_chars,
2984 lyxrc.isp_use_esc_chars);
2985 fl_set_input(dialog_->input_escape_chars, str.c_str());
2988 if (lyxrc.isp_use_pers_dict) str = lyxrc.isp_pers_dict;
2990 fl_set_button(dialog_->check_personal_dict,
2991 lyxrc.isp_use_pers_dict);
2992 fl_set_input(dialog_->input_personal_dict, str.c_str());
2994 fl_set_button(dialog_->check_compound_words,
2995 lyxrc.isp_accept_compound);
2996 fl_set_button(dialog_->check_input_enc,
2997 lyxrc.isp_use_input_encoding);
2999 // Activate/Deactivate the input fields dependent on the state of the
3005 void FormPreferences::printWarning(string const & warning)
3007 warningPosted = true;
3009 string str = _("WARNING!") + string(" ") + warning;
3010 str = formatted(str, dialog_->text_warning->w-10, FL_SMALL_SIZE);
3012 fl_set_object_label(dialog_->text_warning, str.c_str());
3013 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
3017 void FormPreferences::browse(FL_OBJECT * inpt,
3018 string const & title,
3019 string const & pattern,
3020 pair<string,string> const & dir1,
3021 pair<string,string> const & dir2)
3023 // Get the filename from the dialog
3024 string const filename = fl_get_input(inpt);
3026 // Show the file browser dialog
3027 string const new_filename =
3028 browseFile(lv_, filename, title, pattern, dir1, dir2);
3030 // Save the filename to the dialog
3031 if (new_filename != filename && !new_filename.empty()) {
3032 fl_set_input(inpt, new_filename.c_str());
3038 // C function wrapper, required by xforms.
3042 int C_FormPreferencesFeedbackCB(FL_OBJECT * ob, int event,
3043 FL_Coord mx, FL_Coord my,
3044 int key, void * xev)
3046 return FormPreferences::FeedbackCB(ob, event,
3053 int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event,
3054 FL_Coord, FL_Coord, int, void *)
3056 // Note that the return value is important in the pre-emptive handler.
3057 // Don't return anything other than 0.
3060 // Don't Assert this one, as it can happen quite reasonably when things
3061 // are being deleted in the d-tor.
3063 if (!ob->form) return 0;
3065 FormPreferences * pre =
3066 static_cast<FormPreferences*>(ob->form->u_vdata);
3067 pre->Feedback(ob, event);
3072 // preemptive handler for feedback messages
3073 void FormPreferences::Feedback(FL_OBJECT * ob, int event)
3079 warningPosted = false;
3085 fl_set_object_label(dialog_->text_warning, "");
3094 void FormPreferences::setPreHandler(FL_OBJECT * ob)
3097 fl_set_object_prehandler(ob, C_FormPreferencesFeedbackCB);