2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 The LyX Team.
10 *======================================================*/
12 * FormPreferences Interface Class Implementation
21 #include FORMS_H_LOCATION
24 #pragma implementation
30 #include "FormPreferences.h"
31 #include "form_preferences.h"
32 #include "input_validators.h"
40 #include "support/filetools.h"
41 #include "lyx_gui_misc.h" // idex, scex
43 #include "input_validators.h"
44 #include "xforms_helpers.h"
45 #include "converter.h"
46 #include "support/lyxfunctional.h"
47 #include "support/lyxmanip.h"
57 extern string system_lyxdir;
58 extern string user_lyxdir;
59 extern Languages languages;
61 // These should probably go inside the class definition...
62 static Formats local_formats;
63 static Converters local_converters;
65 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
66 : FormBaseBI(lv, d, _("Preferences")),
68 colors_(*this), converters_(*this), inputs_misc_(*this),
69 formats_(*this), interface_(*this), language_(*this),
70 lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
71 printer_(*this), screen_fonts_(*this), spellchecker_(*this)
73 // let the dialog be shown
74 // This is a permanent connection so we won't bother
75 // storing a copy because we won't be disconnecting.
76 d->showPreferences.connect(slot(this, &FormPreferences::show));
80 void FormPreferences::connect()
82 fl_set_form_maxsize( dialog_->form, minw_, minh_ );
84 FormBaseBI::connect();
88 void FormPreferences::disconnect()
90 // colors_->disconnect();
91 // converters_->disconnect(); //local_converters.Clear();
92 // formats_->disconnect(); //local_formats.Clear();
94 FormBaseBI::disconnect();
98 void FormPreferences::redraw()
100 if (!(form() && form()->visible))
102 fl_redraw_form(form());
104 FL_FORM * form2 = fl_get_active_folder(dialog_->tabfolder_prefs);
105 if (!(form2 && form2->visible))
107 fl_redraw_form(form2);
110 if (form2 == converters_tab_->form)
111 form3 = fl_get_active_folder(converters_tab_->tabfolder_outer);
113 else if (form2 == look_n_feel_tab_->form)
114 form3 = fl_get_active_folder(look_n_feel_tab_->tabfolder_outer);
116 else if (form2 == inputs_tab_->form)
117 form3 = fl_get_active_folder(inputs_tab_->tabfolder_outer);
119 else if (form2 == outputs_tab_->form)
120 form3 = fl_get_active_folder(outputs_tab_->tabfolder_outer);
122 else if (form2 == lang_opts_tab_->form)
123 form3 = fl_get_active_folder(lang_opts_tab_->tabfolder_outer);
125 if (form3 && form3->visible)
126 fl_redraw_form(form3);
130 FL_FORM * FormPreferences::form() const
132 if (dialog_.get()) return dialog_->form;
137 void FormPreferences::ok()
139 FormBaseDeprecated::ok();
141 if (colors_.modifiedXformsPrefs) {
142 string const filename =
143 AddName(user_lyxdir, "preferences.xform");
144 colors_.modifiedXformsPrefs = !XformsColor::write(filename);
147 lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
151 void FormPreferences::hide()
153 // We need to hide the active tabfolder otherwise we get a
154 // BadDrawable error from X windows and LyX crashes without saving.
155 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
157 && outer_form->visible) {
158 fl_hide_form(outer_form);
160 FormBaseDeprecated::hide();
164 void FormPreferences::build()
166 dialog_.reset(build_preferences());
168 // Manage the restore, save, apply and cancel/close buttons
169 bc().setOK(dialog_->button_ok);
170 bc().setApply(dialog_->button_apply);
171 bc().setCancel(dialog_->button_cancel);
172 bc().setUndoAll(dialog_->button_restore);
175 // Workaround dumb xforms sizing bug
179 // build the tab folders
180 converters_tab_.reset(build_outer_tab());
181 look_n_feel_tab_.reset(build_outer_tab());
182 inputs_tab_.reset(build_outer_tab());
183 outputs_tab_.reset(build_outer_tab());
184 lang_opts_tab_.reset(build_outer_tab());
186 // build actual tabfolder contents
187 // these will become nested tabfolders
191 inputs_misc_.build();
195 outputs_misc_.build();
198 screen_fonts_.build();
199 spellchecker_.build();
201 // Now add them to the tabfolder
202 fl_addto_tabfolder(dialog_->tabfolder_prefs,
204 look_n_feel_tab_->form);
205 fl_addto_tabfolder(dialog_->tabfolder_prefs,
207 lang_opts_tab_->form);
208 fl_addto_tabfolder(dialog_->tabfolder_prefs,
210 converters_tab_->form);
211 fl_addto_tabfolder(dialog_->tabfolder_prefs,
214 fl_addto_tabfolder(dialog_->tabfolder_prefs,
218 // now build the nested tabfolders
219 // Starting with look and feel
220 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
222 screen_fonts_.dialog()->form);
223 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
225 interface_.dialog()->form);
226 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
228 colors_.dialog()->form);
229 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
231 lnf_misc_.dialog()->form);
233 // then build converters
234 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
236 formats_.dialog()->form);
237 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
239 converters_.dialog()->form);
242 // Paths should probably go in a few outer_tab called Files
243 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
245 paths_.dialog()->form);
246 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
248 inputs_misc_.dialog()->form);
250 // then building outputs
251 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
253 printer_.dialog()->form);
254 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
256 outputs_misc_.dialog()->form);
258 // then building usage
259 fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
261 spellchecker_.dialog()->form);
262 fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
264 language_.dialog()->form);
268 void FormPreferences::apply()
270 // set the new lyxrc entries
271 // many of these need to trigger other functions when the assignment
272 // is made. For example, screen zoom and font types. These could be
273 // handled either by signals/slots in lyxrc or just directly call the
274 // associated functions here.
275 // There are other problems with this scheme. We really should check
276 // what we copy to make sure that it really is necessary to do things
277 // like update the screen fonts because that flushes the textcache
278 // and other stuff which may cost us a lot on slower/high-load
282 formats_.apply(); // Must be before converters_.apply()
284 inputs_misc_.apply();
288 outputs_misc_.apply();
291 screen_fonts_.apply();
292 spellchecker_.apply();
296 void FormPreferences::feedback(FL_OBJECT * ob)
302 if (ob->form->fdui == colors_.dialog()) {
303 str = colors_.feedback(ob);
304 } else if (ob->form->fdui == converters_.dialog()) {
305 str = converters_.feedback(ob);
306 } else if (ob->form->fdui == formats_.dialog()) {
307 str = formats_.feedback(ob);
308 } else if (ob->form->fdui == inputs_misc_.dialog()) {
309 str = inputs_misc_.feedback(ob);
310 } else if (ob->form->fdui == interface_.dialog()) {
311 str = interface_.feedback(ob);
312 } else if (ob->form->fdui == language_.dialog()) {
313 str = language_.feedback(ob);
314 } else if (ob->form->fdui == lnf_misc_.dialog()) {
315 str = lnf_misc_.feedback(ob);
316 } else if (ob->form->fdui == outputs_misc_.dialog()) {
317 str = outputs_misc_.feedback(ob);
318 } else if (ob->form->fdui == paths_.dialog()) {
319 str = paths_.feedback(ob);
320 } else if (ob->form->fdui == printer_.dialog()) {
321 str = printer_.feedback(ob);
322 } else if (ob->form->fdui == screen_fonts_.dialog()) {
323 str = screen_fonts_.feedback(ob);
324 } else if (ob->form->fdui == spellchecker_.dialog()) {
325 str = spellchecker_.feedback(ob);
328 str = formatted(_(str), dialog_->text_warning->w-10, FL_SMALL_SIZE);
330 fl_set_object_label(dialog_->text_warning, str.c_str());
331 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
335 bool FormPreferences::input(FL_OBJECT * ob, long)
339 // whatever checks you need to ensure the user hasn't entered
340 // some totally ridiculous value somewhere. Change activate to suit.
341 // comments before each test describe what is _valid_
343 if (ob->form->fdui == colors_.dialog()) {
346 } else if (ob->form->fdui == converters_.dialog())
347 return converters_.input(ob);
348 else if (ob->form->fdui == formats_.dialog())
349 return formats_.input(ob);
350 else if (ob->form->fdui == interface_.dialog())
351 return interface_.input(ob);
352 else if (ob->form->fdui == language_.dialog())
353 return language_.input(ob);
354 else if (ob->form->fdui == paths_.dialog())
355 return paths_.input(ob);
356 else if (ob->form->fdui == screen_fonts_.dialog())
357 return screen_fonts_.input();
358 else if (ob->form->fdui == spellchecker_.dialog())
359 return spellchecker_.input(ob);
365 void FormPreferences::update()
367 if (!dialog_.get()) return;
369 // read lyxrc entries
371 formats_.update(); // Must be before converters_.update()
372 converters_.update();
373 inputs_misc_.update();
377 outputs_misc_.update();
380 screen_fonts_.update();
381 spellchecker_.update();
385 FormPreferences::Colors::Colors(FormPreferences & p)
390 FD_form_colors const * FormPreferences::Colors::dialog()
392 return dialog_.get();
396 void FormPreferences::Colors::apply()
398 bool modifiedText = false;
399 bool modifiedBackground = false;
401 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
402 cit != xformsColorDB.end(); ++cit) {
404 fl_getmcolor((*cit).colorID, &col.r, &col.g, &col.b);
405 if (col != (*cit).color()) {
406 modifiedXformsPrefs = true;
407 if ((*cit).colorID == FL_BLACK)
409 if ((*cit).colorID == FL_COL1)
410 modifiedBackground = true;
414 if (modifiedXformsPrefs) {
415 for (vector<XformsColor>::const_iterator cit =
416 xformsColorDB.begin();
417 cit != xformsColorDB.end(); ++cit) {
418 fl_mapcolor((*cit).colorID,
419 (*cit).r, (*cit).g, (*cit).b);
421 if (modifiedText && (*cit).colorID == FL_BLACK) {
422 AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
425 if (modifiedBackground && (*cit).colorID == FL_COL1) {
426 AdjustVal(FL_MCOL, FL_COL1, 0.1);
427 AdjustVal(FL_TOP_BCOL, FL_COL1, 0.1);
428 AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
430 AdjustVal(FL_RIGHT_BCOL, FL_COL1, -0.5);
431 AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
434 if ((*cit).colorID == GUI_COLOR_CURSOR) {
435 fl_mapcolor(GUI_COLOR_CURSOR,
436 (*cit).r, (*cit).g, (*cit).b);
437 fl_set_cursor_color(FL_DEFAULT_CURSOR,
438 GUI_COLOR_CURSOR, FL_WHITE);
441 Dialogs::redrawGUI();
444 // Now do the same for the LyX LColors...
445 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
446 cit != lyxColorDB.end(); ++cit) {
447 LColor::color lc = lcolor.getFromGUIName((*cit).getname());
448 if (lc == LColor::inherit) continue;
450 // Create a valid X11 name of the form "#rrggbb"
451 string const hexname = X11hexname((*cit).color());
453 if (lcolor.getX11Name(lc) != hexname) {
455 << "FormPreferences::Colors::apply: "
456 << "resetting LColor " << lcolor.getGUIName(lc)
457 << " from \"" << lcolor.getX11Name(lc)
458 << "\" to \"" << hexname << "\"."
461 string const s = lcolor.getLyXName(lc) + string(" ") +
463 parent_.lv_->getLyXFunc()->Dispatch(LFUN_SET_COLOR, s);
469 void FormPreferences::Colors::build()
471 dialog_.reset(parent_.build_colors());
473 fl_set_object_color(dialog_->button_color,
474 GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
476 fl_set_object_color(dialog_->dial_hue, GUI_COLOR_HUE_DIAL, FL_BLACK);
477 fl_set_dial_bounds(dialog_->dial_hue, 0.0, 360.0);
478 fl_set_dial_step(dialog_->dial_hue, 1.0);
479 fl_set_dial_return(dialog_->dial_hue, FL_RETURN_CHANGED);
481 fl_set_slider_bounds(dialog_->slider_saturation, 0.0, 1.0);
482 fl_set_slider_step(dialog_->slider_saturation, 0.01);
483 fl_set_slider_return(dialog_->slider_saturation, FL_RETURN_CHANGED);
485 fl_set_slider_bounds(dialog_->slider_value, 0.0, 1.0);
486 fl_set_slider_step(dialog_->slider_value, 0.01);
487 fl_set_slider_return(dialog_->slider_value, FL_RETURN_CHANGED);
489 fl_set_slider_bounds(dialog_->slider_red, 0.0, 255.0);
490 fl_set_slider_step(dialog_->slider_red, 1.0);
491 fl_set_slider_return(dialog_->slider_red, FL_RETURN_CHANGED);
493 fl_set_slider_bounds(dialog_->slider_green, 0.0, 255.0);
494 fl_set_slider_step(dialog_->slider_green, 1.0);
495 fl_set_slider_return(dialog_->slider_green, FL_RETURN_CHANGED);
497 fl_set_slider_bounds(dialog_->slider_blue, 0.0, 255.0);
498 fl_set_slider_step(dialog_->slider_blue, 1.0);
499 fl_set_slider_return(dialog_->slider_blue, FL_RETURN_CHANGED);
501 // set up the feedback mechanism
502 setPreHandler(dialog_->browser_lyx_objs);
503 setPreHandler(dialog_->button_color);
504 setPreHandler(dialog_->button_modify);
505 setPreHandler(dialog_->dial_hue);
506 setPreHandler(dialog_->slider_saturation);
507 setPreHandler(dialog_->slider_value);
508 setPreHandler(dialog_->slider_red);
509 setPreHandler(dialog_->slider_green);
510 setPreHandler(dialog_->slider_blue);
511 setPreHandler(dialog_->button_colorspace);
515 FormPreferences::Colors::feedback(FL_OBJECT const * const ob) const
519 if (ob == dialog_->browser_lyx_objs) {
520 str = N_("LyX objects that can be assigned a color.");
522 } else if (ob == dialog_->button_modify) {
523 str = N_("Modify the LyX object's color. Note: you must then \"Apply\" the change.");
525 } else if (ob == dialog_->dial_hue ||
526 ob == dialog_->slider_saturation ||
527 ob == dialog_->slider_value ||
528 ob == dialog_->slider_red ||
529 ob == dialog_->slider_green ||
530 ob == dialog_->slider_blue) {
531 str = N_("Find a new color.");
533 } else if (ob == dialog_->button_colorspace) {
534 str = N_("Toggle between RGB and HSV color spaces.");
541 void FormPreferences::Colors::input(FL_OBJECT const * const ob)
543 if (ob == dialog_->browser_lyx_objs) {
546 } else if (ob == dialog_->dial_hue ||
547 ob == dialog_->slider_saturation ||
548 ob == dialog_->slider_value) {
551 } else if (ob == dialog_->slider_red ||
552 ob == dialog_->slider_green ||
553 ob == dialog_->slider_blue) {
556 } else if (ob == dialog_->button_colorspace) {
559 } else if (ob == dialog_->button_modify) {
565 void FormPreferences::Colors::AdjustVal(int colAdjust, int colParent,
569 fl_getmcolor(colParent, &rgb.r, &rgb.g, &rgb.b);
573 hsv.v = min( 1.0, max(0.0, hsv.v) );
576 fl_mapcolor(colAdjust, rgb.r, rgb.g, rgb.b);
580 void FormPreferences::Colors::InputBrowserLyX() const
582 vector<NamedColor>::size_type const selLyX =
583 fl_get_browser(dialog_->browser_lyx_objs);
584 if (selLyX < 1) return;
586 // Is the choice an Xforms color...
589 if( selLyX-1 < xformsColorDB.size() ) {
590 vector<XformsColor>::size_type const i = selLyX - 1;
591 col = xformsColorDB[i].color();
593 // or a LyX Logical color?
595 vector<NamedColor>::size_type const i = selLyX - 1 -
596 xformsColorDB.size();
597 col = lyxColorDB[i].color();
600 fl_freeze_form(dialog_->form);
602 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
603 fl_redraw_object(dialog_->button_color);
605 // Display either RGB or HSV but not both!
608 // Deactivate the modify button to begin with...
609 setEnabled(dialog_->button_modify, false);
611 fl_unfreeze_form(dialog_->form);
615 void FormPreferences::Colors::InputHSV()
617 double const hue = fl_get_dial_value(dialog_->dial_hue);
618 double const sat = fl_get_slider_value(dialog_->slider_saturation);
619 double const val = fl_get_slider_value(dialog_->slider_value);
621 int const h = int(hue);
622 int const s = int(100.0 * sat);
623 int const v = int(100.0 * val);
625 string const label = tostr(h) + string(", ") + tostr(s) + string(", ") +
627 fl_set_object_label(dialog_->text_color_values, label.c_str());
629 RGBColor col = HSVColor(hue, sat, val);
631 fl_freeze_form(dialog_->form);
633 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
634 fl_redraw_object(dialog_->button_color);
636 col = HSVColor(hue, 1.0, 1.0);
637 col.r = max(col.r, 0);
638 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
639 fl_redraw_object(dialog_->dial_hue);
641 // Ascertain whether to activate the Modify button.
642 vector<NamedColor>::size_type const selLyX =
643 fl_get_browser(dialog_->browser_lyx_objs);
645 fl_unfreeze_form(dialog_->form);
646 if (selLyX < 1) return;
648 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
651 // Is the choice an Xforms color...
652 if( selLyX-1 < xformsColorDB.size() ) {
653 vector<XformsColor>::size_type const i = selLyX - 1;
654 modify = (xformsColorDB[i].color() != col);
656 // or a LyX Logical color?
658 vector<NamedColor>::size_type const i = selLyX - 1 -
659 xformsColorDB.size();
660 modify = (lyxColorDB[i].color() != col);
663 setEnabled(dialog_->button_modify, modify);
667 void FormPreferences::Colors::InputRGB()
669 int const red = int(fl_get_slider_value(dialog_->slider_red));
670 int const green = int(fl_get_slider_value(dialog_->slider_green));
671 int const blue = int(fl_get_slider_value(dialog_->slider_blue));
673 string const label = tostr(red) + string(", ") + tostr(green) +
674 string(", ") + tostr(blue);
675 fl_set_object_label(dialog_->text_color_values, label.c_str());
677 fl_freeze_form(dialog_->form);
679 RGBColor col = RGBColor(red, green, blue);
680 fl_mapcolor(GUI_COLOR_CHOICE, col.r, col.g, col.b);
681 fl_redraw_object(dialog_->button_color);
683 // Ascertain whether to activate the Modify button.
684 vector<NamedColor>::size_type const selLyX =
685 fl_get_browser(dialog_->browser_lyx_objs);
687 fl_unfreeze_form(dialog_->form);
688 if (selLyX < 1) return;
692 // Is the choice an Xforms color...
693 if( selLyX-1 < xformsColorDB.size() ) {
694 vector<XformsColor>::size_type const i = selLyX - 1;
695 modify = (xformsColorDB[i].color() != col);
697 // or a LyX Logical color?
699 vector<NamedColor>::size_type const i = selLyX - 1 -
700 xformsColorDB.size();
701 modify = (lyxColorDB[i].color() != col);
704 setEnabled(dialog_->button_modify, modify);
708 void FormPreferences::Colors::LoadBrowserLyX()
710 if (!dialog_->browser_lyx_objs->visible) return;
712 // First, define the modifiable xforms colors
713 xformsColorDB.clear();
716 xcol.name = _("GUI background");
717 xcol.colorID = FL_COL1;
718 fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
720 xformsColorDB.push_back(xcol);
722 xcol.name = _("GUI text");
723 xcol.colorID = FL_BLACK;
724 fl_getmcolor(FL_BLACK, &xcol.r, &xcol.g, &xcol.b);
726 fl_mapcolor(GUI_COLOR_CURSOR, xcol.r, xcol.g, xcol.b);
727 fl_set_cursor_color(FL_DEFAULT_CURSOR, GUI_COLOR_CURSOR, FL_WHITE);
729 xformsColorDB.push_back(xcol);
731 xcol.name = _("GUI selection");
732 xcol.colorID = FL_YELLOW;
733 fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
735 xformsColorDB.push_back(xcol);
737 xcol.name = _("GUI pointer");
738 xcol.colorID = GUI_COLOR_CURSOR;
739 fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
741 xformsColorDB.push_back(xcol);
743 // Now create the the LyX LColors database
745 for (int i=0; i<LColor::ignore; ++i) {
746 LColor::color lc = static_cast<LColor::color>(i);
747 if (lc == LColor::none
748 || lc == LColor::black
749 || lc == LColor::white
751 || lc == LColor::green
752 || lc == LColor::blue
753 || lc == LColor::cyan
754 || lc == LColor::magenta
755 || lc == LColor::yellow
756 || lc == LColor::inherit
757 || lc == LColor::ignore) continue;
759 string const name = lcolor.getX11Name(lc);
760 Display * display = fl_get_display();;
761 Colormap const colormap = fl_state[fl_get_vclass()].colormap;
764 if (XLookupColor(display, colormap, name.c_str(), &xcol, &ccol)
766 lyxerr << "FormPreferences::Colors::LoadBrowserLyX:\n"
767 << "LColor " << lcolor.getLyXName(lc)
768 << ": X can't find color \"" << name
769 << "\". Set to \"black\"!" << endl;
771 string const arg = lcolor.getLyXName(lc) + " black";
772 parent_.lv_->getLyXFunc()->
773 Dispatch(LFUN_SET_COLOR, arg);
777 // X has found the color. Now find the "appropriate" X11 name
780 // Note that X stores the RGB values in the range 0 - 65535
781 // whilst we require them in the range 0 - 255.
783 col.r = xcol.red / 256;
784 col.g = xcol.green / 256;
785 col.b = xcol.blue / 256;
787 // Create a valid X11 name of the form "#rrggbb" and change the
788 // LColor X11name to this. Don't want to trigger a redraw,
789 // as we're just changing the name not the RGB values.
790 // Also reset the system_lcolor names, so that we don't output
791 // unnecessary changes.
792 string const hexname = X11hexname(col);
794 if (lcolor.getX11Name(lc) != hexname) {
795 lcolor.setColor(lc, hexname);
796 system_lcolor.setColor(lc, hexname);
799 // Finally, push the color onto the database
800 NamedColor ncol(lcolor.getGUIName(lc), col);
801 lyxColorDB.push_back(ncol);
804 // Now construct the browser
805 FL_OBJECT * colbr = dialog_->browser_lyx_objs;
806 fl_freeze_form(dialog_->form);
807 fl_clear_browser(colbr);
808 for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
809 cit != xformsColorDB.end(); ++cit) {
810 fl_addto_browser(colbr, (*cit).getname().c_str());
812 for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
813 cit != lyxColorDB.end(); ++cit) {
814 fl_addto_browser(colbr, (*cit).getname().c_str());
817 // just to be safe...
818 fl_set_browser_topline(dialog_->browser_lyx_objs, 1);
819 fl_select_browser_line(dialog_->browser_lyx_objs, 1);
820 fl_unfreeze_form(dialog_->form);
826 void FormPreferences::Colors::Modify()
828 vector<NamedColor>::size_type const selLyX =
829 fl_get_browser(dialog_->browser_lyx_objs);
830 if (selLyX < 1) return;
833 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
835 // Is the choice an Xforms color...
836 if( selLyX-1 < xformsColorDB.size() ) {
837 vector<XformsColor>::size_type const i = selLyX - 1;
838 xformsColorDB[i].r = col.r;
839 xformsColorDB[i].g = col.g;
840 xformsColorDB[i].b = col.b;
842 // or a LyX Logical color?
844 vector<NamedColor>::size_type const i = selLyX - 1 -
845 xformsColorDB.size();
846 lyxColorDB[i].r = col.r;
847 lyxColorDB[i].g = col.g;
848 lyxColorDB[i].b = col.b;
851 fl_freeze_form(dialog_->form);
852 setEnabled(dialog_->button_modify, false);
853 fl_unfreeze_form(dialog_->form);
857 void FormPreferences::Colors::SwitchColorSpace() const
859 bool const pressed = fl_get_button(dialog_->button_colorspace);
862 fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
864 fl_freeze_form(dialog_->form);
867 fl_set_object_label(dialog_->button_colorspace, _("HSV"));
869 fl_hide_object(dialog_->slider_red);
870 fl_hide_object(dialog_->slider_blue);
871 fl_hide_object(dialog_->slider_green);
872 fl_show_object(dialog_->dial_hue);
873 fl_show_object(dialog_->slider_saturation);
874 fl_show_object(dialog_->slider_value);
876 HSVColor hsv = HSVColor(col);
877 hsv.h = max(hsv.h, 0.0);
879 fl_set_dial_value(dialog_->dial_hue, hsv.h);
880 fl_set_slider_value(dialog_->slider_saturation, hsv.s);
881 fl_set_slider_value(dialog_->slider_value, hsv.v);
883 col = HSVColor(hsv.h, 1.0, 1.0);
884 col.r = max(col.r,0);
885 fl_mapcolor(GUI_COLOR_HUE_DIAL, col.r, col.g, col.b);
886 fl_redraw_object(dialog_->dial_hue);
888 // Adjust the label a bit, but not the actual values.
889 // Means that toggling from one space to the other has no
890 // effect on the final color.
891 int const h = int(hsv.h);
892 int const s = int(100*hsv.s);
893 int const v = int(100*hsv.v);
894 string const label = tostr(h) + string(", ") + tostr(s) +
895 string(", ") + tostr(v);
896 fl_set_object_label(dialog_->text_color_values, label.c_str());
899 fl_set_object_label(dialog_->button_colorspace, _("RGB"));
901 fl_show_object(dialog_->slider_red);
902 fl_show_object(dialog_->slider_blue);
903 fl_show_object(dialog_->slider_green);
904 fl_hide_object(dialog_->dial_hue);
905 fl_hide_object(dialog_->slider_saturation);
906 fl_hide_object(dialog_->slider_value);
908 fl_set_slider_value(dialog_->slider_red, col.r);
909 fl_set_slider_value(dialog_->slider_green, col.g);
910 fl_set_slider_value(dialog_->slider_blue, col.b);
912 // Adjust the label a bit. Same reasoning as above.
913 int const r = int(col.r);
914 int const g = int(col.g);
915 int const b = int(col.b);
916 string const label = tostr(r) + string(", ") + tostr(g) +
917 string(", ") + tostr(b);
918 fl_set_object_label(dialog_->text_color_values, label.c_str());
921 fl_unfreeze_form(dialog_->form);
924 string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
928 ostr << "#" << std::setbase(16) << std::setfill('0')
929 << std::setw(2) << col.r
930 << std::setw(2) << col.g
931 << std::setw(2) << col.b;
933 return ostr.str().c_str();
937 FormPreferences::Converters::Converters(FormPreferences & p)
942 FD_form_converters const * FormPreferences::Converters::dialog()
944 return dialog_.get();
948 void FormPreferences::Converters::apply() const
950 converters = local_converters;
951 converters.Update(formats);
952 converters.BuildGraph();
956 void FormPreferences::Converters::build()
958 dialog_.reset(parent_.build_converters());
960 fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
961 fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
963 // set up the feedback mechanism
964 setPreHandler(dialog_->browser_all);
965 setPreHandler(dialog_->button_delete);
966 setPreHandler(dialog_->button_add);
967 setPreHandler(dialog_->input_converter);
968 setPreHandler(dialog_->choice_from);
969 setPreHandler(dialog_->choice_to);
970 setPreHandler(dialog_->input_flags);
975 FormPreferences::Converters::feedback(FL_OBJECT const * const ob) const
979 if (ob == dialog_->browser_all) {
980 str = N_("All the currently defined converters known to LyX.");
981 } else if (ob == dialog_->choice_from) {
982 str = N_("Convert \"from\" this format");
983 } else if (ob == dialog_->choice_to) {
984 str = N_("Convert \"to\" this format");
985 } else if (ob == dialog_->input_converter) {
986 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.");
987 } else if (ob == dialog_->input_flags) {
988 str = N_("Flags that control the converter behavior");
989 } else if (ob == dialog_->button_delete) {
990 str = N_("Remove the current converter from the list of available converters. Note: you must then \"Apply\" the change.");
991 } else if (ob == dialog_->button_add) {
992 if (string(ob->label) == _("Add"))
993 str = N_("Add the current converter to the list of available converters. Note: you must then \"Apply\" the change.");
995 str = N_("Modify the contents of the current converter. Note: you must then \"Apply\" the change.");
1002 bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
1004 if (ob == dialog_->browser_all) {
1007 } else if (ob == dialog_->choice_from
1008 || ob == dialog_->choice_to
1009 || ob == dialog_->input_converter
1010 || ob == dialog_->input_flags) {
1013 } else if (ob == dialog_->button_add) {
1016 } else if (ob == dialog_->button_delete) {
1024 void FormPreferences::Converters::update()
1026 local_converters = converters;
1027 local_converters.Update(local_formats);
1032 void FormPreferences::Converters::UpdateBrowser()
1034 local_converters.Sort();
1036 fl_freeze_form(dialog_->form);
1037 fl_clear_browser(dialog_->browser_all);
1038 for (::Converters::const_iterator cit = local_converters.begin();
1039 cit != local_converters.end(); ++cit) {
1040 string const name = (*cit).From->prettyname() + " -> "
1041 + (*cit).To->prettyname();
1042 fl_addto_browser(dialog_->browser_all, name.c_str());
1045 fl_unfreeze_form(dialog_->form);
1049 bool FormPreferences::Converters::Add()
1051 string const from = GetFrom();
1052 string const to = GetTo();
1053 string const command = fl_get_input(dialog_->input_converter);
1054 string const flags = fl_get_input(dialog_->input_flags);
1056 Converter const * old = local_converters.GetConverter(from, to);
1057 local_converters.Add(from, to, command, flags);
1059 local_converters.UpdateLast(local_formats);
1062 setEnabled(dialog_->button_add, false);
1068 bool FormPreferences::Converters::Browser()
1070 int const i = fl_get_browser(dialog_->browser_all);
1071 if (i <= 0) return false;
1073 fl_freeze_form(dialog_->form);
1075 Converter const & c = local_converters.Get(i-1);
1076 int j = local_formats.GetNumber(c.from);
1078 fl_set_choice(dialog_->choice_from, j+1);
1080 j = local_formats.GetNumber(c.to);
1082 fl_set_choice(dialog_->choice_to, j+1);
1084 fl_set_input(dialog_->input_converter, c.command.c_str());
1085 fl_set_input(dialog_->input_flags, c.flags.c_str());
1087 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1088 fl_set_button_shortcut(dialog_->button_add,
1089 scex(_("Modify|#M")), 1);
1091 setEnabled(dialog_->button_add, false);
1092 setEnabled(dialog_->button_delete, true);
1094 fl_unfreeze_form(dialog_->form);
1099 bool FormPreferences::Converters::Delete()
1101 string const from = GetFrom();
1102 string const to = GetTo();
1104 local_converters.Delete(from, to);
1110 bool FormPreferences::Converters::Input()
1112 string const from = GetFrom();
1113 string const to = GetTo();
1114 int const sel = local_converters.GetNumber(from, to);
1116 fl_freeze_form(dialog_->form);
1119 fl_set_object_label(dialog_->button_add,
1121 fl_set_button_shortcut(dialog_->button_add,
1122 scex(_("Add|#A")), 1);
1124 fl_deselect_browser(dialog_->browser_all);
1125 setEnabled(dialog_->button_delete, false);
1128 fl_set_object_label(dialog_->button_add,
1129 idex(_("Modify|#M")));
1130 fl_set_button_shortcut(dialog_->button_add,
1131 scex(_("Modify|#M")), 1);
1133 int top = max(sel-5, 0);
1134 fl_set_browser_topline(dialog_->browser_all, top);
1135 fl_select_browser_line(dialog_->browser_all, sel+1);
1136 setEnabled(dialog_->button_delete, true);
1139 string const command = fl_get_input(dialog_->input_converter);
1140 bool const enable = !(command.empty() || from == to);
1141 setEnabled(dialog_->button_add, enable);
1143 fl_unfreeze_form(dialog_->form);
1148 string const FormPreferences::Converters::GetFrom() const
1150 ::Formats::FormatList::size_type const i =
1151 fl_get_choice(dialog_->choice_from);
1153 if (i > 0 && i <= local_formats.size())
1154 return local_formats.Get(i-1).name();
1156 lyxerr << "FormPreferences::Converters::GetFrom: No choice!"
1163 string const FormPreferences::Converters::GetTo() const
1165 ::Formats::FormatList::size_type const i =
1166 fl_get_choice(dialog_->choice_from);
1168 if (i > 0 && i <= local_formats.size())
1169 return local_formats.Get(i-1).name();
1171 lyxerr << "FormPreferences::Converters::GetTo: No choice!"
1178 void FormPreferences::Converters::UpdateChoices() const
1181 for (::Formats::const_iterator cit = local_formats.begin();
1182 cit != local_formats.end(); ++cit) {
1183 if (!choice.empty())
1187 choice += (*cit).prettyname();
1191 fl_clear_choice(dialog_->choice_from);
1192 fl_addto_choice(dialog_->choice_from, choice.c_str());
1194 fl_clear_choice(dialog_->choice_to);
1195 fl_addto_choice(dialog_->choice_to, choice.c_str());
1199 FormPreferences::Formats::Formats( FormPreferences & p )
1204 FD_form_formats const * FormPreferences::Formats::dialog()
1206 return dialog_.get();
1210 void FormPreferences::Formats::apply() const
1212 formats = local_formats;
1216 void FormPreferences::Formats::build()
1218 dialog_.reset(parent_.build_formats());
1220 fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
1221 fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
1222 fl_set_input_return(dialog_->input_shrtcut, FL_RETURN_CHANGED);
1223 fl_set_input_return(dialog_->input_gui_name, FL_RETURN_CHANGED);
1224 fl_set_input_return(dialog_->input_extension, FL_RETURN_CHANGED);
1226 fl_set_input_filter(dialog_->input_format, fl_lowercase_filter);
1228 // set up the feedback mechanism
1229 setPreHandler(dialog_->browser_all);
1230 setPreHandler(dialog_->input_format);
1231 setPreHandler(dialog_->input_gui_name);
1232 setPreHandler(dialog_->button_delete);
1233 setPreHandler(dialog_->button_add);
1234 setPreHandler(dialog_->input_extension);
1235 setPreHandler(dialog_->input_viewer);
1236 setPreHandler(dialog_->input_shrtcut);
1241 FormPreferences::Formats::feedback(FL_OBJECT const * const ob) const
1245 if (ob == dialog_->browser_all) {
1246 str = N_("All the currently defined formats known to LyX.");
1247 } else if (ob == dialog_->input_format) {
1248 str = N_("The format identifier.");
1249 } else if (ob == dialog_->input_gui_name) {
1250 str = N_("The format name as it will appear in the menus.");
1251 } else if (ob == dialog_->input_shrtcut) {
1252 str = N_("The keyboard accelerator. Use a letter in the GUI name. Case sensitive.");
1253 } else if (ob == dialog_->input_extension) {
1254 str = N_("Used to recognize the file. E.g., ps, pdf, tex.");
1255 } else if (ob == dialog_->input_viewer) {
1256 str = N_("The command used to launch the viewer application.");
1257 } else if (ob == dialog_->button_delete) {
1258 str = N_("Remove the current format from the list of available formats. Note: you must then \"Apply\" the change.");
1259 } else if (ob == dialog_->button_add) {
1260 if (string(ob->label) == _("Add"))
1261 str = N_("Add the current format to the list of available formats. Note: you must then \"Apply\" the change.");
1263 str = N_("Modify the contents of the current format. Note: you must then \"Apply\" the change.");
1270 bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
1272 if (ob == dialog_->browser_all) {
1275 } else if (ob == dialog_->input_format
1276 || ob == dialog_->input_gui_name
1277 || ob == dialog_->input_shrtcut
1278 || ob == dialog_->input_extension
1279 || ob == dialog_->input_viewer) {
1282 } else if (ob == dialog_->button_add) {
1285 } else if (ob == dialog_->button_delete) {
1293 void FormPreferences::Formats::update()
1295 local_formats = formats;
1300 void FormPreferences::Formats::UpdateBrowser()
1302 local_formats.Sort();
1304 fl_freeze_form(dialog_->form);
1305 fl_deselect_browser(dialog_->browser_all);
1306 fl_clear_browser(dialog_->browser_all);
1307 for (::Formats::const_iterator cit = local_formats.begin();
1308 cit != local_formats.end(); ++cit)
1309 fl_addto_browser(dialog_->browser_all,
1310 (*cit).prettyname().c_str());
1313 fl_unfreeze_form(dialog_->form);
1315 // Mustn't forget to update the Formats available to the converters_
1316 parent_.converters_.UpdateChoices();
1317 local_converters.Update(local_formats);
1321 bool FormPreferences::Formats::Add()
1323 string const name = fl_get_input(dialog_->input_format);
1324 string const prettyname = fl_get_input(dialog_->input_gui_name);
1325 string const extension = fl_get_input(dialog_->input_extension);
1326 string const shortcut = fl_get_input(dialog_->input_shrtcut);
1327 string const viewer = fl_get_input(dialog_->input_viewer);
1329 Format const * old = local_formats.GetFormat(name);
1330 string const old_prettyname = old ? old->prettyname() : string();
1331 local_formats.Add(name, extension, prettyname, shortcut);
1332 local_formats.SetViewer(name, viewer);
1333 if (!old || prettyname != old_prettyname) {
1336 parent_.converters_.UpdateBrowser();
1338 setEnabled(dialog_->button_add, false);
1344 bool FormPreferences::Formats::Browser()
1346 int const i = fl_get_browser(dialog_->browser_all);
1347 if (i <= 0) return false;
1349 fl_freeze_form(dialog_->form);
1351 Format const & f = local_formats.Get(i-1);
1353 fl_set_input(dialog_->input_format, f.name().c_str());
1354 fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
1355 fl_set_input(dialog_->input_shrtcut, f.shortcut().c_str());
1356 fl_set_input(dialog_->input_extension, f.extension().c_str());
1357 fl_set_input(dialog_->input_viewer, f.viewer().c_str());
1359 fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
1360 fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
1362 setEnabled(dialog_->button_add, false);
1363 setEnabled(dialog_->button_delete, true);
1365 fl_unfreeze_form(dialog_->form);
1370 bool FormPreferences::Formats::Delete()
1372 string const name = fl_get_input(dialog_->input_format);
1374 if (local_converters.FormatIsUsed(name)) {
1375 parent_.printWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
1376 setEnabled(dialog_->button_delete, false);
1380 local_formats.Delete(name);
1386 bool FormPreferences::Formats::Input()
1388 string const name = fl_get_input(dialog_->input_format);
1389 int const sel = local_formats.GetNumber(name);
1390 fl_freeze_form(dialog_->form);
1393 fl_set_object_label(dialog_->button_add,
1395 fl_set_button_shortcut(dialog_->button_add,
1396 scex(_("Add|#A")), 1);
1398 fl_deselect_browser(dialog_->browser_all);
1399 setEnabled(dialog_->button_delete, false);
1402 fl_set_object_label(dialog_->button_add,
1403 idex(_("Modify|#M")));
1404 fl_set_button_shortcut(dialog_->button_add,
1405 scex(_("Modify|#M")), 1);
1407 int const top = max(sel-5, 0);
1408 fl_set_browser_topline(dialog_->browser_all, top);
1409 fl_select_browser_line(dialog_->browser_all, sel+1);
1411 setEnabled(dialog_->button_add, true);
1412 setEnabled(dialog_->button_delete, true);
1415 string const prettyname = fl_get_input(dialog_->input_gui_name);
1416 bool const enable = !(name.empty() || prettyname.empty());
1417 setEnabled(dialog_->button_add, enable);
1419 fl_unfreeze_form(dialog_->form);
1424 FormPreferences::InputsMisc::InputsMisc( FormPreferences & p )
1429 FD_form_inputs_misc const * FormPreferences::InputsMisc::dialog()
1431 return dialog_.get();
1435 void FormPreferences::InputsMisc::apply() const
1437 lyxrc.date_insert_format =
1438 fl_get_input(dialog_->input_date_format);
1442 void FormPreferences::InputsMisc::build()
1444 dialog_.reset(parent_.build_inputs_misc());
1446 fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
1448 // set up the feedback mechanism
1449 setPreHandler(dialog_->input_date_format);
1454 FormPreferences::InputsMisc::feedback(FL_OBJECT const * const ob) const
1458 if (ob == dialog_->input_date_format)
1459 str = lyxrc.getDescription(LyXRC::RC_DATE_INSERT_FORMAT);
1465 void FormPreferences::InputsMisc::update()
1467 fl_set_input(dialog_->input_date_format,
1468 lyxrc.date_insert_format.c_str());
1472 FormPreferences::Interface::Interface( FormPreferences & p )
1477 FD_form_interface const * FormPreferences::Interface::dialog()
1479 return dialog_.get();
1483 void FormPreferences::Interface::apply() const
1485 lyxrc.popup_font_name =
1486 fl_get_input(dialog_->input_popup_font);
1487 lyxrc.menu_font_name = fl_get_input(dialog_->input_menu_font);
1488 lyxrc.font_norm_menu =
1489 fl_get_input(dialog_->input_popup_encoding);
1490 lyxrc.bind_file = fl_get_input(dialog_->input_bind_file);
1491 lyxrc.ui_file = fl_get_input(dialog_->input_ui_file);
1492 lyxrc.override_x_deadkeys =
1493 fl_get_button(dialog_->check_override_x_dead_keys);
1497 void FormPreferences::Interface::build()
1499 dialog_.reset(parent_.build_interface());
1501 fl_set_input_return(dialog_->input_popup_font, FL_RETURN_CHANGED);
1502 fl_set_input_return(dialog_->input_menu_font, FL_RETURN_CHANGED);
1503 fl_set_input_return(dialog_->input_popup_encoding, FL_RETURN_CHANGED);
1504 fl_set_input_return(dialog_->input_bind_file, FL_RETURN_CHANGED);
1505 fl_set_input_return(dialog_->input_ui_file, FL_RETURN_CHANGED);
1507 // set up the feedback mechanism
1508 setPreHandler(dialog_->input_popup_font);
1509 setPreHandler(dialog_->input_menu_font);
1510 setPreHandler(dialog_->input_popup_encoding);
1511 setPreHandler(dialog_->input_bind_file);
1512 setPreHandler(dialog_->button_bind_file_browse);
1513 setPreHandler(dialog_->input_ui_file);
1514 setPreHandler(dialog_->button_ui_file_browse);
1515 setPreHandler(dialog_->check_override_x_dead_keys);
1520 FormPreferences::Interface::feedback(FL_OBJECT const * const ob) const
1524 if (ob == dialog_->input_popup_font)
1525 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_POPUP);
1526 else if (ob == dialog_->input_menu_font)
1527 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_MENU);
1528 else if (ob == dialog_->input_popup_encoding)
1529 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING_MENU);
1530 else if (ob == dialog_->input_bind_file)
1531 str = lyxrc.getDescription(LyXRC::RC_BINDFILE);
1532 else if (ob == dialog_->input_ui_file)
1533 str = lyxrc.getDescription(LyXRC::RC_UIFILE);
1534 else if (ob == dialog_->check_override_x_dead_keys)
1535 str = lyxrc.getDescription(LyXRC::RC_OVERRIDE_X_DEADKEYS);
1541 bool FormPreferences::Interface::input(FL_OBJECT const * const ob)
1543 if (ob == dialog_->button_bind_file_browse) {
1544 string dir = AddName(system_lyxdir, "bind");
1545 string name = N_("Sys Bind");
1546 pair<string,string> dir1(name, dir);
1548 dir = AddName(user_lyxdir, "bind");
1549 name = N_("User Bind");
1550 pair<string,string> dir2(name, dir);
1552 parent_.browse(dialog_->input_bind_file,
1553 N_("Bind file"), "*.bind", dir1, dir2);
1555 } else if (ob == dialog_->button_ui_file_browse) {
1556 string dir = AddName(system_lyxdir, "ui");
1557 string name = N_("Sys UI");
1558 pair<string,string> dir1(name, dir);
1560 dir = AddName(user_lyxdir, "ui");
1561 name = N_("User UI");
1562 pair<string,string> dir2(name, dir);
1564 parent_.browse(dialog_->input_ui_file,
1565 N_("UI file"), "*.ui", dir1, dir2);
1572 void FormPreferences::Interface::update()
1574 fl_set_input(dialog_->input_popup_font,
1575 lyxrc.popup_font_name.c_str());
1576 fl_set_input(dialog_->input_menu_font,
1577 lyxrc.menu_font_name.c_str());
1578 fl_set_input(dialog_->input_popup_encoding,
1579 lyxrc.font_norm_menu.c_str());
1580 fl_set_input(dialog_->input_bind_file,
1581 lyxrc.bind_file.c_str());
1582 fl_set_input(dialog_->input_ui_file,
1583 lyxrc.ui_file.c_str());
1584 fl_set_button(dialog_->check_override_x_dead_keys,
1585 lyxrc.override_x_deadkeys);
1589 FormPreferences::Language::Language( FormPreferences & p )
1594 FD_form_language const * FormPreferences::Language::dialog()
1596 return dialog_.get();
1600 void FormPreferences::Language::apply()
1602 lyxrc.default_language = combo_default_lang->getline();
1604 int button = fl_get_button(dialog_->check_use_kbmap);
1605 string const name_1 = fl_get_input(dialog_->input_kbmap1);
1606 string const name_2 = fl_get_input(dialog_->input_kbmap2);
1608 button = !(name_1.empty() && name_2.empty());
1609 lyxrc.use_kbmap = static_cast<bool>(button);
1611 if (lyxrc.use_kbmap) {
1612 lyxrc.primary_kbmap = name_1;
1613 lyxrc.secondary_kbmap = name_2;
1616 button = fl_get_button(dialog_->check_rtl_support);
1617 lyxrc.rtl_support = static_cast<bool>(button);
1619 button = fl_get_button(dialog_->check_mark_foreign);
1620 lyxrc.mark_foreign_language = static_cast<bool>(button);
1622 button = fl_get_button(dialog_->check_auto_begin);
1623 lyxrc.language_auto_begin = static_cast<bool>(button);
1625 button = fl_get_button(dialog_->check_auto_end);
1626 lyxrc.language_auto_end = static_cast<bool>(button);
1628 button = fl_get_button(dialog_->check_use_babel);
1629 lyxrc.language_use_babel = static_cast<bool>(button);
1631 button = fl_get_button(dialog_->check_global_options);
1632 lyxrc.language_global_options = static_cast<bool>(button);
1634 lyxrc.language_package = fl_get_input(dialog_->input_package);
1635 lyxrc.language_command_begin = fl_get_input(dialog_->input_command_begin);
1636 lyxrc.language_command_end = fl_get_input(dialog_->input_command_end);
1638 // Ensure that all is self-consistent.
1643 void FormPreferences::Language::build()
1645 dialog_.reset(parent_.build_language());
1647 fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
1648 fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
1649 fl_set_input_return(dialog_->input_command_end, FL_RETURN_CHANGED);
1651 // The default_language is a combo-box and has to be inserted manually
1652 fl_freeze_form(dialog_->form);
1653 fl_addto_form(dialog_->form);
1655 FL_OBJECT * obj = dialog_->choice_default_lang;
1656 fl_deactivate_object(dialog_->choice_default_lang);
1657 combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
1658 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
1659 parent_.lang_opts_tab_->tabfolder_outer,
1660 parent_.dialog_->tabfolder_prefs);
1661 combo_default_lang->shortcut("#L",1);
1662 combo_default_lang->setcallback(ComboCB, &parent_);
1664 for (Languages::const_iterator cit = languages.begin();
1665 cit != languages.end(); ++cit) {
1666 combo_default_lang->addto((*cit).second.lang());
1670 fl_unfreeze_form(dialog_->form);
1672 // set up the feedback mechanism
1673 setPreHandler(dialog_->input_package);
1674 setPreHandler(dialog_->check_use_kbmap);
1676 // This is safe, as nothing is done to the pointer, other than
1677 // to use its address in a block-if statement.
1678 // No it's not! Leads to crash.
1680 // reinterpret_cast<FL_OBJECT *>(combo_default_lang),
1681 // C_FormPreferencesFeedbackCB);
1683 setPreHandler(dialog_->input_kbmap1);
1684 setPreHandler(dialog_->input_kbmap2);
1685 setPreHandler(dialog_->check_rtl_support);
1686 setPreHandler(dialog_->check_mark_foreign);
1687 setPreHandler(dialog_->check_auto_begin);
1688 setPreHandler(dialog_->check_auto_end);
1689 setPreHandler(dialog_->check_use_babel);
1690 setPreHandler(dialog_->check_global_options);
1691 setPreHandler(dialog_->input_command_begin);
1692 setPreHandler(dialog_->input_command_end);
1694 // Activate/Deactivate the input fields dependent on the state of the
1701 FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
1705 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
1706 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
1707 else if (ob == dialog_->check_use_kbmap)
1708 str = lyxrc.getDescription(LyXRC::RC_KBMAP);
1709 else if (ob == dialog_->input_kbmap1)
1710 str = lyxrc.getDescription(LyXRC::RC_KBMAP_PRIMARY);
1711 else if (ob == dialog_->input_kbmap2)
1712 str = lyxrc.getDescription(LyXRC::RC_KBMAP_SECONDARY);
1713 else if (ob == dialog_->check_rtl_support)
1714 str = lyxrc.getDescription(LyXRC::RC_RTL_SUPPORT);
1715 else if (ob == dialog_->check_mark_foreign)
1716 str = lyxrc.getDescription(LyXRC::RC_MARK_FOREIGN_LANGUAGE);
1717 else if (ob == dialog_->check_auto_begin)
1718 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_BEGIN);
1719 else if (ob == dialog_->check_auto_end)
1720 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_AUTO_END);
1721 else if (ob == dialog_->check_use_babel)
1722 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_USE_BABEL);
1723 else if (ob == dialog_->check_global_options)
1724 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_GLOBAL_OPTIONS);
1725 else if (ob == dialog_->input_package)
1726 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_PACKAGE);
1727 else if (ob == dialog_->input_command_begin)
1728 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_BEGIN);
1729 else if (ob == dialog_->input_command_end)
1730 str = lyxrc.getDescription(LyXRC::RC_LANGUAGE_COMMAND_END);
1736 bool FormPreferences::Language::input(FL_OBJECT const * const ob)
1738 bool activate = true;
1740 // !ob if function is called from Language::build() to de/activate
1742 // otherwise the function is called by an xforms CB via input().
1743 if (!ob || ob == dialog_->check_use_kbmap) {
1744 bool const enable = fl_get_button(dialog_->check_use_kbmap);
1745 setEnabled(dialog_->button_kbmap1_browse, enable);
1746 setEnabled(dialog_->button_kbmap2_browse, enable);
1747 setEnabled(dialog_->input_kbmap1, enable);
1748 setEnabled(dialog_->input_kbmap2, enable);
1751 if (ob == dialog_->button_kbmap1_browse) {
1752 string const dir = AddName(system_lyxdir, "kbd");
1753 string const name = N_("Key maps");
1754 pair<string, string> dir1(name, dir);
1756 parent_.browse(dialog_->input_kbmap1,
1757 N_("Keyboard map"), "*.kmap", dir1,
1758 make_pair(string(), string()));
1759 } else if (ob == dialog_->button_kbmap2_browse) {
1760 string const dir = AddName(system_lyxdir, "kbd");
1761 string const name = N_("Key maps");
1762 pair<string, string> dir1(name, dir);
1764 parent_.browse(dialog_->input_kbmap2,
1765 N_("Keyboard map"), "*.kmap", dir1,
1766 make_pair(string(), string()));
1773 void FormPreferences::Language::update()
1775 fl_set_button(dialog_->check_use_kbmap,
1778 combo_default_lang->select_text(lyxrc.default_language);
1780 if (lyxrc.use_kbmap) {
1781 fl_set_input(dialog_->input_kbmap1,
1782 lyxrc.primary_kbmap.c_str());
1783 fl_set_input(dialog_->input_kbmap2,
1784 lyxrc.secondary_kbmap.c_str());
1786 fl_set_input(dialog_->input_kbmap1, "");
1787 fl_set_input(dialog_->input_kbmap2, "");
1790 fl_set_button(dialog_->check_rtl_support, lyxrc.rtl_support);
1791 fl_set_button(dialog_->check_mark_foreign,
1792 lyxrc.mark_foreign_language);
1793 fl_set_button(dialog_->check_auto_begin, lyxrc.language_auto_begin);
1794 fl_set_button(dialog_->check_auto_end, lyxrc.language_auto_end);
1795 fl_set_button(dialog_->check_use_babel, lyxrc.language_use_babel);
1796 fl_set_button(dialog_->check_global_options,
1797 lyxrc.language_global_options);
1799 fl_set_input(dialog_->input_package,
1800 lyxrc.language_package.c_str());
1801 fl_set_input(dialog_->input_command_begin,
1802 lyxrc.language_command_begin.c_str());
1803 fl_set_input(dialog_->input_command_end,
1804 lyxrc.language_command_end.c_str());
1806 // Activate/Deactivate the input fields dependent on the state of the
1812 void FormPreferences::Language::ComboCB(int, void * v, Combox * combox)
1814 FormPreferences * pre = static_cast<FormPreferences*>(v);
1815 // This is safe, as nothing is done to the pointer, other than
1816 // to use its address in a block-if statement.
1817 pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
1821 FormPreferences::LnFmisc::LnFmisc( FormPreferences & p )
1826 FD_form_lnf_misc const * FormPreferences::LnFmisc::dialog()
1828 return dialog_.get();
1832 void FormPreferences::LnFmisc::apply() const
1834 lyxrc.show_banner = fl_get_button(dialog_->check_banner);
1835 lyxrc.auto_region_delete =
1836 fl_get_button(dialog_->check_auto_region_delete);
1837 lyxrc.exit_confirmation = fl_get_button(dialog_->check_exit_confirm);
1838 lyxrc.display_shortcuts =
1839 fl_get_button(dialog_->check_display_shrtcuts);
1840 lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
1841 lyxrc.cursor_follows_scrollbar =
1842 fl_get_button(dialog_->check_cursor_follows_scrollbar);
1843 lyxrc.autosave = static_cast<unsigned int>
1844 (fl_get_counter_value(dialog_->counter_autosave));
1845 lyxrc.wheel_jump = static_cast<unsigned int>
1846 (fl_get_counter_value(dialog_->counter_wm_jump));
1850 void FormPreferences::LnFmisc::build()
1852 dialog_.reset(parent_.build_lnf_misc());
1854 fl_set_counter_step(dialog_->counter_autosave, 1, 10);
1855 fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
1857 fl_set_counter_return(dialog_->counter_autosave, FL_RETURN_CHANGED);
1858 fl_set_counter_return(dialog_->counter_wm_jump, FL_RETURN_CHANGED);
1860 // set up the feedback mechanism
1861 setPreHandler(dialog_->check_banner);
1862 setPreHandler(dialog_->check_auto_region_delete);
1863 setPreHandler(dialog_->check_exit_confirm);
1864 setPreHandler(dialog_->check_display_shrtcuts);
1865 setPreHandler(dialog_->counter_autosave);
1866 setPreHandler(dialog_->check_ask_new_file);
1867 setPreHandler(dialog_->check_cursor_follows_scrollbar);
1868 setPreHandler(dialog_->counter_wm_jump);
1873 FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
1877 if (ob == dialog_->check_banner)
1878 str = lyxrc.getDescription(LyXRC::RC_SHOW_BANNER);
1879 else if (ob == dialog_->check_auto_region_delete)
1880 str = lyxrc.getDescription(LyXRC::RC_AUTOREGIONDELETE);
1881 else if (ob == dialog_->check_exit_confirm)
1882 str = lyxrc.getDescription(LyXRC::RC_EXIT_CONFIRMATION);
1883 else if (ob == dialog_->check_display_shrtcuts)
1884 str = lyxrc.getDescription(LyXRC::RC_DISPLAY_SHORTCUTS);
1885 else if (ob == dialog_->check_ask_new_file)
1886 str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
1887 else if (ob == dialog_->check_cursor_follows_scrollbar)
1888 str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
1889 else if (ob == dialog_->counter_autosave)
1890 str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
1891 else if (ob == dialog_->counter_wm_jump)
1892 str = lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
1898 void FormPreferences::LnFmisc::update()
1900 fl_set_button(dialog_->check_banner, lyxrc.show_banner);
1901 fl_set_button(dialog_->check_auto_region_delete,
1902 lyxrc.auto_region_delete);
1903 fl_set_button(dialog_->check_exit_confirm, lyxrc.exit_confirmation);
1904 fl_set_button(dialog_->check_display_shrtcuts, lyxrc.display_shortcuts);
1905 fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
1906 fl_set_button(dialog_->check_cursor_follows_scrollbar,
1907 lyxrc.cursor_follows_scrollbar);
1908 fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
1909 fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
1913 FormPreferences::OutputsMisc::OutputsMisc( FormPreferences & p )
1918 FD_form_outputs_misc const * FormPreferences::OutputsMisc::dialog()
1920 return dialog_.get();
1924 void FormPreferences::OutputsMisc::apply() const
1926 lyxrc.ascii_linelen = static_cast<unsigned int>
1927 (fl_get_counter_value(dialog_->counter_line_len));
1928 lyxrc.fontenc = fl_get_input(dialog_->input_tex_encoding);
1931 fl_get_choice(dialog_->choice_default_papersize) - 1;
1932 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1934 lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
1935 lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
1939 void FormPreferences::OutputsMisc::build()
1941 dialog_.reset(parent_.build_outputs_misc());
1943 fl_set_counter_step(dialog_->counter_line_len, 1, 10);
1945 fl_set_counter_return(dialog_->counter_line_len, FL_RETURN_CHANGED);
1946 fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
1947 fl_set_input_return(dialog_->input_ascii_roff, FL_RETURN_CHANGED);
1948 fl_set_input_return(dialog_->input_checktex, FL_RETURN_CHANGED);
1950 fl_addto_choice(dialog_->choice_default_papersize,
1951 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
1953 // set up the feedback mechanism
1954 setPreHandler(dialog_->counter_line_len);
1955 setPreHandler(dialog_->input_tex_encoding);
1956 setPreHandler(dialog_->choice_default_papersize);
1957 setPreHandler(dialog_->input_ascii_roff);
1958 setPreHandler(dialog_->input_checktex);
1963 FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
1967 if (ob == dialog_->counter_line_len)
1968 str = lyxrc.getDescription(LyXRC::RC_ASCII_LINELEN);
1969 else if (ob == dialog_->input_tex_encoding)
1970 str = lyxrc.getDescription(LyXRC::RC_FONT_ENCODING);
1971 else if (ob == dialog_->input_ascii_roff)
1972 str = lyxrc.getDescription(LyXRC::RC_ASCIIROFF_COMMAND);
1973 else if (ob == dialog_->input_checktex)
1974 str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
1975 else if (ob == dialog_->choice_default_papersize)
1976 str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
1982 void FormPreferences::OutputsMisc::update()
1984 fl_set_counter_value(dialog_->counter_line_len,
1985 lyxrc.ascii_linelen);
1986 fl_set_input(dialog_->input_tex_encoding,
1987 lyxrc.fontenc.c_str());
1988 fl_set_choice(dialog_->choice_default_papersize,
1989 lyxrc.default_papersize+1);
1990 fl_set_input(dialog_->input_ascii_roff,
1991 lyxrc.ascii_roff_command.c_str());
1992 fl_set_input(dialog_->input_checktex,
1993 lyxrc.chktex_command.c_str());
1997 FormPreferences::Paths::Paths( FormPreferences & p )
2002 FD_form_paths const * FormPreferences::Paths::dialog()
2004 return dialog_.get();
2008 void FormPreferences::Paths::apply()
2010 lyxrc.document_path = fl_get_input(dialog_->input_default_path);
2011 lyxrc.template_path = fl_get_input(dialog_->input_template_path);
2013 int button = fl_get_button(dialog_->check_use_temp_dir);
2014 string str = fl_get_input(dialog_->input_temp_dir);
2015 if (!button) str.erase();
2017 lyxrc.use_tempdir = button;
2018 lyxrc.tempdir_path = str;
2020 button = fl_get_button(dialog_->check_last_files);
2021 str = fl_get_input(dialog_->input_lastfiles);
2022 if (!button) str.erase();
2024 lyxrc.check_lastfiles = button;
2025 lyxrc.lastfiles = str;
2026 lyxrc.num_lastfiles = static_cast<unsigned int>
2027 (fl_get_counter_value(dialog_->counter_lastfiles));
2029 button = fl_get_button(dialog_->check_make_backups);
2030 str = fl_get_input(dialog_->input_backup_path);
2031 if (!button) str.erase();
2033 lyxrc.make_backup = button;
2034 lyxrc.backupdir_path = str;
2036 lyxrc.lyxpipes = fl_get_input(dialog_->input_serverpipe);
2043 void FormPreferences::Paths::build()
2045 dialog_.reset(parent_.build_paths());
2047 fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
2048 fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
2049 fl_set_input_return(dialog_->input_temp_dir, FL_RETURN_CHANGED);
2050 fl_set_input_return(dialog_->input_lastfiles, FL_RETURN_CHANGED);
2051 fl_set_input_return(dialog_->input_backup_path, FL_RETURN_CHANGED);
2052 fl_set_counter_return(dialog_->counter_lastfiles, FL_RETURN_CHANGED);
2053 fl_set_input_return(dialog_->input_serverpipe, FL_RETURN_CHANGED);
2055 // set up the feedback mechanism
2056 setPreHandler(dialog_->input_default_path);
2057 setPreHandler(dialog_->counter_lastfiles);
2058 setPreHandler(dialog_->input_template_path);
2059 setPreHandler(dialog_->check_last_files);
2060 setPreHandler(dialog_->input_lastfiles);
2061 setPreHandler(dialog_->check_make_backups);
2062 setPreHandler(dialog_->input_backup_path);
2063 setPreHandler(dialog_->input_serverpipe);
2064 setPreHandler(dialog_->input_temp_dir);
2065 setPreHandler(dialog_->check_use_temp_dir);
2070 FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
2074 if (ob == dialog_->input_default_path)
2075 str = lyxrc.getDescription(LyXRC::RC_DOCUMENTPATH);
2076 else if (ob == dialog_->input_template_path)
2077 str = lyxrc.getDescription(LyXRC::RC_TEMPLATEPATH);
2078 else if (ob == dialog_->check_use_temp_dir)
2079 str = lyxrc.getDescription(LyXRC::RC_USETEMPDIR);
2080 else if (ob == dialog_->input_temp_dir)
2081 str = lyxrc.getDescription(LyXRC::RC_TEMPDIRPATH);
2082 else if (ob == dialog_->check_last_files)
2083 str = lyxrc.getDescription(LyXRC::RC_CHECKLASTFILES);
2084 else if (ob == dialog_->input_lastfiles)
2085 str = lyxrc.getDescription(LyXRC::RC_LASTFILES);
2086 else if (ob == dialog_->counter_lastfiles)
2087 str = lyxrc.getDescription(LyXRC::RC_NUMLASTFILES);
2088 else if (ob == dialog_->check_make_backups)
2089 str = lyxrc.getDescription(LyXRC::RC_MAKE_BACKUP);
2090 else if (ob == dialog_->input_backup_path)
2091 str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
2092 else if (ob == dialog_->input_serverpipe) {
2093 str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
2094 str += " Enter either the input pipe, xxx.in, or the output pipe, xxx.out.";
2101 bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
2103 bool activate = true;
2105 // !ob if function is called from Paths::update() to de/activate
2107 // otherwise the function is called by an xforms CB via input().
2108 if (!ob || ob == dialog_->check_use_temp_dir) {
2109 bool const enable = fl_get_button(dialog_->check_use_temp_dir);
2110 setEnabled(dialog_->input_temp_dir, enable);
2113 if (!ob || ob == dialog_->check_last_files) {
2114 bool const enable = fl_get_button(dialog_->check_last_files);
2115 setEnabled(dialog_->input_lastfiles, enable);
2118 if (!ob || ob == dialog_->check_make_backups) {
2119 bool const enable = fl_get_button(dialog_->check_make_backups);
2120 setEnabled(dialog_->input_backup_path, enable);
2123 if (!ob || ob == dialog_->input_default_path) {
2124 string const name = fl_get_input(dialog_->input_default_path);
2125 if (!RWInfo::WriteableDir(name)) {
2126 parent_.printWarning(RWInfo::ErrorMessage());
2131 if (!ob || ob == dialog_->input_template_path) {
2132 string const name = fl_get_input(dialog_->input_template_path);
2133 if (!RWInfo::ReadableDir(name)) {
2134 parent_.printWarning(RWInfo::ErrorMessage());
2139 if (!ob || ob == dialog_->input_temp_dir) {
2140 string const name = fl_get_input(dialog_->input_temp_dir);
2141 if (fl_get_button(dialog_->check_make_backups)
2143 && !RWInfo::WriteableDir(name)) {
2144 parent_.printWarning(RWInfo::ErrorMessage());
2149 if (!ob || ob == dialog_->input_backup_path) {
2150 string const name = fl_get_input(dialog_->input_backup_path);
2151 if (fl_get_button(dialog_->check_make_backups)
2153 && !RWInfo::WriteableDir(name)) {
2154 parent_.printWarning(RWInfo::ErrorMessage());
2159 if (!ob || ob == dialog_->input_lastfiles) {
2160 string const name = fl_get_input(dialog_->input_lastfiles);
2161 if (fl_get_button(dialog_->check_last_files)
2163 && !RWInfo::WriteableFile(name)) {
2164 parent_.printWarning(RWInfo::ErrorMessage());
2169 if (!ob || ob == dialog_->input_serverpipe) {
2170 string const name = fl_get_input(dialog_->input_serverpipe);
2171 if (!name.empty()) {
2172 // strip off the extension
2173 string const str = ChangeExtension(name, "");
2174 if (!RWInfo::WriteableFile(str + ".in")) {
2175 parent_.printWarning(RWInfo::ErrorMessage());
2178 if (!RWInfo::WriteableFile(str + ".out")) {
2179 parent_.printWarning(RWInfo::ErrorMessage());
2185 if (ob == dialog_->button_default_path_browse) {
2186 parent_.browse(dialog_->input_default_path,
2187 N_("Default path"), string(),
2188 make_pair(string(), string()),
2189 make_pair(string(), string()));
2190 } else if (ob == dialog_->button_template_path_browse) {
2191 parent_.browse(dialog_->input_template_path,
2192 N_("Template path"), string(),
2193 make_pair(string(), string()),
2194 make_pair(string(), string()));
2195 } else if (ob == dialog_->button_temp_dir_browse) {
2196 parent_.browse(dialog_->input_temp_dir,
2197 N_("Temp dir"), string(),
2198 make_pair(string(), string()),
2199 make_pair(string(), string()));
2200 } else if (ob == dialog_->button_lastfiles_browse) {
2201 pair<string, string> dir(_("User"), user_lyxdir);
2203 parent_.browse(dialog_->input_lastfiles,
2204 N_("Lastfiles"), string(), dir,
2205 make_pair(string(), string()));
2206 } else if (ob == dialog_->button_backup_path_browse) {
2207 parent_.browse(dialog_->input_backup_path,
2208 N_("Backup path"), string(),
2209 make_pair(string(), string()),
2210 make_pair(string(), string()));
2211 } else if (ob == dialog_->button_serverpipe_browse) {
2212 parent_.browse(dialog_->input_serverpipe,
2213 N_("LyX Server pipes"), string(),
2214 make_pair(string(), string()),
2215 make_pair(string(), string()));
2222 void FormPreferences::Paths::update()
2224 fl_set_input(dialog_->input_default_path,
2225 lyxrc.document_path.c_str());
2226 fl_set_input(dialog_->input_template_path,
2227 lyxrc.template_path.c_str());
2230 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
2232 fl_set_button(dialog_->check_make_backups,
2234 fl_set_input(dialog_->input_backup_path, str.c_str());
2237 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
2239 fl_set_button(dialog_->check_use_temp_dir,
2241 fl_set_input(dialog_->input_temp_dir, str.c_str());
2244 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
2246 fl_set_button(dialog_->check_last_files,
2247 lyxrc.check_lastfiles);
2248 fl_set_input(dialog_->input_lastfiles, str.c_str());
2249 fl_set_counter_value(dialog_->counter_lastfiles,
2250 lyxrc.num_lastfiles);
2252 fl_set_input(dialog_->input_serverpipe, lyxrc.lyxpipes.c_str());
2254 // Activate/Deactivate the input fields dependent on the state of the
2260 FormPreferences::Printer::Printer(FormPreferences & p)
2265 FD_form_printer const * FormPreferences::Printer::dialog()
2267 return dialog_.get();
2271 void FormPreferences::Printer::apply() const
2273 lyxrc.print_adapt_output = fl_get_button(dialog_->check_adapt_output);
2274 lyxrc.print_command = fl_get_input(dialog_->input_command);
2275 lyxrc.print_pagerange_flag = fl_get_input(dialog_->input_page_range);
2276 lyxrc.print_copies_flag = fl_get_input(dialog_->input_copies);
2277 lyxrc.print_reverse_flag = fl_get_input(dialog_->input_reverse);
2278 lyxrc.print_to_printer = fl_get_input(dialog_->input_to_printer);
2279 lyxrc.print_file_extension =
2280 fl_get_input(dialog_->input_file_extension);
2281 lyxrc.print_spool_command =
2282 fl_get_input(dialog_->input_spool_command);
2283 lyxrc.print_paper_flag = fl_get_input(dialog_->input_paper_type);
2284 lyxrc.print_evenpage_flag = fl_get_input(dialog_->input_even_pages);
2285 lyxrc.print_oddpage_flag = fl_get_input(dialog_->input_odd_pages);
2286 lyxrc.print_collcopies_flag = fl_get_input(dialog_->input_collated);
2287 lyxrc.print_landscape_flag = fl_get_input(dialog_->input_landscape);
2288 lyxrc.print_to_file = fl_get_input(dialog_->input_to_file);
2289 lyxrc.print_extra_options =
2290 fl_get_input(dialog_->input_extra_options);
2291 lyxrc.print_spool_printerprefix =
2292 fl_get_input(dialog_->input_spool_prefix);
2293 lyxrc.print_paper_dimension_flag =
2294 fl_get_input(dialog_->input_paper_size);
2295 lyxrc.printer = fl_get_input(dialog_->input_name);
2300 FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
2304 if (ob == dialog_->input_command)
2305 str = lyxrc.getDescription(LyXRC::RC_PRINT_COMMAND);
2306 else if (ob == dialog_->check_adapt_output)
2307 str = lyxrc.getDescription(LyXRC::RC_PRINT_ADAPTOUTPUT);
2308 else if (ob == dialog_->input_to_printer)
2309 str = lyxrc.getDescription(LyXRC::RC_PRINTTOPRINTER);
2310 else if (ob == dialog_->input_to_file)
2311 str = lyxrc.getDescription(LyXRC::RC_PRINTTOFILE);
2312 else if (ob == dialog_->input_file_extension)
2313 str = lyxrc.getDescription(LyXRC::RC_PRINTFILEEXTENSION);
2314 else if (ob == dialog_->input_extra_options)
2315 str = lyxrc.getDescription(LyXRC::RC_PRINTEXSTRAOPTIONS);
2316 else if (ob == dialog_->input_spool_command)
2317 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_COMMAND);
2318 else if (ob == dialog_->input_spool_prefix)
2319 str = lyxrc.getDescription(LyXRC::RC_PRINTSPOOL_PRINTERPREFIX);
2320 else if (ob == dialog_->input_name)
2321 str = lyxrc.getDescription(LyXRC::RC_PRINTER);
2322 else if (ob == dialog_->input_even_pages)
2323 str = lyxrc.getDescription(LyXRC::RC_PRINTEVENPAGEFLAG);
2324 else if (ob == dialog_->input_odd_pages)
2325 str = lyxrc.getDescription(LyXRC::RC_PRINTODDPAGEFLAG);
2326 else if (ob == dialog_->input_page_range)
2327 str = lyxrc.getDescription(LyXRC::RC_PRINTPAGERANGEFLAG);
2328 else if (ob == dialog_->input_reverse)
2329 str = lyxrc.getDescription(LyXRC::RC_PRINTREVERSEFLAG);
2330 else if (ob == dialog_->input_landscape)
2331 str = lyxrc.getDescription(LyXRC::RC_PRINTLANDSCAPEFLAG);
2332 else if (ob == dialog_->input_copies)
2333 str = lyxrc.getDescription(LyXRC::RC_PRINTCOPIESFLAG);
2334 else if (ob == dialog_->input_collated)
2335 str = lyxrc.getDescription(LyXRC::RC_PRINTCOLLCOPIESFLAG);
2336 else if (ob == dialog_->input_paper_type)
2337 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERFLAG);
2338 else if (ob == dialog_->input_paper_size)
2339 str = lyxrc.getDescription(LyXRC::RC_PRINTPAPERDIMENSIONFLAG);
2345 void FormPreferences::Printer::build()
2347 dialog_.reset(parent_.build_printer());
2349 fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
2350 fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
2351 fl_set_input_return(dialog_->input_copies, FL_RETURN_CHANGED);
2352 fl_set_input_return(dialog_->input_reverse, FL_RETURN_CHANGED);
2353 fl_set_input_return(dialog_->input_to_printer, FL_RETURN_CHANGED);
2354 fl_set_input_return(dialog_->input_file_extension, FL_RETURN_CHANGED);
2355 fl_set_input_return(dialog_->input_spool_command, FL_RETURN_CHANGED);
2356 fl_set_input_return(dialog_->input_paper_type, FL_RETURN_CHANGED);
2357 fl_set_input_return(dialog_->input_even_pages, FL_RETURN_CHANGED);
2358 fl_set_input_return(dialog_->input_odd_pages, FL_RETURN_CHANGED);
2359 fl_set_input_return(dialog_->input_collated, FL_RETURN_CHANGED);
2360 fl_set_input_return(dialog_->input_landscape, FL_RETURN_CHANGED);
2361 fl_set_input_return(dialog_->input_to_file, FL_RETURN_CHANGED);
2362 fl_set_input_return(dialog_->input_extra_options, FL_RETURN_CHANGED);
2363 fl_set_input_return(dialog_->input_spool_prefix, FL_RETURN_CHANGED);
2364 fl_set_input_return(dialog_->input_paper_size, FL_RETURN_CHANGED);
2365 fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
2367 // set up the feedback mechanism
2368 setPreHandler(dialog_->input_command);
2369 setPreHandler(dialog_->input_page_range);
2370 setPreHandler(dialog_->input_copies);
2371 setPreHandler(dialog_->input_reverse);
2372 setPreHandler(dialog_->input_to_printer);
2373 setPreHandler(dialog_->input_file_extension);
2374 setPreHandler(dialog_->input_spool_command);
2375 setPreHandler(dialog_->input_paper_type);
2376 setPreHandler(dialog_->input_even_pages);
2377 setPreHandler(dialog_->input_odd_pages);
2378 setPreHandler(dialog_->input_collated);
2379 setPreHandler(dialog_->input_landscape);
2380 setPreHandler(dialog_->input_to_file);
2381 setPreHandler(dialog_->input_extra_options);
2382 setPreHandler(dialog_->input_spool_prefix);
2383 setPreHandler(dialog_->input_paper_size);
2384 setPreHandler(dialog_->input_name);
2385 setPreHandler(dialog_->check_adapt_output);
2389 void FormPreferences::Printer::update()
2391 fl_set_button(dialog_->check_adapt_output,
2392 lyxrc.print_adapt_output);
2393 fl_set_input(dialog_->input_command,
2394 lyxrc.print_command.c_str());
2395 fl_set_input(dialog_->input_page_range,
2396 lyxrc.print_pagerange_flag.c_str());
2397 fl_set_input(dialog_->input_copies,
2398 lyxrc.print_copies_flag.c_str());
2399 fl_set_input(dialog_->input_reverse,
2400 lyxrc.print_reverse_flag.c_str());
2401 fl_set_input(dialog_->input_to_printer,
2402 lyxrc.print_to_printer.c_str());
2403 fl_set_input(dialog_->input_file_extension,
2404 lyxrc.print_file_extension.c_str());
2405 fl_set_input(dialog_->input_spool_command,
2406 lyxrc.print_spool_command.c_str());
2407 fl_set_input(dialog_->input_paper_type,
2408 lyxrc.print_paper_flag.c_str());
2409 fl_set_input(dialog_->input_even_pages,
2410 lyxrc.print_evenpage_flag.c_str());
2411 fl_set_input(dialog_->input_odd_pages,
2412 lyxrc.print_oddpage_flag.c_str());
2413 fl_set_input(dialog_->input_collated,
2414 lyxrc.print_collcopies_flag.c_str());
2415 fl_set_input(dialog_->input_landscape,
2416 lyxrc.print_landscape_flag.c_str());
2417 fl_set_input(dialog_->input_to_file,
2418 lyxrc.print_to_file.c_str());
2419 fl_set_input(dialog_->input_extra_options,
2420 lyxrc.print_extra_options.c_str());
2421 fl_set_input(dialog_->input_spool_prefix,
2422 lyxrc.print_spool_printerprefix.c_str());
2423 fl_set_input(dialog_->input_paper_size,
2424 lyxrc.print_paper_dimension_flag.c_str());
2425 fl_set_input(dialog_->input_name,
2426 lyxrc.printer.c_str());
2430 FormPreferences::ScreenFonts::ScreenFonts( FormPreferences & p )
2435 FD_form_screen_fonts const * FormPreferences::ScreenFonts::dialog()
2437 return dialog_.get();
2441 void FormPreferences::ScreenFonts::apply() const
2443 bool changed = false;
2445 string str = fl_get_input(dialog_->input_roman);
2446 if (lyxrc.roman_font_name != str) {
2448 lyxrc.roman_font_name = str;
2451 str = fl_get_input(dialog_->input_sans);
2452 if (lyxrc.sans_font_name != str) {
2454 lyxrc.sans_font_name = str;
2457 str = fl_get_input(dialog_->input_typewriter);
2458 if (lyxrc.typewriter_font_name != str) {
2460 lyxrc.typewriter_font_name = str;
2463 str = fl_get_input(dialog_->input_screen_encoding);
2464 if (lyxrc.font_norm != str) {
2466 lyxrc.font_norm = str;
2469 bool button = fl_get_button(dialog_->check_scalable);
2470 if (lyxrc.use_scalable_fonts != button) {
2472 lyxrc.use_scalable_fonts = button;
2475 unsigned int ivalue = static_cast<unsigned int>
2476 (fl_get_counter_value(dialog_->counter_zoom));
2477 if (lyxrc.zoom != ivalue) {
2479 lyxrc.zoom = ivalue;
2482 ivalue = static_cast<unsigned int>
2483 (fl_get_counter_value(dialog_->counter_dpi));
2484 if (lyxrc.dpi != ivalue) {
2489 double dvalue = strToDbl(fl_get_input(dialog_->input_tiny));
2490 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
2492 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
2495 dvalue = strToDbl(fl_get_input(dialog_->input_script));
2496 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
2498 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
2501 dvalue = strToDbl(fl_get_input(dialog_->input_footnote));
2502 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
2504 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
2507 dvalue = strToDbl(fl_get_input(dialog_->input_small));
2508 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
2510 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
2513 dvalue = strToDbl(fl_get_input(dialog_->input_normal));
2514 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
2516 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
2519 dvalue = strToDbl(fl_get_input(dialog_->input_large));
2520 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
2522 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
2525 dvalue = strToDbl(fl_get_input(dialog_->input_larger));
2526 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
2528 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
2531 dvalue = strToDbl(fl_get_input(dialog_->input_largest));
2532 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
2534 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
2537 dvalue = strToDbl(fl_get_input(dialog_->input_huge));
2538 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
2540 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
2543 dvalue = strToDbl(fl_get_input(dialog_->input_huger));
2544 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
2546 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
2550 // Now update the buffers
2551 // Can anything below here affect the redraw process?
2552 parent_.lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
2557 void FormPreferences::ScreenFonts::build()
2559 dialog_.reset(parent_.build_screen_fonts());
2561 fl_set_counter_step(dialog_->counter_zoom, 1, 10);
2562 fl_set_counter_step(dialog_->counter_dpi, 1, 10);
2564 fl_set_input_return(dialog_->input_roman, FL_RETURN_CHANGED);
2565 fl_set_input_return(dialog_->input_sans, FL_RETURN_CHANGED);
2566 fl_set_input_return(dialog_->input_typewriter, FL_RETURN_CHANGED);
2567 fl_set_input_return(dialog_->input_screen_encoding, FL_RETURN_CHANGED);
2568 fl_set_counter_return(dialog_->counter_zoom, FL_RETURN_CHANGED);
2569 fl_set_counter_return(dialog_->counter_dpi, FL_RETURN_CHANGED);
2570 fl_set_input_return(dialog_->input_tiny, FL_RETURN_CHANGED);
2571 fl_set_input_return(dialog_->input_script, FL_RETURN_CHANGED);
2572 fl_set_input_return(dialog_->input_footnote, FL_RETURN_CHANGED);
2573 fl_set_input_return(dialog_->input_small, FL_RETURN_CHANGED);
2574 fl_set_input_return(dialog_->input_normal, FL_RETURN_CHANGED);
2575 fl_set_input_return(dialog_->input_large, FL_RETURN_CHANGED);
2576 fl_set_input_return(dialog_->input_larger, FL_RETURN_CHANGED);
2577 fl_set_input_return(dialog_->input_largest, FL_RETURN_CHANGED);
2578 fl_set_input_return(dialog_->input_huge, FL_RETURN_CHANGED);
2579 fl_set_input_return(dialog_->input_huger, FL_RETURN_CHANGED);
2581 fl_set_input_filter(dialog_->input_tiny, fl_unsigned_float_filter);
2582 fl_set_input_filter(dialog_->input_script, fl_unsigned_float_filter);
2583 fl_set_input_filter(dialog_->input_footnote, fl_unsigned_float_filter);
2584 fl_set_input_filter(dialog_->input_small, fl_unsigned_float_filter);
2585 fl_set_input_filter(dialog_->input_normal, fl_unsigned_float_filter);
2586 fl_set_input_filter(dialog_->input_large, fl_unsigned_float_filter);
2587 fl_set_input_filter(dialog_->input_larger, fl_unsigned_float_filter);
2588 fl_set_input_filter(dialog_->input_largest, fl_unsigned_float_filter);
2589 fl_set_input_filter(dialog_->input_huge, fl_unsigned_float_filter);
2590 fl_set_input_filter(dialog_->input_huger, fl_unsigned_float_filter);
2592 // set up the feedback mechanism
2593 setPreHandler(dialog_->input_roman);
2594 setPreHandler(dialog_->input_sans);
2595 setPreHandler(dialog_->input_typewriter);
2596 setPreHandler(dialog_->counter_zoom);
2597 setPreHandler(dialog_->counter_dpi);
2598 setPreHandler(dialog_->check_scalable);
2599 setPreHandler(dialog_->input_screen_encoding);
2600 setPreHandler(dialog_->input_tiny);
2601 setPreHandler(dialog_->input_script);
2602 setPreHandler(dialog_->input_footnote);
2603 setPreHandler(dialog_->input_small);
2604 setPreHandler(dialog_->input_large);
2605 setPreHandler(dialog_->input_larger);
2606 setPreHandler(dialog_->input_largest);
2607 setPreHandler(dialog_->input_normal);
2608 setPreHandler(dialog_->input_huge);
2609 setPreHandler(dialog_->input_huger);
2614 FormPreferences::ScreenFonts::feedback(FL_OBJECT const * const ob) const
2618 if (ob == dialog_->input_roman)
2619 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ROMAN);
2620 else if (ob == dialog_->input_sans)
2621 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SANS);
2622 else if (ob == dialog_->input_typewriter)
2623 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_TYPEWRITER);
2624 else if (ob == dialog_->check_scalable)
2625 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SCALABLE);
2626 else if (ob == dialog_->input_screen_encoding)
2627 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_ENCODING);
2628 else if (ob == dialog_->counter_zoom)
2629 str = lyxrc.getDescription(LyXRC::RC_SCREEN_ZOOM);
2630 else if (ob == dialog_->counter_dpi)
2631 str = lyxrc.getDescription(LyXRC::RC_SCREEN_DPI);
2632 else if (ob == dialog_->input_tiny
2633 || ob == dialog_->input_script
2634 || ob == dialog_->input_footnote
2635 || ob == dialog_->input_small
2636 || ob == dialog_->input_large
2637 || ob == dialog_->input_larger
2638 || ob == dialog_->input_larger
2639 || ob == dialog_->input_largest
2640 || ob == dialog_->input_normal
2641 || ob == dialog_->input_huge
2642 || ob == dialog_->input_huger)
2643 str = lyxrc.getDescription(LyXRC::RC_SCREEN_FONT_SIZES);
2649 bool FormPreferences::ScreenFonts::input()
2651 bool activate = true;
2654 // Make sure that all fonts all have positive entries
2655 // Also note that an empty entry is returned as 0.0 by strToDbl
2656 if (0.0 >= strToDbl(fl_get_input(dialog_->input_tiny))
2657 || 0.0 >= strToDbl(fl_get_input(dialog_->input_script))
2658 || 0.0 >= strToDbl(fl_get_input(dialog_->input_footnote))
2659 || 0.0 >= strToDbl(fl_get_input(dialog_->input_small))
2660 || 0.0 >= strToDbl(fl_get_input(dialog_->input_normal))
2661 || 0.0 >= strToDbl(fl_get_input(dialog_->input_large))
2662 || 0.0 >= strToDbl(fl_get_input(dialog_->input_larger))
2663 || 0.0 >= strToDbl(fl_get_input(dialog_->input_largest))
2664 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huge))
2665 || 0.0 >= strToDbl(fl_get_input(dialog_->input_huger))) {
2667 str = N_("Fonts must be positive!");
2669 // Fontsizes -- tiny < script < footnote etc.
2670 } else if (strToDbl(fl_get_input(dialog_->input_tiny)) >
2671 strToDbl(fl_get_input(dialog_->input_script)) ||
2672 strToDbl(fl_get_input(dialog_->input_script)) >
2673 strToDbl(fl_get_input(dialog_->input_footnote)) ||
2674 strToDbl(fl_get_input(dialog_->input_footnote)) >
2675 strToDbl(fl_get_input(dialog_->input_small)) ||
2676 strToDbl(fl_get_input(dialog_->input_small)) >
2677 strToDbl(fl_get_input(dialog_->input_normal)) ||
2678 strToDbl(fl_get_input(dialog_->input_normal)) >
2679 strToDbl(fl_get_input(dialog_->input_large)) ||
2680 strToDbl(fl_get_input(dialog_->input_large)) >
2681 strToDbl(fl_get_input(dialog_->input_larger)) ||
2682 strToDbl(fl_get_input(dialog_->input_larger)) >
2683 strToDbl(fl_get_input(dialog_->input_largest)) ||
2684 strToDbl(fl_get_input(dialog_->input_largest)) >
2685 strToDbl(fl_get_input(dialog_->input_huge)) ||
2686 strToDbl(fl_get_input(dialog_->input_huge)) >
2687 strToDbl(fl_get_input(dialog_->input_huger))) {
2690 str = N_("Fonts must be input in the order tiny > script> footnote > small > normal > large > larger > largest > huge > huger.");
2694 parent_.printWarning(str);
2700 void FormPreferences::ScreenFonts::update()
2702 fl_set_input(dialog_->input_roman,
2703 lyxrc.roman_font_name.c_str());
2704 fl_set_input(dialog_->input_sans,
2705 lyxrc.sans_font_name.c_str());
2706 fl_set_input(dialog_->input_typewriter,
2707 lyxrc.typewriter_font_name.c_str());
2708 fl_set_input(dialog_->input_screen_encoding,
2709 lyxrc.font_norm.c_str());
2710 fl_set_button(dialog_->check_scalable,
2711 lyxrc.use_scalable_fonts);
2712 fl_set_counter_value(dialog_->counter_zoom, lyxrc.zoom);
2713 fl_set_counter_value(dialog_->counter_dpi, lyxrc.dpi);
2714 fl_set_input(dialog_->input_tiny,
2715 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2716 fl_set_input(dialog_->input_script,
2717 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2718 fl_set_input(dialog_->input_footnote,
2719 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2720 fl_set_input(dialog_->input_small,
2721 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2722 fl_set_input(dialog_->input_normal,
2723 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2724 fl_set_input(dialog_->input_large,
2725 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2726 fl_set_input(dialog_->input_larger,
2727 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2728 fl_set_input(dialog_->input_largest,
2729 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2730 fl_set_input(dialog_->input_huge,
2731 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2732 fl_set_input(dialog_->input_huger,
2733 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2738 FormPreferences::SpellChecker::SpellChecker( FormPreferences & p )
2743 FD_form_spellchecker const * FormPreferences::SpellChecker::dialog()
2745 return dialog_.get();
2749 void FormPreferences::SpellChecker::apply()
2752 string choice = fl_get_choice_text(dialog_->choice_spell_command);
2753 choice = strip(frontStrip(choice));
2755 lyxrc.isp_command = choice;
2757 // If spell checker == "none", all other input set to off.
2758 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2759 lyxrc.isp_use_alt_lang = false;
2760 lyxrc.isp_alt_lang.erase();
2762 lyxrc.isp_use_esc_chars = false;
2763 lyxrc.isp_esc_chars.erase();
2765 lyxrc.isp_use_pers_dict = false;
2766 lyxrc.isp_pers_dict.erase();
2768 lyxrc.isp_accept_compound = false;
2769 lyxrc.isp_use_input_encoding = false;
2771 int button = fl_get_button(dialog_->check_alt_lang);
2772 choice = fl_get_input(dialog_->input_alt_lang);
2773 if (button && choice.empty()) button = 0;
2774 if (!button) choice.erase();
2776 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2777 lyxrc.isp_alt_lang = choice;
2779 button = fl_get_button(dialog_->check_escape_chars);
2780 choice = fl_get_input(dialog_->input_escape_chars);
2781 if (button && choice.empty()) button = 0;
2782 if (!button) choice.erase();
2784 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2785 lyxrc.isp_esc_chars = choice;
2787 button = fl_get_button(dialog_->check_personal_dict);
2788 choice = fl_get_input(dialog_->input_personal_dict);
2789 if (button && choice.empty()) button = 0;
2790 if (!button) choice.erase();
2792 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2793 lyxrc.isp_pers_dict = choice;
2795 button = fl_get_button(dialog_->check_compound_words);
2796 lyxrc.isp_accept_compound = static_cast<bool>(button);
2798 button = fl_get_button(dialog_->check_input_enc);
2799 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2807 void FormPreferences::SpellChecker::build()
2809 dialog_.reset(parent_.build_spellchecker());
2811 fl_addto_choice(dialog_->choice_spell_command,
2812 _(" none | ispell | aspell "));
2813 fl_set_input_return(dialog_->input_alt_lang, FL_RETURN_CHANGED);
2814 fl_set_input_return(dialog_->input_escape_chars, FL_RETURN_CHANGED);
2815 fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
2817 // set up the feedback mechanism
2818 setPreHandler(dialog_->choice_spell_command);
2819 setPreHandler(dialog_->check_alt_lang);
2820 setPreHandler(dialog_->input_alt_lang);
2821 setPreHandler(dialog_->check_escape_chars);
2822 setPreHandler(dialog_->input_escape_chars);
2823 setPreHandler(dialog_->check_personal_dict);
2824 setPreHandler(dialog_->input_personal_dict);
2825 setPreHandler(dialog_->button_personal_dict);
2826 setPreHandler(dialog_->check_compound_words);
2827 setPreHandler(dialog_->check_input_enc);
2832 FormPreferences::SpellChecker::feedback(FL_OBJECT const * const ob) const
2836 if (ob == dialog_->choice_spell_command)
2837 str = lyxrc.getDescription(LyXRC::RC_SPELL_COMMAND);
2838 else if (ob == dialog_->check_alt_lang)
2839 str = lyxrc.getDescription(LyXRC::RC_USE_ALT_LANG);
2840 else if (ob == dialog_->input_alt_lang)
2841 str = lyxrc.getDescription(LyXRC::RC_ALT_LANG);
2842 else if (ob == dialog_->check_escape_chars)
2843 str = lyxrc.getDescription(LyXRC::RC_USE_ESC_CHARS);
2844 else if (ob == dialog_->input_escape_chars)
2845 str = lyxrc.getDescription(LyXRC::RC_ESC_CHARS);
2846 else if (ob == dialog_->check_personal_dict)
2847 str = lyxrc.getDescription(LyXRC::RC_USE_PERS_DICT);
2848 else if (ob == dialog_->input_personal_dict)
2849 str = lyxrc.getDescription(LyXRC::RC_PERS_DICT);
2850 else if (ob == dialog_->check_compound_words)
2851 str = lyxrc.getDescription(LyXRC::RC_ACCEPT_COMPOUND);
2852 else if (ob == dialog_->check_input_enc)
2853 str = lyxrc.getDescription(LyXRC::RC_USE_INP_ENC);
2859 bool FormPreferences::SpellChecker::input(FL_OBJECT const * const ob)
2861 // !ob if function is called from updateSpellChecker() to de/activate
2863 // otherwise the function is called by an xforms CB via input().
2865 // If spell checker == "none", disable all input.
2866 if (!ob || ob == dialog_->choice_spell_command) {
2867 if (fl_get_choice(dialog_->choice_spell_command) == 1) {
2868 fl_deactivate_object(dialog_->check_alt_lang);
2869 fl_deactivate_object(dialog_->input_alt_lang);
2870 fl_deactivate_object(dialog_->check_escape_chars);
2871 fl_deactivate_object(dialog_->input_escape_chars);
2872 fl_deactivate_object(dialog_->check_personal_dict);
2873 fl_deactivate_object(dialog_->input_personal_dict);
2874 fl_deactivate_object(dialog_->check_compound_words);
2875 fl_deactivate_object(dialog_->check_input_enc);
2878 fl_activate_object(dialog_->check_alt_lang);
2879 fl_activate_object(dialog_->check_escape_chars);
2880 fl_activate_object(dialog_->check_personal_dict);
2881 fl_activate_object(dialog_->check_compound_words);
2882 fl_activate_object(dialog_->check_input_enc);
2886 if (!ob || ob == dialog_->check_alt_lang) {
2887 bool const enable = fl_get_button(dialog_->check_alt_lang);
2888 setEnabled(dialog_->input_alt_lang, enable);
2891 if (!ob || ob == dialog_->check_escape_chars) {
2892 bool const enable = fl_get_button(dialog_->check_escape_chars);
2893 setEnabled(dialog_->input_escape_chars, enable);
2896 if (!ob || ob == dialog_->check_personal_dict) {
2897 bool const enable = fl_get_button(dialog_->check_personal_dict);
2898 setEnabled(dialog_->input_personal_dict, enable);
2901 if (ob == dialog_->button_personal_dict) {
2902 parent_.browse(dialog_->input_personal_dict,
2903 N_("Personal dictionary"), "*.ispell",
2904 make_pair(string(), string()),
2905 make_pair(string(), string()));
2908 return true; // All input is valid!
2912 void FormPreferences::SpellChecker::update()
2915 if (lyxrc.isp_command == "none")
2917 else if (lyxrc.isp_command == "ispell")
2919 else if (lyxrc.isp_command == "aspell")
2921 fl_set_choice(dialog_->choice_spell_command, choice);
2924 if (lyxrc.isp_use_alt_lang) str = lyxrc.isp_alt_lang;
2926 fl_set_button(dialog_->check_alt_lang,
2927 lyxrc.isp_use_alt_lang);
2928 fl_set_input(dialog_->input_alt_lang, str.c_str());
2931 if (lyxrc.isp_use_esc_chars) str = lyxrc.isp_esc_chars;
2933 fl_set_button(dialog_->check_escape_chars,
2934 lyxrc.isp_use_esc_chars);
2935 fl_set_input(dialog_->input_escape_chars, str.c_str());
2938 if (lyxrc.isp_use_pers_dict) str = lyxrc.isp_pers_dict;
2940 fl_set_button(dialog_->check_personal_dict,
2941 lyxrc.isp_use_pers_dict);
2942 fl_set_input(dialog_->input_personal_dict, str.c_str());
2944 fl_set_button(dialog_->check_compound_words,
2945 lyxrc.isp_accept_compound);
2946 fl_set_button(dialog_->check_input_enc,
2947 lyxrc.isp_use_input_encoding);
2949 // Activate/Deactivate the input fields dependent on the state of the
2955 void FormPreferences::printWarning(string const & warning)
2957 warningPosted = true;
2959 string str = _("WARNING!") + string(" ") + warning;
2960 str = formatted(str, dialog_->text_warning->w-10, FL_SMALL_SIZE);
2962 fl_set_object_label(dialog_->text_warning, str.c_str());
2963 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2967 void FormPreferences::browse(FL_OBJECT * inpt,
2968 string const & title,
2969 string const & pattern,
2970 pair<string,string> const & dir1,
2971 pair<string,string> const & dir2)
2973 // Get the filename from the dialog
2974 string const filename = fl_get_input(inpt);
2976 // Show the file browser dialog
2977 string const new_filename =
2978 browseFile(lv_, filename, title, pattern, dir1, dir2);
2980 // Save the filename to the dialog
2981 if (new_filename != filename && !new_filename.empty()) {
2982 fl_set_input(inpt, new_filename.c_str());
2988 // C function wrapper, required by xforms.
2989 extern "C" int C_FormPreferencesFeedbackCB(FL_OBJECT * ob, int event,
2990 FL_Coord mx, FL_Coord my,
2991 int key, void * xev)
2993 return FormPreferences::FeedbackCB(ob, event, mx, my, key, xev);
2996 int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event,
2997 FL_Coord, FL_Coord, int, void *)
2999 // Note that the return value is important in the pre-emptive handler.
3000 // Don't return anything other than 0.
3003 // Don't Assert this one, as it can happen quite reasonably when things
3004 // are being deleted in the d-tor.
3006 if (!ob->form) return 0;
3008 FormPreferences * pre =
3009 static_cast<FormPreferences*>(ob->form->u_vdata);
3010 pre->Feedback(ob, event);
3015 // preemptive handler for feedback messages
3016 void FormPreferences::Feedback(FL_OBJECT * ob, int event)
3022 warningPosted = false;
3028 fl_set_object_label(dialog_->text_warning, "");
3037 void FormPreferences::setPreHandler(FL_OBJECT * ob)
3040 fl_set_object_prehandler(ob, C_FormPreferencesFeedbackCB);