2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 The LyX Team.
10 *======================================================*/
12 * FormPreferences Interface Class Implementation
21 #include FORMS_H_LOCATION
24 #pragma implementation
30 #include "FormPreferences.h"
31 #include "form_preferences.h"
32 #include "input_validators.h"
40 #include "support/filetools.h"
41 #include "lyx_gui_misc.h" // idex, scex
43 #include "input_validators.h"
44 #include "xforms_helpers.h"
45 #include "converter.h"
46 #include "support/lyxfunctional.h"
47 #include "support/lyxmanip.h"
57 extern string system_lyxdir;
58 extern string user_lyxdir;
59 extern Languages languages;
63 // These should probably go inside the class definition...
64 Formats local_formats;
65 Converters local_converters;
70 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
71 : FormBaseBI(lv, d, _("Preferences")),
73 colors_(*this), converters_(*this), inputs_misc_(*this),
74 formats_(*this), interface_(*this), language_(*this),
75 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
76 printer_(*this), screen_fonts_(*this), spellchecker_(*this)
78 // let the dialog be shown
79 // This is a permanent connection so we won't bother
80 // storing a copy because we won't be disconnecting.
81 d->showPreferences.connect(slot(this, &FormPreferences::show));
85 void FormPreferences::connect()
87 fl_set_form_maxsize( dialog_->form, minw_, minh_ );
89 FormBaseBI::connect();
93 void FormPreferences::disconnect()
95 // colors_->disconnect();
96 // converters_->disconnect(); //local_converters.Clear();
97 // formats_->disconnect(); //local_formats.Clear();
99 FormBaseBI::disconnect();
103 void FormPreferences::redraw()
105 if (!(form() && form()->visible))
107 fl_redraw_form(form());
109 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
110 if (!(form2 && form2->visible))
112 fl_redraw_form(form2);
115 if (form2 == converters_tab_->form)
116 form3 = fl_get_active_folder(converters_tab_->tabfolder_outer);
118 else if (form2 == look_n_feel_tab_->form)
119 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_outer);
121 else if (form2 == inputs_tab_->form)
122 form3 = fl_get_active_folder(inputs_tab_->tabfolder_outer);
124 else if (form2 == outputs_tab_->form)
125 form3 = fl_get_active_folder(outputs_tab_->tabfolder_outer);
127 else if (form2 == lang_opts_tab_->form)
128 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_outer);
130 if (form3 && form3->visible)
131 fl_redraw_form(form3);
135 FL_FORM * FormPreferences::form() const
137 if (dialog_.get()) return dialog_->form;
142 void FormPreferences::ok()
144 FormBaseDeprecated::ok();
146 if (colors_.modifiedXformsPrefs) {
147 string const filename =
148 AddName(user_lyxdir, "preferences.xform");
149 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
152 lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
156 void FormPreferences::hide()
158 // We need to hide the active tabfolder otherwise we get a
159 // BadDrawable error from X windows and LyX crashes without saving.
160 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
162 && outer_form->visible) {
163 fl_hide_form(outer_form);
165 FormBaseDeprecated::hide();
169 void FormPreferences::build()
171 dialog_.reset(build_preferences());
173 // Manage the restore, save, apply and cancel/close buttons
174 bc().setOK(dialog_->button_ok);
175 bc().setApply(dialog_->button_apply);
176 bc().setCancel(dialog_->button_cancel);
177 bc().setUndoAll(dialog_->button_restore);
180 // build the tab folders
181 converters_tab_.reset(build_outer_tab());
182 look_n_feel_tab_.reset(build_outer_tab());
183 inputs_tab_.reset(build_outer_tab());
184 outputs_tab_.reset(build_outer_tab());
185 lang_opts_tab_.reset(build_outer_tab());
187 // build actual tabfolder contents
188 // these will become nested tabfolders
192 inputs_misc_.build();
196 outputs_misc_.build();
199 screen_fonts_.build();
200 spellchecker_.build();
202 // Now add them to the tabfolder
203 fl_addto_tabfolder(dialog_->tabfolder_prefs,
205 look_n_feel_tab_->form);
206 fl_addto_tabfolder(dialog_->tabfolder_prefs,
208 lang_opts_tab_->form);
209 fl_addto_tabfolder(dialog_->tabfolder_prefs,
211 converters_tab_->form);
212 fl_addto_tabfolder(dialog_->tabfolder_prefs,
215 fl_addto_tabfolder(dialog_->tabfolder_prefs,
219 // now build the nested tabfolders
220 // Starting with look and feel
221 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
223 screen_fonts_.dialog()->form);
224 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
226 interface_.dialog()->form);
227 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
229 colors_.dialog()->form);
230 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
232 lnf_misc_.dialog()->form);
234 // then build converters
235 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
237 formats_.dialog()->form);
238 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
240 converters_.dialog()->form);
243 // Paths should probably go in a few outer_tab called Files
244 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
246 paths_.dialog()->form);
247 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
249 inputs_misc_.dialog()->form);
251 // then building outputs
252 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
254 printer_.dialog()->form);
255 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
257 outputs_misc_.dialog()->form);
259 // then building usage
260 fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
262 spellchecker_.dialog()->form);
263 fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
265 language_.dialog()->form);
269 void FormPreferences::apply()
271 // set the new lyxrc entries
272 // many of these need to trigger other functions when the assignment
273 // is made. For example, screen zoom and font types. These could be
274 // handled either by signals/slots in lyxrc or just directly call the
275 // associated functions here.
276 // There are other problems with this scheme. We really should check
277 // what we copy to make sure that it really is necessary to do things
278 // like update the screen fonts because that flushes the textcache
279 // and other stuff which may cost us a lot on slower/high-load
283 formats_.apply(); // Must be before converters_.apply()
285 inputs_misc_.apply();
289 outputs_misc_.apply();
292 screen_fonts_.apply();
293 spellchecker_.apply();
297 void FormPreferences::feedback(FL_OBJECT * ob)
303 if (ob->form->fdui == colors_.dialog()) {
304 str = colors_.feedback(ob);
305 } else if (ob->form->fdui == converters_.dialog()) {
306 str = converters_.feedback(ob);
307 } else if (ob->form->fdui == formats_.dialog()) {
308 str = formats_.feedback(ob);
309 } else if (ob->form->fdui == inputs_misc_.dialog()) {
310 str = inputs_misc_.feedback(ob);
311 } else if (ob->form->fdui == interface_.dialog()) {
312 str = interface_.feedback(ob);
313 } else if (ob->form->fdui == language_.dialog()) {
314 str = language_.feedback(ob);
315 } else if (ob->form->fdui == lnf_misc_.dialog()) {
316 str = lnf_misc_.feedback(ob);
317 } else if (ob->form->fdui == outputs_misc_.dialog()) {
318 str = outputs_misc_.feedback(ob);
319 } else if (ob->form->fdui == paths_.dialog()) {
320 str = paths_.feedback(ob);
321 } else if (ob->form->fdui == printer_.dialog()) {
322 str = printer_.feedback(ob);
323 } else if (ob->form->fdui == screen_fonts_.dialog()) {
324 str = screen_fonts_.feedback(ob);
325 } else if (ob->form->fdui == spellchecker_.dialog()) {
326 str = spellchecker_.feedback(ob);
329 str = formatted(_(str), dialog_->text_warning->w-10, FL_SMALL_SIZE);
331 fl_set_object_label(dialog_->text_warning, str.c_str());
332 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
336 bool FormPreferences::input(FL_OBJECT * ob, long)
340 // whatever checks you need to ensure the user hasn't entered
341 // some totally ridiculous value somewhere. Change activate to suit.
342 // comments before each test describe what is _valid_
344 if (ob->form->fdui == colors_.dialog()) {
347 } else if (ob->form->fdui == converters_.dialog())
348 return converters_.input(ob);
349 else if (ob->form->fdui == formats_.dialog())
350 return formats_.input(ob);
351 else if (ob->form->fdui == interface_.dialog())
352 return interface_.input(ob);
353 else if (ob->form->fdui == language_.dialog())
354 return language_.input(ob);
355 else if (ob->form->fdui == paths_.dialog())
356 return paths_.input(ob);
357 else if (ob->form->fdui == screen_fonts_.dialog())
358 return screen_fonts_.input();
359 else if (ob->form->fdui == spellchecker_.dialog())
360 return spellchecker_.input(ob);
366 void FormPreferences::update()
368 if (!dialog_.get()) return;
370 // read lyxrc entries
372 formats_.update(); // Must be before converters_.update()
373 converters_.update();
374 inputs_misc_.update();
378 outputs_misc_.update();
381 screen_fonts_.update();
382 spellchecker_.update();
386 FormPreferences::Colors::Colors(FormPreferences & p)
391 FD_form_colors const * FormPreferences::Colors::dialog()
393 return dialog_.get();
397 void FormPreferences::Colors::apply()
399 bool modifiedText = false;
400 bool modifiedBackground = false;
402 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
403 cit != xformsColorDB.end(); ++cit) {
405 fl_getmcolor((*cit).colorID, &col.r, &col.g, &col.b);
406 if (col != (*cit).color()) {
407 modifiedXformsPrefs = true;
408 if ((*cit).colorID == FL_BLACK)
410 if ((*cit).colorID == FL_COL1)
411 modifiedBackground = true;
415 if (modifiedXformsPrefs) {
416 for (vector<XformsColor>::const_iterator cit =
417 xformsColorDB.begin();
418 cit != xformsColorDB.end(); ++cit) {
419 fl_mapcolor((*cit).colorID,
420 (*cit).r, (*cit).g, (*cit).b);
422 if (modifiedText && (*cit).colorID == FL_BLACK) {
423 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
426 if (modifiedBackground && (*cit).colorID == FL_COL1) {
427 AdjustVal(FL_MCOL, FL_COL1, 0.1);
428 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
429 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
431 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
432 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
435 if ((*cit).colorID == GUI_COLOR_CURSOR) {
436 fl_mapcolor(GUI_COLOR_CURSOR,
437 (*cit).r, (*cit).g, (*cit).b);
438 fl_set_cursor_color(FL_DEFAULT_CURSOR,
439 GUI_COLOR_CURSOR, FL_WHITE);
442 Dialogs::redrawGUI();
445 // Now do the same for the LyX LColors...
446 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
447 cit != lyxColorDB.end(); ++cit) {
448 LColor::color lc = lcolor.getFromGUIName((*cit).getname());
449 if (lc == LColor::inherit) continue;
451 // Create a valid X11 name of the form "#rrggbb"
452 string const hexname = X11hexname((*cit).color());
454 if (lcolor.getX11Name(lc) != hexname) {
456 << "FormPreferences::Colors::apply: "
457 << "resetting LColor " << lcolor.getGUIName(lc)
458 << " from \"" << lcolor.getX11Name(lc)
459 << "\" to \"" << hexname << "\"."
462 string const s = lcolor.getLyXName(lc) + string(" ") +
464 parent_.lv_->getLyXFunc()->Dispatch(LFUN_SET_COLOR, s);
470 void FormPreferences::Colors::build()
472 dialog_.reset(parent_.build_colors());
474 fl_set_object_color(dialog_->button_color,
475 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
477 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
478 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
479 fl_set_dial_step(dialog_->dial_hue, 1.0);
480 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
482 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
483 fl_set_slider_step(dialog_->slider_saturation, 0.01);
484 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
486 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
487 fl_set_slider_step(dialog_->slider_value, 0.01);
488 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
490 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
491 fl_set_slider_step(dialog_->slider_red, 1.0);
492 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
494 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
495 fl_set_slider_step(dialog_->slider_green, 1.0);
496 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
498 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
499 fl_set_slider_step(dialog_->slider_blue, 1.0);
500 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
502 // set up the feedback mechanism
503 setPreHandler(dialog_->browser_lyx_objs);
504 setPreHandler(dialog_->button_color);
505 setPreHandler(dialog_->button_modify);
506 setPreHandler(dialog_->dial_hue);
507 setPreHandler(dialog_->slider_saturation);
508 setPreHandler(dialog_->slider_value);
509 setPreHandler(dialog_->slider_red);
510 setPreHandler(dialog_->slider_green);
511 setPreHandler(dialog_->slider_blue);
512 setPreHandler(dialog_->button_colorspace);
516 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
520 if (ob == dialog_->browser_lyx_objs) {
521 str = N_("LyX objects that can be assigned a color.");
523 } else if (ob == dialog_->button_modify) {
524 str = N_("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
526 } else if (ob == dialog_->dial_hue ||
527 ob == dialog_->slider_saturation ||
528 ob == dialog_->slider_value ||
529 ob == dialog_->slider_red ||
530 ob == dialog_->slider_green ||
531 ob == dialog_->slider_blue) {
532 str = N_("Find a new color.");
534 } else if (ob == dialog_->button_colorspace) {
535 str = N_("Toggle between RGB and HSV color spaces.");
542 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
544 if (ob == dialog_->browser_lyx_objs) {
547 } else if (ob == dialog_->dial_hue ||
548 ob == dialog_->slider_saturation ||
549 ob == dialog_->slider_value) {
552 } else if (ob == dialog_->slider_red ||
553 ob == dialog_->slider_green ||
554 ob == dialog_->slider_blue) {
557 } else if (ob == dialog_->button_colorspace) {
560 } else if (ob == dialog_->button_modify) {
566 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
570 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
574 hsv.v = min( 1.0, max(0.0, hsv.v) );
577 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
581 void FormPreferences::Colors::InputBrowserLyX() const
583 vector<NamedColor>::size_type const selLyX =
584 fl_get_browser(dialog_->browser_lyx_objs);
585 if (selLyX < 1) return;
587 // Is the choice an Xforms color...
590 if( selLyX-1 < xformsColorDB.size() ) {
591 vector<XformsColor>::size_type const i = selLyX - 1;
592 col = xformsColorDB[i].color();
594 // or a LyX Logical color?
596 vector<NamedColor>::size_type const i = selLyX - 1 -
597 xformsColorDB.size();
598 col = lyxColorDB[i].color();
601 fl_freeze_form(dialog_->form);
603 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
604 fl_redraw_object(dialog_->button_color);
606 // Display either RGB or HSV but not both!
609 // Deactivate the modify button to begin with...
610 setEnabled(dialog_->button_modify, false);
612 fl_unfreeze_form(dialog_->form);
616 void FormPreferences::Colors::InputHSV()
618 double const hue = fl_get_dial_value(dialog_->dial_hue);
619 double const sat = fl_get_slider_value(dialog_->slider_saturation);
620 double const val = fl_get_slider_value(dialog_->slider_value);
622 int const h = int(hue);
623 int const s = int(100.0 * sat);
624 int const v = int(100.0 * val);
626 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
628 fl_set_object_label(dialog_->text_color_values, label.c_str());
630 RGBColor col = HSVColor(hue, sat, val);
632 fl_freeze_form(dialog_->form);
634 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
635 fl_redraw_object(dialog_->button_color);
637 col = HSVColor(hue, 1.0, 1.0);
638 col.r = max(col.r, 0);
639 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
640 fl_redraw_object(dialog_->dial_hue);
642 // Ascertain whether to activate the Modify button.
643 vector<NamedColor>::size_type const selLyX =
644 fl_get_browser(dialog_->browser_lyx_objs);
646 fl_unfreeze_form(dialog_->form);
647 if (selLyX < 1) return;
649 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
652 // Is the choice an Xforms color...
653 if( selLyX-1 < xformsColorDB.size() ) {
654 vector<XformsColor>::size_type const i = selLyX - 1;
655 modify = (xformsColorDB[i].color() != col);
657 // or a LyX Logical color?
659 vector<NamedColor>::size_type const i = selLyX - 1 -
660 xformsColorDB.size();
661 modify = (lyxColorDB[i].color() != col);
664 setEnabled(dialog_->button_modify, modify);
668 void FormPreferences::Colors::InputRGB()
670 int const red = int(fl_get_slider_value(dialog_->slider_red));
671 int const green = int(fl_get_slider_value(dialog_->slider_green));
672 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
674 string const label = tostr(red) + string(", ") + tostr(green) +
675 string(", ") + tostr(blue);
676 fl_set_object_label(dialog_->text_color_values, label.c_str());
678 fl_freeze_form(dialog_->form);
680 RGBColor col = RGBColor(red, green, blue);
681 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
682 fl_redraw_object(dialog_->button_color);
684 // Ascertain whether to activate the Modify button.
685 vector<NamedColor>::size_type const selLyX =
686 fl_get_browser(dialog_->browser_lyx_objs);
688 fl_unfreeze_form(dialog_->form);
689 if (selLyX < 1) return;
693 // Is the choice an Xforms color...
694 if( selLyX-1 < xformsColorDB.size() ) {
695 vector<XformsColor>::size_type const i = selLyX - 1;
696 modify = (xformsColorDB[i].color() != col);
698 // or a LyX Logical color?
700 vector<NamedColor>::size_type const i = selLyX - 1 -
701 xformsColorDB.size();
702 modify = (lyxColorDB[i].color() != col);
705 setEnabled(dialog_->button_modify, modify);
709 void FormPreferences::Colors::LoadBrowserLyX()
711 if (!dialog_->browser_lyx_objs->visible) return;
713 // First, define the modifiable xforms colors
714 xformsColorDB.clear();
717 xcol.name = _("GUI background");
718 xcol.colorID = FL_COL1;
719 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
721 xformsColorDB.push_back(xcol);
723 xcol.name = _("GUI text");
724 xcol.colorID = FL_BLACK;
725 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
727 fl_mapcolor(GUI_COLOR_CURSOR, xcol.r, xcol.g, xcol.b);
728 fl_set_cursor_color(FL_DEFAULT_CURSOR, GUI_COLOR_CURSOR, FL_WHITE);
730 xformsColorDB.push_back(xcol);
732 xcol.name = _("GUI selection");
733 xcol.colorID = FL_YELLOW;
734 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
736 xformsColorDB.push_back(xcol);
738 xcol.name = _("GUI pointer");
739 xcol.colorID = GUI_COLOR_CURSOR;
740 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
742 xformsColorDB.push_back(xcol);
744 // Now create the the LyX LColors database
746 for (int i=0; i<LColor::ignore; ++i) {
747 LColor::color lc = static_cast<LColor::color>(i);
748 if (lc == LColor::none
749 || lc == LColor::black
750 || lc == LColor::white
752 || lc == LColor::green
753 || lc == LColor::blue
754 || lc == LColor::cyan
755 || lc == LColor::magenta
756 || lc == LColor::yellow
757 || lc == LColor::inherit
758 || lc == LColor::ignore) continue;
760 string const name = lcolor.getX11Name(lc);
761 Display * display = fl_get_display();;
762 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
765 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
767 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
768 << "LColor " << lcolor.getLyXName(lc)
769 << ": X can't find color \"" << name
770 << "\". Set to \"black\"!" << endl;
772 string const arg = lcolor.getLyXName(lc) + " black";
773 parent_.lv_->getLyXFunc()->
774 Dispatch(LFUN_SET_COLOR, arg);
778 // X has found the color. Now find the "appropriate" X11 name
781 // Note that X stores the RGB values in the range 0 - 65535
782 // whilst we require them in the range 0 - 255.
784 col.r = xcol.red / 256;
785 col.g = xcol.green / 256;
786 col.b = xcol.blue / 256;
788 // Create a valid X11 name of the form "#rrggbb" and change the
789 // LColor X11name to this. Don't want to trigger a redraw,
790 // as we're just changing the name not the RGB values.
791 // Also reset the system_lcolor names, so that we don't output
792 // unnecessary changes.
793 string const hexname = X11hexname(col);
795 if (lcolor.getX11Name(lc) != hexname) {
796 lcolor.setColor(lc, hexname);
797 system_lcolor.setColor(lc, hexname);
800 // Finally, push the color onto the database
801 NamedColor ncol(lcolor.getGUIName(lc), col);
802 lyxColorDB.push_back(ncol);
805 // Now construct the browser
806 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
807 fl_freeze_form(dialog_->form);
808 fl_clear_browser(colbr);
809 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
810 cit != xformsColorDB.end(); ++cit) {
811 fl_addto_browser(colbr, (*cit).getname().c_str());
813 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
814 cit != lyxColorDB.end(); ++cit) {
815 fl_addto_browser(colbr, (*cit).getname().c_str());
818 // just to be safe...
819 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
820 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
821 fl_unfreeze_form(dialog_->form);
827 void FormPreferences::Colors::Modify()
829 vector<NamedColor>::size_type const selLyX =
830 fl_get_browser(dialog_->browser_lyx_objs);
831 if (selLyX < 1) return;
834 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
836 // Is the choice an Xforms color...
837 if( selLyX-1 < xformsColorDB.size() ) {
838 vector<XformsColor>::size_type const i = selLyX - 1;
839 xformsColorDB[i].r = col.r;
840 xformsColorDB[i].g = col.g;
841 xformsColorDB[i].b = col.b;
843 // or a LyX Logical color?
845 vector<NamedColor>::size_type const i = selLyX - 1 -
846 xformsColorDB.size();
847 lyxColorDB[i].r = col.r;
848 lyxColorDB[i].g = col.g;
849 lyxColorDB[i].b = col.b;
852 fl_freeze_form(dialog_->form);
853 setEnabled(dialog_->button_modify, false);
854 fl_unfreeze_form(dialog_->form);
858 void FormPreferences::Colors::SwitchColorSpace() const
860 bool const pressed = fl_get_button(dialog_->button_colorspace);
863 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
865 fl_freeze_form(dialog_->form);
868 fl_set_object_label(dialog_->button_colorspace, _("HSV"));
870 fl_hide_object(dialog_->slider_red);
871 fl_hide_object(dialog_->slider_blue);
872 fl_hide_object(dialog_->slider_green);
873 fl_show_object(dialog_->dial_hue);
874 fl_show_object(dialog_->slider_saturation);
875 fl_show_object(dialog_->slider_value);
877 HSVColor hsv = HSVColor(col);
878 hsv.h = max(hsv.h, 0.0);
880 fl_set_dial_value(dialog_->dial_hue, hsv.h);
881 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
882 fl_set_slider_value(dialog_->slider_value, hsv.v);
884 col = HSVColor(hsv.h, 1.0, 1.0);
885 col.r = max(col.r,0);
886 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
887 fl_redraw_object(dialog_->dial_hue);
889 // Adjust the label a bit, but not the actual values.
890 // Means that toggling from one space to the other has no
891 // effect on the final color.
892 int const h = int(hsv.h);
893 int const s = int(100*hsv.s);
894 int const v = int(100*hsv.v);
895 string const label = tostr(h) + string(", ") + tostr(s) +
896 string(", ") + tostr(v);
897 fl_set_object_label(dialog_->text_color_values, label.c_str());
900 fl_set_object_label(dialog_->button_colorspace, _("RGB"));
902 fl_show_object(dialog_->slider_red);
903 fl_show_object(dialog_->slider_blue);
904 fl_show_object(dialog_->slider_green);
905 fl_hide_object(dialog_->dial_hue);
906 fl_hide_object(dialog_->slider_saturation);
907 fl_hide_object(dialog_->slider_value);
909 fl_set_slider_value(dialog_->slider_red, col.r);
910 fl_set_slider_value(dialog_->slider_green, col.g);
911 fl_set_slider_value(dialog_->slider_blue, col.b);
913 // Adjust the label a bit. Same reasoning as above.
914 int const r = int(col.r);
915 int const g = int(col.g);
916 int const b = int(col.b);
917 string const label = tostr(r) + string(", ") + tostr(g) +
918 string(", ") + tostr(b);
919 fl_set_object_label(dialog_->text_color_values, label.c_str());
922 fl_unfreeze_form(dialog_->form);
925 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
929 ostr << "#" << std::setbase(16) << std::setfill('0')
930 << std::setw(2) << col.r
931 << std::setw(2) << col.g
932 << std::setw(2) << col.b;
934 return ostr.str().c_str();
938 FormPreferences::Converters::Converters(FormPreferences & p)
943 FD_form_converters const * FormPreferences::Converters::dialog()
945 return dialog_.get();
949 void FormPreferences::Converters::apply() const
951 converters = local_converters;
952 converters.Update(formats);
953 converters.BuildGraph();
957 void FormPreferences::Converters::build()
959 dialog_.reset(parent_.build_converters());
961 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
962 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
964 // set up the feedback mechanism
965 setPreHandler(dialog_->browser_all);
966 setPreHandler(dialog_->button_delete);
967 setPreHandler(dialog_->button_add);
968 setPreHandler(dialog_->input_converter);
969 setPreHandler(dialog_->choice_from);
970 setPreHandler(dialog_->choice_to);
971 setPreHandler(dialog_->input_flags);
976 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
980 if (ob == dialog_->browser_all) {
981 str = N_("All the currently defined converters known to LyX.");
982 } else if (ob == dialog_->choice_from) {
983 str = N_("Convert \"from\" this format");
984 } else if (ob == dialog_->choice_to) {
985 str = N_("Convert \"to\" this format");
986 } else if (ob == dialog_->input_converter) {
987 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.");
988 } else if (ob == dialog_->input_flags) {
989 str = N_("Flags that control the converter behavior");
990 } else if (ob == dialog_->button_delete) {
991 str = N_("Remove the current converter from the list of available converters. Note: you must then \"Apply\" the change.");
992 } else if (ob == dialog_->button_add) {
993 if (string(ob->label) == _("Add"))
994 str = N_("Add the current converter to the list of available converters. Note: you must then \"Apply\" the change.");
996 str = N_("Modify the contents of the current converter. Note: you must then \"Apply\" the change.");
1003 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
1005 if (ob == dialog_->browser_all) {
1008 } else if (ob == dialog_->choice_from
1009 || ob == dialog_->choice_to
1010 || ob == dialog_->input_converter
1011 || ob == dialog_->input_flags) {
1014 } else if (ob == dialog_->button_add) {
1017 } else if (ob == dialog_->button_delete) {
1025 void FormPreferences::Converters::update()
1027 local_converters = converters;
1028 local_converters.Update(local_formats);
1033 void FormPreferences::Converters::UpdateBrowser()
1035 local_converters.Sort();
1037 fl_freeze_form(dialog_->form);
1038 fl_clear_browser(dialog_->browser_all);
1039 for (::Converters::const_iterator cit = local_converters.begin();
1040 cit != local_converters.end(); ++cit) {
1041 string const name = (*cit).From->prettyname() + " -> "
1042 + (*cit).To->prettyname();
1043 fl_addto_browser(dialog_->browser_all, name.c_str());
1046 fl_unfreeze_form(dialog_->form);
1050 bool FormPreferences::Converters::Add()
1052 string const from = GetFrom();
1053 string const to = GetTo();
1054 string const command = fl_get_input(dialog_->input_converter);
1055 string const flags = fl_get_input(dialog_->input_flags);
1057 Converter const * old = local_converters.GetConverter(from, to);
1058 local_converters.Add(from, to, command, flags);
1060 local_converters.UpdateLast(local_formats);
1063 setEnabled(dialog_->button_add, false);
1069 bool FormPreferences::Converters::Browser()
1071 int const i = fl_get_browser(dialog_->browser_all);
1072 if (i <= 0) return false;
1074 fl_freeze_form(dialog_->form);
1076 Converter const & c = local_converters.Get(i-1);
1077 int j = local_formats.GetNumber(c.from);
1079 fl_set_choice(dialog_->choice_from, j+1);
1081 j = local_formats.GetNumber(c.to);
1083 fl_set_choice(dialog_->choice_to, j+1);
1085 fl_set_input(dialog_->input_converter, c.command.c_str());
1086 fl_set_input(dialog_->input_flags, c.flags.c_str());
1088 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1089 fl_set_button_shortcut(dialog_->button_add,
1090 scex(_("Modify|#M")), 1);
1092 setEnabled(dialog_->button_add, false);
1093 setEnabled(dialog_->button_delete, true);
1095 fl_unfreeze_form(dialog_->form);
1100 bool FormPreferences::Converters::Delete()
1102 string const from = GetFrom();
1103 string const to = GetTo();
1105 local_converters.Delete(from, to);
1111 bool FormPreferences::Converters::Input()
1113 string const from = GetFrom();
1114 string const to = GetTo();
1115 int const sel = local_converters.GetNumber(from, to);
1117 fl_freeze_form(dialog_->form);
1120 fl_set_object_label(dialog_->button_add,
1122 fl_set_button_shortcut(dialog_->button_add,
1123 scex(_("Add|#A")), 1);
1125 fl_deselect_browser(dialog_->browser_all);
1126 setEnabled(dialog_->button_delete, false);
1129 fl_set_object_label(dialog_->button_add,
1130 idex(_("Modify|#M")));
1131 fl_set_button_shortcut(dialog_->button_add,
1132 scex(_("Modify|#M")), 1);
1134 int top = max(sel-5, 0);
1135 fl_set_browser_topline(dialog_->browser_all, top);
1136 fl_select_browser_line(dialog_->browser_all, sel+1);
1137 setEnabled(dialog_->button_delete, true);
1140 string const command = fl_get_input(dialog_->input_converter);
1141 bool const enable = !(command.empty() || from == to);
1142 setEnabled(dialog_->button_add, enable);
1144 fl_unfreeze_form(dialog_->form);
1149 string const FormPreferences::Converters::GetFrom() const
1151 ::Formats::FormatList::size_type const i =
1152 fl_get_choice(dialog_->choice_from);
1154 if (i > 0 && i <= local_formats.size())
1155 return local_formats.Get(i-1).name();
1157 lyxerr << "FormPreferences::Converters::GetFrom: No choice!"
1164 string const FormPreferences::Converters::GetTo() const
1166 ::Formats::FormatList::size_type const i =
1167 fl_get_choice(dialog_->choice_from);
1169 if (i > 0 && i <= local_formats.size())
1170 return local_formats.Get(i-1).name();
1172 lyxerr << "FormPreferences::Converters::GetTo: No choice!"
1179 void FormPreferences::Converters::UpdateChoices() const
1182 for (::Formats::const_iterator cit = local_formats.begin();
1183 cit != local_formats.end(); ++cit) {
1184 if (!choice.empty())
1188 choice += (*cit).prettyname();
1192 fl_clear_choice(dialog_->choice_from);
1193 fl_addto_choice(dialog_->choice_from, choice.c_str());
1195 fl_clear_choice(dialog_->choice_to);
1196 fl_addto_choice(dialog_->choice_to, choice.c_str());
1200 FormPreferences::Formats::Formats( FormPreferences & p )
1205 FD_form_formats const * FormPreferences::Formats::dialog()
1207 return dialog_.get();
1211 void FormPreferences::Formats::apply() const
1213 formats = local_formats;
1217 void FormPreferences::Formats::build()
1219 dialog_.reset(parent_.build_formats());
1221 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1222 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1223 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1224 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1225 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1227 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1229 // set up the feedback mechanism
1230 setPreHandler(dialog_->browser_all);
1231 setPreHandler(dialog_->input_format);
1232 setPreHandler(dialog_->input_gui_name);
1233 setPreHandler(dialog_->button_delete);
1234 setPreHandler(dialog_->button_add);
1235 setPreHandler(dialog_->input_extension);
1236 setPreHandler(dialog_->input_viewer);
1237 setPreHandler(dialog_->input_shrtcut);
1242 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1246 if (ob == dialog_->browser_all) {
1247 str = N_("All the currently defined formats known to LyX.");
1248 } else if (ob == dialog_->input_format) {
1249 str = N_("The format identifier.");
1250 } else if (ob == dialog_->input_gui_name) {
1251 str = N_("The format name as it will appear in the menus.");
1252 } else if (ob == dialog_->input_shrtcut) {
1253 str = N_("The keyboard accelerator. Use a letter in the GUI name. Case sensitive.");
1254 } else if (ob == dialog_->input_extension) {
1255 str = N_("Used to recognize the file. E.g., ps, pdf, tex.");
1256 } else if (ob == dialog_->input_viewer) {
1257 str = N_("The command used to launch the viewer application.");
1258 } else if (ob == dialog_->button_delete) {
1259 str = N_("Remove the current format from the list of available formats. Note: you must then \"Apply\" the change.");
1260 } else if (ob == dialog_->button_add) {
1261 if (string(ob->label) == _("Add"))
1262 str = N_("Add the current format to the list of available formats. Note: you must then \"Apply\" the change.");
1264 str = N_("Modify the contents of the current format. Note: you must then \"Apply\" the change.");
1271 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1273 if (ob == dialog_->browser_all) {
1276 } else if (ob == dialog_->input_format
1277 || ob == dialog_->input_gui_name
1278 || ob == dialog_->input_shrtcut
1279 || ob == dialog_->input_extension
1280 || ob == dialog_->input_viewer) {
1283 } else if (ob == dialog_->button_add) {
1286 } else if (ob == dialog_->button_delete) {
1294 void FormPreferences::Formats::update()
1296 local_formats = formats;
1301 void FormPreferences::Formats::UpdateBrowser()
1303 local_formats.Sort();
1305 fl_freeze_form(dialog_->form);
1306 fl_deselect_browser(dialog_->browser_all);
1307 fl_clear_browser(dialog_->browser_all);
1308 for (::Formats::const_iterator cit = local_formats.begin();
1309 cit != local_formats.end(); ++cit)
1310 fl_addto_browser(dialog_->browser_all,
1311 (*cit).prettyname().c_str());
1314 fl_unfreeze_form(dialog_->form);
1316 // Mustn't forget to update the Formats available to the converters_
1317 parent_.converters_.UpdateChoices();
1318 local_converters.Update(local_formats);
1322 bool FormPreferences::Formats::Add()
1324 string const name = fl_get_input(dialog_->input_format);
1325 string const prettyname = fl_get_input(dialog_->input_gui_name);
1326 string const extension = fl_get_input(dialog_->input_extension);
1327 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1328 string const viewer = fl_get_input(dialog_->input_viewer);
1330 Format const * old = local_formats.GetFormat(name);
1331 string const old_prettyname = old ? old->prettyname() : string();
1332 local_formats.Add(name, extension, prettyname, shortcut);
1333 local_formats.SetViewer(name, viewer);
1334 if (!old || prettyname != old_prettyname) {
1337 parent_.converters_.UpdateBrowser();
1339 setEnabled(dialog_->button_add, false);
1345 bool FormPreferences::Formats::Browser()
1347 int const i = fl_get_browser(dialog_->browser_all);
1348 if (i <= 0) return false;
1350 fl_freeze_form(dialog_->form);
1352 Format const & f = local_formats.Get(i-1);
1354 fl_set_input(dialog_->input_format, f.name().c_str());
1355 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1356 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1357 fl_set_input(dialog_->input_extension, f.extension().c_str());
1358 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1360 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1361 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1363 setEnabled(dialog_->button_add, false);
1364 setEnabled(dialog_->button_delete, true);
1366 fl_unfreeze_form(dialog_->form);
1371 bool FormPreferences::Formats::Delete()
1373 string const name = fl_get_input(dialog_->input_format);
1375 if (local_converters.FormatIsUsed(name)) {
1376 parent_.printWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
1377 setEnabled(dialog_->button_delete, false);
1381 local_formats.Delete(name);
1387 bool FormPreferences::Formats::Input()
1389 string const name = fl_get_input(dialog_->input_format);
1390 int const sel = local_formats.GetNumber(name);
1391 fl_freeze_form(dialog_->form);
1394 fl_set_object_label(dialog_->button_add,
1396 fl_set_button_shortcut(dialog_->button_add,
1397 scex(_("Add|#A")), 1);
1399 fl_deselect_browser(dialog_->browser_all);
1400 setEnabled(dialog_->button_delete, false);
1403 fl_set_object_label(dialog_->button_add,
1404 idex(_("Modify|#M")));
1405 fl_set_button_shortcut(dialog_->button_add,
1406 scex(_("Modify|#M")), 1);
1408 int const top = max(sel-5, 0);
1409 fl_set_browser_topline(dialog_->browser_all, top);
1410 fl_select_browser_line(dialog_->browser_all, sel+1);
1412 setEnabled(dialog_->button_add, true);
1413 setEnabled(dialog_->button_delete, true);
1416 string const prettyname = fl_get_input(dialog_->input_gui_name);
1417 bool const enable = !(name.empty() || prettyname.empty());
1418 setEnabled(dialog_->button_add, enable);
1420 fl_unfreeze_form(dialog_->form);
1425 FormPreferences::InputsMisc::InputsMisc( FormPreferences & p )
1430 FD_form_inputs_misc const * FormPreferences::InputsMisc::dialog()
1432 return dialog_.get();
1436 void FormPreferences::InputsMisc::apply() const
1438 lyxrc.date_insert_format =
1439 fl_get_input(dialog_->input_date_format);
1443 void FormPreferences::InputsMisc::build()
1445 dialog_.reset(parent_.build_inputs_misc());
1447 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1449 // set up the feedback mechanism
1450 setPreHandler(dialog_->input_date_format);
1455 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1459 if (ob == dialog_->input_date_format)
1460 str = lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1466 void FormPreferences::InputsMisc::update()
1468 fl_set_input(dialog_->input_date_format,
1469 lyxrc.date_insert_format.c_str());
1473 FormPreferences::Interface::Interface( FormPreferences & p )
1478 FD_form_interface const * FormPreferences::Interface::dialog()
1480 return dialog_.get();
1484 void FormPreferences::Interface::apply() const
1486 lyxrc.popup_font_name =
1487 fl_get_input(dialog_->input_popup_font);
1488 lyxrc.menu_font_name = fl_get_input(dialog_->input_menu_font);
1489 lyxrc.font_norm_menu =
1490 fl_get_input(dialog_->input_popup_encoding);
1491 lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
1492 lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
1493 lyxrc.override_x_deadkeys =
1494 fl_get_button(dialog_->check_override_x_dead_keys);
1498 void FormPreferences::Interface::build()
1500 dialog_.reset(parent_.build_interface());
1502 fl_set_input_return(dialog_->input_popup_font, FL_RETURN_CHANGED);
1503 fl_set_input_return(dialog_->input_menu_font, FL_RETURN_CHANGED);
1504 fl_set_input_return(dialog_->input_popup_encoding, FL_RETURN_CHANGED);
1505 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1506 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1508 // set up the feedback mechanism
1509 setPreHandler(dialog_->input_popup_font);
1510 setPreHandler(dialog_->input_menu_font);
1511 setPreHandler(dialog_->input_popup_encoding);
1512 setPreHandler(dialog_->input_bind_file);
1513 setPreHandler(dialog_->button_bind_file_browse);
1514 setPreHandler(dialog_->input_ui_file);
1515 setPreHandler(dialog_->button_ui_file_browse);
1516 setPreHandler(dialog_->check_override_x_dead_keys);
1521 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1525 if (ob == dialog_->input_popup_font)
1526 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_POPUP);
1527 else if (ob == dialog_->input_menu_font)
1528 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_MENU);
1529 else if (ob == dialog_->input_popup_encoding)
1530 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING_MENU);
1531 else if (ob == dialog_->input_bind_file)
1532 str = lyxrc.getDescription(LyXRC::RC_BINDFILE);
1533 else if (ob == dialog_->input_ui_file)
1534 str = lyxrc.getDescription(LyXRC::RC_UIFILE);
1535 else if (ob == dialog_->check_override_x_dead_keys)
1536 str = lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1542 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1544 if (ob == dialog_->button_bind_file_browse) {
1545 string dir = AddName(system_lyxdir, "bind");
1546 string name = N_("Sys Bind");
1547 pair<string,string> dir1(name, dir);
1549 dir = AddName(user_lyxdir, "bind");
1550 name = N_("User Bind");
1551 pair<string,string> dir2(name, dir);
1553 parent_.browse(dialog_->input_bind_file,
1554 N_("Bind file"), "*.bind", dir1, dir2);
1556 } else if (ob == dialog_->button_ui_file_browse) {
1557 string dir = AddName(system_lyxdir, "ui");
1558 string name = N_("Sys UI");
1559 pair<string,string> dir1(name, dir);
1561 dir = AddName(user_lyxdir, "ui");
1562 name = N_("User UI");
1563 pair<string,string> dir2(name, dir);
1565 parent_.browse(dialog_->input_ui_file,
1566 N_("UI file"), "*.ui", dir1, dir2);
1573 void FormPreferences::Interface::update()
1575 fl_set_input(dialog_->input_popup_font,
1576 lyxrc.popup_font_name.c_str());
1577 fl_set_input(dialog_->input_menu_font,
1578 lyxrc.menu_font_name.c_str());
1579 fl_set_input(dialog_->input_popup_encoding,
1580 lyxrc.font_norm_menu.c_str());
1581 fl_set_input(dialog_->input_bind_file,
1582 lyxrc.bind_file.c_str());
1583 fl_set_input(dialog_->input_ui_file,
1584 lyxrc.ui_file.c_str());
1585 fl_set_button(dialog_->check_override_x_dead_keys,
1586 lyxrc.override_x_deadkeys);
1590 FormPreferences::Language::Language( FormPreferences & p )
1595 FD_form_language const * FormPreferences::Language::dialog()
1597 return dialog_.get();
1601 void FormPreferences::Language::apply()
1603 lyxrc.default_language = combo_default_lang->getline();
1605 int button = fl_get_button(dialog_->check_use_kbmap);
1606 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1607 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1609 button = !(name_1.empty() && name_2.empty());
1610 lyxrc.use_kbmap = static_cast<bool>(button);
1612 if (lyxrc.use_kbmap) {
1613 lyxrc.primary_kbmap = name_1;
1614 lyxrc.secondary_kbmap = name_2;
1617 button = fl_get_button(dialog_->check_rtl_support);
1618 lyxrc.rtl_support = static_cast<bool>(button);
1620 button = fl_get_button(dialog_->check_mark_foreign);
1621 lyxrc.mark_foreign_language = static_cast<bool>(button);
1623 button = fl_get_button(dialog_->check_auto_begin);
1624 lyxrc.language_auto_begin = static_cast<bool>(button);
1626 button = fl_get_button(dialog_->check_auto_end);
1627 lyxrc.language_auto_end = static_cast<bool>(button);
1629 button = fl_get_button(dialog_->check_use_babel);
1630 lyxrc.language_use_babel = static_cast<bool>(button);
1632 button = fl_get_button(dialog_->check_global_options);
1633 lyxrc.language_global_options = static_cast<bool>(button);
1635 lyxrc.language_package = fl_get_input(dialog_->input_package);
1636 lyxrc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1637 lyxrc.language_command_end = fl_get_input(dialog_->input_command_end);
1639 // Ensure that all is self-consistent.
1644 void FormPreferences::Language::build()
1646 dialog_.reset(parent_.build_language());
1648 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1649 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1650 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1652 // The default_language is a combo-box and has to be inserted manually
1653 fl_freeze_form(dialog_->form);
1654 fl_addto_form(dialog_->form);
1656 FL_OBJECT * obj = dialog_->choice_default_lang;
1657 fl_deactivate_object(dialog_->choice_default_lang);
1658 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1659 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
1660 parent_.lang_opts_tab_->tabfolder_outer,
1661 parent_.dialog_->tabfolder_prefs);
1662 combo_default_lang->shortcut("#L",1);
1663 combo_default_lang->setcallback(ComboCB, &parent_);
1665 for (Languages::const_iterator cit = languages.begin();
1666 cit != languages.end(); ++cit) {
1667 combo_default_lang->addto((*cit).second.lang());
1671 fl_unfreeze_form(dialog_->form);
1673 // set up the feedback mechanism
1674 setPreHandler(dialog_->input_package);
1675 setPreHandler(dialog_->check_use_kbmap);
1677 // This is safe, as nothing is done to the pointer, other than
1678 // to use its address in a block-if statement.
1679 // No it's not! Leads to crash.
1681 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1682 // C_FormPreferencesFeedbackCB);
1684 setPreHandler(dialog_->input_kbmap1);
1685 setPreHandler(dialog_->input_kbmap2);
1686 setPreHandler(dialog_->check_rtl_support);
1687 setPreHandler(dialog_->check_mark_foreign);
1688 setPreHandler(dialog_->check_auto_begin);
1689 setPreHandler(dialog_->check_auto_end);
1690 setPreHandler(dialog_->check_use_babel);
1691 setPreHandler(dialog_->check_global_options);
1692 setPreHandler(dialog_->input_command_begin);
1693 setPreHandler(dialog_->input_command_end);
1695 // Activate/Deactivate the input fields dependent on the state of the
1702 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1706 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1707 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1708 else if (ob == dialog_->check_use_kbmap)
1709 str = lyxrc.getDescription(LyXRC::RC_KBMAP);
1710 else if (ob == dialog_->input_kbmap1)
1711 str = lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1712 else if (ob == dialog_->input_kbmap2)
1713 str = lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1714 else if (ob == dialog_->check_rtl_support)
1715 str = lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1716 else if (ob == dialog_->check_mark_foreign)
1717 str = lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1718 else if (ob == dialog_->check_auto_begin)
1719 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1720 else if (ob == dialog_->check_auto_end)
1721 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1722 else if (ob == dialog_->check_use_babel)
1723 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1724 else if (ob == dialog_->check_global_options)
1725 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1726 else if (ob == dialog_->input_package)
1727 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1728 else if (ob == dialog_->input_command_begin)
1729 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1730 else if (ob == dialog_->input_command_end)
1731 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1737 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1739 bool activate = true;
1741 // !ob if function is called from Language::build() to de/activate
1743 // otherwise the function is called by an xforms CB via input().
1744 if (!ob || ob == dialog_->check_use_kbmap) {
1745 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1746 setEnabled(dialog_->button_kbmap1_browse, enable);
1747 setEnabled(dialog_->button_kbmap2_browse, enable);
1748 setEnabled(dialog_->input_kbmap1, enable);
1749 setEnabled(dialog_->input_kbmap2, enable);
1752 if (ob == dialog_->button_kbmap1_browse) {
1753 string const dir = AddName(system_lyxdir, "kbd");
1754 string const name = N_("Key maps");
1755 pair<string, string> dir1(name, dir);
1757 parent_.browse(dialog_->input_kbmap1,
1758 N_("Keyboard map"), "*.kmap", dir1,
1759 make_pair(string(), string()));
1760 } else if (ob == dialog_->button_kbmap2_browse) {
1761 string const dir = AddName(system_lyxdir, "kbd");
1762 string const name = N_("Key maps");
1763 pair<string, string> dir1(name, dir);
1765 parent_.browse(dialog_->input_kbmap2,
1766 N_("Keyboard map"), "*.kmap", dir1,
1767 make_pair(string(), string()));
1774 void FormPreferences::Language::update()
1776 fl_set_button(dialog_->check_use_kbmap,
1779 combo_default_lang->select_text(lyxrc.default_language);
1781 if (lyxrc.use_kbmap) {
1782 fl_set_input(dialog_->input_kbmap1,
1783 lyxrc.primary_kbmap.c_str());
1784 fl_set_input(dialog_->input_kbmap2,
1785 lyxrc.secondary_kbmap.c_str());
1787 fl_set_input(dialog_->input_kbmap1, "");
1788 fl_set_input(dialog_->input_kbmap2, "");
1791 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1792 fl_set_button(dialog_->check_mark_foreign,
1793 lyxrc.mark_foreign_language);
1794 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1795 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1796 fl_set_button(dialog_->check_use_babel, lyxrc.language_use_babel);
1797 fl_set_button(dialog_->check_global_options,
1798 lyxrc.language_global_options);
1800 fl_set_input(dialog_->input_package,
1801 lyxrc.language_package.c_str());
1802 fl_set_input(dialog_->input_command_begin,
1803 lyxrc.language_command_begin.c_str());
1804 fl_set_input(dialog_->input_command_end,
1805 lyxrc.language_command_end.c_str());
1807 // Activate/Deactivate the input fields dependent on the state of the
1813 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1815 FormPreferences * pre = static_cast<FormPreferences*>(v);
1816 // This is safe, as nothing is done to the pointer, other than
1817 // to use its address in a block-if statement.
1818 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1822 FormPreferences::LnFmisc::LnFmisc( FormPreferences & p )
1827 FD_form_lnf_misc const * FormPreferences::LnFmisc::dialog()
1829 return dialog_.get();
1833 void FormPreferences::LnFmisc::apply() const
1835 lyxrc.show_banner = fl_get_button(dialog_->check_banner);
1836 lyxrc.auto_region_delete =
1837 fl_get_button(dialog_->check_auto_region_delete);
1838 lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm);
1839 lyxrc.display_shortcuts =
1840 fl_get_button(dialog_->check_display_shrtcuts);
1841 lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
1842 lyxrc.cursor_follows_scrollbar =
1843 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1844 lyxrc.autosave = static_cast<unsigned int>
1845 (fl_get_counter_value(dialog_->counter_autosave));
1846 lyxrc.wheel_jump = static_cast<unsigned int>
1847 (fl_get_counter_value(dialog_->counter_wm_jump));
1851 void FormPreferences::LnFmisc::build()
1853 dialog_.reset(parent_.build_lnf_misc());
1855 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1856 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1858 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1859 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1861 // set up the feedback mechanism
1862 setPreHandler(dialog_->check_banner);
1863 setPreHandler(dialog_->check_auto_region_delete);
1864 setPreHandler(dialog_->check_exit_confirm);
1865 setPreHandler(dialog_->check_display_shrtcuts);
1866 setPreHandler(dialog_->counter_autosave);
1867 setPreHandler(dialog_->check_ask_new_file);
1868 setPreHandler(dialog_->check_cursor_follows_scrollbar);
1869 setPreHandler(dialog_->counter_wm_jump);
1874 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1878 if (ob == dialog_->check_banner)
1879 str = lyxrc.getDescription(LyXRC::RC_SHOW_BANNER);
1880 else if (ob == dialog_->check_auto_region_delete)
1881 str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1882 else if (ob == dialog_->check_exit_confirm)
1883 str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION);
1884 else if (ob == dialog_->check_display_shrtcuts)
1885 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_SHORTCUTS);
1886 else if (ob == dialog_->check_ask_new_file)
1887 str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
1888 else if (ob == dialog_->check_cursor_follows_scrollbar)
1889 str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1890 else if (ob == dialog_->counter_autosave)
1891 str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1892 else if (ob == dialog_->counter_wm_jump)
1893 str = lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1899 void FormPreferences::LnFmisc::update()
1901 fl_set_button(dialog_->check_banner, lyxrc.show_banner);
1902 fl_set_button(dialog_->check_auto_region_delete,
1903 lyxrc.auto_region_delete);
1904 fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
1905 fl_set_button(dialog_->check_display_shrtcuts, lyxrc.display_shortcuts);
1906 fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
1907 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1908 lyxrc.cursor_follows_scrollbar);
1909 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1910 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1914 FormPreferences::OutputsMisc::OutputsMisc( FormPreferences & p )
1919 FD_form_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1921 return dialog_.get();
1925 void FormPreferences::OutputsMisc::apply() const
1927 lyxrc.ascii_linelen = static_cast<unsigned int>
1928 (fl_get_counter_value(dialog_->counter_line_len));
1929 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1932 fl_get_choice(dialog_->choice_default_papersize) - 1;
1933 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1935 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1936 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1940 void FormPreferences::OutputsMisc::build()
1942 dialog_.reset(parent_.build_outputs_misc());
1944 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1946 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1947 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1948 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1949 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1951 fl_addto_choice(dialog_->choice_default_papersize,
1952 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
1954 // set up the feedback mechanism
1955 setPreHandler(dialog_->counter_line_len);
1956 setPreHandler(dialog_->input_tex_encoding);
1957 setPreHandler(dialog_->choice_default_papersize);
1958 setPreHandler(dialog_->input_ascii_roff);
1959 setPreHandler(dialog_->input_checktex);
1964 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1968 if (ob == dialog_->counter_line_len)
1969 str = lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
1970 else if (ob == dialog_->input_tex_encoding)
1971 str = lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
1972 else if (ob == dialog_->input_ascii_roff)
1973 str = lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1974 else if (ob == dialog_->input_checktex)
1975 str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
1976 else if (ob == dialog_->choice_default_papersize)
1977 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1983 void FormPreferences::OutputsMisc::update()
1985 fl_set_counter_value(dialog_->counter_line_len,
1986 lyxrc.ascii_linelen);
1987 fl_set_input(dialog_->input_tex_encoding,
1988 lyxrc.fontenc.c_str());
1989 fl_set_choice(dialog_->choice_default_papersize,
1990 lyxrc.default_papersize+1);
1991 fl_set_input(dialog_->input_ascii_roff,
1992 lyxrc.ascii_roff_command.c_str());
1993 fl_set_input(dialog_->input_checktex,
1994 lyxrc.chktex_command.c_str());
1998 FormPreferences::Paths::Paths( FormPreferences & p )
2003 FD_form_paths const * FormPreferences::Paths::dialog()
2005 return dialog_.get();
2009 void FormPreferences::Paths::apply()
2011 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2012 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2014 int button = fl_get_button(dialog_->check_use_temp_dir);
2015 string str = fl_get_input(dialog_->input_temp_dir);
2016 if (!button) str.erase();
2018 lyxrc.use_tempdir = button;
2019 lyxrc.tempdir_path = str;
2021 button = fl_get_button(dialog_->check_last_files);
2022 str = fl_get_input(dialog_->input_lastfiles);
2023 if (!button) str.erase();
2025 lyxrc.check_lastfiles = button;
2026 lyxrc.lastfiles = str;
2027 lyxrc.num_lastfiles = static_cast<unsigned int>
2028 (fl_get_counter_value(dialog_->counter_lastfiles));
2030 button = fl_get_button(dialog_->check_make_backups);
2031 str = fl_get_input(dialog_->input_backup_path);
2032 if (!button) str.erase();
2034 lyxrc.make_backup = button;
2035 lyxrc.backupdir_path = str;
2037 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2044 void FormPreferences::Paths::build()
2046 dialog_.reset(parent_.build_paths());
2048 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2049 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2050 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2051 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2052 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2053 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2054 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2056 // set up the feedback mechanism
2057 setPreHandler(dialog_->input_default_path);
2058 setPreHandler(dialog_->counter_lastfiles);
2059 setPreHandler(dialog_->input_template_path);
2060 setPreHandler(dialog_->check_last_files);
2061 setPreHandler(dialog_->input_lastfiles);
2062 setPreHandler(dialog_->check_make_backups);
2063 setPreHandler(dialog_->input_backup_path);
2064 setPreHandler(dialog_->input_serverpipe);
2065 setPreHandler(dialog_->input_temp_dir);
2066 setPreHandler(dialog_->check_use_temp_dir);
2071 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2075 if (ob == dialog_->input_default_path)
2076 str = lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2077 else if (ob == dialog_->input_template_path)
2078 str = lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2079 else if (ob == dialog_->check_use_temp_dir)
2080 str = lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2081 else if (ob == dialog_->input_temp_dir)
2082 str = lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2083 else if (ob == dialog_->check_last_files)
2084 str = lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2085 else if (ob == dialog_->input_lastfiles)
2086 str = lyxrc.getDescription(LyXRC::RC_LASTFILES);
2087 else if (ob == dialog_->counter_lastfiles)
2088 str = lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2089 else if (ob == dialog_->check_make_backups)
2090 str = lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2091 else if (ob == dialog_->input_backup_path)
2092 str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2093 else if (ob == dialog_->input_serverpipe) {
2094 str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2095 str += " Enter either the input pipe, xxx.in, or the output pipe, xxx.out.";
2102 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2104 bool activate = true;
2106 // !ob if function is called from Paths::update() to de/activate
2108 // otherwise the function is called by an xforms CB via input().
2109 if (!ob || ob == dialog_->check_use_temp_dir) {
2110 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2111 setEnabled(dialog_->input_temp_dir, enable);
2114 if (!ob || ob == dialog_->check_last_files) {
2115 bool const enable = fl_get_button(dialog_->check_last_files);
2116 setEnabled(dialog_->input_lastfiles, enable);
2119 if (!ob || ob == dialog_->check_make_backups) {
2120 bool const enable = fl_get_button(dialog_->check_make_backups);
2121 setEnabled(dialog_->input_backup_path, enable);
2124 if (!ob || ob == dialog_->input_default_path) {
2125 string const name = fl_get_input(dialog_->input_default_path);
2126 if (!RWInfo::WriteableDir(name)) {
2127 parent_.printWarning(RWInfo::ErrorMessage());
2132 if (!ob || ob == dialog_->input_template_path) {
2133 string const name = fl_get_input(dialog_->input_template_path);
2134 if (!RWInfo::ReadableDir(name)) {
2135 parent_.printWarning(RWInfo::ErrorMessage());
2140 if (!ob || ob == dialog_->input_temp_dir) {
2141 string const name = fl_get_input(dialog_->input_temp_dir);
2142 if (fl_get_button(dialog_->check_make_backups)
2144 && !RWInfo::WriteableDir(name)) {
2145 parent_.printWarning(RWInfo::ErrorMessage());
2150 if (!ob || ob == dialog_->input_backup_path) {
2151 string const name = fl_get_input(dialog_->input_backup_path);
2152 if (fl_get_button(dialog_->check_make_backups)
2154 && !RWInfo::WriteableDir(name)) {
2155 parent_.printWarning(RWInfo::ErrorMessage());
2160 if (!ob || ob == dialog_->input_lastfiles) {
2161 string const name = fl_get_input(dialog_->input_lastfiles);
2162 if (fl_get_button(dialog_->check_last_files)
2164 && !RWInfo::WriteableFile(name)) {
2165 parent_.printWarning(RWInfo::ErrorMessage());
2170 if (!ob || ob == dialog_->input_serverpipe) {
2171 string const name = fl_get_input(dialog_->input_serverpipe);
2172 if (!name.empty()) {
2173 // strip off the extension
2174 string const str = ChangeExtension(name, "");
2175 if (!RWInfo::WriteableFile(str + ".in")) {
2176 parent_.printWarning(RWInfo::ErrorMessage());
2179 if (!RWInfo::WriteableFile(str + ".out")) {
2180 parent_.printWarning(RWInfo::ErrorMessage());
2186 if (ob == dialog_->button_default_path_browse) {
2187 parent_.browse(dialog_->input_default_path,
2188 N_("Default path"), string(),
2189 make_pair(string(), string()),
2190 make_pair(string(), string()));
2191 } else if (ob == dialog_->button_template_path_browse) {
2192 parent_.browse(dialog_->input_template_path,
2193 N_("Template path"), string(),
2194 make_pair(string(), string()),
2195 make_pair(string(), string()));
2196 } else if (ob == dialog_->button_temp_dir_browse) {
2197 parent_.browse(dialog_->input_temp_dir,
2198 N_("Temp dir"), string(),
2199 make_pair(string(), string()),
2200 make_pair(string(), string()));
2201 } else if (ob == dialog_->button_lastfiles_browse) {
2202 pair<string, string> dir(_("User"), user_lyxdir);
2204 parent_.browse(dialog_->input_lastfiles,
2205 N_("Lastfiles"), string(), dir,
2206 make_pair(string(), string()));
2207 } else if (ob == dialog_->button_backup_path_browse) {
2208 parent_.browse(dialog_->input_backup_path,
2209 N_("Backup path"), string(),
2210 make_pair(string(), string()),
2211 make_pair(string(), string()));
2212 } else if (ob == dialog_->button_serverpipe_browse) {
2213 parent_.browse(dialog_->input_serverpipe,
2214 N_("LyX Server pipes"), string(),
2215 make_pair(string(), string()),
2216 make_pair(string(), string()));
2223 void FormPreferences::Paths::update()
2225 fl_set_input(dialog_->input_default_path,
2226 lyxrc.document_path.c_str());
2227 fl_set_input(dialog_->input_template_path,
2228 lyxrc.template_path.c_str());
2231 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
2233 fl_set_button(dialog_->check_make_backups,
2235 fl_set_input(dialog_->input_backup_path, str.c_str());
2238 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
2240 fl_set_button(dialog_->check_use_temp_dir,
2242 fl_set_input(dialog_->input_temp_dir, str.c_str());
2245 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
2247 fl_set_button(dialog_->check_last_files,
2248 lyxrc.check_lastfiles);
2249 fl_set_input(dialog_->input_lastfiles, str.c_str());
2250 fl_set_counter_value(dialog_->counter_lastfiles,
2251 lyxrc.num_lastfiles);
2253 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2255 // Activate/Deactivate the input fields dependent on the state of the
2261 FormPreferences::Printer::Printer(FormPreferences & p)
2266 FD_form_printer const * FormPreferences::Printer::dialog()
2268 return dialog_.get();
2272 void FormPreferences::Printer::apply() const
2274 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2275 lyxrc.print_command = fl_get_input(dialog_->input_command);
2276 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2277 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2278 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2279 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2280 lyxrc.print_file_extension =
2281 fl_get_input(dialog_->input_file_extension);
2282 lyxrc.print_spool_command =
2283 fl_get_input(dialog_->input_spool_command);
2284 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2285 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2286 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2287 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2288 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2289 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2290 lyxrc.print_extra_options =
2291 fl_get_input(dialog_->input_extra_options);
2292 lyxrc.print_spool_printerprefix =
2293 fl_get_input(dialog_->input_spool_prefix);
2294 lyxrc.print_paper_dimension_flag =
2295 fl_get_input(dialog_->input_paper_size);
2296 lyxrc.printer = fl_get_input(dialog_->input_name);
2301 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2305 if (ob == dialog_->input_command)
2306 str = lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2307 else if (ob == dialog_->check_adapt_output)
2308 str = lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2309 else if (ob == dialog_->input_to_printer)
2310 str = lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2311 else if (ob == dialog_->input_to_file)
2312 str = lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2313 else if (ob == dialog_->input_file_extension)
2314 str = lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2315 else if (ob == dialog_->input_extra_options)
2316 str = lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2317 else if (ob == dialog_->input_spool_command)
2318 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2319 else if (ob == dialog_->input_spool_prefix)
2320 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2321 else if (ob == dialog_->input_name)
2322 str = lyxrc.getDescription(LyXRC::RC_PRINTER);
2323 else if (ob == dialog_->input_even_pages)
2324 str = lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2325 else if (ob == dialog_->input_odd_pages)
2326 str = lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2327 else if (ob == dialog_->input_page_range)
2328 str = lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2329 else if (ob == dialog_->input_reverse)
2330 str = lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2331 else if (ob == dialog_->input_landscape)
2332 str = lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2333 else if (ob == dialog_->input_copies)
2334 str = lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2335 else if (ob == dialog_->input_collated)
2336 str = lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2337 else if (ob == dialog_->input_paper_type)
2338 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2339 else if (ob == dialog_->input_paper_size)
2340 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2346 void FormPreferences::Printer::build()
2348 dialog_.reset(parent_.build_printer());
2350 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2351 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2352 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2353 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2354 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2355 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2356 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2357 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2358 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2359 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2360 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2361 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2362 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2363 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2364 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2365 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2366 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2368 // set up the feedback mechanism
2369 setPreHandler(dialog_->input_command);
2370 setPreHandler(dialog_->input_page_range);
2371 setPreHandler(dialog_->input_copies);
2372 setPreHandler(dialog_->input_reverse);
2373 setPreHandler(dialog_->input_to_printer);
2374 setPreHandler(dialog_->input_file_extension);
2375 setPreHandler(dialog_->input_spool_command);
2376 setPreHandler(dialog_->input_paper_type);
2377 setPreHandler(dialog_->input_even_pages);
2378 setPreHandler(dialog_->input_odd_pages);
2379 setPreHandler(dialog_->input_collated);
2380 setPreHandler(dialog_->input_landscape);
2381 setPreHandler(dialog_->input_to_file);
2382 setPreHandler(dialog_->input_extra_options);
2383 setPreHandler(dialog_->input_spool_prefix);
2384 setPreHandler(dialog_->input_paper_size);
2385 setPreHandler(dialog_->input_name);
2386 setPreHandler(dialog_->check_adapt_output);
2390 void FormPreferences::Printer::update()
2392 fl_set_button(dialog_->check_adapt_output,
2393 lyxrc.print_adapt_output);
2394 fl_set_input(dialog_->input_command,
2395 lyxrc.print_command.c_str());
2396 fl_set_input(dialog_->input_page_range,
2397 lyxrc.print_pagerange_flag.c_str());
2398 fl_set_input(dialog_->input_copies,
2399 lyxrc.print_copies_flag.c_str());
2400 fl_set_input(dialog_->input_reverse,
2401 lyxrc.print_reverse_flag.c_str());
2402 fl_set_input(dialog_->input_to_printer,
2403 lyxrc.print_to_printer.c_str());
2404 fl_set_input(dialog_->input_file_extension,
2405 lyxrc.print_file_extension.c_str());
2406 fl_set_input(dialog_->input_spool_command,
2407 lyxrc.print_spool_command.c_str());
2408 fl_set_input(dialog_->input_paper_type,
2409 lyxrc.print_paper_flag.c_str());
2410 fl_set_input(dialog_->input_even_pages,
2411 lyxrc.print_evenpage_flag.c_str());
2412 fl_set_input(dialog_->input_odd_pages,
2413 lyxrc.print_oddpage_flag.c_str());
2414 fl_set_input(dialog_->input_collated,
2415 lyxrc.print_collcopies_flag.c_str());
2416 fl_set_input(dialog_->input_landscape,
2417 lyxrc.print_landscape_flag.c_str());
2418 fl_set_input(dialog_->input_to_file,
2419 lyxrc.print_to_file.c_str());
2420 fl_set_input(dialog_->input_extra_options,
2421 lyxrc.print_extra_options.c_str());
2422 fl_set_input(dialog_->input_spool_prefix,
2423 lyxrc.print_spool_printerprefix.c_str());
2424 fl_set_input(dialog_->input_paper_size,
2425 lyxrc.print_paper_dimension_flag.c_str());
2426 fl_set_input(dialog_->input_name,
2427 lyxrc.printer.c_str());
2431 FormPreferences::ScreenFonts::ScreenFonts( FormPreferences & p )
2436 FD_form_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2438 return dialog_.get();
2442 void FormPreferences::ScreenFonts::apply() const
2444 bool changed = false;
2446 string str = fl_get_input(dialog_->input_roman);
2447 if (lyxrc.roman_font_name != str) {
2449 lyxrc.roman_font_name = str;
2452 str = fl_get_input(dialog_->input_sans);
2453 if (lyxrc.sans_font_name != str) {
2455 lyxrc.sans_font_name = str;
2458 str = fl_get_input(dialog_->input_typewriter);
2459 if (lyxrc.typewriter_font_name != str) {
2461 lyxrc.typewriter_font_name = str;
2464 str = fl_get_input(dialog_->input_screen_encoding);
2465 if (lyxrc.font_norm != str) {
2467 lyxrc.font_norm = str;
2470 bool button = fl_get_button(dialog_->check_scalable);
2471 if (lyxrc.use_scalable_fonts != button) {
2473 lyxrc.use_scalable_fonts = button;
2476 unsigned int ivalue = static_cast<unsigned int>
2477 (fl_get_counter_value(dialog_->counter_zoom));
2478 if (lyxrc.zoom != ivalue) {
2480 lyxrc.zoom = ivalue;
2483 ivalue = static_cast<unsigned int>
2484 (fl_get_counter_value(dialog_->counter_dpi));
2485 if (lyxrc.dpi != ivalue) {
2490 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2491 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2493 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2496 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2497 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2499 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2502 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2503 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2505 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2508 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2509 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2511 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2514 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2515 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2517 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2520 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2521 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2523 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2526 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2527 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2529 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2532 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2533 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2535 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2538 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2539 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2541 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2544 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2545 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2547 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2551 // Now update the buffers
2552 // Can anything below here affect the redraw process?
2553 parent_.lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
2558 void FormPreferences::ScreenFonts::build()
2560 dialog_.reset(parent_.build_screen_fonts());
2562 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2563 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2565 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2566 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2567 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2568 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2569 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2570 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2571 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2572 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2573 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2574 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2575 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2576 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2577 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2578 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2579 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2580 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2582 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2583 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2584 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2585 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2586 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2587 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2588 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2589 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2590 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2591 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2593 // set up the feedback mechanism
2594 setPreHandler(dialog_->input_roman);
2595 setPreHandler(dialog_->input_sans);
2596 setPreHandler(dialog_->input_typewriter);
2597 setPreHandler(dialog_->counter_zoom);
2598 setPreHandler(dialog_->counter_dpi);
2599 setPreHandler(dialog_->check_scalable);
2600 setPreHandler(dialog_->input_screen_encoding);
2601 setPreHandler(dialog_->input_tiny);
2602 setPreHandler(dialog_->input_script);
2603 setPreHandler(dialog_->input_footnote);
2604 setPreHandler(dialog_->input_small);
2605 setPreHandler(dialog_->input_large);
2606 setPreHandler(dialog_->input_larger);
2607 setPreHandler(dialog_->input_largest);
2608 setPreHandler(dialog_->input_normal);
2609 setPreHandler(dialog_->input_huge);
2610 setPreHandler(dialog_->input_huger);
2615 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2619 if (ob == dialog_->input_roman)
2620 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2621 else if (ob == dialog_->input_sans)
2622 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2623 else if (ob == dialog_->input_typewriter)
2624 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2625 else if (ob == dialog_->check_scalable)
2626 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2627 else if (ob == dialog_->input_screen_encoding)
2628 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2629 else if (ob == dialog_->counter_zoom)
2630 str = lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2631 else if (ob == dialog_->counter_dpi)
2632 str = lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2633 else if (ob == dialog_->input_tiny
2634 || ob == dialog_->input_script
2635 || ob == dialog_->input_footnote
2636 || ob == dialog_->input_small
2637 || ob == dialog_->input_large
2638 || ob == dialog_->input_larger
2639 || ob == dialog_->input_larger
2640 || ob == dialog_->input_largest
2641 || ob == dialog_->input_normal
2642 || ob == dialog_->input_huge
2643 || ob == dialog_->input_huger)
2644 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2650 bool FormPreferences::ScreenFonts::input()
2652 bool activate = true;
2655 // Make sure that all fonts all have positive entries
2656 // Also note that an empty entry is returned as 0.0 by strToDbl
2657 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2658 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2659 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2660 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2661 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2662 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2663 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2664 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2665 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2666 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2668 str = N_("Fonts must be positive!");
2670 // Fontsizes -- tiny < script < footnote etc.
2671 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2672 strToDbl(fl_get_input(dialog_->input_script)) ||
2673 strToDbl(fl_get_input(dialog_->input_script)) >
2674 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2675 strToDbl(fl_get_input(dialog_->input_footnote)) >
2676 strToDbl(fl_get_input(dialog_->input_small)) ||
2677 strToDbl(fl_get_input(dialog_->input_small)) >
2678 strToDbl(fl_get_input(dialog_->input_normal)) ||
2679 strToDbl(fl_get_input(dialog_->input_normal)) >
2680 strToDbl(fl_get_input(dialog_->input_large)) ||
2681 strToDbl(fl_get_input(dialog_->input_large)) >
2682 strToDbl(fl_get_input(dialog_->input_larger)) ||
2683 strToDbl(fl_get_input(dialog_->input_larger)) >
2684 strToDbl(fl_get_input(dialog_->input_largest)) ||
2685 strToDbl(fl_get_input(dialog_->input_largest)) >
2686 strToDbl(fl_get_input(dialog_->input_huge)) ||
2687 strToDbl(fl_get_input(dialog_->input_huge)) >
2688 strToDbl(fl_get_input(dialog_->input_huger))) {
2691 str = N_("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2695 parent_.printWarning(str);
2701 void FormPreferences::ScreenFonts::update()
2703 fl_set_input(dialog_->input_roman,
2704 lyxrc.roman_font_name.c_str());
2705 fl_set_input(dialog_->input_sans,
2706 lyxrc.sans_font_name.c_str());
2707 fl_set_input(dialog_->input_typewriter,
2708 lyxrc.typewriter_font_name.c_str());
2709 fl_set_input(dialog_->input_screen_encoding,
2710 lyxrc.font_norm.c_str());
2711 fl_set_button(dialog_->check_scalable,
2712 lyxrc.use_scalable_fonts);
2713 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2714 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2715 fl_set_input(dialog_->input_tiny,
2716 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2717 fl_set_input(dialog_->input_script,
2718 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2719 fl_set_input(dialog_->input_footnote,
2720 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2721 fl_set_input(dialog_->input_small,
2722 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2723 fl_set_input(dialog_->input_normal,
2724 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2725 fl_set_input(dialog_->input_large,
2726 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2727 fl_set_input(dialog_->input_larger,
2728 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2729 fl_set_input(dialog_->input_largest,
2730 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2731 fl_set_input(dialog_->input_huge,
2732 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2733 fl_set_input(dialog_->input_huger,
2734 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2739 FormPreferences::SpellChecker::SpellChecker( FormPreferences & p )
2744 FD_form_spellchecker const * FormPreferences::SpellChecker::dialog()
2746 return dialog_.get();
2750 void FormPreferences::SpellChecker::apply()
2753 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2754 choice = strip(frontStrip(choice));
2756 lyxrc.isp_command = choice;
2758 // If spell checker == "none", all other input set to off.
2759 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2760 lyxrc.isp_use_alt_lang = false;
2761 lyxrc.isp_alt_lang.erase();
2763 lyxrc.isp_use_esc_chars = false;
2764 lyxrc.isp_esc_chars.erase();
2766 lyxrc.isp_use_pers_dict = false;
2767 lyxrc.isp_pers_dict.erase();
2769 lyxrc.isp_accept_compound = false;
2770 lyxrc.isp_use_input_encoding = false;
2772 int button = fl_get_button(dialog_->check_alt_lang);
2773 choice = fl_get_input(dialog_->input_alt_lang);
2774 if (button && choice.empty()) button = 0;
2775 if (!button) choice.erase();
2777 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2778 lyxrc.isp_alt_lang = choice;
2780 button = fl_get_button(dialog_->check_escape_chars);
2781 choice = fl_get_input(dialog_->input_escape_chars);
2782 if (button && choice.empty()) button = 0;
2783 if (!button) choice.erase();
2785 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2786 lyxrc.isp_esc_chars = choice;
2788 button = fl_get_button(dialog_->check_personal_dict);
2789 choice = fl_get_input(dialog_->input_personal_dict);
2790 if (button && choice.empty()) button = 0;
2791 if (!button) choice.erase();
2793 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2794 lyxrc.isp_pers_dict = choice;
2796 button = fl_get_button(dialog_->check_compound_words);
2797 lyxrc.isp_accept_compound = static_cast<bool>(button);
2799 button = fl_get_button(dialog_->check_input_enc);
2800 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2808 void FormPreferences::SpellChecker::build()
2810 dialog_.reset(parent_.build_spellchecker());
2812 fl_addto_choice(dialog_->choice_spell_command,
2813 _(" none | ispell | aspell "));
2814 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2815 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2816 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2818 // set up the feedback mechanism
2819 setPreHandler(dialog_->choice_spell_command);
2820 setPreHandler(dialog_->check_alt_lang);
2821 setPreHandler(dialog_->input_alt_lang);
2822 setPreHandler(dialog_->check_escape_chars);
2823 setPreHandler(dialog_->input_escape_chars);
2824 setPreHandler(dialog_->check_personal_dict);
2825 setPreHandler(dialog_->input_personal_dict);
2826 setPreHandler(dialog_->button_personal_dict);
2827 setPreHandler(dialog_->check_compound_words);
2828 setPreHandler(dialog_->check_input_enc);
2833 FormPreferences::SpellChecker::feedback(FL_OBJECT const * const ob) const
2837 if (ob == dialog_->choice_spell_command)
2838 str = lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2839 else if (ob == dialog_->check_alt_lang)
2840 str = lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2841 else if (ob == dialog_->input_alt_lang)
2842 str = lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2843 else if (ob == dialog_->check_escape_chars)
2844 str = lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2845 else if (ob == dialog_->input_escape_chars)
2846 str = lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2847 else if (ob == dialog_->check_personal_dict)
2848 str = lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2849 else if (ob == dialog_->input_personal_dict)
2850 str = lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2851 else if (ob == dialog_->check_compound_words)
2852 str = lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2853 else if (ob == dialog_->check_input_enc)
2854 str = lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2860 bool FormPreferences::SpellChecker::input(FL_OBJECT const * const ob)
2862 // !ob if function is called from updateSpellChecker() to de/activate
2864 // otherwise the function is called by an xforms CB via input().
2866 // If spell checker == "none", disable all input.
2867 if (!ob || ob == dialog_->choice_spell_command) {
2868 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2869 fl_deactivate_object(dialog_->check_alt_lang);
2870 fl_deactivate_object(dialog_->input_alt_lang);
2871 fl_deactivate_object(dialog_->check_escape_chars);
2872 fl_deactivate_object(dialog_->input_escape_chars);
2873 fl_deactivate_object(dialog_->check_personal_dict);
2874 fl_deactivate_object(dialog_->input_personal_dict);
2875 fl_deactivate_object(dialog_->check_compound_words);
2876 fl_deactivate_object(dialog_->check_input_enc);
2879 fl_activate_object(dialog_->check_alt_lang);
2880 fl_activate_object(dialog_->check_escape_chars);
2881 fl_activate_object(dialog_->check_personal_dict);
2882 fl_activate_object(dialog_->check_compound_words);
2883 fl_activate_object(dialog_->check_input_enc);
2887 if (!ob || ob == dialog_->check_alt_lang) {
2888 bool const enable = fl_get_button(dialog_->check_alt_lang);
2889 setEnabled(dialog_->input_alt_lang, enable);
2892 if (!ob || ob == dialog_->check_escape_chars) {
2893 bool const enable = fl_get_button(dialog_->check_escape_chars);
2894 setEnabled(dialog_->input_escape_chars, enable);
2897 if (!ob || ob == dialog_->check_personal_dict) {
2898 bool const enable = fl_get_button(dialog_->check_personal_dict);
2899 setEnabled(dialog_->input_personal_dict, enable);
2902 if (ob == dialog_->button_personal_dict) {
2903 parent_.browse(dialog_->input_personal_dict,
2904 N_("Personal dictionary"), "*.ispell",
2905 make_pair(string(), string()),
2906 make_pair(string(), string()));
2909 return true; // All input is valid!
2913 void FormPreferences::SpellChecker::update()
2916 if (lyxrc.isp_command == "none")
2918 else if (lyxrc.isp_command == "ispell")
2920 else if (lyxrc.isp_command == "aspell")
2922 fl_set_choice(dialog_->choice_spell_command, choice);
2925 if (lyxrc.isp_use_alt_lang) str = lyxrc.isp_alt_lang;
2927 fl_set_button(dialog_->check_alt_lang,
2928 lyxrc.isp_use_alt_lang);
2929 fl_set_input(dialog_->input_alt_lang, str.c_str());
2932 if (lyxrc.isp_use_esc_chars) str = lyxrc.isp_esc_chars;
2934 fl_set_button(dialog_->check_escape_chars,
2935 lyxrc.isp_use_esc_chars);
2936 fl_set_input(dialog_->input_escape_chars, str.c_str());
2939 if (lyxrc.isp_use_pers_dict) str = lyxrc.isp_pers_dict;
2941 fl_set_button(dialog_->check_personal_dict,
2942 lyxrc.isp_use_pers_dict);
2943 fl_set_input(dialog_->input_personal_dict, str.c_str());
2945 fl_set_button(dialog_->check_compound_words,
2946 lyxrc.isp_accept_compound);
2947 fl_set_button(dialog_->check_input_enc,
2948 lyxrc.isp_use_input_encoding);
2950 // Activate/Deactivate the input fields dependent on the state of the
2956 void FormPreferences::printWarning(string const & warning)
2958 warningPosted = true;
2960 string str = _("WARNING!") + string(" ") + warning;
2961 str = formatted(str, dialog_->text_warning->w-10, FL_SMALL_SIZE);
2963 fl_set_object_label(dialog_->text_warning, str.c_str());
2964 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2968 void FormPreferences::browse(FL_OBJECT * inpt,
2969 string const & title,
2970 string const & pattern,
2971 pair<string,string> const & dir1,
2972 pair<string,string> const & dir2)
2974 // Get the filename from the dialog
2975 string const filename = fl_get_input(inpt);
2977 // Show the file browser dialog
2978 string const new_filename =
2979 browseFile(lv_, filename, title, pattern, dir1, dir2);
2981 // Save the filename to the dialog
2982 if (new_filename != filename && !new_filename.empty()) {
2983 fl_set_input(inpt, new_filename.c_str());
2989 // C function wrapper, required by xforms.
2990 extern "C" int C_FormPreferencesFeedbackCB(FL_OBJECT * ob, int event,
2991 FL_Coord mx, FL_Coord my,
2992 int key, void * xev)
2994 return FormPreferences::FeedbackCB(ob, event, mx, my, key, xev);
2997 int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event,
2998 FL_Coord, FL_Coord, int, void *)
3000 // Note that the return value is important in the pre-emptive handler.
3001 // Don't return anything other than 0.
3004 // Don't Assert this one, as it can happen quite reasonably when things
3005 // are being deleted in the d-tor.
3007 if (!ob->form) return 0;
3009 FormPreferences * pre =
3010 static_cast<FormPreferences*>(ob->form->u_vdata);
3011 pre->Feedback(ob, event);
3016 // preemptive handler for feedback messages
3017 void FormPreferences::Feedback(FL_OBJECT * ob, int event)
3023 warningPosted = false;
3029 fl_set_object_label(dialog_->text_warning, "");
3038 void FormPreferences::setPreHandler(FL_OBJECT * ob)
3041 fl_set_object_prehandler(ob, C_FormPreferencesFeedbackCB);