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 "xform_helpers.h"
45 #include "converter.h"
46 #include "support/lyxfunctional.h"
47 #include "support/lyxmanip.h"
59 extern string system_lyxdir;
60 extern string user_lyxdir;
61 extern Languages languages;
63 // These should probably go inside the class definition...
64 static Formats local_formats;
65 static Converters local_converters;
67 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
68 : FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
70 converters_tab_(0), inputs_tab_(0), look_n_feel_tab_(0),
71 outputs_tab_(0), lang_opts_tab_(0),
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 FormPreferences::~FormPreferences()
87 delete converters_tab_;
89 delete look_n_feel_tab_;
91 delete lang_opts_tab_;
97 void FormPreferences::connect()
99 fl_set_form_maxsize( dialog_->form, minw_, minh_ );
101 FormBaseBI::connect();
105 void FormPreferences::disconnect()
107 // colors_->disconnect();
108 // converters_->disconnect(); //local_converters.Clear();
109 // formats_->disconnect(); //local_formats.Clear();
111 FormBaseBI::disconnect();
115 void FormPreferences::redraw()
117 if (!(form() && form()->visible))
119 fl_redraw_form(form());
121 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
122 if (!(form2 && form2->visible))
124 fl_redraw_form(form2);
127 if (form2 == converters_tab_->form)
128 form3 = fl_get_active_folder(converters_tab_->tabfolder_outer);
130 else if (form2 == look_n_feel_tab_->form)
131 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_outer);
133 else if (form2 == inputs_tab_->form)
134 form3 = fl_get_active_folder(inputs_tab_->tabfolder_outer);
136 else if (form2 == outputs_tab_->form)
137 form3 = fl_get_active_folder(outputs_tab_->tabfolder_outer);
139 else if (form2 == lang_opts_tab_->form)
140 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_outer);
142 if (form3 && form3->visible)
143 fl_redraw_form(form3);
147 FL_FORM * FormPreferences::form() const
149 if (dialog_) return dialog_->form;
154 void FormPreferences::ok()
158 if (colors_.modifiedXformPrefs) {
159 string const filename =
160 AddName(user_lyxdir, "preferences.xform");
161 colors_.modifiedXformPrefs = !XformColor::write(filename);
164 lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
168 void FormPreferences::hide()
170 // We need to hide the active tabfolder otherwise we get a
171 // BadDrawable error from X windows and LyX crashes without saving.
172 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
174 && outer_form->visible) {
175 fl_hide_form(outer_form);
181 void FormPreferences::build()
183 dialog_ = build_preferences();
185 // Manage the restore, save, apply and cancel/close buttons
186 bc_.setOK(dialog_->button_ok);
187 bc_.setApply(dialog_->button_apply);
188 bc_.setCancel(dialog_->button_cancel);
189 bc_.setUndoAll(dialog_->button_restore);
192 // Workaround dumb xforms sizing bug
196 // build the tab folders
197 converters_tab_ = build_outer_tab();
198 look_n_feel_tab_ = build_outer_tab();
199 inputs_tab_ = build_outer_tab();
200 outputs_tab_ = build_outer_tab();
201 lang_opts_tab_ = build_outer_tab();
203 // build actual tabfolder contents
204 // these will become nested tabfolders
208 inputs_misc_.build();
212 outputs_misc_.build();
215 screen_fonts_.build();
216 spellchecker_.build();
218 // Now add them to the tabfolder
219 fl_addto_tabfolder(dialog_->tabfolder_prefs,
221 look_n_feel_tab_->form);
222 fl_addto_tabfolder(dialog_->tabfolder_prefs,
224 lang_opts_tab_->form);
225 fl_addto_tabfolder(dialog_->tabfolder_prefs,
227 converters_tab_->form);
228 fl_addto_tabfolder(dialog_->tabfolder_prefs,
231 fl_addto_tabfolder(dialog_->tabfolder_prefs,
235 // now build the nested tabfolders
236 // Starting with look and feel
237 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
239 screen_fonts_.dialog()->form);
240 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
242 interface_.dialog()->form);
243 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
245 colors_.dialog()->form);
246 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
248 lnf_misc_.dialog()->form);
250 // then build converters
251 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
253 formats_.dialog()->form);
254 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
256 converters_.dialog()->form);
259 // Paths should probably go in a few outer_tab called Files
260 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
262 paths_.dialog()->form);
263 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
265 inputs_misc_.dialog()->form);
267 // then building outputs
268 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
270 printer_.dialog()->form);
271 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
273 outputs_misc_.dialog()->form);
275 // then building usage
276 fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
278 spellchecker_.dialog()->form);
279 fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
281 language_.dialog()->form);
285 void FormPreferences::apply()
287 // set the new lyxrc entries
288 // many of these need to trigger other functions when the assignment
289 // is made. For example, screen zoom and font types. These could be
290 // handled either by signals/slots in lyxrc or just directly call the
291 // associated functions here.
292 // There are other problems with this scheme. We really should check
293 // what we copy to make sure that it really is necessary to do things
294 // like update the screen fonts because that flushes the textcache
295 // and other stuff which may cost us a lot on slower/high-load
299 formats_.apply(); // Must be before converters_.apply()
301 inputs_misc_.apply();
305 outputs_misc_.apply();
308 screen_fonts_.apply();
309 spellchecker_.apply();
313 void FormPreferences::feedback(FL_OBJECT * ob)
319 if (ob->form->fdui == colors_.dialog()) {
320 str = colors_.feedback(ob);
321 } else if (ob->form->fdui == converters_.dialog()) {
322 str = converters_.feedback(ob);
323 } else if (ob->form->fdui == formats_.dialog()) {
324 str = formats_.feedback(ob);
325 } else if (ob->form->fdui == inputs_misc_.dialog()) {
326 str = inputs_misc_.feedback(ob);
327 } else if (ob->form->fdui == interface_.dialog()) {
328 str = interface_.feedback(ob);
329 } else if (ob->form->fdui == language_.dialog()) {
330 str = language_.feedback(ob);
331 } else if (ob->form->fdui == lnf_misc_.dialog()) {
332 str = lnf_misc_.feedback(ob);
333 } else if (ob->form->fdui == outputs_misc_.dialog()) {
334 str = outputs_misc_.feedback(ob);
335 } else if (ob->form->fdui == paths_.dialog()) {
336 str = paths_.feedback(ob);
337 } else if (ob->form->fdui == printer_.dialog()) {
338 str = printer_.feedback(ob);
339 } else if (ob->form->fdui == screen_fonts_.dialog()) {
340 str = screen_fonts_.feedback(ob);
341 } else if (ob->form->fdui == spellchecker_.dialog()) {
342 str = spellchecker_.feedback(ob);
345 str = formatted(_(str), dialog_->text_warning->w-10,
346 FL_SMALL_SIZE, FL_NORMAL_STYLE);
348 fl_set_object_label(dialog_->text_warning, str.c_str());
349 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
353 bool FormPreferences::input(FL_OBJECT * ob, long)
357 // whatever checks you need to ensure the user hasn't entered
358 // some totally ridiculous value somewhere. Change activate to suit.
359 // comments before each test describe what is _valid_
361 if (ob->form->fdui == colors_.dialog()) {
364 } else if (ob->form->fdui == converters_.dialog())
365 return converters_.input(ob);
366 else if (ob->form->fdui == formats_.dialog())
367 return formats_.input(ob);
368 else if (ob->form->fdui == interface_.dialog())
369 return interface_.input(ob);
370 else if (ob->form->fdui == language_.dialog())
371 return language_.input(ob);
372 else if (ob->form->fdui == paths_.dialog())
373 return paths_.input(ob);
374 else if (ob->form->fdui == screen_fonts_.dialog())
375 return screen_fonts_.input();
376 else if (ob->form->fdui == spellchecker_.dialog())
377 return spellchecker_.input(ob);
383 void FormPreferences::update()
385 if (!dialog_) return;
387 // read lyxrc entries
389 formats_.update(); // Must be before converters_.update()
390 converters_.update();
391 inputs_misc_.update();
395 outputs_misc_.update();
398 screen_fonts_.update();
399 spellchecker_.update();
403 FormPreferences::Colors::~Colors()
409 void FormPreferences::Colors::apply()
411 bool modifiedText = false;
412 bool modifiedBackground = false;
414 for (vector<XformColor>::const_iterator cit = xformColorDB.begin();
415 cit != xformColorDB.end(); ++cit) {
417 fl_getmcolor((*cit).colorID, &col.r, &col.g, &col.b);
418 if (col != (*cit).color()) {
419 modifiedXformPrefs = true;
420 if ((*cit).colorID == FL_BLACK)
422 if ((*cit).colorID == FL_COL1)
423 modifiedBackground = true;
427 if (modifiedXformPrefs) {
428 for (vector<XformColor>::const_iterator cit =
429 xformColorDB.begin();
430 cit != xformColorDB.end(); ++cit) {
431 fl_mapcolor((*cit).colorID,
432 (*cit).r, (*cit).g, (*cit).b);
434 if (modifiedText && (*cit).colorID == FL_BLACK) {
435 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
438 if (modifiedBackground && (*cit).colorID == FL_COL1) {
439 AdjustVal(FL_MCOL, FL_COL1, 0.1);
440 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
441 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
443 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
444 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
447 if ((*cit).colorID == GUI_COLOR_CURSOR) {
448 fl_mapcolor(GUI_COLOR_CURSOR,
449 (*cit).r, (*cit).g, (*cit).b);
450 fl_set_cursor_color(FL_DEFAULT_CURSOR,
451 GUI_COLOR_CURSOR, FL_WHITE);
454 Dialogs::redrawGUI();
457 // Now do the same for the LyX LColors...
458 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
459 cit != lyxColorDB.end(); ++cit) {
460 LColor::color lc = lcolor.getFromGUIName((*cit).getname());
461 if (lc == LColor::inherit) continue;
463 // Create a valid X11 name of the form "#rrggbb"
464 string const hexname = X11hexname((*cit).color());
466 if (lcolor.getX11Name(lc) != hexname) {
468 << "FormPreferences::Colors::apply: "
469 << "resetting LColor " << lcolor.getGUIName(lc)
470 << " from \"" << lcolor.getX11Name(lc)
471 << "\" to \"" << hexname << "\"."
474 string const s = lcolor.getLyXName(lc) + string(" ") +
476 parent_.lv_->getLyXFunc()->Dispatch(LFUN_SET_COLOR, s);
482 void FormPreferences::Colors::build()
484 dialog_ = parent_.build_colors();
486 fl_set_object_color(dialog_->button_color,
487 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
489 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
490 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
491 fl_set_dial_step(dialog_->dial_hue, 1.0);
492 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
494 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
495 fl_set_slider_step(dialog_->slider_saturation, 0.01);
496 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
498 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
499 fl_set_slider_step(dialog_->slider_value, 0.01);
500 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
502 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
503 fl_set_slider_step(dialog_->slider_red, 1.0);
504 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
506 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
507 fl_set_slider_step(dialog_->slider_green, 1.0);
508 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
510 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
511 fl_set_slider_step(dialog_->slider_blue, 1.0);
512 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
514 // set up the feedback mechanism
515 setPreHandler(dialog_->browser_lyx_objs);
516 setPreHandler(dialog_->button_color);
517 setPreHandler(dialog_->button_modify);
518 setPreHandler(dialog_->dial_hue);
519 setPreHandler(dialog_->slider_saturation);
520 setPreHandler(dialog_->slider_value);
521 setPreHandler(dialog_->slider_red);
522 setPreHandler(dialog_->slider_green);
523 setPreHandler(dialog_->slider_blue);
524 setPreHandler(dialog_->button_colorspace);
528 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
532 if (ob == dialog_->browser_lyx_objs) {
533 str = N_("LyX objects that can be assigned a color.");
535 } else if (ob == dialog_->button_modify) {
536 str = N_("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
538 } else if (ob == dialog_->dial_hue ||
539 ob == dialog_->slider_saturation ||
540 ob == dialog_->slider_value ||
541 ob == dialog_->slider_red ||
542 ob == dialog_->slider_green ||
543 ob == dialog_->slider_blue) {
544 str = N_("Find a new color.");
546 } else if (ob == dialog_->button_colorspace) {
547 str = N_("Toggle between RGB and HSV color spaces.");
554 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
556 if (ob == dialog_->browser_lyx_objs) {
559 } else if (ob == dialog_->dial_hue ||
560 ob == dialog_->slider_saturation ||
561 ob == dialog_->slider_value) {
564 } else if (ob == dialog_->slider_red ||
565 ob == dialog_->slider_green ||
566 ob == dialog_->slider_blue) {
569 } else if (ob == dialog_->button_colorspace) {
572 } else if (ob == dialog_->button_modify) {
578 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
582 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
586 hsv.v = min( 1.0, max(0.0, hsv.v) );
589 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
593 void FormPreferences::Colors::InputBrowserLyX() const
595 vector<NamedColor>::size_type const selLyX =
596 fl_get_browser(dialog_->browser_lyx_objs);
597 if (selLyX < 1) return;
599 // Is the choice an Xforms color...
602 if( selLyX-1 < xformColorDB.size() ) {
603 vector<XformColor>::size_type const i = selLyX - 1;
604 col = xformColorDB[i].color();
606 // or a LyX Logical color?
608 vector<NamedColor>::size_type const i = selLyX - 1 -
610 col = lyxColorDB[i].color();
613 fl_freeze_form(dialog_->form);
615 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
616 fl_redraw_object(dialog_->button_color);
618 // Display either RGB or HSV but not both!
621 // Deactivate the modify button to begin with...
622 fl_deactivate_object(dialog_->button_modify);
623 fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
625 fl_unfreeze_form(dialog_->form);
629 void FormPreferences::Colors::InputHSV()
631 double const hue = fl_get_dial_value(dialog_->dial_hue);
632 double const sat = fl_get_slider_value(dialog_->slider_saturation);
633 double const val = fl_get_slider_value(dialog_->slider_value);
635 int const h = int(hue);
636 int const s = int(100.0 * sat);
637 int const v = int(100.0 * val);
639 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
641 fl_set_object_label(dialog_->text_color_values, label.c_str());
643 RGBColor col = HSVColor(hue, sat, val);
645 fl_freeze_form(dialog_->form);
647 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
648 fl_redraw_object(dialog_->button_color);
650 col = HSVColor(hue, 1.0, 1.0);
651 col.r = max(col.r, 0);
652 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
653 fl_redraw_object(dialog_->dial_hue);
655 // Ascertain whether to activate the Modify button.
656 vector<NamedColor>::size_type const selLyX =
657 fl_get_browser(dialog_->browser_lyx_objs);
659 fl_unfreeze_form(dialog_->form);
660 if (selLyX < 1) return;
662 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
665 // Is the choice an Xforms color...
666 if( selLyX-1 < xformColorDB.size() ) {
667 vector<XformColor>::size_type const i = selLyX - 1;
668 modify = (xformColorDB[i].color() != col);
670 // or a LyX Logical color?
672 vector<NamedColor>::size_type const i = selLyX - 1 -
674 modify = (lyxColorDB[i].color() != col);
678 fl_activate_object(dialog_->button_modify);
679 fl_set_object_lcol(dialog_->button_modify, FL_BLACK);
681 fl_deactivate_object(dialog_->button_modify);
682 fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
687 void FormPreferences::Colors::InputRGB()
689 int const red = int(fl_get_slider_value(dialog_->slider_red));
690 int const green = int(fl_get_slider_value(dialog_->slider_green));
691 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
693 string const label = tostr(red) + string(", ") + tostr(green) +
694 string(", ") + tostr(blue);
695 fl_set_object_label(dialog_->text_color_values, label.c_str());
697 fl_freeze_form(dialog_->form);
699 RGBColor col = RGBColor(red, green, blue);
700 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
701 fl_redraw_object(dialog_->button_color);
703 // Ascertain whether to activate the Modify button.
704 vector<NamedColor>::size_type const selLyX =
705 fl_get_browser(dialog_->browser_lyx_objs);
707 fl_unfreeze_form(dialog_->form);
708 if (selLyX < 1) return;
712 // Is the choice an Xforms color...
713 if( selLyX-1 < xformColorDB.size() ) {
714 vector<XformColor>::size_type const i = selLyX - 1;
715 modify = (xformColorDB[i].color() != col);
717 // or a LyX Logical color?
719 vector<NamedColor>::size_type const i = selLyX - 1 -
721 modify = (lyxColorDB[i].color() != col);
725 fl_activate_object(dialog_->button_modify);
726 fl_set_object_lcol(dialog_->button_modify, FL_BLACK);
728 fl_deactivate_object(dialog_->button_modify);
729 fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
734 void FormPreferences::Colors::LoadBrowserLyX()
736 if (!dialog_->browser_lyx_objs->visible) return;
738 // First, define the modifiable xform colors
739 xformColorDB.clear();
742 xcol.name = _("GUI background");
743 xcol.colorID = FL_COL1;
744 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
746 xformColorDB.push_back(xcol);
748 xcol.name = _("GUI text");
749 xcol.colorID = FL_BLACK;
750 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
752 fl_mapcolor(GUI_COLOR_CURSOR, xcol.r, xcol.g, xcol.b);
753 fl_set_cursor_color(FL_DEFAULT_CURSOR, GUI_COLOR_CURSOR, FL_WHITE);
755 xformColorDB.push_back(xcol);
757 xcol.name = _("GUI selection");
758 xcol.colorID = FL_YELLOW;
759 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
761 xformColorDB.push_back(xcol);
763 xcol.name = _("GUI pointer");
764 xcol.colorID = GUI_COLOR_CURSOR;
765 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
767 xformColorDB.push_back(xcol);
769 // Now create the the LyX LColors database
771 for (int i=0; i<LColor::ignore; ++i) {
772 LColor::color lc = static_cast<LColor::color>(i);
773 if (lc == LColor::none
774 || lc == LColor::black
775 || lc == LColor::white
777 || lc == LColor::green
778 || lc == LColor::blue
779 || lc == LColor::cyan
780 || lc == LColor::magenta
781 || lc == LColor::yellow
782 || lc == LColor::inherit
783 || lc == LColor::ignore) continue;
785 string const name = lcolor.getX11Name(lc);
786 Display * display = fl_get_display();;
787 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
790 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
792 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
793 << "LColor " << lcolor.getLyXName(lc)
794 << ": X can't find color \"" << name
795 << "\". Set to \"black\"!" << endl;
797 string const arg = lcolor.getLyXName(lc) + " black";
798 parent_.lv_->getLyXFunc()->
799 Dispatch(LFUN_SET_COLOR, arg);
803 // X has found the color. Now find the "appropriate" X11 name
806 // Note that X stores the RGB values in the range 0 - 65535
807 // whilst we require them in the range 0 - 255.
809 col.r = xcol.red / 256;
810 col.g = xcol.green / 256;
811 col.b = xcol.blue / 256;
813 // Create a valid X11 name of the form "#rrggbb" and change the
814 // LColor X11name to this. Don't want to trigger a redraw,
815 // as we're just changing the name not the RGB values.
816 // Also reset the system_lcolor names, so that we don't output
817 // unnecessary changes.
818 string const hexname = X11hexname(col);
820 if (lcolor.getX11Name(lc) != hexname) {
821 lcolor.setColor(lc, hexname);
822 system_lcolor.setColor(lc, hexname);
825 // Finally, push the color onto the database
826 NamedColor ncol(lcolor.getGUIName(lc), col);
827 lyxColorDB.push_back(ncol);
830 // Now construct the browser
831 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
832 fl_freeze_form(dialog_->form);
833 fl_clear_browser(colbr);
834 for (vector<XformColor>::const_iterator cit = xformColorDB.begin();
835 cit != xformColorDB.end(); ++cit) {
836 fl_addto_browser(colbr, (*cit).getname().c_str());
838 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
839 cit != lyxColorDB.end(); ++cit) {
840 fl_addto_browser(colbr, (*cit).getname().c_str());
843 // just to be safe...
844 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
845 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
846 fl_unfreeze_form(dialog_->form);
852 void FormPreferences::Colors::Modify()
854 vector<NamedColor>::size_type const selLyX =
855 fl_get_browser(dialog_->browser_lyx_objs);
856 if (selLyX < 1) return;
859 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
861 // Is the choice an Xforms color...
862 if( selLyX-1 < xformColorDB.size() ) {
863 vector<XformColor>::size_type const i = selLyX - 1;
864 xformColorDB[i].r = col.r;
865 xformColorDB[i].g = col.g;
866 xformColorDB[i].b = col.b;
868 // or a LyX Logical color?
870 vector<NamedColor>::size_type const i = selLyX - 1 -
872 lyxColorDB[i].r = col.r;
873 lyxColorDB[i].g = col.g;
874 lyxColorDB[i].b = col.b;
877 fl_freeze_form(dialog_->form);
879 fl_deactivate_object(dialog_->button_modify);
880 fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
882 fl_unfreeze_form(dialog_->form);
886 void FormPreferences::Colors::SwitchColorSpace() const
888 bool const pressed = fl_get_button(dialog_->button_colorspace);
891 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
893 fl_freeze_form(dialog_->form);
896 fl_set_object_label(dialog_->button_colorspace, _("HSV"));
898 fl_hide_object(dialog_->slider_red);
899 fl_hide_object(dialog_->slider_blue);
900 fl_hide_object(dialog_->slider_green);
901 fl_show_object(dialog_->dial_hue);
902 fl_show_object(dialog_->slider_saturation);
903 fl_show_object(dialog_->slider_value);
905 HSVColor hsv = HSVColor(col);
906 hsv.h = max(hsv.h, 0.0);
908 fl_set_dial_value(dialog_->dial_hue, hsv.h);
909 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
910 fl_set_slider_value(dialog_->slider_value, hsv.v);
912 col = HSVColor(hsv.h, 1.0, 1.0);
913 col.r = max(col.r,0);
914 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
915 fl_redraw_object(dialog_->dial_hue);
917 // Adjust the label a bit, but not the actual values.
918 // Means that toggling from one space to the other has no
919 // effect on the final color.
920 int const h = int(hsv.h);
921 int const s = int(100*hsv.s);
922 int const v = int(100*hsv.v);
923 string const label = tostr(h) + string(", ") + tostr(s) +
924 string(", ") + tostr(v);
925 fl_set_object_label(dialog_->text_color_values, label.c_str());
928 fl_set_object_label(dialog_->button_colorspace, _("RGB"));
930 fl_show_object(dialog_->slider_red);
931 fl_show_object(dialog_->slider_blue);
932 fl_show_object(dialog_->slider_green);
933 fl_hide_object(dialog_->dial_hue);
934 fl_hide_object(dialog_->slider_saturation);
935 fl_hide_object(dialog_->slider_value);
937 fl_set_slider_value(dialog_->slider_red, col.r);
938 fl_set_slider_value(dialog_->slider_green, col.g);
939 fl_set_slider_value(dialog_->slider_blue, col.b);
941 // Adjust the label a bit. Same reasoning as above.
942 int const r = int(col.r);
943 int const g = int(col.g);
944 int const b = int(col.b);
945 string const label = tostr(r) + string(", ") + tostr(g) +
946 string(", ") + tostr(b);
947 fl_set_object_label(dialog_->text_color_values, label.c_str());
950 fl_unfreeze_form(dialog_->form);
953 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
957 ostr << "#" << std::setbase(16) << std::setfill('0')
958 << std::setw(2) << col.r
959 << std::setw(2) << col.g
960 << std::setw(2) << col.b;
962 return ostr.str().c_str();
966 FormPreferences::Converters::~Converters()
972 void FormPreferences::Converters::apply() const
974 converters = local_converters;
975 converters.Update(formats);
976 converters.BuildGraph();
980 void FormPreferences::Converters::build()
982 dialog_ = parent_.build_converters();
984 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
985 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
987 // set up the feedback mechanism
988 setPreHandler(dialog_->browser_all);
989 setPreHandler(dialog_->button_delete);
990 setPreHandler(dialog_->button_add);
991 setPreHandler(dialog_->input_converter);
992 setPreHandler(dialog_->choice_from);
993 setPreHandler(dialog_->choice_to);
994 setPreHandler(dialog_->input_flags);
999 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
1003 if (ob == dialog_->browser_all) {
1004 str = N_("All the currently defined converters known to LyX.");
1005 } else if (ob == dialog_->choice_from) {
1006 str = N_("Convert \"from\" this format");
1007 } else if (ob == dialog_->choice_to) {
1008 str = N_("Convert \"to\" this format");
1009 } else if (ob == dialog_->input_converter) {
1010 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.");
1011 } else if (ob == dialog_->input_flags) {
1012 str = N_("Flags that control the converter behavior");
1013 } else if (ob == dialog_->button_delete) {
1014 str = N_("Remove the current converter from the list of available converters. Note: you must then \"Apply\" the change.");
1015 } else if (ob == dialog_->button_add) {
1016 if (string(ob->label) == _("Add"))
1017 str = N_("Add the current converter to the list of available converters. Note: you must then \"Apply\" the change.");
1019 str = N_("Modify the contents of the current converter. Note: you must then \"Apply\" the change.");
1026 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
1028 if (ob == dialog_->browser_all) {
1031 } else if (ob == dialog_->choice_from
1032 || ob == dialog_->choice_to
1033 || ob == dialog_->input_converter
1034 || ob == dialog_->input_flags) {
1037 } else if (ob == dialog_->button_add) {
1040 } else if (ob == dialog_->button_delete) {
1048 void FormPreferences::Converters::update()
1050 local_converters = converters;
1051 local_converters.Update(local_formats);
1056 void FormPreferences::Converters::UpdateBrowser()
1058 local_converters.Sort();
1060 fl_freeze_form(dialog_->form);
1061 fl_clear_browser(dialog_->browser_all);
1062 for (::Converters::const_iterator cit = local_converters.begin();
1063 cit != local_converters.end(); ++cit) {
1064 string const name = (*cit).From->prettyname() + " -> "
1065 + (*cit).To->prettyname();
1066 fl_addto_browser(dialog_->browser_all, name.c_str());
1069 fl_unfreeze_form(dialog_->form);
1073 bool FormPreferences::Converters::Add()
1075 string const from = GetFrom();
1076 string const to = GetTo();
1077 string const command = fl_get_input(dialog_->input_converter);
1078 string const flags = fl_get_input(dialog_->input_flags);
1080 Converter const * old = local_converters.GetConverter(from, to);
1081 local_converters.Add(from, to, command, flags);
1083 local_converters.UpdateLast(local_formats);
1086 fl_deactivate_object(dialog_->button_add);
1087 fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
1093 bool FormPreferences::Converters::Browser()
1095 int const i = fl_get_browser(dialog_->browser_all);
1096 if (i <= 0) return false;
1098 fl_freeze_form(dialog_->form);
1100 Converter const & c = local_converters.Get(i-1);
1101 int j = local_formats.GetNumber(c.from);
1103 fl_set_choice(dialog_->choice_from, j+1);
1105 j = local_formats.GetNumber(c.to);
1107 fl_set_choice(dialog_->choice_to, j+1);
1109 fl_set_input(dialog_->input_converter, c.command.c_str());
1110 fl_set_input(dialog_->input_flags, c.flags.c_str());
1112 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1113 fl_set_button_shortcut(dialog_->button_add,
1114 scex(_("Modify|#M")), 1);
1116 fl_deactivate_object(dialog_->button_add);
1117 fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
1119 fl_activate_object(dialog_->button_delete);
1120 fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
1122 fl_unfreeze_form(dialog_->form);
1127 bool FormPreferences::Converters::Delete()
1129 string const from = GetFrom();
1130 string const to = GetTo();
1132 local_converters.Delete(from, to);
1138 bool FormPreferences::Converters::Input()
1140 string const from = GetFrom();
1141 string const to = GetTo();
1142 int const sel = local_converters.GetNumber(from, to);
1144 fl_freeze_form(dialog_->form);
1147 fl_set_object_label(dialog_->button_add,
1149 fl_set_button_shortcut(dialog_->button_add,
1150 scex(_("Add|#A")), 1);
1152 fl_deselect_browser(dialog_->browser_all);
1154 fl_deactivate_object(dialog_->button_delete);
1155 fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
1158 fl_set_object_label(dialog_->button_add,
1159 idex(_("Modify|#M")));
1160 fl_set_button_shortcut(dialog_->button_add,
1161 scex(_("Modify|#M")), 1);
1163 int top = max(sel-5, 0);
1164 fl_set_browser_topline(dialog_->browser_all, top);
1165 fl_select_browser_line(dialog_->browser_all, sel+1);
1167 fl_activate_object(dialog_->button_delete);
1168 fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
1171 string const command = fl_get_input(dialog_->input_converter);
1172 if (command.empty() || from == to) {
1173 fl_deactivate_object(dialog_->button_add);
1174 fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
1176 fl_activate_object(dialog_->button_add);
1177 fl_set_object_lcol(dialog_->button_add, FL_BLACK);
1180 fl_unfreeze_form(dialog_->form);
1185 string const FormPreferences::Converters::GetFrom() const
1187 Formats::FormatList::size_type const i =
1188 fl_get_choice(dialog_->choice_from);
1190 if (i > 0 && i <= local_formats.size())
1191 return local_formats.Get(i-1).name();
1193 lyxerr << "FormPreferences::Converters::GetFrom: No choice!"
1200 string const FormPreferences::Converters::GetTo() const
1202 Formats::FormatList::size_type const i =
1203 fl_get_choice(dialog_->choice_from);
1205 if (i > 0 && i <= local_formats.size())
1206 return local_formats.Get(i-1).name();
1208 lyxerr << "FormPreferences::Converters::GetTo: No choice!"
1215 void FormPreferences::Converters::UpdateChoices() const
1218 for (::Formats::const_iterator cit = local_formats.begin();
1219 cit != local_formats.end(); ++cit) {
1220 if (!choice.empty())
1224 choice += (*cit).prettyname();
1228 fl_clear_choice(dialog_->choice_from);
1229 fl_addto_choice(dialog_->choice_from, choice.c_str());
1231 fl_clear_choice(dialog_->choice_to);
1232 fl_addto_choice(dialog_->choice_to, choice.c_str());
1236 FormPreferences::Formats::~Formats()
1242 void FormPreferences::Formats::apply() const
1244 formats = local_formats;
1248 void FormPreferences::Formats::build()
1250 dialog_ = parent_.build_formats();
1252 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1253 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1254 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1255 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1256 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1258 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1260 // set up the feedback mechanism
1261 setPreHandler(dialog_->browser_all);
1262 setPreHandler(dialog_->input_format);
1263 setPreHandler(dialog_->input_gui_name);
1264 setPreHandler(dialog_->button_delete);
1265 setPreHandler(dialog_->button_add);
1266 setPreHandler(dialog_->input_extension);
1267 setPreHandler(dialog_->input_viewer);
1268 setPreHandler(dialog_->input_shrtcut);
1273 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1277 if (ob == dialog_->browser_all) {
1278 str = N_("All the currently defined formats known to LyX.");
1279 } else if (ob == dialog_->input_format) {
1280 str = N_("The format identifier.");
1281 } else if (ob == dialog_->input_gui_name) {
1282 str = N_("The format name as it will appear in the menus.");
1283 } else if (ob == dialog_->input_shrtcut) {
1284 str = N_("The keyboard accelerator. Use a letter in the GUI name. Case sensitive.");
1285 } else if (ob == dialog_->input_extension) {
1286 str = N_("Used to recognize the file. E.g., ps, pdf, tex.");
1287 } else if (ob == dialog_->input_viewer) {
1288 str = N_("The command used to launch the viewer application.");
1289 } else if (ob == dialog_->button_delete) {
1290 str = N_("Remove the current format from the list of available formats. Note: you must then \"Apply\" the change.");
1291 } else if (ob == dialog_->button_add) {
1292 if (string(ob->label) == _("Add"))
1293 str = N_("Add the current format to the list of available formats. Note: you must then \"Apply\" the change.");
1295 str = N_("Modify the contents of the current format. Note: you must then \"Apply\" the change.");
1302 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1304 if (ob == dialog_->browser_all) {
1307 } else if (ob == dialog_->input_format
1308 || ob == dialog_->input_gui_name
1309 || ob == dialog_->input_shrtcut
1310 || ob == dialog_->input_extension
1311 || ob == dialog_->input_viewer) {
1314 } else if (ob == dialog_->button_add) {
1317 } else if (ob == dialog_->button_delete) {
1325 void FormPreferences::Formats::update()
1327 local_formats = formats;
1332 void FormPreferences::Formats::UpdateBrowser()
1334 local_formats.Sort();
1336 fl_freeze_form(dialog_->form);
1337 fl_deselect_browser(dialog_->browser_all);
1338 fl_clear_browser(dialog_->browser_all);
1339 for (::Formats::const_iterator cit = local_formats.begin();
1340 cit != local_formats.end(); ++cit)
1341 fl_addto_browser(dialog_->browser_all,
1342 (*cit).prettyname().c_str());
1345 fl_unfreeze_form(dialog_->form);
1347 // Mustn't forget to update the Formats available to the converters_
1348 parent_.converters_.UpdateChoices();
1349 local_converters.Update(local_formats);
1353 bool FormPreferences::Formats::Add()
1355 string const name = fl_get_input(dialog_->input_format);
1356 string const prettyname = fl_get_input(dialog_->input_gui_name);
1357 string const extension = fl_get_input(dialog_->input_extension);
1358 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1359 string const viewer = fl_get_input(dialog_->input_viewer);
1361 Format const * old = local_formats.GetFormat(name);
1362 string const old_prettyname = old ? old->prettyname() : string();
1363 local_formats.Add(name, extension, prettyname, shortcut);
1364 local_formats.SetViewer(name, viewer);
1365 if (!old || prettyname != old_prettyname) {
1368 parent_.converters_.UpdateBrowser();
1370 fl_deactivate_object(dialog_->button_add);
1371 fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
1377 bool FormPreferences::Formats::Browser()
1379 int const i = fl_get_browser(dialog_->browser_all);
1380 if (i <= 0) return false;
1382 fl_freeze_form(dialog_->form);
1384 Format const & f = local_formats.Get(i-1);
1386 fl_set_input(dialog_->input_format, f.name().c_str());
1387 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1388 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1389 fl_set_input(dialog_->input_extension, f.extension().c_str());
1390 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1392 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1393 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1395 fl_deactivate_object(dialog_->button_add);
1396 fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
1398 fl_activate_object(dialog_->button_delete);
1399 fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
1401 fl_unfreeze_form(dialog_->form);
1406 bool FormPreferences::Formats::Delete()
1408 string const name = fl_get_input(dialog_->input_format);
1410 if (local_converters.FormatIsUsed(name)) {
1411 parent_.printWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
1412 fl_deactivate_object(dialog_->button_delete);
1413 fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
1417 local_formats.Delete(name);
1423 bool FormPreferences::Formats::Input()
1425 string const name = fl_get_input(dialog_->input_format);
1426 int const sel = local_formats.GetNumber(name);
1427 fl_freeze_form(dialog_->form);
1430 fl_set_object_label(dialog_->button_add,
1432 fl_set_button_shortcut(dialog_->button_add,
1433 scex(_("Add|#A")), 1);
1435 fl_deselect_browser(dialog_->browser_all);
1437 fl_deactivate_object(dialog_->button_delete);
1438 fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
1441 fl_set_object_label(dialog_->button_add,
1442 idex(_("Modify|#M")));
1443 fl_set_button_shortcut(dialog_->button_add,
1444 scex(_("Modify|#M")), 1);
1446 int const top = max(sel-5, 0);
1447 fl_set_browser_topline(dialog_->browser_all, top);
1448 fl_select_browser_line(dialog_->browser_all, sel+1);
1450 fl_activate_object(dialog_->button_add);
1451 fl_set_object_lcol(dialog_->button_add, FL_BLACK);
1453 fl_activate_object(dialog_->button_delete);
1454 fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
1457 string const prettyname = fl_get_input(dialog_->input_gui_name);
1458 if (name.empty() || prettyname.empty()) {
1459 fl_deactivate_object(dialog_->button_add);
1460 fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
1462 fl_activate_object(dialog_->button_add);
1463 fl_set_object_lcol(dialog_->button_add, FL_BLACK);
1466 fl_unfreeze_form(dialog_->form);
1471 FormPreferences::InputsMisc::~InputsMisc()
1477 void FormPreferences::InputsMisc::apply() const
1479 lyxrc.date_insert_format =
1480 fl_get_input(dialog_->input_date_format);
1484 void FormPreferences::InputsMisc::build()
1486 dialog_ = parent_.build_inputs_misc();
1488 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1490 // set up the feedback mechanism
1491 setPreHandler(dialog_->input_date_format);
1496 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1500 if (ob == dialog_->input_date_format)
1501 str = lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1507 void FormPreferences::InputsMisc::update()
1509 fl_set_input(dialog_->input_date_format,
1510 lyxrc.date_insert_format.c_str());
1514 FormPreferences::Interface::~Interface()
1520 void FormPreferences::Interface::apply() const
1522 lyxrc.popup_font_name =
1523 fl_get_input(dialog_->input_popup_font);
1524 lyxrc.menu_font_name = fl_get_input(dialog_->input_menu_font);
1525 lyxrc.font_norm_menu =
1526 fl_get_input(dialog_->input_popup_encoding);
1527 lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
1528 lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
1529 lyxrc.override_x_deadkeys =
1530 fl_get_button(dialog_->check_override_x_dead_keys);
1534 void FormPreferences::Interface::build()
1536 dialog_ = parent_.build_interface();
1538 fl_set_input_return(dialog_->input_popup_font, FL_RETURN_CHANGED);
1539 fl_set_input_return(dialog_->input_menu_font, FL_RETURN_CHANGED);
1540 fl_set_input_return(dialog_->input_popup_encoding, FL_RETURN_CHANGED);
1541 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1542 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1544 // set up the feedback mechanism
1545 setPreHandler(dialog_->input_popup_font);
1546 setPreHandler(dialog_->input_menu_font);
1547 setPreHandler(dialog_->input_popup_encoding);
1548 setPreHandler(dialog_->input_bind_file);
1549 setPreHandler(dialog_->button_bind_file_browse);
1550 setPreHandler(dialog_->input_ui_file);
1551 setPreHandler(dialog_->button_ui_file_browse);
1552 setPreHandler(dialog_->check_override_x_dead_keys);
1557 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1561 if (ob == dialog_->input_popup_font)
1562 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_POPUP);
1563 else if (ob == dialog_->input_menu_font)
1564 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_MENU);
1565 else if (ob == dialog_->input_popup_encoding)
1566 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING_MENU);
1567 else if (ob == dialog_->input_bind_file)
1568 str = lyxrc.getDescription(LyXRC::RC_BINDFILE);
1569 else if (ob == dialog_->input_ui_file)
1570 str = lyxrc.getDescription(LyXRC::RC_UIFILE);
1571 else if (ob == dialog_->check_override_x_dead_keys)
1572 str = lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1578 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1580 if (ob == dialog_->button_bind_file_browse) {
1581 string dir = AddName(system_lyxdir, "bind");
1582 string name = N_("Sys Bind");
1583 pair<string,string> dir1(name, dir);
1585 dir = AddName(user_lyxdir, "bind");
1586 name = N_("User Bind");
1587 pair<string,string> dir2(name, dir);
1589 parent_.browse(dialog_->input_bind_file,
1590 N_("Bind file"), "*.bind", dir1, dir2);
1592 } else if (ob == dialog_->button_ui_file_browse) {
1593 string dir = AddName(system_lyxdir, "ui");
1594 string name = N_("Sys UI");
1595 pair<string,string> dir1(name, dir);
1597 dir = AddName(user_lyxdir, "ui");
1598 name = N_("User UI");
1599 pair<string,string> dir2(name, dir);
1601 parent_.browse(dialog_->input_ui_file,
1602 N_("UI file"), "*.ui", dir1, dir2);
1609 void FormPreferences::Interface::update()
1611 fl_set_input(dialog_->input_popup_font,
1612 lyxrc.popup_font_name.c_str());
1613 fl_set_input(dialog_->input_menu_font,
1614 lyxrc.menu_font_name.c_str());
1615 fl_set_input(dialog_->input_popup_encoding,
1616 lyxrc.font_norm_menu.c_str());
1617 fl_set_input(dialog_->input_bind_file,
1618 lyxrc.bind_file.c_str());
1619 fl_set_input(dialog_->input_ui_file,
1620 lyxrc.ui_file.c_str());
1621 fl_set_button(dialog_->check_override_x_dead_keys,
1622 lyxrc.override_x_deadkeys);
1626 FormPreferences::Language::~Language()
1628 delete combo_default_lang;
1633 void FormPreferences::Language::apply()
1635 lyxrc.default_language = combo_default_lang->getline();
1637 int button = fl_get_button(dialog_->check_use_kbmap);
1638 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1639 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1641 button = !(name_1.empty() && name_2.empty());
1642 lyxrc.use_kbmap = static_cast<bool>(button);
1644 if (lyxrc.use_kbmap) {
1645 lyxrc.primary_kbmap = name_1;
1646 lyxrc.secondary_kbmap = name_2;
1649 button = fl_get_button(dialog_->check_rtl_support);
1650 lyxrc.rtl_support = static_cast<bool>(button);
1652 button = fl_get_button(dialog_->check_auto_begin);
1653 lyxrc.language_auto_begin = static_cast<bool>(button);
1655 button = fl_get_button(dialog_->check_auto_end);
1656 lyxrc.language_auto_end = static_cast<bool>(button);
1658 button = fl_get_button(dialog_->check_mark_foreign);
1659 lyxrc.mark_foreign_language = static_cast<bool>(button);
1661 lyxrc.language_package = fl_get_input(dialog_->input_package);
1662 lyxrc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1663 lyxrc.language_command_end = fl_get_input(dialog_->input_command_end);
1665 // Ensure that all is self-consistent.
1670 void FormPreferences::Language::build()
1672 dialog_ = parent_.build_language();
1674 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1675 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1676 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1678 // The default_language is a combo-box and has to be inserted manually
1679 fl_freeze_form(dialog_->form);
1680 fl_addto_form(dialog_->form);
1682 FL_OBJECT * obj = dialog_->choice_default_lang;
1683 fl_deactivate_object(dialog_->choice_default_lang);
1684 combo_default_lang = new Combox(FL_COMBOX_DROPLIST);
1685 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
1686 parent_.lang_opts_tab_->tabfolder_outer,
1687 parent_.dialog_->tabfolder_prefs);
1688 combo_default_lang->shortcut("#L",1);
1689 combo_default_lang->setcallback(ComboCB, &parent_);
1691 for (Languages::const_iterator cit = languages.begin();
1692 cit != languages.end(); ++cit) {
1693 combo_default_lang->addto((*cit).second.lang());
1697 fl_unfreeze_form(dialog_->form);
1699 // set up the feedback mechanism
1700 setPreHandler(dialog_->input_package);
1701 setPreHandler(dialog_->check_use_kbmap);
1703 // This is safe, as nothing is done to the pointer, other than
1704 // to use its address in a block-if statement.
1705 // No it's not! Leads to crash.
1707 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1708 // C_FormPreferencesFeedbackCB);
1710 setPreHandler(dialog_->input_kbmap1);
1711 setPreHandler(dialog_->input_kbmap2);
1712 setPreHandler(dialog_->check_rtl_support);
1713 setPreHandler(dialog_->check_mark_foreign);
1714 setPreHandler(dialog_->check_auto_begin);
1715 setPreHandler(dialog_->check_auto_end);
1716 setPreHandler(dialog_->input_command_begin);
1717 setPreHandler(dialog_->input_command_end);
1719 // Activate/Deactivate the input fields dependent on the state of the
1726 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1730 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang)
1731 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1732 else if (ob == dialog_->check_use_kbmap)
1733 str = lyxrc.getDescription(LyXRC::RC_KBMAP);
1734 else if (ob == dialog_->input_kbmap1)
1735 str = lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1736 else if (ob == dialog_->input_kbmap2)
1737 str = lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1738 else if (ob == dialog_->check_rtl_support)
1739 str = lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1740 else if (ob == dialog_->check_auto_begin)
1741 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1742 else if (ob == dialog_->check_auto_end)
1743 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1744 else if (ob == dialog_->check_mark_foreign)
1745 str = lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1746 else if (ob == dialog_->input_package)
1747 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1748 else if (ob == dialog_->input_command_begin)
1749 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1750 else if (ob == dialog_->input_command_end)
1751 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1757 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1759 bool activate = true;
1761 // !ob if function is called from Language::build() to de/activate
1763 // otherwise the function is called by an xforms CB via input().
1764 if (!ob || ob == dialog_->check_use_kbmap) {
1765 if (fl_get_button(dialog_->check_use_kbmap)) {
1766 fl_activate_object(dialog_->button_kbmap1_browse);
1767 fl_set_object_lcol(dialog_->button_kbmap1_browse,
1770 fl_activate_object(dialog_->button_kbmap2_browse);
1771 fl_set_object_lcol(dialog_->button_kbmap2_browse,
1774 fl_activate_object(dialog_->input_kbmap1);
1775 fl_set_object_lcol(dialog_->input_kbmap1, FL_BLACK);
1776 fl_activate_object(dialog_->input_kbmap2);
1777 fl_set_object_lcol(dialog_->input_kbmap2, FL_BLACK);
1779 fl_deactivate_object(dialog_->button_kbmap1_browse);
1780 fl_set_object_lcol(dialog_->button_kbmap1_browse,
1783 fl_deactivate_object(dialog_->button_kbmap2_browse);
1784 fl_set_object_lcol(dialog_->button_kbmap2_browse,
1787 fl_deactivate_object(dialog_->input_kbmap1);
1788 fl_set_object_lcol(dialog_->input_kbmap1,
1790 fl_deactivate_object(dialog_->input_kbmap2);
1791 fl_set_object_lcol(dialog_->input_kbmap2,
1796 if (ob == dialog_->button_kbmap1_browse) {
1797 string const dir = AddName(system_lyxdir, "kbd");
1798 string const name = N_("Key maps");
1799 pair<string, string> dir1(name, dir);
1801 parent_.browse(dialog_->input_kbmap1,
1802 N_("Keyboard map"), "*.kmap", dir1,
1803 make_pair(string(), string()));
1804 } else if (ob == dialog_->button_kbmap2_browse) {
1805 string const dir = AddName(system_lyxdir, "kbd");
1806 string const name = N_("Key maps");
1807 pair<string, string> dir1(name, dir);
1809 parent_.browse(dialog_->input_kbmap2,
1810 N_("Keyboard map"), "*.kmap", dir1,
1811 make_pair(string(), string()));
1818 void FormPreferences::Language::update()
1820 fl_set_button(dialog_->check_use_kbmap,
1823 combo_default_lang->select_text(lyxrc.default_language);
1825 if (lyxrc.use_kbmap) {
1826 fl_set_input(dialog_->input_kbmap1,
1827 lyxrc.primary_kbmap.c_str());
1828 fl_set_input(dialog_->input_kbmap2,
1829 lyxrc.secondary_kbmap.c_str());
1831 fl_set_input(dialog_->input_kbmap1, "");
1832 fl_set_input(dialog_->input_kbmap2, "");
1835 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1836 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1837 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1838 fl_set_button(dialog_->check_mark_foreign,
1839 lyxrc.mark_foreign_language);
1841 fl_set_input(dialog_->input_package,
1842 lyxrc.language_package.c_str());
1843 fl_set_input(dialog_->input_command_begin,
1844 lyxrc.language_command_begin.c_str());
1845 fl_set_input(dialog_->input_command_end,
1846 lyxrc.language_command_end.c_str());
1848 // Activate/Deactivate the input fields dependent on the state of the
1854 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1856 FormPreferences * pre = static_cast<FormPreferences*>(v);
1857 // This is safe, as nothing is done to the pointer, other than
1858 // to use its address in a block-if statement.
1859 pre->bc_.valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1863 FormPreferences::LnFmisc::~LnFmisc()
1869 void FormPreferences::LnFmisc::apply() const
1871 lyxrc.show_banner = fl_get_button(dialog_->check_banner);
1872 lyxrc.auto_region_delete =
1873 fl_get_button(dialog_->check_auto_region_delete);
1874 lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm);
1875 lyxrc.display_shortcuts =
1876 fl_get_button(dialog_->check_display_shrtcuts);
1877 lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
1878 lyxrc.cursor_follows_scrollbar =
1879 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1880 lyxrc.autosave = static_cast<unsigned int>
1881 (fl_get_counter_value(dialog_->counter_autosave));
1882 lyxrc.wheel_jump = static_cast<unsigned int>
1883 (fl_get_counter_value(dialog_->counter_wm_jump));
1887 void FormPreferences::LnFmisc::build()
1889 dialog_ = parent_.build_lnf_misc();
1891 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1892 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1894 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1895 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1897 // set up the feedback mechanism
1898 setPreHandler(dialog_->check_banner);
1899 setPreHandler(dialog_->check_auto_region_delete);
1900 setPreHandler(dialog_->check_exit_confirm);
1901 setPreHandler(dialog_->check_display_shrtcuts);
1902 setPreHandler(dialog_->counter_autosave);
1903 setPreHandler(dialog_->check_ask_new_file);
1904 setPreHandler(dialog_->check_cursor_follows_scrollbar);
1905 setPreHandler(dialog_->counter_wm_jump);
1910 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1914 if (ob == dialog_->check_banner)
1915 str = lyxrc.getDescription(LyXRC::RC_SHOW_BANNER);
1916 else if (ob == dialog_->check_auto_region_delete)
1917 str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1918 else if (ob == dialog_->check_exit_confirm)
1919 str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION);
1920 else if (ob == dialog_->check_display_shrtcuts)
1921 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_SHORTCUTS);
1922 else if (ob == dialog_->check_ask_new_file)
1923 str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
1924 else if (ob == dialog_->check_cursor_follows_scrollbar)
1925 str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1926 else if (ob == dialog_->counter_autosave)
1927 str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1928 else if (ob == dialog_->counter_wm_jump)
1929 str = lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1935 void FormPreferences::LnFmisc::update()
1937 fl_set_button(dialog_->check_banner, lyxrc.show_banner);
1938 fl_set_button(dialog_->check_auto_region_delete,
1939 lyxrc.auto_region_delete);
1940 fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
1941 fl_set_button(dialog_->check_display_shrtcuts, lyxrc.display_shortcuts);
1942 fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
1943 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1944 lyxrc.cursor_follows_scrollbar);
1945 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1946 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1950 FormPreferences::OutputsMisc::~OutputsMisc()
1956 void FormPreferences::OutputsMisc::apply() const
1958 lyxrc.ascii_linelen = static_cast<unsigned int>
1959 (fl_get_counter_value(dialog_->counter_line_len));
1960 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1963 fl_get_choice(dialog_->choice_default_papersize) - 1;
1964 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1966 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1967 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1971 void FormPreferences::OutputsMisc::build()
1973 dialog_ = parent_.build_outputs_misc();
1975 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1977 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1978 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1979 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1980 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1982 fl_addto_choice(dialog_->choice_default_papersize,
1983 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
1985 // set up the feedback mechanism
1986 setPreHandler(dialog_->counter_line_len);
1987 setPreHandler(dialog_->input_tex_encoding);
1988 setPreHandler(dialog_->choice_default_papersize);
1989 setPreHandler(dialog_->input_ascii_roff);
1990 setPreHandler(dialog_->input_checktex);
1995 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1999 if (ob == dialog_->counter_line_len)
2000 str = lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
2001 else if (ob == dialog_->input_tex_encoding)
2002 str = lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
2003 else if (ob == dialog_->input_ascii_roff)
2004 str = lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
2005 else if (ob == dialog_->input_checktex)
2006 str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
2007 else if (ob == dialog_->choice_default_papersize)
2008 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2014 void FormPreferences::OutputsMisc::update()
2016 fl_set_counter_value(dialog_->counter_line_len,
2017 lyxrc.ascii_linelen);
2018 fl_set_input(dialog_->input_tex_encoding,
2019 lyxrc.fontenc.c_str());
2020 fl_set_choice(dialog_->choice_default_papersize,
2021 lyxrc.default_papersize+1);
2022 fl_set_input(dialog_->input_ascii_roff,
2023 lyxrc.ascii_roff_command.c_str());
2024 fl_set_input(dialog_->input_checktex,
2025 lyxrc.chktex_command.c_str());
2029 FormPreferences::Paths::~Paths()
2035 void FormPreferences::Paths::apply()
2037 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2038 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2040 int button = fl_get_button(dialog_->check_use_temp_dir);
2041 string str = fl_get_input(dialog_->input_temp_dir);
2042 if (!button) str.erase();
2044 lyxrc.use_tempdir = button;
2045 lyxrc.tempdir_path = str;
2047 button = fl_get_button(dialog_->check_last_files);
2048 str = fl_get_input(dialog_->input_lastfiles);
2049 if (!button) str.erase();
2051 lyxrc.check_lastfiles = button;
2052 lyxrc.lastfiles = str;
2053 lyxrc.num_lastfiles = static_cast<unsigned int>
2054 (fl_get_counter_value(dialog_->counter_lastfiles));
2056 button = fl_get_button(dialog_->check_make_backups);
2057 str = fl_get_input(dialog_->input_backup_path);
2058 if (!button) str.erase();
2060 lyxrc.make_backup = button;
2061 lyxrc.backupdir_path = str;
2063 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2070 void FormPreferences::Paths::build()
2072 dialog_ = parent_.build_paths();
2074 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2075 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2076 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2077 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2078 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2079 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2080 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2082 // set up the feedback mechanism
2083 setPreHandler(dialog_->input_default_path);
2084 setPreHandler(dialog_->counter_lastfiles);
2085 setPreHandler(dialog_->input_template_path);
2086 setPreHandler(dialog_->check_last_files);
2087 setPreHandler(dialog_->input_lastfiles);
2088 setPreHandler(dialog_->check_make_backups);
2089 setPreHandler(dialog_->input_backup_path);
2090 setPreHandler(dialog_->input_serverpipe);
2091 setPreHandler(dialog_->input_temp_dir);
2092 setPreHandler(dialog_->check_use_temp_dir);
2097 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2101 if (ob == dialog_->input_default_path)
2102 str = lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2103 else if (ob == dialog_->input_template_path)
2104 str = lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2105 else if (ob == dialog_->check_use_temp_dir)
2106 str = lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2107 else if (ob == dialog_->input_temp_dir)
2108 str = lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2109 else if (ob == dialog_->check_last_files)
2110 str = lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2111 else if (ob == dialog_->input_lastfiles)
2112 str = lyxrc.getDescription(LyXRC::RC_LASTFILES);
2113 else if (ob == dialog_->counter_lastfiles)
2114 str = lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2115 else if (ob == dialog_->check_make_backups)
2116 str = lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2117 else if (ob == dialog_->input_backup_path)
2118 str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2119 else if (ob == dialog_->input_serverpipe) {
2120 str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2121 str += " Enter either the input pipe, xxx.in, or the output pipe, xxx.out.";
2128 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2130 bool activate = true;
2132 // !ob if function is called from Paths::update() to de/activate
2134 // otherwise the function is called by an xforms CB via input().
2135 if (!ob || ob == dialog_->check_use_temp_dir) {
2136 if (fl_get_button(dialog_->check_use_temp_dir)) {
2137 fl_activate_object(dialog_->input_temp_dir);
2138 fl_set_object_lcol(dialog_->input_temp_dir,
2141 fl_deactivate_object(dialog_->input_temp_dir);
2142 fl_set_object_lcol(dialog_->input_temp_dir,
2147 if (!ob || ob == dialog_->check_last_files) {
2148 if (fl_get_button(dialog_->check_last_files)) {
2149 fl_activate_object(dialog_->input_lastfiles);
2150 fl_set_object_lcol(dialog_->input_lastfiles,
2153 fl_deactivate_object(dialog_->input_lastfiles);
2154 fl_set_object_lcol(dialog_->input_lastfiles,
2159 if (!ob || ob == dialog_->check_make_backups) {
2160 if (fl_get_button(dialog_->check_make_backups)) {
2161 fl_activate_object(dialog_->input_backup_path);
2162 fl_set_object_lcol(dialog_->input_backup_path,
2165 fl_deactivate_object(dialog_->input_backup_path);
2166 fl_set_object_lcol(dialog_->input_backup_path,
2171 if (!ob || ob == dialog_->input_default_path) {
2172 string const name = fl_get_input(dialog_->input_default_path);
2173 if (!RWInfo::WriteableDir(name)) {
2174 parent_.printWarning(RWInfo::ErrorMessage());
2179 if (!ob || ob == dialog_->input_template_path) {
2180 string const name = fl_get_input(dialog_->input_template_path);
2181 if (!RWInfo::ReadableDir(name)) {
2182 parent_.printWarning(RWInfo::ErrorMessage());
2187 if (!ob || ob == dialog_->input_temp_dir) {
2188 string const name = fl_get_input(dialog_->input_temp_dir);
2189 if (fl_get_button(dialog_->check_make_backups)
2191 && !RWInfo::WriteableDir(name)) {
2192 parent_.printWarning(RWInfo::ErrorMessage());
2197 if (!ob || ob == dialog_->input_backup_path) {
2198 string const name = fl_get_input(dialog_->input_backup_path);
2199 if (fl_get_button(dialog_->check_make_backups)
2201 && !RWInfo::WriteableDir(name)) {
2202 parent_.printWarning(RWInfo::ErrorMessage());
2207 if (!ob || ob == dialog_->input_lastfiles) {
2208 string const name = fl_get_input(dialog_->input_lastfiles);
2209 if (fl_get_button(dialog_->check_last_files)
2211 && !RWInfo::WriteableFile(name)) {
2212 parent_.printWarning(RWInfo::ErrorMessage());
2217 if (!ob || ob == dialog_->input_serverpipe) {
2218 string const name = fl_get_input(dialog_->input_serverpipe);
2219 if (!name.empty()) {
2220 // strip off the extension
2221 string const str = ChangeExtension(name, "");
2222 if (!RWInfo::WriteableFile(str + ".in")) {
2223 parent_.printWarning(RWInfo::ErrorMessage());
2226 if (!RWInfo::WriteableFile(str + ".out")) {
2227 parent_.printWarning(RWInfo::ErrorMessage());
2233 if (ob == dialog_->button_default_path_browse) {
2234 parent_.browse(dialog_->input_default_path,
2235 N_("Default path"), string(),
2236 make_pair(string(), string()),
2237 make_pair(string(), string()));
2238 } else if (ob == dialog_->button_template_path_browse) {
2239 parent_.browse(dialog_->input_template_path,
2240 N_("Template path"), string(),
2241 make_pair(string(), string()),
2242 make_pair(string(), string()));
2243 } else if (ob == dialog_->button_temp_dir_browse) {
2244 parent_.browse(dialog_->input_temp_dir,
2245 N_("Temp dir"), string(),
2246 make_pair(string(), string()),
2247 make_pair(string(), string()));
2248 } else if (ob == dialog_->button_lastfiles_browse) {
2249 pair<string, string> dir(_("User"), user_lyxdir);
2251 parent_.browse(dialog_->input_lastfiles,
2252 N_("Lastfiles"), string(), dir,
2253 make_pair(string(), string()));
2254 } else if (ob == dialog_->button_backup_path_browse) {
2255 parent_.browse(dialog_->input_backup_path,
2256 N_("Backup path"), string(),
2257 make_pair(string(), string()),
2258 make_pair(string(), string()));
2259 } else if (ob == dialog_->button_serverpipe_browse) {
2260 parent_.browse(dialog_->input_serverpipe,
2261 N_("LyX Server pipes"), string(),
2262 make_pair(string(), string()),
2263 make_pair(string(), string()));
2270 void FormPreferences::Paths::update()
2272 fl_set_input(dialog_->input_default_path,
2273 lyxrc.document_path.c_str());
2274 fl_set_input(dialog_->input_template_path,
2275 lyxrc.template_path.c_str());
2278 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
2280 fl_set_button(dialog_->check_make_backups,
2282 fl_set_input(dialog_->input_backup_path, str.c_str());
2285 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
2287 fl_set_button(dialog_->check_use_temp_dir,
2289 fl_set_input(dialog_->input_temp_dir, str.c_str());
2292 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
2294 fl_set_button(dialog_->check_last_files,
2295 lyxrc.check_lastfiles);
2296 fl_set_input(dialog_->input_lastfiles, str.c_str());
2297 fl_set_counter_value(dialog_->counter_lastfiles,
2298 lyxrc.num_lastfiles);
2300 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2302 // Activate/Deactivate the input fields dependent on the state of the
2308 FormPreferences::Printer::~Printer()
2314 void FormPreferences::Printer::apply() const
2316 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2317 lyxrc.print_command = fl_get_input(dialog_->input_command);
2318 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2319 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2320 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2321 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2322 lyxrc.print_file_extension =
2323 fl_get_input(dialog_->input_file_extension);
2324 lyxrc.print_spool_command =
2325 fl_get_input(dialog_->input_spool_command);
2326 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2327 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2328 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2329 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2330 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2331 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2332 lyxrc.print_extra_options =
2333 fl_get_input(dialog_->input_extra_options);
2334 lyxrc.print_spool_printerprefix =
2335 fl_get_input(dialog_->input_spool_prefix);
2336 lyxrc.print_paper_dimension_flag =
2337 fl_get_input(dialog_->input_paper_size);
2338 lyxrc.printer = fl_get_input(dialog_->input_name);
2343 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2347 if (ob == dialog_->input_command)
2348 str = lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2349 else if (ob == dialog_->check_adapt_output)
2350 str = lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2351 else if (ob == dialog_->input_to_printer)
2352 str = lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2353 else if (ob == dialog_->input_to_file)
2354 str = lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2355 else if (ob == dialog_->input_file_extension)
2356 str = lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2357 else if (ob == dialog_->input_extra_options)
2358 str = lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2359 else if (ob == dialog_->input_spool_command)
2360 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2361 else if (ob == dialog_->input_spool_prefix)
2362 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2363 else if (ob == dialog_->input_name)
2364 str = lyxrc.getDescription(LyXRC::RC_PRINTER);
2365 else if (ob == dialog_->input_even_pages)
2366 str = lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2367 else if (ob == dialog_->input_odd_pages)
2368 str = lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2369 else if (ob == dialog_->input_page_range)
2370 str = lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2371 else if (ob == dialog_->input_reverse)
2372 str = lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2373 else if (ob == dialog_->input_landscape)
2374 str = lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2375 else if (ob == dialog_->input_copies)
2376 str = lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2377 else if (ob == dialog_->input_collated)
2378 str = lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2379 else if (ob == dialog_->input_paper_type)
2380 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2381 else if (ob == dialog_->input_paper_size)
2382 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2388 void FormPreferences::Printer::build()
2390 dialog_ = parent_.build_printer();
2392 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2393 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2394 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2395 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2396 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2397 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2398 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2399 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2400 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2401 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2402 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2403 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2404 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2405 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2406 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2407 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2408 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2410 // set up the feedback mechanism
2411 setPreHandler(dialog_->input_command);
2412 setPreHandler(dialog_->input_page_range);
2413 setPreHandler(dialog_->input_copies);
2414 setPreHandler(dialog_->input_reverse);
2415 setPreHandler(dialog_->input_to_printer);
2416 setPreHandler(dialog_->input_file_extension);
2417 setPreHandler(dialog_->input_spool_command);
2418 setPreHandler(dialog_->input_paper_type);
2419 setPreHandler(dialog_->input_even_pages);
2420 setPreHandler(dialog_->input_odd_pages);
2421 setPreHandler(dialog_->input_collated);
2422 setPreHandler(dialog_->input_landscape);
2423 setPreHandler(dialog_->input_to_file);
2424 setPreHandler(dialog_->input_extra_options);
2425 setPreHandler(dialog_->input_spool_prefix);
2426 setPreHandler(dialog_->input_paper_size);
2427 setPreHandler(dialog_->input_name);
2428 setPreHandler(dialog_->check_adapt_output);
2432 void FormPreferences::Printer::update()
2434 fl_set_button(dialog_->check_adapt_output,
2435 lyxrc.print_adapt_output);
2436 fl_set_input(dialog_->input_command,
2437 lyxrc.print_command.c_str());
2438 fl_set_input(dialog_->input_page_range,
2439 lyxrc.print_pagerange_flag.c_str());
2440 fl_set_input(dialog_->input_copies,
2441 lyxrc.print_copies_flag.c_str());
2442 fl_set_input(dialog_->input_reverse,
2443 lyxrc.print_reverse_flag.c_str());
2444 fl_set_input(dialog_->input_to_printer,
2445 lyxrc.print_to_printer.c_str());
2446 fl_set_input(dialog_->input_file_extension,
2447 lyxrc.print_file_extension.c_str());
2448 fl_set_input(dialog_->input_spool_command,
2449 lyxrc.print_spool_command.c_str());
2450 fl_set_input(dialog_->input_paper_type,
2451 lyxrc.print_paper_flag.c_str());
2452 fl_set_input(dialog_->input_even_pages,
2453 lyxrc.print_evenpage_flag.c_str());
2454 fl_set_input(dialog_->input_odd_pages,
2455 lyxrc.print_oddpage_flag.c_str());
2456 fl_set_input(dialog_->input_collated,
2457 lyxrc.print_collcopies_flag.c_str());
2458 fl_set_input(dialog_->input_landscape,
2459 lyxrc.print_landscape_flag.c_str());
2460 fl_set_input(dialog_->input_to_file,
2461 lyxrc.print_to_file.c_str());
2462 fl_set_input(dialog_->input_extra_options,
2463 lyxrc.print_extra_options.c_str());
2464 fl_set_input(dialog_->input_spool_prefix,
2465 lyxrc.print_spool_printerprefix.c_str());
2466 fl_set_input(dialog_->input_paper_size,
2467 lyxrc.print_paper_dimension_flag.c_str());
2468 fl_set_input(dialog_->input_name,
2469 lyxrc.printer.c_str());
2473 FormPreferences::ScreenFonts::~ScreenFonts()
2479 void FormPreferences::ScreenFonts::apply() const
2481 bool changed = false;
2483 string str = fl_get_input(dialog_->input_roman);
2484 if (lyxrc.roman_font_name != str) {
2486 lyxrc.roman_font_name = str;
2489 str = fl_get_input(dialog_->input_sans);
2490 if (lyxrc.sans_font_name != str) {
2492 lyxrc.sans_font_name = str;
2495 str = fl_get_input(dialog_->input_typewriter);
2496 if (lyxrc.typewriter_font_name != str) {
2498 lyxrc.typewriter_font_name = str;
2501 str = fl_get_input(dialog_->input_screen_encoding);
2502 if (lyxrc.font_norm != str) {
2504 lyxrc.font_norm = str;
2507 bool button = fl_get_button(dialog_->check_scalable);
2508 if (lyxrc.use_scalable_fonts != button) {
2510 lyxrc.use_scalable_fonts = button;
2513 unsigned int ivalue = static_cast<unsigned int>
2514 (fl_get_counter_value(dialog_->counter_zoom));
2515 if (lyxrc.zoom != ivalue) {
2517 lyxrc.zoom = ivalue;
2520 ivalue = static_cast<unsigned int>
2521 (fl_get_counter_value(dialog_->counter_dpi));
2522 if (lyxrc.dpi != ivalue) {
2527 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2528 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2530 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2533 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2534 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2536 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2539 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2540 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2542 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2545 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2546 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2548 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2551 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2552 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2554 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2557 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2558 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2560 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2563 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2564 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2566 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2569 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2570 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2572 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2575 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2576 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2578 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2581 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2582 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2584 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2588 // Now update the buffers
2589 // Can anything below here affect the redraw process?
2590 parent_.lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
2595 void FormPreferences::ScreenFonts::build()
2597 dialog_ = parent_.build_screen_fonts();
2599 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2600 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2602 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2603 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2604 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2605 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2606 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2607 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2608 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2609 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2610 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2611 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2612 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2613 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2614 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2615 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2616 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2617 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2619 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2620 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2621 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2622 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2623 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2624 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2625 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2626 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2627 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2628 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2630 // set up the feedback mechanism
2631 setPreHandler(dialog_->input_roman);
2632 setPreHandler(dialog_->input_sans);
2633 setPreHandler(dialog_->input_typewriter);
2634 setPreHandler(dialog_->counter_zoom);
2635 setPreHandler(dialog_->counter_dpi);
2636 setPreHandler(dialog_->check_scalable);
2637 setPreHandler(dialog_->input_screen_encoding);
2638 setPreHandler(dialog_->input_tiny);
2639 setPreHandler(dialog_->input_script);
2640 setPreHandler(dialog_->input_footnote);
2641 setPreHandler(dialog_->input_small);
2642 setPreHandler(dialog_->input_large);
2643 setPreHandler(dialog_->input_larger);
2644 setPreHandler(dialog_->input_largest);
2645 setPreHandler(dialog_->input_normal);
2646 setPreHandler(dialog_->input_huge);
2647 setPreHandler(dialog_->input_huger);
2652 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2656 if (ob == dialog_->input_roman)
2657 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2658 else if (ob == dialog_->input_sans)
2659 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2660 else if (ob == dialog_->input_typewriter)
2661 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2662 else if (ob == dialog_->check_scalable)
2663 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2664 else if (ob == dialog_->input_screen_encoding)
2665 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2666 else if (ob == dialog_->counter_zoom)
2667 str = lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2668 else if (ob == dialog_->counter_dpi)
2669 str = lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2670 else if (ob == dialog_->input_tiny
2671 || ob == dialog_->input_script
2672 || ob == dialog_->input_footnote
2673 || ob == dialog_->input_small
2674 || ob == dialog_->input_large
2675 || ob == dialog_->input_larger
2676 || ob == dialog_->input_larger
2677 || ob == dialog_->input_largest
2678 || ob == dialog_->input_normal
2679 || ob == dialog_->input_huge
2680 || ob == dialog_->input_huger)
2681 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2687 bool FormPreferences::ScreenFonts::input()
2689 bool activate = true;
2692 // Make sure that all fonts all have positive entries
2693 // Also note that an empty entry is returned as 0.0 by strToDbl
2694 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2695 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2696 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2697 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2698 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2699 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2700 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2701 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2702 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2703 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2705 str = N_("Fonts must be positive!");
2707 // Fontsizes -- tiny < script < footnote etc.
2708 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2709 strToDbl(fl_get_input(dialog_->input_script)) ||
2710 strToDbl(fl_get_input(dialog_->input_script)) >
2711 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2712 strToDbl(fl_get_input(dialog_->input_footnote)) >
2713 strToDbl(fl_get_input(dialog_->input_small)) ||
2714 strToDbl(fl_get_input(dialog_->input_small)) >
2715 strToDbl(fl_get_input(dialog_->input_normal)) ||
2716 strToDbl(fl_get_input(dialog_->input_normal)) >
2717 strToDbl(fl_get_input(dialog_->input_large)) ||
2718 strToDbl(fl_get_input(dialog_->input_large)) >
2719 strToDbl(fl_get_input(dialog_->input_larger)) ||
2720 strToDbl(fl_get_input(dialog_->input_larger)) >
2721 strToDbl(fl_get_input(dialog_->input_largest)) ||
2722 strToDbl(fl_get_input(dialog_->input_largest)) >
2723 strToDbl(fl_get_input(dialog_->input_huge)) ||
2724 strToDbl(fl_get_input(dialog_->input_huge)) >
2725 strToDbl(fl_get_input(dialog_->input_huger))) {
2728 str = N_("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2732 parent_.printWarning(str);
2738 void FormPreferences::ScreenFonts::update()
2740 fl_set_input(dialog_->input_roman,
2741 lyxrc.roman_font_name.c_str());
2742 fl_set_input(dialog_->input_sans,
2743 lyxrc.sans_font_name.c_str());
2744 fl_set_input(dialog_->input_typewriter,
2745 lyxrc.typewriter_font_name.c_str());
2746 fl_set_input(dialog_->input_screen_encoding,
2747 lyxrc.font_norm.c_str());
2748 fl_set_button(dialog_->check_scalable,
2749 lyxrc.use_scalable_fonts);
2750 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2751 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2752 fl_set_input(dialog_->input_tiny,
2753 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2754 fl_set_input(dialog_->input_script,
2755 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2756 fl_set_input(dialog_->input_footnote,
2757 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2758 fl_set_input(dialog_->input_small,
2759 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2760 fl_set_input(dialog_->input_normal,
2761 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2762 fl_set_input(dialog_->input_large,
2763 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2764 fl_set_input(dialog_->input_larger,
2765 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2766 fl_set_input(dialog_->input_largest,
2767 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2768 fl_set_input(dialog_->input_huge,
2769 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2770 fl_set_input(dialog_->input_huger,
2771 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2775 FormPreferences::SpellChecker::~SpellChecker()
2781 void FormPreferences::SpellChecker::apply()
2784 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2785 choice = strip(frontStrip(choice));
2787 lyxrc.isp_command = choice;
2789 // If spell checker == "none", all other input set to off.
2790 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2791 lyxrc.isp_use_alt_lang = false;
2792 lyxrc.isp_alt_lang.erase();
2794 lyxrc.isp_use_esc_chars = false;
2795 lyxrc.isp_esc_chars.erase();
2797 lyxrc.isp_use_pers_dict = false;
2798 lyxrc.isp_pers_dict.erase();
2800 lyxrc.isp_accept_compound = false;
2801 lyxrc.isp_use_input_encoding = false;
2803 int button = fl_get_button(dialog_->check_alt_lang);
2804 choice = fl_get_input(dialog_->input_alt_lang);
2805 if (button && choice.empty()) button = 0;
2806 if (!button) choice.erase();
2808 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2809 lyxrc.isp_alt_lang = choice;
2811 button = fl_get_button(dialog_->check_escape_chars);
2812 choice = fl_get_input(dialog_->input_escape_chars);
2813 if (button && choice.empty()) button = 0;
2814 if (!button) choice.erase();
2816 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2817 lyxrc.isp_esc_chars = choice;
2819 button = fl_get_button(dialog_->check_personal_dict);
2820 choice = fl_get_input(dialog_->input_personal_dict);
2821 if (button && choice.empty()) button = 0;
2822 if (!button) choice.erase();
2824 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2825 lyxrc.isp_pers_dict = choice;
2827 button = fl_get_button(dialog_->check_compound_words);
2828 lyxrc.isp_accept_compound = static_cast<bool>(button);
2830 button = fl_get_button(dialog_->check_input_enc);
2831 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2839 void FormPreferences::SpellChecker::build()
2841 dialog_ = parent_.build_spellchecker();
2843 fl_addto_choice(dialog_->choice_spell_command,
2844 _(" none | ispell | aspell "));
2845 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2846 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2847 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2849 // set up the feedback mechanism
2850 setPreHandler(dialog_->choice_spell_command);
2851 setPreHandler(dialog_->check_alt_lang);
2852 setPreHandler(dialog_->input_alt_lang);
2853 setPreHandler(dialog_->check_escape_chars);
2854 setPreHandler(dialog_->input_escape_chars);
2855 setPreHandler(dialog_->check_personal_dict);
2856 setPreHandler(dialog_->input_personal_dict);
2857 setPreHandler(dialog_->button_personal_dict);
2858 setPreHandler(dialog_->check_compound_words);
2859 setPreHandler(dialog_->check_input_enc);
2864 FormPreferences::SpellChecker::feedback(FL_OBJECT const * const ob) const
2868 if (ob == dialog_->choice_spell_command)
2869 str = lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2870 else if (ob == dialog_->check_alt_lang)
2871 str = lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2872 else if (ob == dialog_->input_alt_lang)
2873 str = lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2874 else if (ob == dialog_->check_escape_chars)
2875 str = lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2876 else if (ob == dialog_->input_escape_chars)
2877 str = lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2878 else if (ob == dialog_->check_personal_dict)
2879 str = lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2880 else if (ob == dialog_->input_personal_dict)
2881 str = lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2882 else if (ob == dialog_->check_compound_words)
2883 str = lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2884 else if (ob == dialog_->check_input_enc)
2885 str = lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2891 bool FormPreferences::SpellChecker::input(FL_OBJECT const * const ob)
2893 // !ob if function is called from updateSpellChecker() to de/activate
2895 // otherwise the function is called by an xforms CB via input().
2897 // If spell checker == "none", disable all input.
2898 if (!ob || ob == dialog_->choice_spell_command) {
2899 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2900 fl_deactivate_object(dialog_->check_alt_lang);
2901 fl_deactivate_object(dialog_->input_alt_lang);
2902 fl_deactivate_object(dialog_->check_escape_chars);
2903 fl_deactivate_object(dialog_->input_escape_chars);
2904 fl_deactivate_object(dialog_->check_personal_dict);
2905 fl_deactivate_object(dialog_->input_personal_dict);
2906 fl_deactivate_object(dialog_->check_compound_words);
2907 fl_deactivate_object(dialog_->check_input_enc);
2910 fl_activate_object(dialog_->check_alt_lang);
2911 fl_activate_object(dialog_->check_escape_chars);
2912 fl_activate_object(dialog_->check_personal_dict);
2913 fl_activate_object(dialog_->check_compound_words);
2914 fl_activate_object(dialog_->check_input_enc);
2918 if (!ob || ob == dialog_->check_alt_lang) {
2919 if (fl_get_button(dialog_->check_alt_lang)) {
2920 fl_activate_object(dialog_->input_alt_lang);
2921 fl_set_object_lcol(dialog_->input_alt_lang,
2924 fl_deactivate_object(dialog_->input_alt_lang);
2925 fl_set_object_lcol(dialog_->input_alt_lang,
2930 if (!ob || ob == dialog_->check_escape_chars) {
2931 if (fl_get_button(dialog_->check_escape_chars)) {
2932 fl_activate_object(dialog_->input_escape_chars);
2933 fl_set_object_lcol(dialog_->input_escape_chars,
2936 fl_deactivate_object(dialog_->input_escape_chars);
2937 fl_set_object_lcol(dialog_->input_escape_chars,
2942 if (!ob || ob == dialog_->check_personal_dict) {
2943 if (fl_get_button(dialog_->check_personal_dict)) {
2944 fl_activate_object(dialog_->input_personal_dict);
2945 fl_set_object_lcol(dialog_->input_personal_dict,
2948 fl_deactivate_object(dialog_->input_personal_dict);
2949 fl_set_object_lcol(dialog_->input_personal_dict,
2954 if (ob == dialog_->button_personal_dict) {
2955 parent_.browse(dialog_->input_personal_dict,
2956 N_("Personal dictionary"), "*.ispell",
2957 make_pair(string(), string()),
2958 make_pair(string(), string()));
2961 return true; // All input is valid!
2965 void FormPreferences::SpellChecker::update()
2968 if (lyxrc.isp_command == "none")
2970 else if (lyxrc.isp_command == "ispell")
2972 else if (lyxrc.isp_command == "aspell")
2974 fl_set_choice(dialog_->choice_spell_command, choice);
2977 if (lyxrc.isp_use_alt_lang) str = lyxrc.isp_alt_lang;
2979 fl_set_button(dialog_->check_alt_lang,
2980 lyxrc.isp_use_alt_lang);
2981 fl_set_input(dialog_->input_alt_lang, str.c_str());
2984 if (lyxrc.isp_use_esc_chars) str = lyxrc.isp_esc_chars;
2986 fl_set_button(dialog_->check_escape_chars,
2987 lyxrc.isp_use_esc_chars);
2988 fl_set_input(dialog_->input_escape_chars, str.c_str());
2991 if (lyxrc.isp_use_pers_dict) str = lyxrc.isp_pers_dict;
2993 fl_set_button(dialog_->check_personal_dict,
2994 lyxrc.isp_use_pers_dict);
2995 fl_set_input(dialog_->input_personal_dict, str.c_str());
2997 fl_set_button(dialog_->check_compound_words,
2998 lyxrc.isp_accept_compound);
2999 fl_set_button(dialog_->check_input_enc,
3000 lyxrc.isp_use_input_encoding);
3002 // Activate/Deactivate the input fields dependent on the state of the
3008 void FormPreferences::printWarning(string const & warning)
3010 warningPosted = true;
3012 string str = _("WARNING!") + string(" ") + warning;
3013 str = formatted(str, dialog_->text_warning->w-10,
3014 FL_SMALL_SIZE, FL_NORMAL_STYLE);
3016 fl_set_object_label(dialog_->text_warning, str.c_str());
3017 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
3021 void FormPreferences::browse(FL_OBJECT * inpt,
3022 string const & title,
3023 string const & pattern,
3024 pair<string,string> const & dir1,
3025 pair<string,string> const & dir2)
3027 // Get the filename from the dialog
3028 string const filename = fl_get_input(inpt);
3030 // Show the file browser dialog
3031 string const new_filename =
3032 browseFile(filename, title, pattern, dir1, dir2);
3034 // Save the filename to the dialog
3035 if (new_filename != filename && !new_filename.empty()) {
3036 fl_set_input(inpt, new_filename.c_str());
3042 // C function wrapper, required by xforms.
3043 extern "C" int C_FormPreferencesFeedbackCB(FL_OBJECT * ob, int event,
3044 FL_Coord mx, FL_Coord my,
3045 int key, void * xev)
3047 return FormPreferences::FeedbackCB(ob, event, mx, my, key, xev);
3050 int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event,
3051 FL_Coord, FL_Coord, int, void *)
3053 // Note that the return value is important in the pre-emptive handler.
3054 // Don't return anything other than 0.
3057 // Don't Assert this one, as it can happen quite reasonably when things
3058 // are being deleted in the d-tor.
3060 if (!ob->form) return 0;
3062 FormPreferences * pre =
3063 static_cast<FormPreferences*>(ob->form->u_vdata);
3064 pre->Feedback(ob, event);
3069 // preemptive handler for feedback messages
3070 void FormPreferences::Feedback(FL_OBJECT * ob, int event)
3076 warningPosted = false;
3082 fl_set_object_label(dialog_->text_warning, "");
3091 void FormPreferences::setPreHandler(FL_OBJECT * ob)
3094 fl_set_object_prehandler(ob, C_FormPreferencesFeedbackCB);