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 int const i = fl_get_choice(dialog_->choice_from);
1188 if (i > 0 && i <= local_formats.size())
1189 return local_formats.Get(i-1).name();
1191 lyxerr << "FormPreferences::Converters::GetFrom: No choice!"
1198 string const FormPreferences::Converters::GetTo() const
1200 int const i = fl_get_choice(dialog_->choice_to);
1201 if (i > 0 && i <= local_formats.size())
1202 return local_formats.Get(i-1).name();
1204 lyxerr << "FormPreferences::Converters::GetTo: No choice!"
1211 void FormPreferences::Converters::UpdateChoices() const
1214 for (::Formats::const_iterator cit = local_formats.begin();
1215 cit != local_formats.end(); ++cit) {
1216 if (!choice.empty())
1220 choice += (*cit).prettyname();
1224 fl_clear_choice(dialog_->choice_from);
1225 fl_addto_choice(dialog_->choice_from, choice.c_str());
1227 fl_clear_choice(dialog_->choice_to);
1228 fl_addto_choice(dialog_->choice_to, choice.c_str());
1232 FormPreferences::Formats::~Formats()
1238 void FormPreferences::Formats::apply() const
1240 formats = local_formats;
1244 void FormPreferences::Formats::build()
1246 dialog_ = parent_.build_formats();
1248 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1249 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1250 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1251 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1252 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1254 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1256 // set up the feedback mechanism
1257 setPreHandler(dialog_->browser_all);
1258 setPreHandler(dialog_->input_format);
1259 setPreHandler(dialog_->input_gui_name);
1260 setPreHandler(dialog_->button_delete);
1261 setPreHandler(dialog_->button_add);
1262 setPreHandler(dialog_->input_extension);
1263 setPreHandler(dialog_->input_viewer);
1264 setPreHandler(dialog_->input_shrtcut);
1269 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1273 if (ob == dialog_->browser_all) {
1274 str = N_("All the currently defined formats known to LyX.");
1275 } else if (ob == dialog_->input_format) {
1276 str = N_("The format identifier.");
1277 } else if (ob == dialog_->input_gui_name) {
1278 str = N_("The format name as it will appear in the menus.");
1279 } else if (ob == dialog_->input_shrtcut) {
1280 str = N_("The keyboard accelerator. Use a letter in the GUI name. Case sensitive.");
1281 } else if (ob == dialog_->input_extension) {
1282 str = N_("Used to recognize the file. E.g., ps, pdf, tex.");
1283 } else if (ob == dialog_->input_viewer) {
1284 str = N_("The command used to launch the viewer application.");
1285 } else if (ob == dialog_->button_delete) {
1286 str = N_("Remove the current format from the list of available formats. Note: you must then \"Apply\" the change.");
1287 } else if (ob == dialog_->button_add) {
1288 if (string(ob->label) == _("Add"))
1289 str = N_("Add the current format to the list of available formats. Note: you must then \"Apply\" the change.");
1291 str = N_("Modify the contents of the current format. Note: you must then \"Apply\" the change.");
1298 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1300 if (ob == dialog_->browser_all) {
1303 } else if (ob == dialog_->input_format
1304 || ob == dialog_->input_gui_name
1305 || ob == dialog_->input_shrtcut
1306 || ob == dialog_->input_extension
1307 || ob == dialog_->input_viewer) {
1310 } else if (ob == dialog_->button_add) {
1313 } else if (ob == dialog_->button_delete) {
1321 void FormPreferences::Formats::update()
1323 local_formats = formats;
1328 void FormPreferences::Formats::UpdateBrowser()
1330 local_formats.Sort();
1332 fl_freeze_form(dialog_->form);
1333 fl_deselect_browser(dialog_->browser_all);
1334 fl_clear_browser(dialog_->browser_all);
1335 for (::Formats::const_iterator cit = local_formats.begin();
1336 cit != local_formats.end(); ++cit)
1337 fl_addto_browser(dialog_->browser_all,
1338 (*cit).prettyname().c_str());
1341 fl_unfreeze_form(dialog_->form);
1343 // Mustn't forget to update the Formats available to the converters_
1344 parent_.converters_.UpdateChoices();
1345 local_converters.Update(local_formats);
1349 bool FormPreferences::Formats::Add()
1351 string const name = fl_get_input(dialog_->input_format);
1352 string const prettyname = fl_get_input(dialog_->input_gui_name);
1353 string const extension = fl_get_input(dialog_->input_extension);
1354 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1355 string const viewer = fl_get_input(dialog_->input_viewer);
1357 Format const * old = local_formats.GetFormat(name);
1358 string const old_prettyname = old ? old->prettyname() : string();
1359 local_formats.Add(name, extension, prettyname, shortcut);
1360 local_formats.SetViewer(name, viewer);
1361 if (!old || prettyname != old_prettyname) {
1364 parent_.converters_.UpdateBrowser();
1366 fl_deactivate_object(dialog_->button_add);
1367 fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
1373 bool FormPreferences::Formats::Browser()
1375 int const i = fl_get_browser(dialog_->browser_all);
1376 if (i <= 0) return false;
1378 fl_freeze_form(dialog_->form);
1380 Format const & f = local_formats.Get(i-1);
1382 fl_set_input(dialog_->input_format, f.name().c_str());
1383 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1384 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1385 fl_set_input(dialog_->input_extension, f.extension().c_str());
1386 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1388 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1389 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1391 fl_deactivate_object(dialog_->button_add);
1392 fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
1394 fl_activate_object(dialog_->button_delete);
1395 fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
1397 fl_unfreeze_form(dialog_->form);
1402 bool FormPreferences::Formats::Delete()
1404 string const name = fl_get_input(dialog_->input_format);
1406 if (local_converters.FormatIsUsed(name)) {
1407 parent_.printWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
1408 fl_deactivate_object(dialog_->button_delete);
1409 fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
1413 local_formats.Delete(name);
1419 bool FormPreferences::Formats::Input()
1421 string const name = fl_get_input(dialog_->input_format);
1422 int const sel = local_formats.GetNumber(name);
1423 fl_freeze_form(dialog_->form);
1426 fl_set_object_label(dialog_->button_add,
1428 fl_set_button_shortcut(dialog_->button_add,
1429 scex(_("Add|#A")), 1);
1431 fl_deselect_browser(dialog_->browser_all);
1433 fl_deactivate_object(dialog_->button_delete);
1434 fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
1437 fl_set_object_label(dialog_->button_add,
1438 idex(_("Modify|#M")));
1439 fl_set_button_shortcut(dialog_->button_add,
1440 scex(_("Modify|#M")), 1);
1442 int const top = max(sel-5, 0);
1443 fl_set_browser_topline(dialog_->browser_all, top);
1444 fl_select_browser_line(dialog_->browser_all, sel+1);
1446 fl_activate_object(dialog_->button_add);
1447 fl_set_object_lcol(dialog_->button_add, FL_BLACK);
1449 fl_activate_object(dialog_->button_delete);
1450 fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
1453 string const prettyname = fl_get_input(dialog_->input_gui_name);
1454 if (name.empty() || prettyname.empty()) {
1455 fl_deactivate_object(dialog_->button_add);
1456 fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
1458 fl_activate_object(dialog_->button_add);
1459 fl_set_object_lcol(dialog_->button_add, FL_BLACK);
1462 fl_unfreeze_form(dialog_->form);
1467 FormPreferences::InputsMisc::~InputsMisc()
1473 void FormPreferences::InputsMisc::apply() const
1475 lyxrc.date_insert_format =
1476 fl_get_input(dialog_->input_date_format);
1480 void FormPreferences::InputsMisc::build()
1482 dialog_ = parent_.build_inputs_misc();
1484 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1486 // set up the feedback mechanism
1487 setPreHandler(dialog_->input_date_format);
1492 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1496 if (ob == dialog_->input_date_format)
1497 str = lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1503 void FormPreferences::InputsMisc::update()
1505 fl_set_input(dialog_->input_date_format,
1506 lyxrc.date_insert_format.c_str());
1510 FormPreferences::Interface::~Interface()
1516 void FormPreferences::Interface::apply() const
1518 lyxrc.popup_font_name =
1519 fl_get_input(dialog_->input_popup_font);
1520 lyxrc.menu_font_name = fl_get_input(dialog_->input_menu_font);
1521 lyxrc.font_norm_menu =
1522 fl_get_input(dialog_->input_popup_encoding);
1523 lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
1524 lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
1525 lyxrc.override_x_deadkeys =
1526 fl_get_button(dialog_->check_override_x_dead_keys);
1530 void FormPreferences::Interface::build()
1532 dialog_ = parent_.build_interface();
1534 fl_set_input_return(dialog_->input_popup_font, FL_RETURN_CHANGED);
1535 fl_set_input_return(dialog_->input_menu_font, FL_RETURN_CHANGED);
1536 fl_set_input_return(dialog_->input_popup_encoding, FL_RETURN_CHANGED);
1537 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1538 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1540 // set up the feedback mechanism
1541 setPreHandler(dialog_->input_popup_font);
1542 setPreHandler(dialog_->input_menu_font);
1543 setPreHandler(dialog_->input_popup_encoding);
1544 setPreHandler(dialog_->input_bind_file);
1545 setPreHandler(dialog_->button_bind_file_browse);
1546 setPreHandler(dialog_->input_ui_file);
1547 setPreHandler(dialog_->button_ui_file_browse);
1548 setPreHandler(dialog_->check_override_x_dead_keys);
1553 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1557 if (ob == dialog_->input_popup_font)
1558 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_POPUP);
1559 else if (ob == dialog_->input_menu_font)
1560 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_MENU);
1561 else if (ob == dialog_->input_popup_encoding)
1562 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING_MENU);
1563 else if (ob == dialog_->input_bind_file)
1564 str = lyxrc.getDescription(LyXRC::RC_BINDFILE);
1565 else if (ob == dialog_->input_ui_file)
1566 str = lyxrc.getDescription(LyXRC::RC_UIFILE);
1567 else if (ob == dialog_->check_override_x_dead_keys)
1568 str = lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1574 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1576 if (ob == dialog_->button_bind_file_browse) {
1577 string dir = AddName(system_lyxdir, "bind");
1578 string name = N_("Sys Bind");
1579 pair<string,string> dir1(name, dir);
1581 dir = AddName(user_lyxdir, "bind");
1582 name = N_("User Bind");
1583 pair<string,string> dir2(name, dir);
1585 parent_.browse(dialog_->input_bind_file,
1586 N_("Bind file"), "*.bind", dir1, dir2);
1588 } else if (ob == dialog_->button_ui_file_browse) {
1589 string dir = AddName(system_lyxdir, "ui");
1590 string name = N_("Sys UI");
1591 pair<string,string> dir1(name, dir);
1593 dir = AddName(user_lyxdir, "ui");
1594 name = N_("User UI");
1595 pair<string,string> dir2(name, dir);
1597 parent_.browse(dialog_->input_ui_file,
1598 N_("UI file"), "*.ui", dir1, dir2);
1605 void FormPreferences::Interface::update()
1607 fl_set_input(dialog_->input_popup_font,
1608 lyxrc.popup_font_name.c_str());
1609 fl_set_input(dialog_->input_menu_font,
1610 lyxrc.menu_font_name.c_str());
1611 fl_set_input(dialog_->input_popup_encoding,
1612 lyxrc.font_norm_menu.c_str());
1613 fl_set_input(dialog_->input_bind_file,
1614 lyxrc.bind_file.c_str());
1615 fl_set_input(dialog_->input_ui_file,
1616 lyxrc.ui_file.c_str());
1617 fl_set_button(dialog_->check_override_x_dead_keys,
1618 lyxrc.override_x_deadkeys);
1622 FormPreferences::Language::~Language()
1624 delete combo_default_lang;
1629 void FormPreferences::Language::apply()
1631 lyxrc.default_language = combo_default_lang->getline();
1633 int button = fl_get_button(dialog_->check_use_kbmap);
1634 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1635 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1637 button = !(name_1.empty() && name_2.empty());
1638 lyxrc.use_kbmap = static_cast<bool>(button);
1640 if (lyxrc.use_kbmap) {
1641 lyxrc.primary_kbmap = name_1;
1642 lyxrc.secondary_kbmap = name_2;
1645 button = fl_get_button(dialog_->check_rtl_support);
1646 lyxrc.rtl_support = static_cast<bool>(button);
1648 button = fl_get_button(dialog_->check_auto_begin);
1649 lyxrc.language_auto_begin = static_cast<bool>(button);
1651 button = fl_get_button(dialog_->check_auto_end);
1652 lyxrc.language_auto_end = static_cast<bool>(button);
1654 button = fl_get_button(dialog_->check_mark_foreign);
1655 lyxrc.mark_foreign_language = static_cast<bool>(button);
1657 lyxrc.language_package = fl_get_input(dialog_->input_package);
1658 lyxrc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1659 lyxrc.language_command_end = fl_get_input(dialog_->input_command_end);
1661 // Ensure that all is self-consistent.
1666 void FormPreferences::Language::build()
1668 dialog_ = parent_.build_language();
1670 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1671 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1672 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1674 // The default_language is a combo-box and has to be inserted manually
1675 fl_freeze_form(dialog_->form);
1676 fl_addto_form(dialog_->form);
1678 FL_OBJECT * obj = dialog_->choice_default_lang;
1679 fl_deactivate_object(dialog_->choice_default_lang);
1680 combo_default_lang = new Combox(FL_COMBOX_DROPLIST);
1681 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
1682 parent_.lang_opts_tab_->tabfolder_outer,
1683 parent_.dialog_->tabfolder_prefs);
1684 combo_default_lang->shortcut("#L",1);
1685 combo_default_lang->setcallback(ComboCB, &parent_);
1687 for (Languages::const_iterator cit = languages.begin();
1688 cit != languages.end(); ++cit) {
1689 combo_default_lang->addto((*cit).second.lang());
1693 fl_unfreeze_form(dialog_->form);
1695 // set up the feedback mechanism
1696 setPreHandler(dialog_->input_package);
1697 setPreHandler(dialog_->check_use_kbmap);
1699 // This is safe, as nothing is done to the pointer, other than
1700 // to use its address in a block-if statement.
1701 // No it's not! Leads to crash.
1703 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1704 // C_FormPreferencesFeedbackCB);
1706 setPreHandler(dialog_->input_kbmap1);
1707 setPreHandler(dialog_->input_kbmap2);
1708 setPreHandler(dialog_->check_rtl_support);
1709 setPreHandler(dialog_->check_mark_foreign);
1710 setPreHandler(dialog_->check_auto_begin);
1711 setPreHandler(dialog_->check_auto_end);
1712 setPreHandler(dialog_->input_command_begin);
1713 setPreHandler(dialog_->input_command_end);
1715 // Activate/Deactivate the input fields dependent on the state of the
1722 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1726 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang)
1727 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1728 else if (ob == dialog_->check_use_kbmap)
1729 str = lyxrc.getDescription(LyXRC::RC_KBMAP);
1730 else if (ob == dialog_->input_kbmap1)
1731 str = lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1732 else if (ob == dialog_->input_kbmap2)
1733 str = lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1734 else if (ob == dialog_->check_rtl_support)
1735 str = lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1736 else if (ob == dialog_->check_auto_begin)
1737 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1738 else if (ob == dialog_->check_auto_end)
1739 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1740 else if (ob == dialog_->check_mark_foreign)
1741 str = lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1742 else if (ob == dialog_->input_package)
1743 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1744 else if (ob == dialog_->input_command_begin)
1745 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1746 else if (ob == dialog_->input_command_end)
1747 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1753 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1755 bool activate = true;
1757 // !ob if function is called from Language::build() to de/activate
1759 // otherwise the function is called by an xforms CB via input().
1760 if (!ob || ob == dialog_->check_use_kbmap) {
1761 if (fl_get_button(dialog_->check_use_kbmap)) {
1762 fl_activate_object(dialog_->button_kbmap1_browse);
1763 fl_set_object_lcol(dialog_->button_kbmap1_browse,
1766 fl_activate_object(dialog_->button_kbmap2_browse);
1767 fl_set_object_lcol(dialog_->button_kbmap2_browse,
1770 fl_activate_object(dialog_->input_kbmap1);
1771 fl_set_object_lcol(dialog_->input_kbmap1, FL_BLACK);
1772 fl_activate_object(dialog_->input_kbmap2);
1773 fl_set_object_lcol(dialog_->input_kbmap2, FL_BLACK);
1775 fl_deactivate_object(dialog_->button_kbmap1_browse);
1776 fl_set_object_lcol(dialog_->button_kbmap1_browse,
1779 fl_deactivate_object(dialog_->button_kbmap2_browse);
1780 fl_set_object_lcol(dialog_->button_kbmap2_browse,
1783 fl_deactivate_object(dialog_->input_kbmap1);
1784 fl_set_object_lcol(dialog_->input_kbmap1,
1786 fl_deactivate_object(dialog_->input_kbmap2);
1787 fl_set_object_lcol(dialog_->input_kbmap2,
1792 if (ob == dialog_->button_kbmap1_browse) {
1793 string const dir = AddName(system_lyxdir, "kbd");
1794 string const name = N_("Key maps");
1795 pair<string, string> dir1(name, dir);
1797 parent_.browse(dialog_->input_kbmap1,
1798 N_("Keyboard map"), "*.kmap", dir1,
1799 make_pair(string(), string()));
1800 } else if (ob == dialog_->button_kbmap2_browse) {
1801 string const dir = AddName(system_lyxdir, "kbd");
1802 string const name = N_("Key maps");
1803 pair<string, string> dir1(name, dir);
1805 parent_.browse(dialog_->input_kbmap2,
1806 N_("Keyboard map"), "*.kmap", dir1,
1807 make_pair(string(), string()));
1814 void FormPreferences::Language::update()
1816 fl_set_button(dialog_->check_use_kbmap,
1819 combo_default_lang->select_text(lyxrc.default_language);
1821 if (lyxrc.use_kbmap) {
1822 fl_set_input(dialog_->input_kbmap1,
1823 lyxrc.primary_kbmap.c_str());
1824 fl_set_input(dialog_->input_kbmap2,
1825 lyxrc.secondary_kbmap.c_str());
1827 fl_set_input(dialog_->input_kbmap1, "");
1828 fl_set_input(dialog_->input_kbmap2, "");
1831 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1832 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1833 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1834 fl_set_button(dialog_->check_mark_foreign,
1835 lyxrc.mark_foreign_language);
1837 fl_set_input(dialog_->input_package,
1838 lyxrc.language_package.c_str());
1839 fl_set_input(dialog_->input_command_begin,
1840 lyxrc.language_command_begin.c_str());
1841 fl_set_input(dialog_->input_command_end,
1842 lyxrc.language_command_end.c_str());
1844 // Activate/Deactivate the input fields dependent on the state of the
1850 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1852 FormPreferences * pre = static_cast<FormPreferences*>(v);
1853 // This is safe, as nothing is done to the pointer, other than
1854 // to use its address in a block-if statement.
1855 pre->bc_.valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1859 FormPreferences::LnFmisc::~LnFmisc()
1865 void FormPreferences::LnFmisc::apply() const
1867 lyxrc.show_banner = fl_get_button(dialog_->check_banner);
1868 lyxrc.auto_region_delete =
1869 fl_get_button(dialog_->check_auto_region_delete);
1870 lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm);
1871 lyxrc.display_shortcuts =
1872 fl_get_button(dialog_->check_display_shrtcuts);
1873 lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
1874 lyxrc.cursor_follows_scrollbar =
1875 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1876 lyxrc.autosave = static_cast<unsigned int>
1877 (fl_get_counter_value(dialog_->counter_autosave));
1878 lyxrc.wheel_jump = static_cast<unsigned int>
1879 (fl_get_counter_value(dialog_->counter_wm_jump));
1883 void FormPreferences::LnFmisc::build()
1885 dialog_ = parent_.build_lnf_misc();
1887 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1888 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1890 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1891 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1893 // set up the feedback mechanism
1894 setPreHandler(dialog_->check_banner);
1895 setPreHandler(dialog_->check_auto_region_delete);
1896 setPreHandler(dialog_->check_exit_confirm);
1897 setPreHandler(dialog_->check_display_shrtcuts);
1898 setPreHandler(dialog_->counter_autosave);
1899 setPreHandler(dialog_->check_ask_new_file);
1900 setPreHandler(dialog_->check_cursor_follows_scrollbar);
1901 setPreHandler(dialog_->counter_wm_jump);
1906 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1910 if (ob == dialog_->check_banner)
1911 str = lyxrc.getDescription(LyXRC::RC_SHOW_BANNER);
1912 else if (ob == dialog_->check_auto_region_delete)
1913 str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1914 else if (ob == dialog_->check_exit_confirm)
1915 str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION);
1916 else if (ob == dialog_->check_display_shrtcuts)
1917 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_SHORTCUTS);
1918 else if (ob == dialog_->check_ask_new_file)
1919 str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
1920 else if (ob == dialog_->check_cursor_follows_scrollbar)
1921 str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1922 else if (ob == dialog_->counter_autosave)
1923 str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1924 else if (ob == dialog_->counter_wm_jump)
1925 str = lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1931 void FormPreferences::LnFmisc::update()
1933 fl_set_button(dialog_->check_banner, lyxrc.show_banner);
1934 fl_set_button(dialog_->check_auto_region_delete,
1935 lyxrc.auto_region_delete);
1936 fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
1937 fl_set_button(dialog_->check_display_shrtcuts, lyxrc.display_shortcuts);
1938 fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
1939 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1940 lyxrc.cursor_follows_scrollbar);
1941 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1942 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1946 FormPreferences::OutputsMisc::~OutputsMisc()
1952 void FormPreferences::OutputsMisc::apply() const
1954 lyxrc.ascii_linelen = static_cast<unsigned int>
1955 (fl_get_counter_value(dialog_->counter_line_len));
1956 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1959 fl_get_choice(dialog_->choice_default_papersize) - 1;
1960 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1962 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1963 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1967 void FormPreferences::OutputsMisc::build()
1969 dialog_ = parent_.build_outputs_misc();
1971 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1973 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1974 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1975 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1976 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1978 fl_addto_choice(dialog_->choice_default_papersize,
1979 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
1981 // set up the feedback mechanism
1982 setPreHandler(dialog_->counter_line_len);
1983 setPreHandler(dialog_->input_tex_encoding);
1984 setPreHandler(dialog_->choice_default_papersize);
1985 setPreHandler(dialog_->input_ascii_roff);
1986 setPreHandler(dialog_->input_checktex);
1991 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1995 if (ob == dialog_->counter_line_len)
1996 str = lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
1997 else if (ob == dialog_->input_tex_encoding)
1998 str = lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
1999 else if (ob == dialog_->input_ascii_roff)
2000 str = lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
2001 else if (ob == dialog_->input_checktex)
2002 str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
2003 else if (ob == dialog_->choice_default_papersize)
2004 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
2010 void FormPreferences::OutputsMisc::update()
2012 fl_set_counter_value(dialog_->counter_line_len,
2013 lyxrc.ascii_linelen);
2014 fl_set_input(dialog_->input_tex_encoding,
2015 lyxrc.fontenc.c_str());
2016 fl_set_choice(dialog_->choice_default_papersize,
2017 lyxrc.default_papersize+1);
2018 fl_set_input(dialog_->input_ascii_roff,
2019 lyxrc.ascii_roff_command.c_str());
2020 fl_set_input(dialog_->input_checktex,
2021 lyxrc.chktex_command.c_str());
2025 FormPreferences::Paths::~Paths()
2031 void FormPreferences::Paths::apply()
2033 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2034 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2036 int button = fl_get_button(dialog_->check_use_temp_dir);
2037 string str = fl_get_input(dialog_->input_temp_dir);
2038 if (!button) str.erase();
2040 lyxrc.use_tempdir = button;
2041 lyxrc.tempdir_path = str;
2043 button = fl_get_button(dialog_->check_last_files);
2044 str = fl_get_input(dialog_->input_lastfiles);
2045 if (!button) str.erase();
2047 lyxrc.check_lastfiles = button;
2048 lyxrc.lastfiles = str;
2049 lyxrc.num_lastfiles = static_cast<unsigned int>
2050 (fl_get_counter_value(dialog_->counter_lastfiles));
2052 button = fl_get_button(dialog_->check_make_backups);
2053 str = fl_get_input(dialog_->input_backup_path);
2054 if (!button) str.erase();
2056 lyxrc.make_backup = button;
2057 lyxrc.backupdir_path = str;
2059 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2066 void FormPreferences::Paths::build()
2068 dialog_ = parent_.build_paths();
2070 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2071 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2072 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2073 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2074 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2075 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2076 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2078 // set up the feedback mechanism
2079 setPreHandler(dialog_->input_default_path);
2080 setPreHandler(dialog_->counter_lastfiles);
2081 setPreHandler(dialog_->input_template_path);
2082 setPreHandler(dialog_->check_last_files);
2083 setPreHandler(dialog_->input_lastfiles);
2084 setPreHandler(dialog_->check_make_backups);
2085 setPreHandler(dialog_->input_backup_path);
2086 setPreHandler(dialog_->input_serverpipe);
2087 setPreHandler(dialog_->input_temp_dir);
2088 setPreHandler(dialog_->check_use_temp_dir);
2093 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2097 if (ob == dialog_->input_default_path)
2098 str = lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2099 else if (ob == dialog_->input_template_path)
2100 str = lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2101 else if (ob == dialog_->check_use_temp_dir)
2102 str = lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2103 else if (ob == dialog_->input_temp_dir)
2104 str = lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2105 else if (ob == dialog_->check_last_files)
2106 str = lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2107 else if (ob == dialog_->input_lastfiles)
2108 str = lyxrc.getDescription(LyXRC::RC_LASTFILES);
2109 else if (ob == dialog_->counter_lastfiles)
2110 str = lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2111 else if (ob == dialog_->check_make_backups)
2112 str = lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2113 else if (ob == dialog_->input_backup_path)
2114 str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2115 else if (ob == dialog_->input_serverpipe) {
2116 str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2117 str += " Enter either the input pipe, xxx.in, or the output pipe, xxx.out.";
2124 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2126 bool activate = true;
2128 // !ob if function is called from Paths::update() to de/activate
2130 // otherwise the function is called by an xforms CB via input().
2131 if (!ob || ob == dialog_->check_use_temp_dir) {
2132 if (fl_get_button(dialog_->check_use_temp_dir)) {
2133 fl_activate_object(dialog_->input_temp_dir);
2134 fl_set_object_lcol(dialog_->input_temp_dir,
2137 fl_deactivate_object(dialog_->input_temp_dir);
2138 fl_set_object_lcol(dialog_->input_temp_dir,
2143 if (!ob || ob == dialog_->check_last_files) {
2144 if (fl_get_button(dialog_->check_last_files)) {
2145 fl_activate_object(dialog_->input_lastfiles);
2146 fl_set_object_lcol(dialog_->input_lastfiles,
2149 fl_deactivate_object(dialog_->input_lastfiles);
2150 fl_set_object_lcol(dialog_->input_lastfiles,
2155 if (!ob || ob == dialog_->check_make_backups) {
2156 if (fl_get_button(dialog_->check_make_backups)) {
2157 fl_activate_object(dialog_->input_backup_path);
2158 fl_set_object_lcol(dialog_->input_backup_path,
2161 fl_deactivate_object(dialog_->input_backup_path);
2162 fl_set_object_lcol(dialog_->input_backup_path,
2167 if (!ob || ob == dialog_->input_default_path) {
2168 string const name = fl_get_input(dialog_->input_default_path);
2169 if (!RWInfo::WriteableDir(name)) {
2170 parent_.printWarning(RWInfo::ErrorMessage());
2175 if (!ob || ob == dialog_->input_template_path) {
2176 string const name = fl_get_input(dialog_->input_template_path);
2177 if (!RWInfo::ReadableDir(name)) {
2178 parent_.printWarning(RWInfo::ErrorMessage());
2183 if (!ob || ob == dialog_->input_temp_dir) {
2184 string const name = fl_get_input(dialog_->input_temp_dir);
2185 if (fl_get_button(dialog_->check_make_backups)
2187 && !RWInfo::WriteableDir(name)) {
2188 parent_.printWarning(RWInfo::ErrorMessage());
2193 if (!ob || ob == dialog_->input_backup_path) {
2194 string const name = fl_get_input(dialog_->input_backup_path);
2195 if (fl_get_button(dialog_->check_make_backups)
2197 && !RWInfo::WriteableDir(name)) {
2198 parent_.printWarning(RWInfo::ErrorMessage());
2203 if (!ob || ob == dialog_->input_lastfiles) {
2204 string const name = fl_get_input(dialog_->input_lastfiles);
2205 if (fl_get_button(dialog_->check_last_files)
2207 && !RWInfo::WriteableFile(name)) {
2208 parent_.printWarning(RWInfo::ErrorMessage());
2213 if (!ob || ob == dialog_->input_serverpipe) {
2214 string const name = fl_get_input(dialog_->input_serverpipe);
2215 if (!name.empty()) {
2216 // strip off the extension
2217 string const str = ChangeExtension(name, "");
2218 if (!RWInfo::WriteableFile(str + ".in")) {
2219 parent_.printWarning(RWInfo::ErrorMessage());
2222 if (!RWInfo::WriteableFile(str + ".out")) {
2223 parent_.printWarning(RWInfo::ErrorMessage());
2229 if (ob == dialog_->button_default_path_browse) {
2230 parent_.browse(dialog_->input_default_path,
2231 N_("Default path"), string(),
2232 make_pair(string(), string()),
2233 make_pair(string(), string()));
2234 } else if (ob == dialog_->button_template_path_browse) {
2235 parent_.browse(dialog_->input_template_path,
2236 N_("Template path"), string(),
2237 make_pair(string(), string()),
2238 make_pair(string(), string()));
2239 } else if (ob == dialog_->button_temp_dir_browse) {
2240 parent_.browse(dialog_->input_temp_dir,
2241 N_("Temp dir"), string(),
2242 make_pair(string(), string()),
2243 make_pair(string(), string()));
2244 } else if (ob == dialog_->button_lastfiles_browse) {
2245 pair<string, string> dir(_("User"), user_lyxdir);
2247 parent_.browse(dialog_->input_lastfiles,
2248 N_("Lastfiles"), string(), dir,
2249 make_pair(string(), string()));
2250 } else if (ob == dialog_->button_backup_path_browse) {
2251 parent_.browse(dialog_->input_backup_path,
2252 N_("Backup path"), string(),
2253 make_pair(string(), string()),
2254 make_pair(string(), string()));
2255 } else if (ob == dialog_->button_serverpipe_browse) {
2256 parent_.browse(dialog_->input_serverpipe,
2257 N_("LyX Server pipes"), string(),
2258 make_pair(string(), string()),
2259 make_pair(string(), string()));
2266 void FormPreferences::Paths::update()
2268 fl_set_input(dialog_->input_default_path,
2269 lyxrc.document_path.c_str());
2270 fl_set_input(dialog_->input_template_path,
2271 lyxrc.template_path.c_str());
2274 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
2276 fl_set_button(dialog_->check_make_backups,
2278 fl_set_input(dialog_->input_backup_path, str.c_str());
2281 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
2283 fl_set_button(dialog_->check_use_temp_dir,
2285 fl_set_input(dialog_->input_temp_dir, str.c_str());
2288 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
2290 fl_set_button(dialog_->check_last_files,
2291 lyxrc.check_lastfiles);
2292 fl_set_input(dialog_->input_lastfiles, str.c_str());
2293 fl_set_counter_value(dialog_->counter_lastfiles,
2294 lyxrc.num_lastfiles);
2296 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2298 // Activate/Deactivate the input fields dependent on the state of the
2304 FormPreferences::Printer::~Printer()
2310 void FormPreferences::Printer::apply() const
2312 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2313 lyxrc.print_command = fl_get_input(dialog_->input_command);
2314 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2315 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2316 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2317 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2318 lyxrc.print_file_extension =
2319 fl_get_input(dialog_->input_file_extension);
2320 lyxrc.print_spool_command =
2321 fl_get_input(dialog_->input_spool_command);
2322 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2323 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2324 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2325 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2326 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2327 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2328 lyxrc.print_extra_options =
2329 fl_get_input(dialog_->input_extra_options);
2330 lyxrc.print_spool_printerprefix =
2331 fl_get_input(dialog_->input_spool_prefix);
2332 lyxrc.print_paper_dimension_flag =
2333 fl_get_input(dialog_->input_paper_size);
2334 lyxrc.printer = fl_get_input(dialog_->input_name);
2339 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2343 if (ob == dialog_->input_command)
2344 str = lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2345 else if (ob == dialog_->check_adapt_output)
2346 str = lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2347 else if (ob == dialog_->input_to_printer)
2348 str = lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2349 else if (ob == dialog_->input_to_file)
2350 str = lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2351 else if (ob == dialog_->input_file_extension)
2352 str = lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2353 else if (ob == dialog_->input_extra_options)
2354 str = lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2355 else if (ob == dialog_->input_spool_command)
2356 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2357 else if (ob == dialog_->input_spool_prefix)
2358 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2359 else if (ob == dialog_->input_name)
2360 str = lyxrc.getDescription(LyXRC::RC_PRINTER);
2361 else if (ob == dialog_->input_even_pages)
2362 str = lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2363 else if (ob == dialog_->input_odd_pages)
2364 str = lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2365 else if (ob == dialog_->input_page_range)
2366 str = lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2367 else if (ob == dialog_->input_reverse)
2368 str = lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2369 else if (ob == dialog_->input_landscape)
2370 str = lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2371 else if (ob == dialog_->input_copies)
2372 str = lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2373 else if (ob == dialog_->input_collated)
2374 str = lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2375 else if (ob == dialog_->input_paper_type)
2376 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2377 else if (ob == dialog_->input_paper_size)
2378 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2384 void FormPreferences::Printer::build()
2386 dialog_ = parent_.build_printer();
2388 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2389 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2390 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2391 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2392 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2393 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2394 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2395 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2396 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2397 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2398 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2399 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2400 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2401 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2402 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2403 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2404 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2406 // set up the feedback mechanism
2407 setPreHandler(dialog_->input_command);
2408 setPreHandler(dialog_->input_page_range);
2409 setPreHandler(dialog_->input_copies);
2410 setPreHandler(dialog_->input_reverse);
2411 setPreHandler(dialog_->input_to_printer);
2412 setPreHandler(dialog_->input_file_extension);
2413 setPreHandler(dialog_->input_spool_command);
2414 setPreHandler(dialog_->input_paper_type);
2415 setPreHandler(dialog_->input_even_pages);
2416 setPreHandler(dialog_->input_odd_pages);
2417 setPreHandler(dialog_->input_collated);
2418 setPreHandler(dialog_->input_landscape);
2419 setPreHandler(dialog_->input_to_file);
2420 setPreHandler(dialog_->input_extra_options);
2421 setPreHandler(dialog_->input_spool_prefix);
2422 setPreHandler(dialog_->input_paper_size);
2423 setPreHandler(dialog_->input_name);
2424 setPreHandler(dialog_->check_adapt_output);
2428 void FormPreferences::Printer::update()
2430 fl_set_button(dialog_->check_adapt_output,
2431 lyxrc.print_adapt_output);
2432 fl_set_input(dialog_->input_command,
2433 lyxrc.print_command.c_str());
2434 fl_set_input(dialog_->input_page_range,
2435 lyxrc.print_pagerange_flag.c_str());
2436 fl_set_input(dialog_->input_copies,
2437 lyxrc.print_copies_flag.c_str());
2438 fl_set_input(dialog_->input_reverse,
2439 lyxrc.print_reverse_flag.c_str());
2440 fl_set_input(dialog_->input_to_printer,
2441 lyxrc.print_to_printer.c_str());
2442 fl_set_input(dialog_->input_file_extension,
2443 lyxrc.print_file_extension.c_str());
2444 fl_set_input(dialog_->input_spool_command,
2445 lyxrc.print_spool_command.c_str());
2446 fl_set_input(dialog_->input_paper_type,
2447 lyxrc.print_paper_flag.c_str());
2448 fl_set_input(dialog_->input_even_pages,
2449 lyxrc.print_evenpage_flag.c_str());
2450 fl_set_input(dialog_->input_odd_pages,
2451 lyxrc.print_oddpage_flag.c_str());
2452 fl_set_input(dialog_->input_collated,
2453 lyxrc.print_collcopies_flag.c_str());
2454 fl_set_input(dialog_->input_landscape,
2455 lyxrc.print_landscape_flag.c_str());
2456 fl_set_input(dialog_->input_to_file,
2457 lyxrc.print_to_file.c_str());
2458 fl_set_input(dialog_->input_extra_options,
2459 lyxrc.print_extra_options.c_str());
2460 fl_set_input(dialog_->input_spool_prefix,
2461 lyxrc.print_spool_printerprefix.c_str());
2462 fl_set_input(dialog_->input_paper_size,
2463 lyxrc.print_paper_dimension_flag.c_str());
2464 fl_set_input(dialog_->input_name,
2465 lyxrc.printer.c_str());
2469 FormPreferences::ScreenFonts::~ScreenFonts()
2475 void FormPreferences::ScreenFonts::apply() const
2477 bool changed = false;
2479 string str = fl_get_input(dialog_->input_roman);
2480 if (lyxrc.roman_font_name != str) {
2482 lyxrc.roman_font_name = str;
2485 str = fl_get_input(dialog_->input_sans);
2486 if (lyxrc.sans_font_name != str) {
2488 lyxrc.sans_font_name = str;
2491 str = fl_get_input(dialog_->input_typewriter);
2492 if (lyxrc.typewriter_font_name != str) {
2494 lyxrc.typewriter_font_name = str;
2497 str = fl_get_input(dialog_->input_screen_encoding);
2498 if (lyxrc.font_norm != str) {
2500 lyxrc.font_norm = str;
2503 bool button = fl_get_button(dialog_->check_scalable);
2504 if (lyxrc.use_scalable_fonts != button) {
2506 lyxrc.use_scalable_fonts = button;
2509 unsigned int ivalue = static_cast<unsigned int>
2510 (fl_get_counter_value(dialog_->counter_zoom));
2511 if (lyxrc.zoom != ivalue) {
2513 lyxrc.zoom = ivalue;
2516 ivalue = static_cast<unsigned int>
2517 (fl_get_counter_value(dialog_->counter_dpi));
2518 if (lyxrc.dpi != ivalue) {
2523 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2524 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2526 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2529 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2530 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2532 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2535 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2536 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2538 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2541 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2542 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2544 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2547 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2548 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2550 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2553 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2554 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2556 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2559 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2560 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2562 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2565 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2566 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2568 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2571 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2572 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2574 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2577 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2578 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2580 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2584 // Now update the buffers
2585 // Can anything below here affect the redraw process?
2586 parent_.lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
2591 void FormPreferences::ScreenFonts::build()
2593 dialog_ = parent_.build_screen_fonts();
2595 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2596 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2598 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2599 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2600 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2601 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2602 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2603 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2604 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2605 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2606 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2607 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2608 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2609 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2610 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2611 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2612 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2613 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2615 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2616 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2617 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2618 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2619 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2620 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2621 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2622 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2623 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2624 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2626 // set up the feedback mechanism
2627 setPreHandler(dialog_->input_roman);
2628 setPreHandler(dialog_->input_sans);
2629 setPreHandler(dialog_->input_typewriter);
2630 setPreHandler(dialog_->counter_zoom);
2631 setPreHandler(dialog_->counter_dpi);
2632 setPreHandler(dialog_->check_scalable);
2633 setPreHandler(dialog_->input_screen_encoding);
2634 setPreHandler(dialog_->input_tiny);
2635 setPreHandler(dialog_->input_script);
2636 setPreHandler(dialog_->input_footnote);
2637 setPreHandler(dialog_->input_small);
2638 setPreHandler(dialog_->input_large);
2639 setPreHandler(dialog_->input_larger);
2640 setPreHandler(dialog_->input_largest);
2641 setPreHandler(dialog_->input_normal);
2642 setPreHandler(dialog_->input_huge);
2643 setPreHandler(dialog_->input_huger);
2648 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2652 if (ob == dialog_->input_roman)
2653 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2654 else if (ob == dialog_->input_sans)
2655 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2656 else if (ob == dialog_->input_typewriter)
2657 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2658 else if (ob == dialog_->check_scalable)
2659 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2660 else if (ob == dialog_->input_screen_encoding)
2661 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2662 else if (ob == dialog_->counter_zoom)
2663 str = lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2664 else if (ob == dialog_->counter_dpi)
2665 str = lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2666 else if (ob == dialog_->input_tiny
2667 || ob == dialog_->input_script
2668 || ob == dialog_->input_footnote
2669 || ob == dialog_->input_small
2670 || ob == dialog_->input_large
2671 || ob == dialog_->input_larger
2672 || ob == dialog_->input_larger
2673 || ob == dialog_->input_largest
2674 || ob == dialog_->input_normal
2675 || ob == dialog_->input_huge
2676 || ob == dialog_->input_huger)
2677 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2683 bool FormPreferences::ScreenFonts::input()
2685 bool activate = true;
2688 // Make sure that all fonts all have positive entries
2689 // Also note that an empty entry is returned as 0.0 by strToDbl
2690 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2691 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2692 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2693 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2694 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2695 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2696 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2697 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2698 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2699 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2701 str = N_("Fonts must be positive!");
2703 // Fontsizes -- tiny < script < footnote etc.
2704 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2705 strToDbl(fl_get_input(dialog_->input_script)) ||
2706 strToDbl(fl_get_input(dialog_->input_script)) >
2707 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2708 strToDbl(fl_get_input(dialog_->input_footnote)) >
2709 strToDbl(fl_get_input(dialog_->input_small)) ||
2710 strToDbl(fl_get_input(dialog_->input_small)) >
2711 strToDbl(fl_get_input(dialog_->input_normal)) ||
2712 strToDbl(fl_get_input(dialog_->input_normal)) >
2713 strToDbl(fl_get_input(dialog_->input_large)) ||
2714 strToDbl(fl_get_input(dialog_->input_large)) >
2715 strToDbl(fl_get_input(dialog_->input_larger)) ||
2716 strToDbl(fl_get_input(dialog_->input_larger)) >
2717 strToDbl(fl_get_input(dialog_->input_largest)) ||
2718 strToDbl(fl_get_input(dialog_->input_largest)) >
2719 strToDbl(fl_get_input(dialog_->input_huge)) ||
2720 strToDbl(fl_get_input(dialog_->input_huge)) >
2721 strToDbl(fl_get_input(dialog_->input_huger))) {
2724 str = N_("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2728 parent_.printWarning(str);
2734 void FormPreferences::ScreenFonts::update()
2736 fl_set_input(dialog_->input_roman,
2737 lyxrc.roman_font_name.c_str());
2738 fl_set_input(dialog_->input_sans,
2739 lyxrc.sans_font_name.c_str());
2740 fl_set_input(dialog_->input_typewriter,
2741 lyxrc.typewriter_font_name.c_str());
2742 fl_set_input(dialog_->input_screen_encoding,
2743 lyxrc.font_norm.c_str());
2744 fl_set_button(dialog_->check_scalable,
2745 lyxrc.use_scalable_fonts);
2746 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2747 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2748 fl_set_input(dialog_->input_tiny,
2749 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2750 fl_set_input(dialog_->input_script,
2751 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2752 fl_set_input(dialog_->input_footnote,
2753 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2754 fl_set_input(dialog_->input_small,
2755 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2756 fl_set_input(dialog_->input_normal,
2757 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2758 fl_set_input(dialog_->input_large,
2759 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2760 fl_set_input(dialog_->input_larger,
2761 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2762 fl_set_input(dialog_->input_largest,
2763 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2764 fl_set_input(dialog_->input_huge,
2765 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2766 fl_set_input(dialog_->input_huger,
2767 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2771 FormPreferences::SpellChecker::~SpellChecker()
2777 void FormPreferences::SpellChecker::apply()
2780 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2781 choice = strip(frontStrip(choice));
2783 lyxrc.isp_command = choice;
2785 // If spell checker == "none", all other input set to off.
2786 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2787 lyxrc.isp_use_alt_lang = false;
2788 lyxrc.isp_alt_lang.erase();
2790 lyxrc.isp_use_esc_chars = false;
2791 lyxrc.isp_esc_chars.erase();
2793 lyxrc.isp_use_pers_dict = false;
2794 lyxrc.isp_pers_dict.erase();
2796 lyxrc.isp_accept_compound = false;
2797 lyxrc.isp_use_input_encoding = false;
2799 int button = fl_get_button(dialog_->check_alt_lang);
2800 choice = fl_get_input(dialog_->input_alt_lang);
2801 if (button && choice.empty()) button = 0;
2802 if (!button) choice.erase();
2804 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2805 lyxrc.isp_alt_lang = choice;
2807 button = fl_get_button(dialog_->check_escape_chars);
2808 choice = fl_get_input(dialog_->input_escape_chars);
2809 if (button && choice.empty()) button = 0;
2810 if (!button) choice.erase();
2812 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2813 lyxrc.isp_esc_chars = choice;
2815 button = fl_get_button(dialog_->check_personal_dict);
2816 choice = fl_get_input(dialog_->input_personal_dict);
2817 if (button && choice.empty()) button = 0;
2818 if (!button) choice.erase();
2820 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2821 lyxrc.isp_pers_dict = choice;
2823 button = fl_get_button(dialog_->check_compound_words);
2824 lyxrc.isp_accept_compound = static_cast<bool>(button);
2826 button = fl_get_button(dialog_->check_input_enc);
2827 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2835 void FormPreferences::SpellChecker::build()
2837 dialog_ = parent_.build_spellchecker();
2839 fl_addto_choice(dialog_->choice_spell_command,
2840 _(" none | ispell | aspell "));
2841 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2842 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2843 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2845 // set up the feedback mechanism
2846 setPreHandler(dialog_->choice_spell_command);
2847 setPreHandler(dialog_->check_alt_lang);
2848 setPreHandler(dialog_->input_alt_lang);
2849 setPreHandler(dialog_->check_escape_chars);
2850 setPreHandler(dialog_->input_escape_chars);
2851 setPreHandler(dialog_->check_personal_dict);
2852 setPreHandler(dialog_->input_personal_dict);
2853 setPreHandler(dialog_->button_personal_dict);
2854 setPreHandler(dialog_->check_compound_words);
2855 setPreHandler(dialog_->check_input_enc);
2860 FormPreferences::SpellChecker::feedback(FL_OBJECT const * const ob) const
2864 if (ob == dialog_->choice_spell_command)
2865 str = lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2866 else if (ob == dialog_->check_alt_lang)
2867 str = lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2868 else if (ob == dialog_->input_alt_lang)
2869 str = lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2870 else if (ob == dialog_->check_escape_chars)
2871 str = lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2872 else if (ob == dialog_->input_escape_chars)
2873 str = lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2874 else if (ob == dialog_->check_personal_dict)
2875 str = lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2876 else if (ob == dialog_->input_personal_dict)
2877 str = lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2878 else if (ob == dialog_->check_compound_words)
2879 str = lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2880 else if (ob == dialog_->check_input_enc)
2881 str = lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2887 bool FormPreferences::SpellChecker::input(FL_OBJECT const * const ob)
2889 // !ob if function is called from updateSpellChecker() to de/activate
2891 // otherwise the function is called by an xforms CB via input().
2893 // If spell checker == "none", disable all input.
2894 if (!ob || ob == dialog_->choice_spell_command) {
2895 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2896 fl_deactivate_object(dialog_->check_alt_lang);
2897 fl_deactivate_object(dialog_->input_alt_lang);
2898 fl_deactivate_object(dialog_->check_escape_chars);
2899 fl_deactivate_object(dialog_->input_escape_chars);
2900 fl_deactivate_object(dialog_->check_personal_dict);
2901 fl_deactivate_object(dialog_->input_personal_dict);
2902 fl_deactivate_object(dialog_->check_compound_words);
2903 fl_deactivate_object(dialog_->check_input_enc);
2906 fl_activate_object(dialog_->check_alt_lang);
2907 fl_activate_object(dialog_->check_escape_chars);
2908 fl_activate_object(dialog_->check_personal_dict);
2909 fl_activate_object(dialog_->check_compound_words);
2910 fl_activate_object(dialog_->check_input_enc);
2914 if (!ob || ob == dialog_->check_alt_lang) {
2915 if (fl_get_button(dialog_->check_alt_lang)) {
2916 fl_activate_object(dialog_->input_alt_lang);
2917 fl_set_object_lcol(dialog_->input_alt_lang,
2920 fl_deactivate_object(dialog_->input_alt_lang);
2921 fl_set_object_lcol(dialog_->input_alt_lang,
2926 if (!ob || ob == dialog_->check_escape_chars) {
2927 if (fl_get_button(dialog_->check_escape_chars)) {
2928 fl_activate_object(dialog_->input_escape_chars);
2929 fl_set_object_lcol(dialog_->input_escape_chars,
2932 fl_deactivate_object(dialog_->input_escape_chars);
2933 fl_set_object_lcol(dialog_->input_escape_chars,
2938 if (!ob || ob == dialog_->check_personal_dict) {
2939 if (fl_get_button(dialog_->check_personal_dict)) {
2940 fl_activate_object(dialog_->input_personal_dict);
2941 fl_set_object_lcol(dialog_->input_personal_dict,
2944 fl_deactivate_object(dialog_->input_personal_dict);
2945 fl_set_object_lcol(dialog_->input_personal_dict,
2950 if (ob == dialog_->button_personal_dict) {
2951 parent_.browse(dialog_->input_personal_dict,
2952 N_("Personal dictionary"), "*.ispell",
2953 make_pair(string(), string()),
2954 make_pair(string(), string()));
2957 return true; // All input is valid!
2961 void FormPreferences::SpellChecker::update()
2964 if (lyxrc.isp_command == "none")
2966 else if (lyxrc.isp_command == "ispell")
2968 else if (lyxrc.isp_command == "aspell")
2970 fl_set_choice(dialog_->choice_spell_command, choice);
2973 if (lyxrc.isp_use_alt_lang) str = lyxrc.isp_alt_lang;
2975 fl_set_button(dialog_->check_alt_lang,
2976 lyxrc.isp_use_alt_lang);
2977 fl_set_input(dialog_->input_alt_lang, str.c_str());
2980 if (lyxrc.isp_use_esc_chars) str = lyxrc.isp_esc_chars;
2982 fl_set_button(dialog_->check_escape_chars,
2983 lyxrc.isp_use_esc_chars);
2984 fl_set_input(dialog_->input_escape_chars, str.c_str());
2987 if (lyxrc.isp_use_pers_dict) str = lyxrc.isp_pers_dict;
2989 fl_set_button(dialog_->check_personal_dict,
2990 lyxrc.isp_use_pers_dict);
2991 fl_set_input(dialog_->input_personal_dict, str.c_str());
2993 fl_set_button(dialog_->check_compound_words,
2994 lyxrc.isp_accept_compound);
2995 fl_set_button(dialog_->check_input_enc,
2996 lyxrc.isp_use_input_encoding);
2998 // Activate/Deactivate the input fields dependent on the state of the
3004 void FormPreferences::printWarning(string const & warning)
3006 warningPosted = true;
3008 string str = _("WARNING!") + string(" ") + warning;
3009 str = formatted(str, dialog_->text_warning->w-10,
3010 FL_SMALL_SIZE, FL_NORMAL_STYLE);
3012 fl_set_object_label(dialog_->text_warning, str.c_str());
3013 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
3017 void FormPreferences::browse(FL_OBJECT * inpt,
3018 string const & title,
3019 string const & pattern,
3020 pair<string,string> const & dir1,
3021 pair<string,string> const & dir2)
3023 // Get the filename from the dialog
3024 string const filename = fl_get_input(inpt);
3026 // Show the file browser dialog
3027 string const new_filename =
3028 browseFile(filename, title, pattern, dir1, dir2);
3030 // Save the filename to the dialog
3031 if (new_filename != filename && !new_filename.empty()) {
3032 fl_set_input(inpt, new_filename.c_str());
3038 // C function wrapper, required by xforms.
3039 extern "C" int C_FormPreferencesFeedbackCB(FL_OBJECT * ob, int event,
3040 FL_Coord mx, FL_Coord my,
3041 int key, void * xev)
3043 return FormPreferences::FeedbackCB(ob, event, mx, my, key, xev);
3046 int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event,
3047 FL_Coord, FL_Coord, int, void *)
3049 // Note that the return value is important in the pre-emptive handler.
3050 // Don't return anything other than 0.
3053 // Don't Assert this one, as it can happen quite reasonably when things
3054 // are being deleted in the d-tor.
3056 if (!ob->form) return 0;
3058 FormPreferences * pre =
3059 static_cast<FormPreferences*>(ob->form->u_vdata);
3060 pre->Feedback(ob, event);
3065 // preemptive handler for feedback messages
3066 void FormPreferences::Feedback(FL_OBJECT * ob, int event)
3072 warningPosted = false;
3078 fl_set_object_label(dialog_->text_warning, "");
3087 void FormPreferences::setPreHandler(FL_OBJECT * ob)
3090 fl_set_object_prehandler(ob, C_FormPreferencesFeedbackCB);