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"
56 extern string system_lyxdir;
57 extern string user_lyxdir;
58 extern Languages languages;
60 // These should probably go inside the class definition...
61 static Formats local_formats;
62 static Converters local_converters;
64 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
65 : FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
67 converters_tab_(0), inputs_tab_(0), look_n_feel_tab_(0),
68 outputs_tab_(0), lang_opts_tab_(0),
70 colors_(*this), converters_(*this), inputs_misc_(*this),
71 formats_(*this), interface_(*this), language_(*this),
72 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
73 printer_(*this), screen_fonts_(*this), spellchecker_(*this)
75 // let the dialog be shown
76 // This is a permanent connection so we won't bother
77 // storing a copy because we won't be disconnecting.
78 d->showPreferences.connect(slot(this, &FormPreferences::show));
82 FormPreferences::~FormPreferences()
84 delete converters_tab_;
86 delete look_n_feel_tab_;
88 delete lang_opts_tab_;
94 void FormPreferences::connect()
96 fl_set_form_maxsize( dialog_->form, minw_, minh_ );
98 FormBaseBI::connect();
102 void FormPreferences::disconnect()
104 // colors_->disconnect();
105 // converters_->disconnect(); //local_converters.Clear();
106 // formats_->disconnect(); //local_formats.Clear();
108 FormBaseBI::disconnect();
112 void FormPreferences::redraw()
114 if (!(form() && form()->visible))
116 fl_redraw_form(form());
118 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
119 if (!(form2 && form2->visible))
121 fl_redraw_form(form2);
124 if (form2 == converters_tab_->form)
125 form3 = fl_get_active_folder(converters_tab_->tabfolder_outer);
127 else if (form2 == look_n_feel_tab_->form)
128 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_outer);
130 else if (form2 == inputs_tab_->form)
131 form3 = fl_get_active_folder(inputs_tab_->tabfolder_outer);
133 else if (form2 == outputs_tab_->form)
134 form3 = fl_get_active_folder(outputs_tab_->tabfolder_outer);
136 else if (form2 == lang_opts_tab_->form)
137 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_outer);
139 if (form3 && form3->visible)
140 fl_redraw_form(form3);
144 FL_FORM * FormPreferences::form() const
146 if (dialog_) return dialog_->form;
151 void FormPreferences::ok()
155 if (colors_.modifiedXformsPrefs) {
156 string const filename =
157 AddName(user_lyxdir, "preferences.xform");
158 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
161 lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
165 void FormPreferences::hide()
167 // We need to hide the active tabfolder otherwise we get a
168 // BadDrawable error from X windows and LyX crashes without saving.
169 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
171 && outer_form->visible) {
172 fl_hide_form(outer_form);
178 void FormPreferences::build()
180 dialog_ = build_preferences();
182 // Manage the restore, save, apply and cancel/close buttons
183 bc_.setOK(dialog_->button_ok);
184 bc_.setApply(dialog_->button_apply);
185 bc_.setCancel(dialog_->button_cancel);
186 bc_.setUndoAll(dialog_->button_restore);
189 // Workaround dumb xforms sizing bug
193 // build the tab folders
194 converters_tab_ = build_outer_tab();
195 look_n_feel_tab_ = build_outer_tab();
196 inputs_tab_ = build_outer_tab();
197 outputs_tab_ = build_outer_tab();
198 lang_opts_tab_ = build_outer_tab();
200 // build actual tabfolder contents
201 // these will become nested tabfolders
205 inputs_misc_.build();
209 outputs_misc_.build();
212 screen_fonts_.build();
213 spellchecker_.build();
215 // Now add them to the tabfolder
216 fl_addto_tabfolder(dialog_->tabfolder_prefs,
218 look_n_feel_tab_->form);
219 fl_addto_tabfolder(dialog_->tabfolder_prefs,
221 lang_opts_tab_->form);
222 fl_addto_tabfolder(dialog_->tabfolder_prefs,
224 converters_tab_->form);
225 fl_addto_tabfolder(dialog_->tabfolder_prefs,
228 fl_addto_tabfolder(dialog_->tabfolder_prefs,
232 // now build the nested tabfolders
233 // Starting with look and feel
234 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
236 screen_fonts_.dialog()->form);
237 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
239 interface_.dialog()->form);
240 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
242 colors_.dialog()->form);
243 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
245 lnf_misc_.dialog()->form);
247 // then build converters
248 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
250 formats_.dialog()->form);
251 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
253 converters_.dialog()->form);
256 // Paths should probably go in a few outer_tab called Files
257 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
259 paths_.dialog()->form);
260 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
262 inputs_misc_.dialog()->form);
264 // then building outputs
265 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
267 printer_.dialog()->form);
268 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
270 outputs_misc_.dialog()->form);
272 // then building usage
273 fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
275 spellchecker_.dialog()->form);
276 fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
278 language_.dialog()->form);
282 void FormPreferences::apply()
284 // set the new lyxrc entries
285 // many of these need to trigger other functions when the assignment
286 // is made. For example, screen zoom and font types. These could be
287 // handled either by signals/slots in lyxrc or just directly call the
288 // associated functions here.
289 // There are other problems with this scheme. We really should check
290 // what we copy to make sure that it really is necessary to do things
291 // like update the screen fonts because that flushes the textcache
292 // and other stuff which may cost us a lot on slower/high-load
296 formats_.apply(); // Must be before converters_.apply()
298 inputs_misc_.apply();
302 outputs_misc_.apply();
305 screen_fonts_.apply();
306 spellchecker_.apply();
310 void FormPreferences::feedback(FL_OBJECT * ob)
316 if (ob->form->fdui == colors_.dialog()) {
317 str = colors_.feedback(ob);
318 } else if (ob->form->fdui == converters_.dialog()) {
319 str = converters_.feedback(ob);
320 } else if (ob->form->fdui == formats_.dialog()) {
321 str = formats_.feedback(ob);
322 } else if (ob->form->fdui == inputs_misc_.dialog()) {
323 str = inputs_misc_.feedback(ob);
324 } else if (ob->form->fdui == interface_.dialog()) {
325 str = interface_.feedback(ob);
326 } else if (ob->form->fdui == language_.dialog()) {
327 str = language_.feedback(ob);
328 } else if (ob->form->fdui == lnf_misc_.dialog()) {
329 str = lnf_misc_.feedback(ob);
330 } else if (ob->form->fdui == outputs_misc_.dialog()) {
331 str = outputs_misc_.feedback(ob);
332 } else if (ob->form->fdui == paths_.dialog()) {
333 str = paths_.feedback(ob);
334 } else if (ob->form->fdui == printer_.dialog()) {
335 str = printer_.feedback(ob);
336 } else if (ob->form->fdui == screen_fonts_.dialog()) {
337 str = screen_fonts_.feedback(ob);
338 } else if (ob->form->fdui == spellchecker_.dialog()) {
339 str = spellchecker_.feedback(ob);
342 str = formatted(_(str), dialog_->text_warning->w-10,
343 FL_SMALL_SIZE, FL_NORMAL_STYLE);
345 fl_set_object_label(dialog_->text_warning, str.c_str());
346 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
350 bool FormPreferences::input(FL_OBJECT * ob, long)
354 // whatever checks you need to ensure the user hasn't entered
355 // some totally ridiculous value somewhere. Change activate to suit.
356 // comments before each test describe what is _valid_
358 if (ob->form->fdui == colors_.dialog()) {
361 } else if (ob->form->fdui == converters_.dialog())
362 return converters_.input(ob);
363 else if (ob->form->fdui == formats_.dialog())
364 return formats_.input(ob);
365 else if (ob->form->fdui == interface_.dialog())
366 return interface_.input(ob);
367 else if (ob->form->fdui == language_.dialog())
368 return language_.input(ob);
369 else if (ob->form->fdui == paths_.dialog())
370 return paths_.input(ob);
371 else if (ob->form->fdui == screen_fonts_.dialog())
372 return screen_fonts_.input();
373 else if (ob->form->fdui == spellchecker_.dialog())
374 return spellchecker_.input(ob);
380 void FormPreferences::update()
382 if (!dialog_) return;
384 // read lyxrc entries
386 formats_.update(); // Must be before converters_.update()
387 converters_.update();
388 inputs_misc_.update();
392 outputs_misc_.update();
395 screen_fonts_.update();
396 spellchecker_.update();
400 FormPreferences::Colors::~Colors()
406 void FormPreferences::Colors::apply()
408 bool modifiedText = false;
409 bool modifiedBackground = false;
411 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
412 cit != xformsColorDB.end(); ++cit) {
414 fl_getmcolor((*cit).colorID, &col.r, &col.g, &col.b);
415 if (col != (*cit).color()) {
416 modifiedXformsPrefs = true;
417 if ((*cit).colorID == FL_BLACK)
419 if ((*cit).colorID == FL_COL1)
420 modifiedBackground = true;
424 if (modifiedXformsPrefs) {
425 for (vector<XformsColor>::const_iterator cit =
426 xformsColorDB.begin();
427 cit != xformsColorDB.end(); ++cit) {
428 fl_mapcolor((*cit).colorID,
429 (*cit).r, (*cit).g, (*cit).b);
431 if (modifiedText && (*cit).colorID == FL_BLACK) {
432 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
435 if (modifiedBackground && (*cit).colorID == FL_COL1) {
436 AdjustVal(FL_MCOL, FL_COL1, 0.1);
437 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
438 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
440 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
441 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
444 if ((*cit).colorID == GUI_COLOR_CURSOR) {
445 fl_mapcolor(GUI_COLOR_CURSOR,
446 (*cit).r, (*cit).g, (*cit).b);
447 fl_set_cursor_color(FL_DEFAULT_CURSOR,
448 GUI_COLOR_CURSOR, FL_WHITE);
451 Dialogs::redrawGUI();
454 // Now do the same for the LyX LColors...
455 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
456 cit != lyxColorDB.end(); ++cit) {
457 LColor::color lc = lcolor.getFromGUIName((*cit).getname());
458 if (lc == LColor::inherit) continue;
460 // Create a valid X11 name of the form "#rrggbb"
461 string const hexname = X11hexname((*cit).color());
463 if (lcolor.getX11Name(lc) != hexname) {
465 << "FormPreferences::Colors::apply: "
466 << "resetting LColor " << lcolor.getGUIName(lc)
467 << " from \"" << lcolor.getX11Name(lc)
468 << "\" to \"" << hexname << "\"."
471 string const s = lcolor.getLyXName(lc) + string(" ") +
473 parent_.lv_->getLyXFunc()->Dispatch(LFUN_SET_COLOR, s);
479 void FormPreferences::Colors::build()
481 dialog_ = parent_.build_colors();
483 fl_set_object_color(dialog_->button_color,
484 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
486 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
487 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
488 fl_set_dial_step(dialog_->dial_hue, 1.0);
489 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
491 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
492 fl_set_slider_step(dialog_->slider_saturation, 0.01);
493 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
495 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
496 fl_set_slider_step(dialog_->slider_value, 0.01);
497 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
499 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
500 fl_set_slider_step(dialog_->slider_red, 1.0);
501 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
503 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
504 fl_set_slider_step(dialog_->slider_green, 1.0);
505 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
507 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
508 fl_set_slider_step(dialog_->slider_blue, 1.0);
509 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
511 // set up the feedback mechanism
512 setPreHandler(dialog_->browser_lyx_objs);
513 setPreHandler(dialog_->button_color);
514 setPreHandler(dialog_->button_modify);
515 setPreHandler(dialog_->dial_hue);
516 setPreHandler(dialog_->slider_saturation);
517 setPreHandler(dialog_->slider_value);
518 setPreHandler(dialog_->slider_red);
519 setPreHandler(dialog_->slider_green);
520 setPreHandler(dialog_->slider_blue);
521 setPreHandler(dialog_->button_colorspace);
525 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
529 if (ob == dialog_->browser_lyx_objs) {
530 str = N_("LyX objects that can be assigned a color.");
532 } else if (ob == dialog_->button_modify) {
533 str = N_("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
535 } else if (ob == dialog_->dial_hue ||
536 ob == dialog_->slider_saturation ||
537 ob == dialog_->slider_value ||
538 ob == dialog_->slider_red ||
539 ob == dialog_->slider_green ||
540 ob == dialog_->slider_blue) {
541 str = N_("Find a new color.");
543 } else if (ob == dialog_->button_colorspace) {
544 str = N_("Toggle between RGB and HSV color spaces.");
551 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
553 if (ob == dialog_->browser_lyx_objs) {
556 } else if (ob == dialog_->dial_hue ||
557 ob == dialog_->slider_saturation ||
558 ob == dialog_->slider_value) {
561 } else if (ob == dialog_->slider_red ||
562 ob == dialog_->slider_green ||
563 ob == dialog_->slider_blue) {
566 } else if (ob == dialog_->button_colorspace) {
569 } else if (ob == dialog_->button_modify) {
575 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
579 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
583 hsv.v = min( 1.0, max(0.0, hsv.v) );
586 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
590 void FormPreferences::Colors::InputBrowserLyX() const
592 vector<NamedColor>::size_type const selLyX =
593 fl_get_browser(dialog_->browser_lyx_objs);
594 if (selLyX < 1) return;
596 // Is the choice an Xforms color...
599 if( selLyX-1 < xformsColorDB.size() ) {
600 vector<XformsColor>::size_type const i = selLyX - 1;
601 col = xformsColorDB[i].color();
603 // or a LyX Logical color?
605 vector<NamedColor>::size_type const i = selLyX - 1 -
606 xformsColorDB.size();
607 col = lyxColorDB[i].color();
610 fl_freeze_form(dialog_->form);
612 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
613 fl_redraw_object(dialog_->button_color);
615 // Display either RGB or HSV but not both!
618 // Deactivate the modify button to begin with...
619 setEnabled(dialog_->button_modify, false);
621 fl_unfreeze_form(dialog_->form);
625 void FormPreferences::Colors::InputHSV()
627 double const hue = fl_get_dial_value(dialog_->dial_hue);
628 double const sat = fl_get_slider_value(dialog_->slider_saturation);
629 double const val = fl_get_slider_value(dialog_->slider_value);
631 int const h = int(hue);
632 int const s = int(100.0 * sat);
633 int const v = int(100.0 * val);
635 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
637 fl_set_object_label(dialog_->text_color_values, label.c_str());
639 RGBColor col = HSVColor(hue, sat, val);
641 fl_freeze_form(dialog_->form);
643 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
644 fl_redraw_object(dialog_->button_color);
646 col = HSVColor(hue, 1.0, 1.0);
647 col.r = max(col.r, 0);
648 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
649 fl_redraw_object(dialog_->dial_hue);
651 // Ascertain whether to activate the Modify button.
652 vector<NamedColor>::size_type const selLyX =
653 fl_get_browser(dialog_->browser_lyx_objs);
655 fl_unfreeze_form(dialog_->form);
656 if (selLyX < 1) return;
658 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
661 // Is the choice an Xforms color...
662 if( selLyX-1 < xformsColorDB.size() ) {
663 vector<XformsColor>::size_type const i = selLyX - 1;
664 modify = (xformsColorDB[i].color() != col);
666 // or a LyX Logical color?
668 vector<NamedColor>::size_type const i = selLyX - 1 -
669 xformsColorDB.size();
670 modify = (lyxColorDB[i].color() != col);
673 setEnabled(dialog_->button_modify, modify);
677 void FormPreferences::Colors::InputRGB()
679 int const red = int(fl_get_slider_value(dialog_->slider_red));
680 int const green = int(fl_get_slider_value(dialog_->slider_green));
681 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
683 string const label = tostr(red) + string(", ") + tostr(green) +
684 string(", ") + tostr(blue);
685 fl_set_object_label(dialog_->text_color_values, label.c_str());
687 fl_freeze_form(dialog_->form);
689 RGBColor col = RGBColor(red, green, blue);
690 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
691 fl_redraw_object(dialog_->button_color);
693 // Ascertain whether to activate the Modify button.
694 vector<NamedColor>::size_type const selLyX =
695 fl_get_browser(dialog_->browser_lyx_objs);
697 fl_unfreeze_form(dialog_->form);
698 if (selLyX < 1) return;
702 // Is the choice an Xforms color...
703 if( selLyX-1 < xformsColorDB.size() ) {
704 vector<XformsColor>::size_type const i = selLyX - 1;
705 modify = (xformsColorDB[i].color() != col);
707 // or a LyX Logical color?
709 vector<NamedColor>::size_type const i = selLyX - 1 -
710 xformsColorDB.size();
711 modify = (lyxColorDB[i].color() != col);
714 setEnabled(dialog_->button_modify, modify);
718 void FormPreferences::Colors::LoadBrowserLyX()
720 if (!dialog_->browser_lyx_objs->visible) return;
722 // First, define the modifiable xforms colors
723 xformsColorDB.clear();
726 xcol.name = _("GUI background");
727 xcol.colorID = FL_COL1;
728 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
730 xformsColorDB.push_back(xcol);
732 xcol.name = _("GUI text");
733 xcol.colorID = FL_BLACK;
734 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
736 fl_mapcolor(GUI_COLOR_CURSOR, xcol.r, xcol.g, xcol.b);
737 fl_set_cursor_color(FL_DEFAULT_CURSOR, GUI_COLOR_CURSOR, FL_WHITE);
739 xformsColorDB.push_back(xcol);
741 xcol.name = _("GUI selection");
742 xcol.colorID = FL_YELLOW;
743 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
745 xformsColorDB.push_back(xcol);
747 xcol.name = _("GUI pointer");
748 xcol.colorID = GUI_COLOR_CURSOR;
749 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
751 xformsColorDB.push_back(xcol);
753 // Now create the the LyX LColors database
755 for (int i=0; i<LColor::ignore; ++i) {
756 LColor::color lc = static_cast<LColor::color>(i);
757 if (lc == LColor::none
758 || lc == LColor::black
759 || lc == LColor::white
761 || lc == LColor::green
762 || lc == LColor::blue
763 || lc == LColor::cyan
764 || lc == LColor::magenta
765 || lc == LColor::yellow
766 || lc == LColor::inherit
767 || lc == LColor::ignore) continue;
769 string const name = lcolor.getX11Name(lc);
770 Display * display = fl_get_display();;
771 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
774 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
776 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
777 << "LColor " << lcolor.getLyXName(lc)
778 << ": X can't find color \"" << name
779 << "\". Set to \"black\"!" << endl;
781 string const arg = lcolor.getLyXName(lc) + " black";
782 parent_.lv_->getLyXFunc()->
783 Dispatch(LFUN_SET_COLOR, arg);
787 // X has found the color. Now find the "appropriate" X11 name
790 // Note that X stores the RGB values in the range 0 - 65535
791 // whilst we require them in the range 0 - 255.
793 col.r = xcol.red / 256;
794 col.g = xcol.green / 256;
795 col.b = xcol.blue / 256;
797 // Create a valid X11 name of the form "#rrggbb" and change the
798 // LColor X11name to this. Don't want to trigger a redraw,
799 // as we're just changing the name not the RGB values.
800 // Also reset the system_lcolor names, so that we don't output
801 // unnecessary changes.
802 string const hexname = X11hexname(col);
804 if (lcolor.getX11Name(lc) != hexname) {
805 lcolor.setColor(lc, hexname);
806 system_lcolor.setColor(lc, hexname);
809 // Finally, push the color onto the database
810 NamedColor ncol(lcolor.getGUIName(lc), col);
811 lyxColorDB.push_back(ncol);
814 // Now construct the browser
815 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
816 fl_freeze_form(dialog_->form);
817 fl_clear_browser(colbr);
818 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
819 cit != xformsColorDB.end(); ++cit) {
820 fl_addto_browser(colbr, (*cit).getname().c_str());
822 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
823 cit != lyxColorDB.end(); ++cit) {
824 fl_addto_browser(colbr, (*cit).getname().c_str());
827 // just to be safe...
828 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
829 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
830 fl_unfreeze_form(dialog_->form);
836 void FormPreferences::Colors::Modify()
838 vector<NamedColor>::size_type const selLyX =
839 fl_get_browser(dialog_->browser_lyx_objs);
840 if (selLyX < 1) return;
843 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
845 // Is the choice an Xforms color...
846 if( selLyX-1 < xformsColorDB.size() ) {
847 vector<XformsColor>::size_type const i = selLyX - 1;
848 xformsColorDB[i].r = col.r;
849 xformsColorDB[i].g = col.g;
850 xformsColorDB[i].b = col.b;
852 // or a LyX Logical color?
854 vector<NamedColor>::size_type const i = selLyX - 1 -
855 xformsColorDB.size();
856 lyxColorDB[i].r = col.r;
857 lyxColorDB[i].g = col.g;
858 lyxColorDB[i].b = col.b;
861 fl_freeze_form(dialog_->form);
862 setEnabled(dialog_->button_modify, false);
863 fl_unfreeze_form(dialog_->form);
867 void FormPreferences::Colors::SwitchColorSpace() const
869 bool const pressed = fl_get_button(dialog_->button_colorspace);
872 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
874 fl_freeze_form(dialog_->form);
877 fl_set_object_label(dialog_->button_colorspace, _("HSV"));
879 fl_hide_object(dialog_->slider_red);
880 fl_hide_object(dialog_->slider_blue);
881 fl_hide_object(dialog_->slider_green);
882 fl_show_object(dialog_->dial_hue);
883 fl_show_object(dialog_->slider_saturation);
884 fl_show_object(dialog_->slider_value);
886 HSVColor hsv = HSVColor(col);
887 hsv.h = max(hsv.h, 0.0);
889 fl_set_dial_value(dialog_->dial_hue, hsv.h);
890 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
891 fl_set_slider_value(dialog_->slider_value, hsv.v);
893 col = HSVColor(hsv.h, 1.0, 1.0);
894 col.r = max(col.r,0);
895 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
896 fl_redraw_object(dialog_->dial_hue);
898 // Adjust the label a bit, but not the actual values.
899 // Means that toggling from one space to the other has no
900 // effect on the final color.
901 int const h = int(hsv.h);
902 int const s = int(100*hsv.s);
903 int const v = int(100*hsv.v);
904 string const label = tostr(h) + string(", ") + tostr(s) +
905 string(", ") + tostr(v);
906 fl_set_object_label(dialog_->text_color_values, label.c_str());
909 fl_set_object_label(dialog_->button_colorspace, _("RGB"));
911 fl_show_object(dialog_->slider_red);
912 fl_show_object(dialog_->slider_blue);
913 fl_show_object(dialog_->slider_green);
914 fl_hide_object(dialog_->dial_hue);
915 fl_hide_object(dialog_->slider_saturation);
916 fl_hide_object(dialog_->slider_value);
918 fl_set_slider_value(dialog_->slider_red, col.r);
919 fl_set_slider_value(dialog_->slider_green, col.g);
920 fl_set_slider_value(dialog_->slider_blue, col.b);
922 // Adjust the label a bit. Same reasoning as above.
923 int const r = int(col.r);
924 int const g = int(col.g);
925 int const b = int(col.b);
926 string const label = tostr(r) + string(", ") + tostr(g) +
927 string(", ") + tostr(b);
928 fl_set_object_label(dialog_->text_color_values, label.c_str());
931 fl_unfreeze_form(dialog_->form);
934 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
938 ostr << "#" << std::setbase(16) << std::setfill('0')
939 << std::setw(2) << col.r
940 << std::setw(2) << col.g
941 << std::setw(2) << col.b;
943 return ostr.str().c_str();
947 FormPreferences::Converters::~Converters()
953 void FormPreferences::Converters::apply() const
955 converters = local_converters;
956 converters.Update(formats);
957 converters.BuildGraph();
961 void FormPreferences::Converters::build()
963 dialog_ = parent_.build_converters();
965 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
966 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
968 // set up the feedback mechanism
969 setPreHandler(dialog_->browser_all);
970 setPreHandler(dialog_->button_delete);
971 setPreHandler(dialog_->button_add);
972 setPreHandler(dialog_->input_converter);
973 setPreHandler(dialog_->choice_from);
974 setPreHandler(dialog_->choice_to);
975 setPreHandler(dialog_->input_flags);
980 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
984 if (ob == dialog_->browser_all) {
985 str = N_("All the currently defined converters known to LyX.");
986 } else if (ob == dialog_->choice_from) {
987 str = N_("Convert \"from\" this format");
988 } else if (ob == dialog_->choice_to) {
989 str = N_("Convert \"to\" this format");
990 } else if (ob == dialog_->input_converter) {
991 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.");
992 } else if (ob == dialog_->input_flags) {
993 str = N_("Flags that control the converter behavior");
994 } else if (ob == dialog_->button_delete) {
995 str = N_("Remove the current converter from the list of available converters. Note: you must then \"Apply\" the change.");
996 } else if (ob == dialog_->button_add) {
997 if (string(ob->label) == _("Add"))
998 str = N_("Add the current converter to the list of available converters. Note: you must then \"Apply\" the change.");
1000 str = N_("Modify the contents of the current converter. Note: you must then \"Apply\" the change.");
1007 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
1009 if (ob == dialog_->browser_all) {
1012 } else if (ob == dialog_->choice_from
1013 || ob == dialog_->choice_to
1014 || ob == dialog_->input_converter
1015 || ob == dialog_->input_flags) {
1018 } else if (ob == dialog_->button_add) {
1021 } else if (ob == dialog_->button_delete) {
1029 void FormPreferences::Converters::update()
1031 local_converters = converters;
1032 local_converters.Update(local_formats);
1037 void FormPreferences::Converters::UpdateBrowser()
1039 local_converters.Sort();
1041 fl_freeze_form(dialog_->form);
1042 fl_clear_browser(dialog_->browser_all);
1043 for (::Converters::const_iterator cit = local_converters.begin();
1044 cit != local_converters.end(); ++cit) {
1045 string const name = (*cit).From->prettyname() + " -> "
1046 + (*cit).To->prettyname();
1047 fl_addto_browser(dialog_->browser_all, name.c_str());
1050 fl_unfreeze_form(dialog_->form);
1054 bool FormPreferences::Converters::Add()
1056 string const from = GetFrom();
1057 string const to = GetTo();
1058 string const command = fl_get_input(dialog_->input_converter);
1059 string const flags = fl_get_input(dialog_->input_flags);
1061 Converter const * old = local_converters.GetConverter(from, to);
1062 local_converters.Add(from, to, command, flags);
1064 local_converters.UpdateLast(local_formats);
1067 setEnabled(dialog_->button_add, false);
1073 bool FormPreferences::Converters::Browser()
1075 int const i = fl_get_browser(dialog_->browser_all);
1076 if (i <= 0) return false;
1078 fl_freeze_form(dialog_->form);
1080 Converter const & c = local_converters.Get(i-1);
1081 int j = local_formats.GetNumber(c.from);
1083 fl_set_choice(dialog_->choice_from, j+1);
1085 j = local_formats.GetNumber(c.to);
1087 fl_set_choice(dialog_->choice_to, j+1);
1089 fl_set_input(dialog_->input_converter, c.command.c_str());
1090 fl_set_input(dialog_->input_flags, c.flags.c_str());
1092 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1093 fl_set_button_shortcut(dialog_->button_add,
1094 scex(_("Modify|#M")), 1);
1096 setEnabled(dialog_->button_add, false);
1097 setEnabled(dialog_->button_delete, true);
1099 fl_unfreeze_form(dialog_->form);
1104 bool FormPreferences::Converters::Delete()
1106 string const from = GetFrom();
1107 string const to = GetTo();
1109 local_converters.Delete(from, to);
1115 bool FormPreferences::Converters::Input()
1117 string const from = GetFrom();
1118 string const to = GetTo();
1119 int const sel = local_converters.GetNumber(from, to);
1121 fl_freeze_form(dialog_->form);
1124 fl_set_object_label(dialog_->button_add,
1126 fl_set_button_shortcut(dialog_->button_add,
1127 scex(_("Add|#A")), 1);
1129 fl_deselect_browser(dialog_->browser_all);
1130 setEnabled(dialog_->button_delete, false);
1133 fl_set_object_label(dialog_->button_add,
1134 idex(_("Modify|#M")));
1135 fl_set_button_shortcut(dialog_->button_add,
1136 scex(_("Modify|#M")), 1);
1138 int top = max(sel-5, 0);
1139 fl_set_browser_topline(dialog_->browser_all, top);
1140 fl_select_browser_line(dialog_->browser_all, sel+1);
1141 setEnabled(dialog_->button_delete, true);
1144 string const command = fl_get_input(dialog_->input_converter);
1145 bool const enable = !(command.empty() || from == to);
1146 setEnabled(dialog_->button_add, enable);
1148 fl_unfreeze_form(dialog_->form);
1153 string const FormPreferences::Converters::GetFrom() const
1155 ::Formats::FormatList::size_type const i =
1156 fl_get_choice(dialog_->choice_from);
1158 if (i > 0 && i <= local_formats.size())
1159 return local_formats.Get(i-1).name();
1161 lyxerr << "FormPreferences::Converters::GetFrom: No choice!"
1168 string const FormPreferences::Converters::GetTo() const
1170 ::Formats::FormatList::size_type const i =
1171 fl_get_choice(dialog_->choice_from);
1173 if (i > 0 && i <= local_formats.size())
1174 return local_formats.Get(i-1).name();
1176 lyxerr << "FormPreferences::Converters::GetTo: No choice!"
1183 void FormPreferences::Converters::UpdateChoices() const
1186 for (::Formats::const_iterator cit = local_formats.begin();
1187 cit != local_formats.end(); ++cit) {
1188 if (!choice.empty())
1192 choice += (*cit).prettyname();
1196 fl_clear_choice(dialog_->choice_from);
1197 fl_addto_choice(dialog_->choice_from, choice.c_str());
1199 fl_clear_choice(dialog_->choice_to);
1200 fl_addto_choice(dialog_->choice_to, choice.c_str());
1204 FormPreferences::Formats::~Formats()
1210 void FormPreferences::Formats::apply() const
1212 formats = local_formats;
1216 void FormPreferences::Formats::build()
1218 dialog_ = parent_.build_formats();
1220 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1221 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1222 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1223 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1224 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1226 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1228 // set up the feedback mechanism
1229 setPreHandler(dialog_->browser_all);
1230 setPreHandler(dialog_->input_format);
1231 setPreHandler(dialog_->input_gui_name);
1232 setPreHandler(dialog_->button_delete);
1233 setPreHandler(dialog_->button_add);
1234 setPreHandler(dialog_->input_extension);
1235 setPreHandler(dialog_->input_viewer);
1236 setPreHandler(dialog_->input_shrtcut);
1241 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1245 if (ob == dialog_->browser_all) {
1246 str = N_("All the currently defined formats known to LyX.");
1247 } else if (ob == dialog_->input_format) {
1248 str = N_("The format identifier.");
1249 } else if (ob == dialog_->input_gui_name) {
1250 str = N_("The format name as it will appear in the menus.");
1251 } else if (ob == dialog_->input_shrtcut) {
1252 str = N_("The keyboard accelerator. Use a letter in the GUI name. Case sensitive.");
1253 } else if (ob == dialog_->input_extension) {
1254 str = N_("Used to recognize the file. E.g., ps, pdf, tex.");
1255 } else if (ob == dialog_->input_viewer) {
1256 str = N_("The command used to launch the viewer application.");
1257 } else if (ob == dialog_->button_delete) {
1258 str = N_("Remove the current format from the list of available formats. Note: you must then \"Apply\" the change.");
1259 } else if (ob == dialog_->button_add) {
1260 if (string(ob->label) == _("Add"))
1261 str = N_("Add the current format to the list of available formats. Note: you must then \"Apply\" the change.");
1263 str = N_("Modify the contents of the current format. Note: you must then \"Apply\" the change.");
1270 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1272 if (ob == dialog_->browser_all) {
1275 } else if (ob == dialog_->input_format
1276 || ob == dialog_->input_gui_name
1277 || ob == dialog_->input_shrtcut
1278 || ob == dialog_->input_extension
1279 || ob == dialog_->input_viewer) {
1282 } else if (ob == dialog_->button_add) {
1285 } else if (ob == dialog_->button_delete) {
1293 void FormPreferences::Formats::update()
1295 local_formats = formats;
1300 void FormPreferences::Formats::UpdateBrowser()
1302 local_formats.Sort();
1304 fl_freeze_form(dialog_->form);
1305 fl_deselect_browser(dialog_->browser_all);
1306 fl_clear_browser(dialog_->browser_all);
1307 for (::Formats::const_iterator cit = local_formats.begin();
1308 cit != local_formats.end(); ++cit)
1309 fl_addto_browser(dialog_->browser_all,
1310 (*cit).prettyname().c_str());
1313 fl_unfreeze_form(dialog_->form);
1315 // Mustn't forget to update the Formats available to the converters_
1316 parent_.converters_.UpdateChoices();
1317 local_converters.Update(local_formats);
1321 bool FormPreferences::Formats::Add()
1323 string const name = fl_get_input(dialog_->input_format);
1324 string const prettyname = fl_get_input(dialog_->input_gui_name);
1325 string const extension = fl_get_input(dialog_->input_extension);
1326 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1327 string const viewer = fl_get_input(dialog_->input_viewer);
1329 Format const * old = local_formats.GetFormat(name);
1330 string const old_prettyname = old ? old->prettyname() : string();
1331 local_formats.Add(name, extension, prettyname, shortcut);
1332 local_formats.SetViewer(name, viewer);
1333 if (!old || prettyname != old_prettyname) {
1336 parent_.converters_.UpdateBrowser();
1338 setEnabled(dialog_->button_add, false);
1344 bool FormPreferences::Formats::Browser()
1346 int const i = fl_get_browser(dialog_->browser_all);
1347 if (i <= 0) return false;
1349 fl_freeze_form(dialog_->form);
1351 Format const & f = local_formats.Get(i-1);
1353 fl_set_input(dialog_->input_format, f.name().c_str());
1354 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1355 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1356 fl_set_input(dialog_->input_extension, f.extension().c_str());
1357 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1359 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1360 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1362 setEnabled(dialog_->button_add, false);
1363 setEnabled(dialog_->button_delete, true);
1365 fl_unfreeze_form(dialog_->form);
1370 bool FormPreferences::Formats::Delete()
1372 string const name = fl_get_input(dialog_->input_format);
1374 if (local_converters.FormatIsUsed(name)) {
1375 parent_.printWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
1376 setEnabled(dialog_->button_delete, false);
1380 local_formats.Delete(name);
1386 bool FormPreferences::Formats::Input()
1388 string const name = fl_get_input(dialog_->input_format);
1389 int const sel = local_formats.GetNumber(name);
1390 fl_freeze_form(dialog_->form);
1393 fl_set_object_label(dialog_->button_add,
1395 fl_set_button_shortcut(dialog_->button_add,
1396 scex(_("Add|#A")), 1);
1398 fl_deselect_browser(dialog_->browser_all);
1399 setEnabled(dialog_->button_delete, false);
1402 fl_set_object_label(dialog_->button_add,
1403 idex(_("Modify|#M")));
1404 fl_set_button_shortcut(dialog_->button_add,
1405 scex(_("Modify|#M")), 1);
1407 int const top = max(sel-5, 0);
1408 fl_set_browser_topline(dialog_->browser_all, top);
1409 fl_select_browser_line(dialog_->browser_all, sel+1);
1411 setEnabled(dialog_->button_add, true);
1412 setEnabled(dialog_->button_delete, true);
1415 string const prettyname = fl_get_input(dialog_->input_gui_name);
1416 bool const enable = !(name.empty() || prettyname.empty());
1417 setEnabled(dialog_->button_add, enable);
1419 fl_unfreeze_form(dialog_->form);
1424 FormPreferences::InputsMisc::~InputsMisc()
1430 void FormPreferences::InputsMisc::apply() const
1432 lyxrc.date_insert_format =
1433 fl_get_input(dialog_->input_date_format);
1437 void FormPreferences::InputsMisc::build()
1439 dialog_ = parent_.build_inputs_misc();
1441 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1443 // set up the feedback mechanism
1444 setPreHandler(dialog_->input_date_format);
1449 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1453 if (ob == dialog_->input_date_format)
1454 str = lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1460 void FormPreferences::InputsMisc::update()
1462 fl_set_input(dialog_->input_date_format,
1463 lyxrc.date_insert_format.c_str());
1467 FormPreferences::Interface::~Interface()
1473 void FormPreferences::Interface::apply() const
1475 lyxrc.popup_font_name =
1476 fl_get_input(dialog_->input_popup_font);
1477 lyxrc.menu_font_name = fl_get_input(dialog_->input_menu_font);
1478 lyxrc.font_norm_menu =
1479 fl_get_input(dialog_->input_popup_encoding);
1480 lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
1481 lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
1482 lyxrc.override_x_deadkeys =
1483 fl_get_button(dialog_->check_override_x_dead_keys);
1487 void FormPreferences::Interface::build()
1489 dialog_ = parent_.build_interface();
1491 fl_set_input_return(dialog_->input_popup_font, FL_RETURN_CHANGED);
1492 fl_set_input_return(dialog_->input_menu_font, FL_RETURN_CHANGED);
1493 fl_set_input_return(dialog_->input_popup_encoding, FL_RETURN_CHANGED);
1494 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1495 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1497 // set up the feedback mechanism
1498 setPreHandler(dialog_->input_popup_font);
1499 setPreHandler(dialog_->input_menu_font);
1500 setPreHandler(dialog_->input_popup_encoding);
1501 setPreHandler(dialog_->input_bind_file);
1502 setPreHandler(dialog_->button_bind_file_browse);
1503 setPreHandler(dialog_->input_ui_file);
1504 setPreHandler(dialog_->button_ui_file_browse);
1505 setPreHandler(dialog_->check_override_x_dead_keys);
1510 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1514 if (ob == dialog_->input_popup_font)
1515 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_POPUP);
1516 else if (ob == dialog_->input_menu_font)
1517 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_MENU);
1518 else if (ob == dialog_->input_popup_encoding)
1519 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING_MENU);
1520 else if (ob == dialog_->input_bind_file)
1521 str = lyxrc.getDescription(LyXRC::RC_BINDFILE);
1522 else if (ob == dialog_->input_ui_file)
1523 str = lyxrc.getDescription(LyXRC::RC_UIFILE);
1524 else if (ob == dialog_->check_override_x_dead_keys)
1525 str = lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1531 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1533 if (ob == dialog_->button_bind_file_browse) {
1534 string dir = AddName(system_lyxdir, "bind");
1535 string name = N_("Sys Bind");
1536 pair<string,string> dir1(name, dir);
1538 dir = AddName(user_lyxdir, "bind");
1539 name = N_("User Bind");
1540 pair<string,string> dir2(name, dir);
1542 parent_.browse(dialog_->input_bind_file,
1543 N_("Bind file"), "*.bind", dir1, dir2);
1545 } else if (ob == dialog_->button_ui_file_browse) {
1546 string dir = AddName(system_lyxdir, "ui");
1547 string name = N_("Sys UI");
1548 pair<string,string> dir1(name, dir);
1550 dir = AddName(user_lyxdir, "ui");
1551 name = N_("User UI");
1552 pair<string,string> dir2(name, dir);
1554 parent_.browse(dialog_->input_ui_file,
1555 N_("UI file"), "*.ui", dir1, dir2);
1562 void FormPreferences::Interface::update()
1564 fl_set_input(dialog_->input_popup_font,
1565 lyxrc.popup_font_name.c_str());
1566 fl_set_input(dialog_->input_menu_font,
1567 lyxrc.menu_font_name.c_str());
1568 fl_set_input(dialog_->input_popup_encoding,
1569 lyxrc.font_norm_menu.c_str());
1570 fl_set_input(dialog_->input_bind_file,
1571 lyxrc.bind_file.c_str());
1572 fl_set_input(dialog_->input_ui_file,
1573 lyxrc.ui_file.c_str());
1574 fl_set_button(dialog_->check_override_x_dead_keys,
1575 lyxrc.override_x_deadkeys);
1579 FormPreferences::Language::~Language()
1581 delete combo_default_lang;
1586 void FormPreferences::Language::apply()
1588 lyxrc.default_language = combo_default_lang->getline();
1590 int button = fl_get_button(dialog_->check_use_kbmap);
1591 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1592 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1594 button = !(name_1.empty() && name_2.empty());
1595 lyxrc.use_kbmap = static_cast<bool>(button);
1597 if (lyxrc.use_kbmap) {
1598 lyxrc.primary_kbmap = name_1;
1599 lyxrc.secondary_kbmap = name_2;
1602 button = fl_get_button(dialog_->check_rtl_support);
1603 lyxrc.rtl_support = static_cast<bool>(button);
1605 button = fl_get_button(dialog_->check_mark_foreign);
1606 lyxrc.mark_foreign_language = static_cast<bool>(button);
1608 button = fl_get_button(dialog_->check_auto_begin);
1609 lyxrc.language_auto_begin = static_cast<bool>(button);
1611 button = fl_get_button(dialog_->check_auto_end);
1612 lyxrc.language_auto_end = static_cast<bool>(button);
1614 button = fl_get_button(dialog_->check_use_babel);
1615 lyxrc.language_use_babel = static_cast<bool>(button);
1617 button = fl_get_button(dialog_->check_global_options);
1618 lyxrc.language_global_options = static_cast<bool>(button);
1620 lyxrc.language_package = fl_get_input(dialog_->input_package);
1621 lyxrc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1622 lyxrc.language_command_end = fl_get_input(dialog_->input_command_end);
1624 // Ensure that all is self-consistent.
1629 void FormPreferences::Language::build()
1631 dialog_ = parent_.build_language();
1633 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1634 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1635 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1637 // The default_language is a combo-box and has to be inserted manually
1638 fl_freeze_form(dialog_->form);
1639 fl_addto_form(dialog_->form);
1641 FL_OBJECT * obj = dialog_->choice_default_lang;
1642 fl_deactivate_object(dialog_->choice_default_lang);
1643 combo_default_lang = new Combox(FL_COMBOX_DROPLIST);
1644 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
1645 parent_.lang_opts_tab_->tabfolder_outer,
1646 parent_.dialog_->tabfolder_prefs);
1647 combo_default_lang->shortcut("#L",1);
1648 combo_default_lang->setcallback(ComboCB, &parent_);
1650 for (Languages::const_iterator cit = languages.begin();
1651 cit != languages.end(); ++cit) {
1652 combo_default_lang->addto((*cit).second.lang());
1656 fl_unfreeze_form(dialog_->form);
1658 // set up the feedback mechanism
1659 setPreHandler(dialog_->input_package);
1660 setPreHandler(dialog_->check_use_kbmap);
1662 // This is safe, as nothing is done to the pointer, other than
1663 // to use its address in a block-if statement.
1664 // No it's not! Leads to crash.
1666 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1667 // C_FormPreferencesFeedbackCB);
1669 setPreHandler(dialog_->input_kbmap1);
1670 setPreHandler(dialog_->input_kbmap2);
1671 setPreHandler(dialog_->check_rtl_support);
1672 setPreHandler(dialog_->check_mark_foreign);
1673 setPreHandler(dialog_->check_auto_begin);
1674 setPreHandler(dialog_->check_auto_end);
1675 setPreHandler(dialog_->check_use_babel);
1676 setPreHandler(dialog_->check_global_options);
1677 setPreHandler(dialog_->input_command_begin);
1678 setPreHandler(dialog_->input_command_end);
1680 // Activate/Deactivate the input fields dependent on the state of the
1687 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1691 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang)
1692 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1693 else if (ob == dialog_->check_use_kbmap)
1694 str = lyxrc.getDescription(LyXRC::RC_KBMAP);
1695 else if (ob == dialog_->input_kbmap1)
1696 str = lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1697 else if (ob == dialog_->input_kbmap2)
1698 str = lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1699 else if (ob == dialog_->check_rtl_support)
1700 str = lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1701 else if (ob == dialog_->check_mark_foreign)
1702 str = lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1703 else if (ob == dialog_->check_auto_begin)
1704 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1705 else if (ob == dialog_->check_auto_end)
1706 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1707 else if (ob == dialog_->check_use_babel)
1708 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1709 else if (ob == dialog_->check_global_options)
1710 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1711 else if (ob == dialog_->input_package)
1712 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1713 else if (ob == dialog_->input_command_begin)
1714 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1715 else if (ob == dialog_->input_command_end)
1716 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1722 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1724 bool activate = true;
1726 // !ob if function is called from Language::build() to de/activate
1728 // otherwise the function is called by an xforms CB via input().
1729 if (!ob || ob == dialog_->check_use_kbmap) {
1730 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1731 setEnabled(dialog_->button_kbmap1_browse, enable);
1732 setEnabled(dialog_->button_kbmap2_browse, enable);
1733 setEnabled(dialog_->input_kbmap1, enable);
1734 setEnabled(dialog_->input_kbmap2, enable);
1737 if (ob == dialog_->button_kbmap1_browse) {
1738 string const dir = AddName(system_lyxdir, "kbd");
1739 string const name = N_("Key maps");
1740 pair<string, string> dir1(name, dir);
1742 parent_.browse(dialog_->input_kbmap1,
1743 N_("Keyboard map"), "*.kmap", dir1,
1744 make_pair(string(), string()));
1745 } else if (ob == dialog_->button_kbmap2_browse) {
1746 string const dir = AddName(system_lyxdir, "kbd");
1747 string const name = N_("Key maps");
1748 pair<string, string> dir1(name, dir);
1750 parent_.browse(dialog_->input_kbmap2,
1751 N_("Keyboard map"), "*.kmap", dir1,
1752 make_pair(string(), string()));
1759 void FormPreferences::Language::update()
1761 fl_set_button(dialog_->check_use_kbmap,
1764 combo_default_lang->select_text(lyxrc.default_language);
1766 if (lyxrc.use_kbmap) {
1767 fl_set_input(dialog_->input_kbmap1,
1768 lyxrc.primary_kbmap.c_str());
1769 fl_set_input(dialog_->input_kbmap2,
1770 lyxrc.secondary_kbmap.c_str());
1772 fl_set_input(dialog_->input_kbmap1, "");
1773 fl_set_input(dialog_->input_kbmap2, "");
1776 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1777 fl_set_button(dialog_->check_mark_foreign,
1778 lyxrc.mark_foreign_language);
1779 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1780 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1781 fl_set_button(dialog_->check_use_babel, lyxrc.language_use_babel);
1782 fl_set_button(dialog_->check_global_options,
1783 lyxrc.language_global_options);
1785 fl_set_input(dialog_->input_package,
1786 lyxrc.language_package.c_str());
1787 fl_set_input(dialog_->input_command_begin,
1788 lyxrc.language_command_begin.c_str());
1789 fl_set_input(dialog_->input_command_end,
1790 lyxrc.language_command_end.c_str());
1792 // Activate/Deactivate the input fields dependent on the state of the
1798 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1800 FormPreferences * pre = static_cast<FormPreferences*>(v);
1801 // This is safe, as nothing is done to the pointer, other than
1802 // to use its address in a block-if statement.
1803 pre->bc_.valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1807 FormPreferences::LnFmisc::~LnFmisc()
1813 void FormPreferences::LnFmisc::apply() const
1815 lyxrc.show_banner = fl_get_button(dialog_->check_banner);
1816 lyxrc.auto_region_delete =
1817 fl_get_button(dialog_->check_auto_region_delete);
1818 lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm);
1819 lyxrc.display_shortcuts =
1820 fl_get_button(dialog_->check_display_shrtcuts);
1821 lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
1822 lyxrc.cursor_follows_scrollbar =
1823 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1824 lyxrc.autosave = static_cast<unsigned int>
1825 (fl_get_counter_value(dialog_->counter_autosave));
1826 lyxrc.wheel_jump = static_cast<unsigned int>
1827 (fl_get_counter_value(dialog_->counter_wm_jump));
1831 void FormPreferences::LnFmisc::build()
1833 dialog_ = parent_.build_lnf_misc();
1835 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1836 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1838 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1839 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1841 // set up the feedback mechanism
1842 setPreHandler(dialog_->check_banner);
1843 setPreHandler(dialog_->check_auto_region_delete);
1844 setPreHandler(dialog_->check_exit_confirm);
1845 setPreHandler(dialog_->check_display_shrtcuts);
1846 setPreHandler(dialog_->counter_autosave);
1847 setPreHandler(dialog_->check_ask_new_file);
1848 setPreHandler(dialog_->check_cursor_follows_scrollbar);
1849 setPreHandler(dialog_->counter_wm_jump);
1854 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1858 if (ob == dialog_->check_banner)
1859 str = lyxrc.getDescription(LyXRC::RC_SHOW_BANNER);
1860 else if (ob == dialog_->check_auto_region_delete)
1861 str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1862 else if (ob == dialog_->check_exit_confirm)
1863 str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION);
1864 else if (ob == dialog_->check_display_shrtcuts)
1865 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_SHORTCUTS);
1866 else if (ob == dialog_->check_ask_new_file)
1867 str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
1868 else if (ob == dialog_->check_cursor_follows_scrollbar)
1869 str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1870 else if (ob == dialog_->counter_autosave)
1871 str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1872 else if (ob == dialog_->counter_wm_jump)
1873 str = lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1879 void FormPreferences::LnFmisc::update()
1881 fl_set_button(dialog_->check_banner, lyxrc.show_banner);
1882 fl_set_button(dialog_->check_auto_region_delete,
1883 lyxrc.auto_region_delete);
1884 fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
1885 fl_set_button(dialog_->check_display_shrtcuts, lyxrc.display_shortcuts);
1886 fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
1887 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1888 lyxrc.cursor_follows_scrollbar);
1889 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1890 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1894 FormPreferences::OutputsMisc::~OutputsMisc()
1900 void FormPreferences::OutputsMisc::apply() const
1902 lyxrc.ascii_linelen = static_cast<unsigned int>
1903 (fl_get_counter_value(dialog_->counter_line_len));
1904 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1907 fl_get_choice(dialog_->choice_default_papersize) - 1;
1908 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1910 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1911 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1915 void FormPreferences::OutputsMisc::build()
1917 dialog_ = parent_.build_outputs_misc();
1919 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1921 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1922 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1923 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1924 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1926 fl_addto_choice(dialog_->choice_default_papersize,
1927 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
1929 // set up the feedback mechanism
1930 setPreHandler(dialog_->counter_line_len);
1931 setPreHandler(dialog_->input_tex_encoding);
1932 setPreHandler(dialog_->choice_default_papersize);
1933 setPreHandler(dialog_->input_ascii_roff);
1934 setPreHandler(dialog_->input_checktex);
1939 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1943 if (ob == dialog_->counter_line_len)
1944 str = lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
1945 else if (ob == dialog_->input_tex_encoding)
1946 str = lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
1947 else if (ob == dialog_->input_ascii_roff)
1948 str = lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1949 else if (ob == dialog_->input_checktex)
1950 str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
1951 else if (ob == dialog_->choice_default_papersize)
1952 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1958 void FormPreferences::OutputsMisc::update()
1960 fl_set_counter_value(dialog_->counter_line_len,
1961 lyxrc.ascii_linelen);
1962 fl_set_input(dialog_->input_tex_encoding,
1963 lyxrc.fontenc.c_str());
1964 fl_set_choice(dialog_->choice_default_papersize,
1965 lyxrc.default_papersize+1);
1966 fl_set_input(dialog_->input_ascii_roff,
1967 lyxrc.ascii_roff_command.c_str());
1968 fl_set_input(dialog_->input_checktex,
1969 lyxrc.chktex_command.c_str());
1973 FormPreferences::Paths::~Paths()
1979 void FormPreferences::Paths::apply()
1981 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
1982 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
1984 int button = fl_get_button(dialog_->check_use_temp_dir);
1985 string str = fl_get_input(dialog_->input_temp_dir);
1986 if (!button) str.erase();
1988 lyxrc.use_tempdir = button;
1989 lyxrc.tempdir_path = str;
1991 button = fl_get_button(dialog_->check_last_files);
1992 str = fl_get_input(dialog_->input_lastfiles);
1993 if (!button) str.erase();
1995 lyxrc.check_lastfiles = button;
1996 lyxrc.lastfiles = str;
1997 lyxrc.num_lastfiles = static_cast<unsigned int>
1998 (fl_get_counter_value(dialog_->counter_lastfiles));
2000 button = fl_get_button(dialog_->check_make_backups);
2001 str = fl_get_input(dialog_->input_backup_path);
2002 if (!button) str.erase();
2004 lyxrc.make_backup = button;
2005 lyxrc.backupdir_path = str;
2007 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2014 void FormPreferences::Paths::build()
2016 dialog_ = parent_.build_paths();
2018 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2019 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2020 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2021 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2022 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2023 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2024 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2026 // set up the feedback mechanism
2027 setPreHandler(dialog_->input_default_path);
2028 setPreHandler(dialog_->counter_lastfiles);
2029 setPreHandler(dialog_->input_template_path);
2030 setPreHandler(dialog_->check_last_files);
2031 setPreHandler(dialog_->input_lastfiles);
2032 setPreHandler(dialog_->check_make_backups);
2033 setPreHandler(dialog_->input_backup_path);
2034 setPreHandler(dialog_->input_serverpipe);
2035 setPreHandler(dialog_->input_temp_dir);
2036 setPreHandler(dialog_->check_use_temp_dir);
2041 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2045 if (ob == dialog_->input_default_path)
2046 str = lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2047 else if (ob == dialog_->input_template_path)
2048 str = lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2049 else if (ob == dialog_->check_use_temp_dir)
2050 str = lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2051 else if (ob == dialog_->input_temp_dir)
2052 str = lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2053 else if (ob == dialog_->check_last_files)
2054 str = lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2055 else if (ob == dialog_->input_lastfiles)
2056 str = lyxrc.getDescription(LyXRC::RC_LASTFILES);
2057 else if (ob == dialog_->counter_lastfiles)
2058 str = lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2059 else if (ob == dialog_->check_make_backups)
2060 str = lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2061 else if (ob == dialog_->input_backup_path)
2062 str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2063 else if (ob == dialog_->input_serverpipe) {
2064 str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2065 str += " Enter either the input pipe, xxx.in, or the output pipe, xxx.out.";
2072 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2074 bool activate = true;
2076 // !ob if function is called from Paths::update() to de/activate
2078 // otherwise the function is called by an xforms CB via input().
2079 if (!ob || ob == dialog_->check_use_temp_dir) {
2080 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2081 setEnabled(dialog_->input_temp_dir, enable);
2084 if (!ob || ob == dialog_->check_last_files) {
2085 bool const enable = fl_get_button(dialog_->check_last_files);
2086 setEnabled(dialog_->input_lastfiles, enable);
2089 if (!ob || ob == dialog_->check_make_backups) {
2090 bool const enable = fl_get_button(dialog_->check_make_backups);
2091 setEnabled(dialog_->input_backup_path, enable);
2094 if (!ob || ob == dialog_->input_default_path) {
2095 string const name = fl_get_input(dialog_->input_default_path);
2096 if (!RWInfo::WriteableDir(name)) {
2097 parent_.printWarning(RWInfo::ErrorMessage());
2102 if (!ob || ob == dialog_->input_template_path) {
2103 string const name = fl_get_input(dialog_->input_template_path);
2104 if (!RWInfo::ReadableDir(name)) {
2105 parent_.printWarning(RWInfo::ErrorMessage());
2110 if (!ob || ob == dialog_->input_temp_dir) {
2111 string const name = fl_get_input(dialog_->input_temp_dir);
2112 if (fl_get_button(dialog_->check_make_backups)
2114 && !RWInfo::WriteableDir(name)) {
2115 parent_.printWarning(RWInfo::ErrorMessage());
2120 if (!ob || ob == dialog_->input_backup_path) {
2121 string const name = fl_get_input(dialog_->input_backup_path);
2122 if (fl_get_button(dialog_->check_make_backups)
2124 && !RWInfo::WriteableDir(name)) {
2125 parent_.printWarning(RWInfo::ErrorMessage());
2130 if (!ob || ob == dialog_->input_lastfiles) {
2131 string const name = fl_get_input(dialog_->input_lastfiles);
2132 if (fl_get_button(dialog_->check_last_files)
2134 && !RWInfo::WriteableFile(name)) {
2135 parent_.printWarning(RWInfo::ErrorMessage());
2140 if (!ob || ob == dialog_->input_serverpipe) {
2141 string const name = fl_get_input(dialog_->input_serverpipe);
2142 if (!name.empty()) {
2143 // strip off the extension
2144 string const str = ChangeExtension(name, "");
2145 if (!RWInfo::WriteableFile(str + ".in")) {
2146 parent_.printWarning(RWInfo::ErrorMessage());
2149 if (!RWInfo::WriteableFile(str + ".out")) {
2150 parent_.printWarning(RWInfo::ErrorMessage());
2156 if (ob == dialog_->button_default_path_browse) {
2157 parent_.browse(dialog_->input_default_path,
2158 N_("Default path"), string(),
2159 make_pair(string(), string()),
2160 make_pair(string(), string()));
2161 } else if (ob == dialog_->button_template_path_browse) {
2162 parent_.browse(dialog_->input_template_path,
2163 N_("Template path"), string(),
2164 make_pair(string(), string()),
2165 make_pair(string(), string()));
2166 } else if (ob == dialog_->button_temp_dir_browse) {
2167 parent_.browse(dialog_->input_temp_dir,
2168 N_("Temp dir"), string(),
2169 make_pair(string(), string()),
2170 make_pair(string(), string()));
2171 } else if (ob == dialog_->button_lastfiles_browse) {
2172 pair<string, string> dir(_("User"), user_lyxdir);
2174 parent_.browse(dialog_->input_lastfiles,
2175 N_("Lastfiles"), string(), dir,
2176 make_pair(string(), string()));
2177 } else if (ob == dialog_->button_backup_path_browse) {
2178 parent_.browse(dialog_->input_backup_path,
2179 N_("Backup path"), string(),
2180 make_pair(string(), string()),
2181 make_pair(string(), string()));
2182 } else if (ob == dialog_->button_serverpipe_browse) {
2183 parent_.browse(dialog_->input_serverpipe,
2184 N_("LyX Server pipes"), string(),
2185 make_pair(string(), string()),
2186 make_pair(string(), string()));
2193 void FormPreferences::Paths::update()
2195 fl_set_input(dialog_->input_default_path,
2196 lyxrc.document_path.c_str());
2197 fl_set_input(dialog_->input_template_path,
2198 lyxrc.template_path.c_str());
2201 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
2203 fl_set_button(dialog_->check_make_backups,
2205 fl_set_input(dialog_->input_backup_path, str.c_str());
2208 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
2210 fl_set_button(dialog_->check_use_temp_dir,
2212 fl_set_input(dialog_->input_temp_dir, str.c_str());
2215 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
2217 fl_set_button(dialog_->check_last_files,
2218 lyxrc.check_lastfiles);
2219 fl_set_input(dialog_->input_lastfiles, str.c_str());
2220 fl_set_counter_value(dialog_->counter_lastfiles,
2221 lyxrc.num_lastfiles);
2223 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2225 // Activate/Deactivate the input fields dependent on the state of the
2231 FormPreferences::Printer::~Printer()
2237 void FormPreferences::Printer::apply() const
2239 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2240 lyxrc.print_command = fl_get_input(dialog_->input_command);
2241 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2242 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2243 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2244 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2245 lyxrc.print_file_extension =
2246 fl_get_input(dialog_->input_file_extension);
2247 lyxrc.print_spool_command =
2248 fl_get_input(dialog_->input_spool_command);
2249 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2250 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2251 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2252 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2253 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2254 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2255 lyxrc.print_extra_options =
2256 fl_get_input(dialog_->input_extra_options);
2257 lyxrc.print_spool_printerprefix =
2258 fl_get_input(dialog_->input_spool_prefix);
2259 lyxrc.print_paper_dimension_flag =
2260 fl_get_input(dialog_->input_paper_size);
2261 lyxrc.printer = fl_get_input(dialog_->input_name);
2266 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2270 if (ob == dialog_->input_command)
2271 str = lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2272 else if (ob == dialog_->check_adapt_output)
2273 str = lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2274 else if (ob == dialog_->input_to_printer)
2275 str = lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2276 else if (ob == dialog_->input_to_file)
2277 str = lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2278 else if (ob == dialog_->input_file_extension)
2279 str = lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2280 else if (ob == dialog_->input_extra_options)
2281 str = lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2282 else if (ob == dialog_->input_spool_command)
2283 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2284 else if (ob == dialog_->input_spool_prefix)
2285 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2286 else if (ob == dialog_->input_name)
2287 str = lyxrc.getDescription(LyXRC::RC_PRINTER);
2288 else if (ob == dialog_->input_even_pages)
2289 str = lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2290 else if (ob == dialog_->input_odd_pages)
2291 str = lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2292 else if (ob == dialog_->input_page_range)
2293 str = lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2294 else if (ob == dialog_->input_reverse)
2295 str = lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2296 else if (ob == dialog_->input_landscape)
2297 str = lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2298 else if (ob == dialog_->input_copies)
2299 str = lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2300 else if (ob == dialog_->input_collated)
2301 str = lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2302 else if (ob == dialog_->input_paper_type)
2303 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2304 else if (ob == dialog_->input_paper_size)
2305 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2311 void FormPreferences::Printer::build()
2313 dialog_ = parent_.build_printer();
2315 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2316 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2317 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2318 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2319 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2320 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2321 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2322 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2323 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2324 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2325 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2326 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2327 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2328 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2329 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2330 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2331 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2333 // set up the feedback mechanism
2334 setPreHandler(dialog_->input_command);
2335 setPreHandler(dialog_->input_page_range);
2336 setPreHandler(dialog_->input_copies);
2337 setPreHandler(dialog_->input_reverse);
2338 setPreHandler(dialog_->input_to_printer);
2339 setPreHandler(dialog_->input_file_extension);
2340 setPreHandler(dialog_->input_spool_command);
2341 setPreHandler(dialog_->input_paper_type);
2342 setPreHandler(dialog_->input_even_pages);
2343 setPreHandler(dialog_->input_odd_pages);
2344 setPreHandler(dialog_->input_collated);
2345 setPreHandler(dialog_->input_landscape);
2346 setPreHandler(dialog_->input_to_file);
2347 setPreHandler(dialog_->input_extra_options);
2348 setPreHandler(dialog_->input_spool_prefix);
2349 setPreHandler(dialog_->input_paper_size);
2350 setPreHandler(dialog_->input_name);
2351 setPreHandler(dialog_->check_adapt_output);
2355 void FormPreferences::Printer::update()
2357 fl_set_button(dialog_->check_adapt_output,
2358 lyxrc.print_adapt_output);
2359 fl_set_input(dialog_->input_command,
2360 lyxrc.print_command.c_str());
2361 fl_set_input(dialog_->input_page_range,
2362 lyxrc.print_pagerange_flag.c_str());
2363 fl_set_input(dialog_->input_copies,
2364 lyxrc.print_copies_flag.c_str());
2365 fl_set_input(dialog_->input_reverse,
2366 lyxrc.print_reverse_flag.c_str());
2367 fl_set_input(dialog_->input_to_printer,
2368 lyxrc.print_to_printer.c_str());
2369 fl_set_input(dialog_->input_file_extension,
2370 lyxrc.print_file_extension.c_str());
2371 fl_set_input(dialog_->input_spool_command,
2372 lyxrc.print_spool_command.c_str());
2373 fl_set_input(dialog_->input_paper_type,
2374 lyxrc.print_paper_flag.c_str());
2375 fl_set_input(dialog_->input_even_pages,
2376 lyxrc.print_evenpage_flag.c_str());
2377 fl_set_input(dialog_->input_odd_pages,
2378 lyxrc.print_oddpage_flag.c_str());
2379 fl_set_input(dialog_->input_collated,
2380 lyxrc.print_collcopies_flag.c_str());
2381 fl_set_input(dialog_->input_landscape,
2382 lyxrc.print_landscape_flag.c_str());
2383 fl_set_input(dialog_->input_to_file,
2384 lyxrc.print_to_file.c_str());
2385 fl_set_input(dialog_->input_extra_options,
2386 lyxrc.print_extra_options.c_str());
2387 fl_set_input(dialog_->input_spool_prefix,
2388 lyxrc.print_spool_printerprefix.c_str());
2389 fl_set_input(dialog_->input_paper_size,
2390 lyxrc.print_paper_dimension_flag.c_str());
2391 fl_set_input(dialog_->input_name,
2392 lyxrc.printer.c_str());
2396 FormPreferences::ScreenFonts::~ScreenFonts()
2402 void FormPreferences::ScreenFonts::apply() const
2404 bool changed = false;
2406 string str = fl_get_input(dialog_->input_roman);
2407 if (lyxrc.roman_font_name != str) {
2409 lyxrc.roman_font_name = str;
2412 str = fl_get_input(dialog_->input_sans);
2413 if (lyxrc.sans_font_name != str) {
2415 lyxrc.sans_font_name = str;
2418 str = fl_get_input(dialog_->input_typewriter);
2419 if (lyxrc.typewriter_font_name != str) {
2421 lyxrc.typewriter_font_name = str;
2424 str = fl_get_input(dialog_->input_screen_encoding);
2425 if (lyxrc.font_norm != str) {
2427 lyxrc.font_norm = str;
2430 bool button = fl_get_button(dialog_->check_scalable);
2431 if (lyxrc.use_scalable_fonts != button) {
2433 lyxrc.use_scalable_fonts = button;
2436 unsigned int ivalue = static_cast<unsigned int>
2437 (fl_get_counter_value(dialog_->counter_zoom));
2438 if (lyxrc.zoom != ivalue) {
2440 lyxrc.zoom = ivalue;
2443 ivalue = static_cast<unsigned int>
2444 (fl_get_counter_value(dialog_->counter_dpi));
2445 if (lyxrc.dpi != ivalue) {
2450 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2451 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2453 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2456 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2457 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2459 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2462 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2463 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2465 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2468 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2469 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2471 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2474 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2475 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2477 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2480 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2481 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2483 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2486 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2487 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2489 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2492 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2493 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2495 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2498 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2499 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2501 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2504 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2505 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2507 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2511 // Now update the buffers
2512 // Can anything below here affect the redraw process?
2513 parent_.lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
2518 void FormPreferences::ScreenFonts::build()
2520 dialog_ = parent_.build_screen_fonts();
2522 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2523 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2525 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2526 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2527 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2528 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2529 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2530 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2531 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2532 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2533 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2534 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2535 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2536 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2537 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2538 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2539 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2540 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2542 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2543 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2544 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2545 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2546 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2547 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2548 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2549 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2550 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2551 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2553 // set up the feedback mechanism
2554 setPreHandler(dialog_->input_roman);
2555 setPreHandler(dialog_->input_sans);
2556 setPreHandler(dialog_->input_typewriter);
2557 setPreHandler(dialog_->counter_zoom);
2558 setPreHandler(dialog_->counter_dpi);
2559 setPreHandler(dialog_->check_scalable);
2560 setPreHandler(dialog_->input_screen_encoding);
2561 setPreHandler(dialog_->input_tiny);
2562 setPreHandler(dialog_->input_script);
2563 setPreHandler(dialog_->input_footnote);
2564 setPreHandler(dialog_->input_small);
2565 setPreHandler(dialog_->input_large);
2566 setPreHandler(dialog_->input_larger);
2567 setPreHandler(dialog_->input_largest);
2568 setPreHandler(dialog_->input_normal);
2569 setPreHandler(dialog_->input_huge);
2570 setPreHandler(dialog_->input_huger);
2575 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2579 if (ob == dialog_->input_roman)
2580 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2581 else if (ob == dialog_->input_sans)
2582 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2583 else if (ob == dialog_->input_typewriter)
2584 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2585 else if (ob == dialog_->check_scalable)
2586 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2587 else if (ob == dialog_->input_screen_encoding)
2588 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2589 else if (ob == dialog_->counter_zoom)
2590 str = lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2591 else if (ob == dialog_->counter_dpi)
2592 str = lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2593 else if (ob == dialog_->input_tiny
2594 || ob == dialog_->input_script
2595 || ob == dialog_->input_footnote
2596 || ob == dialog_->input_small
2597 || ob == dialog_->input_large
2598 || ob == dialog_->input_larger
2599 || ob == dialog_->input_larger
2600 || ob == dialog_->input_largest
2601 || ob == dialog_->input_normal
2602 || ob == dialog_->input_huge
2603 || ob == dialog_->input_huger)
2604 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2610 bool FormPreferences::ScreenFonts::input()
2612 bool activate = true;
2615 // Make sure that all fonts all have positive entries
2616 // Also note that an empty entry is returned as 0.0 by strToDbl
2617 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2618 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2619 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2620 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2621 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2622 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2623 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2624 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2625 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2626 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2628 str = N_("Fonts must be positive!");
2630 // Fontsizes -- tiny < script < footnote etc.
2631 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2632 strToDbl(fl_get_input(dialog_->input_script)) ||
2633 strToDbl(fl_get_input(dialog_->input_script)) >
2634 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2635 strToDbl(fl_get_input(dialog_->input_footnote)) >
2636 strToDbl(fl_get_input(dialog_->input_small)) ||
2637 strToDbl(fl_get_input(dialog_->input_small)) >
2638 strToDbl(fl_get_input(dialog_->input_normal)) ||
2639 strToDbl(fl_get_input(dialog_->input_normal)) >
2640 strToDbl(fl_get_input(dialog_->input_large)) ||
2641 strToDbl(fl_get_input(dialog_->input_large)) >
2642 strToDbl(fl_get_input(dialog_->input_larger)) ||
2643 strToDbl(fl_get_input(dialog_->input_larger)) >
2644 strToDbl(fl_get_input(dialog_->input_largest)) ||
2645 strToDbl(fl_get_input(dialog_->input_largest)) >
2646 strToDbl(fl_get_input(dialog_->input_huge)) ||
2647 strToDbl(fl_get_input(dialog_->input_huge)) >
2648 strToDbl(fl_get_input(dialog_->input_huger))) {
2651 str = N_("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2655 parent_.printWarning(str);
2661 void FormPreferences::ScreenFonts::update()
2663 fl_set_input(dialog_->input_roman,
2664 lyxrc.roman_font_name.c_str());
2665 fl_set_input(dialog_->input_sans,
2666 lyxrc.sans_font_name.c_str());
2667 fl_set_input(dialog_->input_typewriter,
2668 lyxrc.typewriter_font_name.c_str());
2669 fl_set_input(dialog_->input_screen_encoding,
2670 lyxrc.font_norm.c_str());
2671 fl_set_button(dialog_->check_scalable,
2672 lyxrc.use_scalable_fonts);
2673 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2674 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2675 fl_set_input(dialog_->input_tiny,
2676 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2677 fl_set_input(dialog_->input_script,
2678 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2679 fl_set_input(dialog_->input_footnote,
2680 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2681 fl_set_input(dialog_->input_small,
2682 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2683 fl_set_input(dialog_->input_normal,
2684 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2685 fl_set_input(dialog_->input_large,
2686 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2687 fl_set_input(dialog_->input_larger,
2688 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2689 fl_set_input(dialog_->input_largest,
2690 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2691 fl_set_input(dialog_->input_huge,
2692 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2693 fl_set_input(dialog_->input_huger,
2694 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2698 FormPreferences::SpellChecker::~SpellChecker()
2704 void FormPreferences::SpellChecker::apply()
2707 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2708 choice = strip(frontStrip(choice));
2710 lyxrc.isp_command = choice;
2712 // If spell checker == "none", all other input set to off.
2713 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2714 lyxrc.isp_use_alt_lang = false;
2715 lyxrc.isp_alt_lang.erase();
2717 lyxrc.isp_use_esc_chars = false;
2718 lyxrc.isp_esc_chars.erase();
2720 lyxrc.isp_use_pers_dict = false;
2721 lyxrc.isp_pers_dict.erase();
2723 lyxrc.isp_accept_compound = false;
2724 lyxrc.isp_use_input_encoding = false;
2726 int button = fl_get_button(dialog_->check_alt_lang);
2727 choice = fl_get_input(dialog_->input_alt_lang);
2728 if (button && choice.empty()) button = 0;
2729 if (!button) choice.erase();
2731 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2732 lyxrc.isp_alt_lang = choice;
2734 button = fl_get_button(dialog_->check_escape_chars);
2735 choice = fl_get_input(dialog_->input_escape_chars);
2736 if (button && choice.empty()) button = 0;
2737 if (!button) choice.erase();
2739 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2740 lyxrc.isp_esc_chars = choice;
2742 button = fl_get_button(dialog_->check_personal_dict);
2743 choice = fl_get_input(dialog_->input_personal_dict);
2744 if (button && choice.empty()) button = 0;
2745 if (!button) choice.erase();
2747 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2748 lyxrc.isp_pers_dict = choice;
2750 button = fl_get_button(dialog_->check_compound_words);
2751 lyxrc.isp_accept_compound = static_cast<bool>(button);
2753 button = fl_get_button(dialog_->check_input_enc);
2754 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2762 void FormPreferences::SpellChecker::build()
2764 dialog_ = parent_.build_spellchecker();
2766 fl_addto_choice(dialog_->choice_spell_command,
2767 _(" none | ispell | aspell "));
2768 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2769 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2770 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2772 // set up the feedback mechanism
2773 setPreHandler(dialog_->choice_spell_command);
2774 setPreHandler(dialog_->check_alt_lang);
2775 setPreHandler(dialog_->input_alt_lang);
2776 setPreHandler(dialog_->check_escape_chars);
2777 setPreHandler(dialog_->input_escape_chars);
2778 setPreHandler(dialog_->check_personal_dict);
2779 setPreHandler(dialog_->input_personal_dict);
2780 setPreHandler(dialog_->button_personal_dict);
2781 setPreHandler(dialog_->check_compound_words);
2782 setPreHandler(dialog_->check_input_enc);
2787 FormPreferences::SpellChecker::feedback(FL_OBJECT const * const ob) const
2791 if (ob == dialog_->choice_spell_command)
2792 str = lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2793 else if (ob == dialog_->check_alt_lang)
2794 str = lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2795 else if (ob == dialog_->input_alt_lang)
2796 str = lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2797 else if (ob == dialog_->check_escape_chars)
2798 str = lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2799 else if (ob == dialog_->input_escape_chars)
2800 str = lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2801 else if (ob == dialog_->check_personal_dict)
2802 str = lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2803 else if (ob == dialog_->input_personal_dict)
2804 str = lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2805 else if (ob == dialog_->check_compound_words)
2806 str = lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2807 else if (ob == dialog_->check_input_enc)
2808 str = lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2814 bool FormPreferences::SpellChecker::input(FL_OBJECT const * const ob)
2816 // !ob if function is called from updateSpellChecker() to de/activate
2818 // otherwise the function is called by an xforms CB via input().
2820 // If spell checker == "none", disable all input.
2821 if (!ob || ob == dialog_->choice_spell_command) {
2822 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2823 fl_deactivate_object(dialog_->check_alt_lang);
2824 fl_deactivate_object(dialog_->input_alt_lang);
2825 fl_deactivate_object(dialog_->check_escape_chars);
2826 fl_deactivate_object(dialog_->input_escape_chars);
2827 fl_deactivate_object(dialog_->check_personal_dict);
2828 fl_deactivate_object(dialog_->input_personal_dict);
2829 fl_deactivate_object(dialog_->check_compound_words);
2830 fl_deactivate_object(dialog_->check_input_enc);
2833 fl_activate_object(dialog_->check_alt_lang);
2834 fl_activate_object(dialog_->check_escape_chars);
2835 fl_activate_object(dialog_->check_personal_dict);
2836 fl_activate_object(dialog_->check_compound_words);
2837 fl_activate_object(dialog_->check_input_enc);
2841 if (!ob || ob == dialog_->check_alt_lang) {
2842 bool const enable = fl_get_button(dialog_->check_alt_lang);
2843 setEnabled(dialog_->input_alt_lang, enable);
2846 if (!ob || ob == dialog_->check_escape_chars) {
2847 bool const enable = fl_get_button(dialog_->check_escape_chars);
2848 setEnabled(dialog_->input_escape_chars, enable);
2851 if (!ob || ob == dialog_->check_personal_dict) {
2852 bool const enable = fl_get_button(dialog_->check_personal_dict);
2853 setEnabled(dialog_->input_personal_dict, enable);
2856 if (ob == dialog_->button_personal_dict) {
2857 parent_.browse(dialog_->input_personal_dict,
2858 N_("Personal dictionary"), "*.ispell",
2859 make_pair(string(), string()),
2860 make_pair(string(), string()));
2863 return true; // All input is valid!
2867 void FormPreferences::SpellChecker::update()
2870 if (lyxrc.isp_command == "none")
2872 else if (lyxrc.isp_command == "ispell")
2874 else if (lyxrc.isp_command == "aspell")
2876 fl_set_choice(dialog_->choice_spell_command, choice);
2879 if (lyxrc.isp_use_alt_lang) str = lyxrc.isp_alt_lang;
2881 fl_set_button(dialog_->check_alt_lang,
2882 lyxrc.isp_use_alt_lang);
2883 fl_set_input(dialog_->input_alt_lang, str.c_str());
2886 if (lyxrc.isp_use_esc_chars) str = lyxrc.isp_esc_chars;
2888 fl_set_button(dialog_->check_escape_chars,
2889 lyxrc.isp_use_esc_chars);
2890 fl_set_input(dialog_->input_escape_chars, str.c_str());
2893 if (lyxrc.isp_use_pers_dict) str = lyxrc.isp_pers_dict;
2895 fl_set_button(dialog_->check_personal_dict,
2896 lyxrc.isp_use_pers_dict);
2897 fl_set_input(dialog_->input_personal_dict, str.c_str());
2899 fl_set_button(dialog_->check_compound_words,
2900 lyxrc.isp_accept_compound);
2901 fl_set_button(dialog_->check_input_enc,
2902 lyxrc.isp_use_input_encoding);
2904 // Activate/Deactivate the input fields dependent on the state of the
2910 void FormPreferences::printWarning(string const & warning)
2912 warningPosted = true;
2914 string str = _("WARNING!") + string(" ") + warning;
2915 str = formatted(str, dialog_->text_warning->w-10,
2916 FL_SMALL_SIZE, FL_NORMAL_STYLE);
2918 fl_set_object_label(dialog_->text_warning, str.c_str());
2919 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2923 void FormPreferences::browse(FL_OBJECT * inpt,
2924 string const & title,
2925 string const & pattern,
2926 pair<string,string> const & dir1,
2927 pair<string,string> const & dir2)
2929 // Get the filename from the dialog
2930 string const filename = fl_get_input(inpt);
2932 // Show the file browser dialog
2933 string const new_filename =
2934 browseFile(filename, title, pattern, dir1, dir2);
2936 // Save the filename to the dialog
2937 if (new_filename != filename && !new_filename.empty()) {
2938 fl_set_input(inpt, new_filename.c_str());
2944 // C function wrapper, required by xforms.
2945 extern "C" int C_FormPreferencesFeedbackCB(FL_OBJECT * ob, int event,
2946 FL_Coord mx, FL_Coord my,
2947 int key, void * xev)
2949 return FormPreferences::FeedbackCB(ob, event, mx, my, key, xev);
2952 int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event,
2953 FL_Coord, FL_Coord, int, void *)
2955 // Note that the return value is important in the pre-emptive handler.
2956 // Don't return anything other than 0.
2959 // Don't Assert this one, as it can happen quite reasonably when things
2960 // are being deleted in the d-tor.
2962 if (!ob->form) return 0;
2964 FormPreferences * pre =
2965 static_cast<FormPreferences*>(ob->form->u_vdata);
2966 pre->Feedback(ob, event);
2971 // preemptive handler for feedback messages
2972 void FormPreferences::Feedback(FL_OBJECT * ob, int event)
2978 warningPosted = false;
2984 fl_set_object_label(dialog_->text_warning, "");
2993 void FormPreferences::setPreHandler(FL_OBJECT * ob)
2996 fl_set_object_prehandler(ob, C_FormPreferencesFeedbackCB);