2 * FormPreferences Interface Class Implementation
8 #include FORMS_H_LOCATION
11 #pragma implementation
15 #include "FormPreferences.h"
16 #include "form_preferences.h"
17 #include "input_validators.h"
25 #include "support/FileInfo.h"
26 #include "support/filetools.h"
27 #include "lyx_gui_misc.h"
29 #include "input_validators.h"
30 #include "xform_helpers.h" // formatted()
31 #include "xform_macros.h"
32 #include "converter.h"
33 #include "support/lyxfunctional.h"
36 #ifdef SIGC_CXX_NAMESPACES
46 extern string fmt(char const * fmtstr ...);
47 extern string system_lyxdir;
48 extern Languages languages;
50 static string const colourFile("/usr/lib/X11/rgb.txt");
51 vector<FormPreferences::X11Colour> FormPreferences::colourDB;
52 pair<vector<string>, vector<string> > FormPreferences::dirlist;
54 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
55 : FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
57 converters_tab_(0), inputs_tab_(0), look_n_feel_tab_(0),
58 outputs_tab_(0), usage_tab_(0),
59 colours_(0), converters_(0), formats_(0), inputs_misc_(0),
60 interface_(0), language_(0), lnf_misc_(0), outputs_misc_(0),
61 paths_(0), printer_(0), screen_fonts_(0), spellchecker_(0),
62 combo_default_lang(0), combo_kbmap_1(0), combo_kbmap_2(0),
65 // let the dialog be shown
66 // This is a permanent connection so we won't bother
67 // storing a copy because we won't be disconnecting.
68 d->showPreferences.connect(slot(this, &FormPreferences::show));
72 FormPreferences::~FormPreferences()
74 delete combo_default_lang;
78 delete converters_tab_;
80 delete look_n_feel_tab_;
97 // Must delete dialog last or we'll end up with a SIGSEGV trying to
98 // access dialog_->timer_feedback in feedbackPost().
103 FL_FORM * FormPreferences::form() const
105 if (dialog_) return dialog_->form;
110 void FormPreferences::ok()
113 lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
117 void FormPreferences::hide()
119 // We need to hide the active tabfolder otherwise we get a
120 // BadDrawable error from X windows and LyX crashes without saving.
121 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
123 && outer_form->visible) {
124 fl_hide_form(outer_form);
130 void FormPreferences::build()
132 dialog_ = build_preferences();
134 // manage the restore, save, apply and cancel/close buttons
135 bc_.setOK(dialog_->button_ok);
136 bc_.setApply(dialog_->button_apply);
137 bc_.setCancel(dialog_->button_cancel);
138 bc_.setUndoAll(dialog_->button_restore);
141 // Workaround dumb xforms sizing bug
145 // build the tab folders
146 converters_tab_ = build_outer_tab();
147 look_n_feel_tab_ = build_outer_tab();
148 inputs_tab_ = build_outer_tab();
149 outputs_tab_ = build_outer_tab();
150 usage_tab_ = build_outer_tab();
152 // build actual tabfolder contents
153 // these will become nested tabfolders
167 // Now add them to the tabfolder
168 fl_addto_tabfolder(dialog_->tabfolder_prefs,
170 look_n_feel_tab_->form);
171 fl_addto_tabfolder(dialog_->tabfolder_prefs,
174 fl_addto_tabfolder(dialog_->tabfolder_prefs,
176 converters_tab_->form);
177 fl_addto_tabfolder(dialog_->tabfolder_prefs,
180 fl_addto_tabfolder(dialog_->tabfolder_prefs,
184 // now build the nested tabfolders
185 // Starting with look and feel
186 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
188 screen_fonts_->form);
189 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
192 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
195 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
199 // then build converters
200 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
203 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
208 // Paths should probably go in a few outer_tab called Files
209 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
212 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
216 // then building outputs
217 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
220 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
222 outputs_misc_->form);
224 // then building usage
225 fl_addto_tabfolder(usage_tab_->tabfolder_outer,
227 spellchecker_->form);
228 fl_addto_tabfolder(usage_tab_->tabfolder_outer,
234 void FormPreferences::apply()
236 // set the new lyxrc entries
237 // many of these need to trigger other functions when the assignment
238 // is made. For example, screen zoom and font types. These could be
239 // handled either by signals/slots in lyxrc or just directly call the
240 // associated functions here.
241 // There are other problems with this scheme. We really should check
242 // what we copy to make sure that it really is necessary to do things
243 // like update the screen fonts because that flushes the textcache
244 // and other stuff which may cost us a lot on slower/high-load machines.
261 void FormPreferences::feedback( FL_OBJECT * ob )
267 if (ob->form->fdui == colours_) {
268 str = feedbackColours( ob );
269 } else if (ob->form->fdui == converters_) {
270 str = feedbackConverters( ob );
271 } else if (ob->form->fdui == formats_) {
272 str = feedbackFormats( ob );
273 } else if (ob->form->fdui == inputs_misc_) {
274 str = feedbackInputsMisc( ob );
275 } else if (ob->form->fdui == interface_) {
276 str = feedbackInterface( ob );
277 } else if (ob->form->fdui == language_) {
278 str = feedbackLanguage( ob );
279 } else if (ob->form->fdui == lnf_misc_) {
280 str = feedbackLnFmisc( ob );
281 } else if (ob->form->fdui == outputs_misc_) {
282 str = feedbackOutputsMisc( ob );
283 } else if (ob->form->fdui == paths_) {
284 str = feedbackPaths( ob );
285 } else if (ob->form->fdui == printer_) {
286 str = feedbackPrinter( ob );
287 } else if (ob->form->fdui == screen_fonts_) {
288 str = feedbackScreenFonts( ob );
289 } else if (ob->form->fdui == spellchecker_) {
290 str = feedbackSpellChecker( ob );
293 str = formatted( str, dialog_->text_warning->w-10,
294 FL_SMALL_SIZE, FL_NORMAL_STYLE );
296 fl_set_object_label(dialog_->text_warning, str.c_str());
297 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
301 bool FormPreferences::input(FL_OBJECT * ob, long)
305 // whatever checks you need to ensure the user hasn't entered
306 // some totally ridiculous value somewhere. Change activate to suit.
307 // comments before each test describe what is _valid_
309 if (ob->form->fdui == colours_)
310 return inputColours(ob);
311 else if (ob->form->fdui == language_)
312 return inputLanguage(ob);
313 else if (ob->form->fdui == paths_)
314 return inputPaths(ob);
315 else if (ob->form->fdui == screen_fonts_)
316 return inputScreenFonts();
317 else if (ob->form->fdui == spellchecker_)
318 return inputSpellChecker(ob);
319 else if (ob->form->fdui == formats_)
320 return inputFormats(ob);
326 void FormPreferences::update()
328 if (!dialog_) return;
330 // read lyxrc entries
342 updateSpellChecker();
346 void FormPreferences::applyColours() const
351 void FormPreferences::buildColours()
353 colours_ = build_colours();
355 FL_OBJECT * obj = colours_->valslider_red;
356 fl_set_slider_bounds(obj, 0, 255);
357 fl_set_slider_precision(obj, 0);
358 fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
360 obj = colours_->valslider_green;
361 fl_set_slider_bounds(obj, 0, 255);
362 fl_set_slider_precision(obj, 0);
363 fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
365 obj = colours_->valslider_blue;
366 fl_set_slider_bounds(obj, 0, 255);
367 fl_set_slider_precision(obj, 0);
368 fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
370 fl_set_object_color(colours_->button_colour,
371 FL_FREE_COL4, FL_FREE_COL4);
373 fl_set_input_return(colours_->input_name, FL_RETURN_END_CHANGED);
375 if (ColoursLoadBrowser(colourFile) )
376 fl_set_input(colours_->input_name, colourFile.c_str());
378 fl_set_input(colours_->input_name, N_("No file found"));
380 // deactivate the browse button because it isn't implemented
381 fl_deactivate_object(colours_->button_browse);
382 fl_set_object_lcol(colours_->button_browse, FL_INACTIVE);
387 FormPreferences::feedbackColours(FL_OBJECT const * const ob) const
394 bool FormPreferences::inputColours( FL_OBJECT const * const ob )
397 bool activate = true;
399 if (ob == colours_->browser_x11) {
400 int i = fl_get_browser(colours_->browser_x11);
402 ColoursUpdateBrowser(i-1);
405 } else if (ob == colours_->valslider_red
406 || ob == colours_->valslider_green
407 || ob == colours_->valslider_blue) {
410 } else if (ob == colours_->input_name) {
411 string file = fl_get_input(colours_->input_name);
412 if (ColoursLoadBrowser(file) )
413 fl_set_input(colours_->input_name, file.c_str());
414 else if (ColoursLoadBrowser(colourFile) )
415 fl_set_input(colours_->input_name, colourFile.c_str());
417 fl_set_input(colours_->input_name, N_("No file found"));
424 bool FormPreferences::ColoursLoadBrowser(string const & filename)
427 lex.setCommentChar('!');
429 if (!lex.setFile(filename))
433 vector<string> names;
437 col.r = lex.GetInteger();
439 col.g = lex.GetInteger();
441 col.b = lex.GetInteger();
443 string name = frontStrip(lex.GetString(), " \t");
445 // remove redundant entries on the fly
446 bool add = cols.empty();
448 vector<RGB>::const_iterator it =
449 find( cols.begin(), cols.end(), col );
450 add = (it == cols.end());
454 name = lowercase( name );
455 if (name == "gray0" ) name = "black";
456 if (name == "gray100" ) name = "white";
458 if (name == "black" || name == "white") {
459 cols.insert(cols.begin(), col);
460 names.insert(names.begin(), name);
463 names.push_back(name);
468 vector<string>::iterator sit = names.begin();
469 for (vector<RGB>::const_iterator iit = cols.begin();
470 iit != cols.end(); ++iit, ++sit) {
471 colourDB.push_back( X11Colour(*sit, *iit) );
474 FL_OBJECT * colbr = colours_->browser_x11;
475 fl_freeze_form(colours_->form);
476 fl_clear_browser( colbr );
478 for (vector<X11Colour>::const_iterator cit = colourDB.begin();
479 cit != colourDB.end(); ++cit) {
480 string name = (*cit).first;
481 //RGB col = (*cit).second;
482 //name += " (" + tostr(col.r) + ", " + tostr(col.g) +
483 // ", " + tostr(col.b) + ")";
484 fl_addto_browser(colbr, name.c_str());
487 fl_set_browser_topline(colbr, 1);
488 fl_select_browser_line(colbr, 1);
489 ColoursUpdateBrowser(0);
490 fl_unfreeze_form(colours_->form);
496 int FormPreferences::ColoursSearchEntry(RGB const & col) const
498 int mindiff = 0x7fffffff;
499 vector<X11Colour>::const_iterator mincit = colourDB.begin();
501 for (vector<X11Colour>::const_iterator cit = colourDB.begin();
502 cit != colourDB.end(); ++cit) {
503 RGB colDB = (*cit).second;
505 diff.r = col.r - colDB.r;
506 diff.g = col.g - colDB.g;
507 diff.b = col.b - colDB.b;
509 int d = (2 * (diff.r * diff.r) +
510 3 * (diff.g * diff.g) +
518 return static_cast<int>(mincit - colourDB.begin());
522 void FormPreferences::ColoursUpdateBrowser(int i)
524 fl_freeze_form(colours_->form);
526 RGB col = colourDB[i].second;
528 fl_mapcolor(FL_FREE_COL4 + i, col.r, col.g, col.b);
529 fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
530 fl_set_slider_value(colours_->valslider_red, col.r);
531 fl_set_slider_value(colours_->valslider_green, col.g);
532 fl_set_slider_value(colours_->valslider_blue, col.b);
533 fl_redraw_object(colours_->button_colour);
535 fl_unfreeze_form(colours_->form);
539 void FormPreferences::ColoursUpdateRGB()
541 fl_freeze_form(colours_->form);
544 col.r = int(fl_get_slider_value(colours_->valslider_red));
545 col.g = int(fl_get_slider_value(colours_->valslider_green));
546 col.b = int(fl_get_slider_value(colours_->valslider_blue));
548 fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
549 fl_redraw_object(colours_->button_colour);
551 int const i = ColoursSearchEntry( col );
552 // change topline only if necessary
553 // int top = fl_get_browser_topline(colours_->browser_x11);
554 // if (i < top || i > (top+15))
555 fl_set_browser_topline(colours_->browser_x11, i - 5);
556 fl_select_browser_line(colours_->browser_x11, i + 1);
558 fl_unfreeze_form(colours_->form);
562 void FormPreferences::updateColours()
566 void FormPreferences::applyConverters() const
570 void FormPreferences::buildConverters()
572 converters_ = build_converters();
574 fl_set_input_return(converters_->input_converter, FL_RETURN_CHANGED);
575 fl_set_input_return(converters_->input_flags, FL_RETURN_CHANGED);
582 FormPreferences::feedbackConverters( FL_OBJECT const * const ob) const
589 void FormPreferences::updateConverters()
591 vector<Command> commands = Converter::GetAllCommands();
593 vector<string> names;
594 for(vector<Command>::const_iterator cit = commands.begin();
595 cit != commands.end(); ++cit) {
596 string from = cit->from->prettyname;
597 string to = cit->to->prettyname;
598 string name = from + " -> " + to;
599 names.push_back(name);
601 sort(names.begin(), names.end());
603 fl_clear_browser(converters_->browser_converters);
604 for (vector<string>::const_iterator cit = names.begin();
605 cit != names.end(); ++cit)
606 fl_addto_browser(converters_->browser_converters,
608 fl_deactivate_object(converters_->button_add);
609 fl_set_object_lcol(converters_->button_add, FL_INACTIVE);
611 fl_deactivate_object(converters_->button_delete);
612 fl_set_object_lcol(converters_->button_delete, FL_INACTIVE);
616 void FormPreferences::applyFormats() const
618 vector<Format> old = formats.GetAllFormats();
619 for (vector<Format>::const_iterator it = old.begin();
620 it != old.end(); ++it)
621 if (find_if(formats_vec.begin(),formats_vec.end(),
622 compare_memfun(&Format::getname, it->name))
623 == formats_vec.end()) {
624 formats.Add(it->name, string(), string(), string());
627 for (vector<Format>::const_iterator it = formats_vec.begin();
628 it != formats_vec.end(); ++it) {
629 formats.Add(it->name, it->extension, it->prettyname,
631 formats.SetViewer(it->name, it->viewer);
636 void FormPreferences::buildFormats()
638 formats_ = build_formats();
640 fl_set_input_return(formats_->input_format, FL_RETURN_CHANGED);
641 fl_set_input_return(formats_->input_viewer, FL_RETURN_CHANGED);
642 fl_set_input_return(formats_->input_shrtcut, FL_RETURN_CHANGED);
643 fl_set_input_return(formats_->input_gui_name, FL_RETURN_CHANGED);
644 fl_set_input_return(formats_->input_extension, FL_RETURN_CHANGED);
646 fl_set_input_filter(formats_->input_format, fl_lowercase_filter);
653 FormPreferences::feedbackFormats(FL_OBJECT const * const ob) const
665 bool FormPreferences::inputFormats(FL_OBJECT const * const ob)
669 //if( !ob ) return false;
671 if (ob == formats_->browser_formats) {
672 FormatsInputBrowser();
674 } else if (ob == formats_->input_format) {
677 } else if (ob == formats_->button_add) {
680 } else if (ob == formats_->button_delete) {
681 FormatsInputDelete();
687 void FormPreferences::updateFormats()
689 formats_vec = formats.GetAllFormats();
691 vector<string> names;
692 for (vector<Format>::const_iterator it = formats_vec.begin();
693 it != formats_vec.end(); ++it)
694 names.push_back( it->name.c_str() );
695 sort(names.begin(), names.end());
697 fl_clear_browser(formats_->browser_formats);
698 for (vector<string>::const_iterator it = names.begin();
699 it != names.end(); ++it)
700 fl_addto_browser(formats_->browser_formats, it->c_str());
702 fl_deactivate_object(formats_->button_add);
703 fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
705 fl_deactivate_object(formats_->button_delete);
706 fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
710 bool FormPreferences::FormatsInputAdd()
712 string name = fl_get_input(formats_->input_format);
713 string prettyname = fl_get_input(formats_->input_gui_name);
714 string extension = fl_get_input(formats_->input_extension);
715 string viewer = fl_get_input(formats_->input_viewer);
716 string shortcut = fl_get_input(formats_->input_shrtcut);
717 if (prettyname.empty())
720 Format format(name, extension, prettyname, shortcut, viewer);
721 vector<Format>::iterator it =
722 find_if(formats_vec.begin(), formats_vec.end(),
723 compare_memfun(&Format::getname, name));
725 if (it == formats_vec.end()) {
726 fl_freeze_form(formats_->form);
728 formats_vec.push_back(format);
730 vector<string> names;
731 for (vector<Format>::const_iterator it = formats_vec.begin();
732 it != formats_vec.end(); ++it)
733 names.push_back( it->name.c_str() );
735 sort( names.begin(), names.end() );
737 fl_clear_browser( formats_->browser_formats );
738 for (vector<string>::const_iterator it = names.begin();
739 it != names.end(); ++it)
740 fl_addto_browser(formats_->browser_formats,
743 fl_set_input(formats_->input_format, "");
744 fl_set_input(formats_->input_gui_name, "");
745 fl_set_input(formats_->input_shrtcut, "");
746 fl_set_input(formats_->input_extension, "");
747 fl_set_input(formats_->input_viewer, "");
749 fl_set_object_label( formats_->button_add,
751 fl_set_button_shortcut( formats_->button_add,
752 scex(_("Add|#A")), 1);
754 fl_deactivate_object(formats_->button_add);
755 fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
757 fl_deactivate_object(formats_->button_delete);
758 fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
760 fl_unfreeze_form(formats_->form);
771 bool FormPreferences::FormatsInputDelete()
773 string name = fl_get_input(formats_->input_format);
774 vector<Format>::iterator it =
775 find_if(formats_vec.begin(), formats_vec.end(),
776 compare_memfun(&Format::getname, name));
778 fl_freeze_form(formats_->form);
780 if (it == formats_vec.end()) {
781 fl_deactivate_object(formats_->button_delete);
782 fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
787 i < fl_get_browser_maxline(formats_->browser_formats);
789 string str = fl_get_browser_line( formats_->browser_formats, i+1 );
797 fl_delete_browser_line(formats_->browser_formats, sel );
799 fl_set_input(formats_->input_format, "");
800 fl_set_input(formats_->input_gui_name, "");
801 fl_set_input(formats_->input_shrtcut, "");
802 fl_set_input(formats_->input_extension, "");
803 fl_set_input(formats_->input_viewer, "");
805 fl_set_object_label( formats_->button_add,
807 fl_set_button_shortcut( formats_->button_add,
808 scex(_("Add|#A")), 1);
810 fl_deactivate_object(formats_->button_add);
811 fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
813 fl_deactivate_object(formats_->button_delete);
814 fl_set_object_lcol(formats_->button_delete,
819 fl_unfreeze_form(formats_->form);
825 bool FormPreferences::FormatsInputBrowser()
827 int const i = fl_get_browser(formats_->browser_formats);
828 if( i <= 0 ) return true;
830 string name = fl_get_browser_line(formats_->browser_formats, i);
831 vector<Format>::iterator it =
832 find_if(formats_vec.begin(), formats_vec.end(),
833 compare_memfun(&Format::getname, name));
835 if (it != formats_vec.end()) {
836 fl_freeze_form(formats_->form);
838 fl_set_input(formats_->input_format, it->name.c_str());
839 fl_set_input(formats_->input_gui_name, it->prettyname.c_str());
840 fl_set_input(formats_->input_shrtcut, it->shortcut.c_str());
841 fl_set_input(formats_->input_extension, it->extension.c_str());
842 fl_set_input(formats_->input_viewer, it->viewer.c_str());
844 fl_set_object_label( formats_->button_add,
845 idex(_("Modify|#M")) );
846 fl_set_button_shortcut( formats_->button_add,
847 scex(_("Modify|#M")), 1);
849 fl_activate_object(formats_->button_add);
850 fl_set_object_lcol(formats_->button_add, FL_BLACK);
852 fl_activate_object(formats_->button_delete);
853 fl_set_object_lcol(formats_->button_delete, FL_BLACK);
855 fl_unfreeze_form(formats_->form);
861 bool FormPreferences::FormatsInputInput()
863 string const name = fl_get_input(formats_->input_format);
864 vector<Format>::iterator it =
865 find_if(formats_vec.begin(), formats_vec.end(),
866 compare_memfun(&Format::getname, name));
868 fl_freeze_form(formats_->form);
870 if (it == formats_vec.end()) {
871 fl_set_object_label( formats_->button_add,
873 fl_set_button_shortcut( formats_->button_add,
874 scex(_("Add|#A")), 1);
877 fl_deactivate_object(formats_->button_add);
878 fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
880 fl_activate_object(formats_->button_add);
881 fl_set_object_lcol(formats_->button_add, FL_BLACK);
884 fl_deselect_browser(formats_->browser_formats);
886 fl_deactivate_object(formats_->button_delete);
887 fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
890 fl_set_object_label( formats_->button_add,
891 idex(_("Modify|#M")) );
892 fl_set_button_shortcut( formats_->button_add,
893 scex(_("Modify|#M")), 1);
897 i < fl_get_browser_maxline(formats_->browser_formats);
899 string str = fl_get_browser_line( formats_->browser_formats, i+1 );
907 if( top < 1 ) top = 0;
908 fl_set_browser_topline(formats_->browser_formats, top);
909 fl_select_browser_line(formats_->browser_formats, sel);
911 fl_activate_object(formats_->button_add);
912 fl_set_object_lcol(formats_->button_add, FL_BLACK);
914 fl_activate_object(formats_->button_delete);
915 fl_set_object_lcol(formats_->button_delete, FL_BLACK);
918 fl_unfreeze_form(formats_->form);
923 void FormPreferences::applyInputsMisc() const
925 lyxrc.date_insert_format =
926 fl_get_input(inputs_misc_->input_date_format);
930 void FormPreferences::buildInputsMisc()
932 inputs_misc_ = build_inputs_misc();
934 fl_set_input_return(inputs_misc_->input_date_format,
937 // set up the feedback mechanism
938 fl_addto_form(inputs_misc_->form);
940 setPostHandler( inputs_misc_->input_date_format );
947 FormPreferences::feedbackInputsMisc(FL_OBJECT const * const ob) const
951 //if( !ob ) return string();
955 if (ob == inputs_misc_->input_date_format )
956 str = lyxrc.getDescription( LyXRC::RC_DATE_INSERT_FORMAT );
962 void FormPreferences::updateInputsMisc()
964 fl_set_input(inputs_misc_->input_date_format,
965 lyxrc.date_insert_format.c_str());
969 void FormPreferences::applyInterface() const
971 lyxrc.popup_font_name =
972 fl_get_input(interface_->input_popup_font);
973 lyxrc.menu_font_name = fl_get_input(interface_->input_menu_font);
974 lyxrc.font_norm_menu =
975 fl_get_input(interface_->input_popup_encoding);
976 lyxrc.bind_file = fl_get_input(interface_->input_bind_file);
977 lyxrc.ui_file = fl_get_input(interface_->input_ui_file);
978 lyxrc.override_x_deadkeys =
979 fl_get_button(interface_->check_override_x_dead_keys);
983 void FormPreferences::buildInterface()
985 interface_ = build_interface();
987 fl_set_input_return(interface_->input_popup_font, FL_RETURN_CHANGED);
988 fl_set_input_return(interface_->input_menu_font, FL_RETURN_CHANGED);
989 fl_set_input_return(interface_->input_popup_encoding,
991 fl_set_input_return(interface_->input_bind_file, FL_RETURN_CHANGED);
992 fl_set_input_return(interface_->input_ui_file, FL_RETURN_CHANGED);
994 // deactivate the browse buttons because they aren't implemented
995 fl_deactivate_object(interface_->button_bind_file_browse);
996 fl_deactivate_object(interface_->button_ui_file_browse);
997 fl_set_object_lcol(interface_->button_bind_file_browse, FL_INACTIVE);
998 fl_set_object_lcol(interface_->button_ui_file_browse, FL_INACTIVE);
1000 // set up the feedback mechanism
1001 fl_addto_form(interface_->form);
1003 setPostHandler( interface_->input_popup_font );
1004 setPostHandler( interface_->input_menu_font );
1005 setPostHandler( interface_->input_popup_encoding );
1006 setPostHandler( interface_->input_bind_file );
1007 setPostHandler( interface_->button_bind_file_browse );
1008 setPostHandler( interface_->input_ui_file );
1009 setPostHandler( interface_->button_ui_file_browse );
1010 setPostHandler( interface_->check_override_x_dead_keys );
1017 FormPreferences::feedbackInterface( FL_OBJECT const * const ob ) const
1021 //if( !ob ) return string();
1025 if (ob == interface_->input_popup_font )
1026 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_POPUP );
1027 else if (ob == interface_->input_menu_font )
1028 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_MENU );
1029 else if (ob == interface_->input_popup_encoding )
1030 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING_MENU );
1031 else if (ob == interface_->input_bind_file )
1032 str = lyxrc.getDescription( LyXRC::RC_BINDFILE );
1033 else if (ob == interface_->input_ui_file )
1034 str = lyxrc.getDescription( LyXRC::RC_UIFILE );
1035 else if (ob == interface_->check_override_x_dead_keys )
1036 str = lyxrc.getDescription( LyXRC::RC_OVERRIDE_X_DEADKEYS );
1042 void FormPreferences::updateInterface()
1044 fl_set_input(interface_->input_popup_font,
1045 lyxrc.popup_font_name.c_str());
1046 fl_set_input(interface_->input_menu_font,
1047 lyxrc.menu_font_name.c_str());
1048 fl_set_input(interface_->input_popup_encoding,
1049 lyxrc.font_norm_menu.c_str());
1050 fl_set_input(interface_->input_bind_file,
1051 lyxrc.bind_file.c_str());
1052 fl_set_input(interface_->input_ui_file,
1053 lyxrc.ui_file.c_str());
1054 fl_set_button(interface_->check_override_x_dead_keys,
1055 lyxrc.override_x_deadkeys);
1059 void FormPreferences::applyLanguage()
1061 lyxrc.default_language = combo_default_lang->getline();
1063 int button = fl_get_button(language_->check_use_kbmap);
1064 string name_1 = combo_kbmap_1->getline();
1065 string name_2 = combo_kbmap_2->getline();
1067 button = ( !name_1.empty() && !name_2.empty() );
1068 lyxrc.use_kbmap = static_cast<bool>(button);
1071 vector<string>::iterator it =
1072 find( dirlist.second.begin(), dirlist.second.end(),
1074 vector<string>::size_type sel = it - dirlist.second.begin();
1075 lyxrc.primary_kbmap = dirlist.first[sel];
1077 it = find( dirlist.second.begin(), dirlist.second.end(),
1079 sel = it - dirlist.second.begin();
1080 lyxrc.secondary_kbmap = dirlist.first[sel];
1083 button = fl_get_button(language_->check_rtl_support);
1084 lyxrc.rtl_support = static_cast<bool>(button);
1086 button = fl_get_button(language_->check_auto_begin);
1087 lyxrc.language_auto_begin = static_cast<bool>(button);
1089 button = fl_get_button(language_->check_auto_end);
1090 lyxrc.language_auto_end = static_cast<bool>(button);
1092 button = fl_get_button(language_->check_mark_foreign);
1093 lyxrc.mark_foreign_language = static_cast<bool>(button);
1095 lyxrc.language_package = fl_get_input(language_->input_package);
1096 lyxrc.language_command_begin = fl_get_input(language_->input_command_begin);
1097 lyxrc.language_command_end = fl_get_input(language_->input_command_end);
1099 // Ensure that all is self-consistent.
1104 void FormPreferences::buildLanguage()
1106 language_ = build_language();
1108 fl_set_input_return(language_->input_package, FL_RETURN_CHANGED);
1109 fl_set_input_return(language_->input_command_begin, FL_RETURN_CHANGED);
1110 fl_set_input_return(language_->input_command_end, FL_RETURN_CHANGED);
1112 // The default_language is a combo-box and has to be inserted manually
1113 fl_freeze_form(language_->form);
1114 fl_addto_form(language_->form);
1116 FL_OBJECT * obj = language_->choice_default_lang;
1117 fl_deactivate_object(language_->choice_default_lang);
1118 combo_default_lang = new Combox(FL_COMBOX_DROPLIST);
1119 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
1120 combo_default_lang->shortcut("#L",1);
1121 combo_default_lang->setcallback(ComboLanguageCB, this);
1123 for (Languages::const_iterator cit = languages.begin();
1124 cit != languages.end(); cit++) {
1125 combo_default_lang->addto((*cit).second.lang());
1129 string dir = AddPath(system_lyxdir, "kbd");
1130 vector<string> dirlist = DirList(dir , "kmap");
1132 obj = language_->choice_kbmap_1;
1133 fl_deactivate_object(language_->choice_kbmap_1);
1134 combo_kbmap_1 = new Combox(FL_COMBOX_DROPLIST);
1135 combo_kbmap_1->add(obj->x, obj->y, obj->w, obj->h, 400);
1136 combo_kbmap_1->shortcut("#1",1);
1137 combo_kbmap_1->setcallback(ComboLanguageCB, this);
1139 for (vector<string>::const_iterator cit = dirlist.begin();
1140 cit != dirlist.end(); cit++) {
1141 combo_kbmap_1->addto(*cit);
1145 obj = language_->choice_kbmap_2;
1146 fl_deactivate_object(language_->choice_kbmap_2);
1147 combo_kbmap_2 = new Combox(FL_COMBOX_DROPLIST);
1148 combo_kbmap_2->add(obj->x, obj->y, obj->w, obj->h, 400);
1149 combo_kbmap_2->shortcut("#2",1);
1150 combo_kbmap_2->setcallback(ComboLanguageCB, this);
1152 for (vector<string>::const_iterator cit = dirlist.begin();
1153 cit != dirlist.end(); cit++) {
1154 combo_kbmap_2->addto(*cit);
1158 fl_unfreeze_form(language_->form);
1160 // set up the feedback mechanism
1161 fl_addto_form(language_->form);
1163 setPostHandler( language_->input_package );
1164 setPostHandler( language_->check_use_kbmap );
1166 // This is safe, as nothing is done to the pointer, other than
1167 // to use its address in a block-if statement.
1168 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_default_lang) );
1169 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_1) );
1170 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_2) );
1172 setPostHandler( language_->check_rtl_support );
1173 setPostHandler( language_->check_mark_foreign );
1174 setPostHandler( language_->check_auto_begin );
1175 setPostHandler( language_->check_auto_end );
1176 setPostHandler( language_->input_command_begin );
1177 setPostHandler( language_->input_command_end );
1181 // Activate/Deactivate the input fields dependent on the state of the
1188 FormPreferences::feedbackLanguage(FL_OBJECT const * const ob) const
1192 //if( !ob ) return string();
1196 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang )
1197 str = lyxrc.getDescription( LyXRC::RC_DEFAULT_LANGUAGE );
1198 else if (ob == language_->check_use_kbmap )
1199 str = lyxrc.getDescription( LyXRC::RC_KBMAP );
1200 else if (reinterpret_cast<Combox const *>(ob) == combo_kbmap_1)
1201 str = lyxrc.getDescription( LyXRC::RC_KBMAP_PRIMARY );
1202 else if (reinterpret_cast<Combox const *>(ob) == combo_kbmap_2 )
1203 str = lyxrc.getDescription( LyXRC::RC_KBMAP_SECONDARY );
1204 else if (ob == language_->check_rtl_support )
1205 str = lyxrc.getDescription( LyXRC::RC_RTL_SUPPORT );
1206 else if (ob == language_->check_auto_begin )
1207 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_BEGIN );
1208 else if (ob == language_->check_auto_end )
1209 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_END );
1210 else if (ob == language_->check_mark_foreign )
1211 str = lyxrc.getDescription( LyXRC::RC_MARK_FOREIGN_LANGUAGE );
1212 else if (ob == language_->input_package )
1213 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_PACKAGE );
1214 else if (ob == language_->input_command_begin )
1215 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_BEGIN );
1216 else if (ob == language_->input_command_end )
1217 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_END );
1223 bool FormPreferences::inputLanguage( FL_OBJECT const * const ob )
1225 bool activate = true;
1227 if (!ob || ob == language_->check_use_kbmap) {
1228 if (fl_get_button(language_->check_use_kbmap)) {
1229 combo_kbmap_1->activate();
1230 combo_kbmap_2->activate();
1232 combo_kbmap_1->deactivate();
1233 combo_kbmap_2->deactivate();
1241 void FormPreferences::updateLanguage()
1243 fl_set_button(language_->check_use_kbmap,
1246 combo_default_lang->select_text( lyxrc.default_language );
1248 if (lyxrc.use_kbmap) {
1249 string fullpath = lyxrc.primary_kbmap;
1250 vector<string>::iterator it =
1251 find( dirlist.first.begin(), dirlist.first.end(),
1253 vector<string>::size_type sel = it - dirlist.first.begin();
1254 combo_kbmap_1->select_text( dirlist.second[sel] );
1256 fullpath = lyxrc.secondary_kbmap;
1257 it = find( dirlist.first.begin(), dirlist.first.end(),
1259 sel = it - dirlist.first.begin();
1260 combo_kbmap_2->select_text( dirlist.second[sel] );
1262 combo_kbmap_1->select_text( "" );
1263 combo_kbmap_2->select_text( "" );
1266 fl_set_button(language_->check_rtl_support, lyxrc.rtl_support);
1267 fl_set_button(language_->check_auto_begin, lyxrc.language_auto_begin);
1268 fl_set_button(language_->check_auto_end, lyxrc.language_auto_end);
1269 fl_set_button(language_->check_mark_foreign,
1270 lyxrc.mark_foreign_language);
1272 fl_set_input(language_->input_package,
1273 lyxrc.language_package.c_str());
1274 fl_set_input(language_->input_command_begin,
1275 lyxrc.language_command_begin.c_str());
1276 fl_set_input(language_->input_command_end,
1277 lyxrc.language_command_end.c_str());
1279 // Activate/Deactivate the input fields dependent on the state of the
1285 void FormPreferences::applyLnFmisc() const
1287 lyxrc.show_banner = fl_get_button(lnf_misc_->check_banner);
1288 lyxrc.auto_region_delete = fl_get_button(lnf_misc_->
1289 check_auto_region_delete);
1290 lyxrc.exit_confirmation = fl_get_button(lnf_misc_->check_exit_confirm);
1291 lyxrc.display_shortcuts =
1292 fl_get_button(lnf_misc_->check_display_shrtcuts);
1293 lyxrc.new_ask_filename = fl_get_button(lnf_misc_->check_ask_new_file);
1294 lyxrc.cursor_follows_scrollbar =
1295 fl_get_button(lnf_misc_->check_cursor_follows_scrollbar);
1296 lyxrc.autosave = static_cast<unsigned int>
1297 (fl_get_counter_value(lnf_misc_->counter_autosave));
1298 lyxrc.wheel_jump = static_cast<unsigned int>
1299 (fl_get_counter_value(lnf_misc_->counter_wm_jump));
1303 void FormPreferences::buildLnFmisc()
1305 lnf_misc_ = build_lnf_misc();
1307 fl_set_counter_return(lnf_misc_->counter_autosave,
1309 fl_set_counter_return(lnf_misc_->counter_wm_jump,
1312 // set up the feedback mechanism
1313 fl_addto_form(lnf_misc_->form);
1315 setPostHandler( lnf_misc_->check_banner );
1316 setPostHandler( lnf_misc_->check_auto_region_delete );
1317 setPostHandler( lnf_misc_->check_exit_confirm );
1318 setPostHandler( lnf_misc_->check_display_shrtcuts );
1319 setPostHandler( lnf_misc_->counter_autosave );
1320 setPostHandler( lnf_misc_->check_ask_new_file );
1321 setPostHandler( lnf_misc_->check_cursor_follows_scrollbar );
1322 setPostHandler( lnf_misc_->counter_wm_jump );
1328 string const FormPreferences::feedbackLnFmisc(FL_OBJECT const * const ob) const
1332 //if( !ob ) return string();
1336 if (ob == lnf_misc_->check_banner )
1337 str = lyxrc.getDescription( LyXRC::RC_SHOW_BANNER );
1338 else if (ob == lnf_misc_->check_auto_region_delete )
1339 str = lyxrc.getDescription( LyXRC::RC_AUTOREGIONDELETE );
1340 else if (ob == lnf_misc_->check_exit_confirm )
1341 str = lyxrc.getDescription( LyXRC::RC_EXIT_CONFIRMATION );
1342 else if (ob == lnf_misc_->check_display_shrtcuts )
1343 str = lyxrc.getDescription( LyXRC::RC_DISPLAY_SHORTCUTS );
1344 else if (ob == lnf_misc_->check_ask_new_file )
1345 str = lyxrc.getDescription( LyXRC::RC_NEW_ASK_FILENAME );
1346 else if (ob == lnf_misc_->check_cursor_follows_scrollbar )
1347 str = lyxrc.getDescription( LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR );
1348 else if (ob == lnf_misc_->counter_autosave )
1349 str = lyxrc.getDescription( LyXRC::RC_AUTOSAVE );
1350 else if (ob == lnf_misc_->counter_wm_jump )
1351 str = lyxrc.getDescription( LyXRC::RC_WHEEL_JUMP );
1357 void FormPreferences::updateLnFmisc()
1359 fl_set_button(lnf_misc_->check_banner,
1361 fl_set_button(lnf_misc_->check_auto_region_delete,
1362 lyxrc.auto_region_delete);
1363 fl_set_button(lnf_misc_->check_exit_confirm,
1364 lyxrc.exit_confirmation);
1365 fl_set_button(lnf_misc_->check_display_shrtcuts,
1366 lyxrc.display_shortcuts);
1367 fl_set_button(lnf_misc_->check_ask_new_file,
1368 lyxrc.new_ask_filename);
1369 fl_set_button(lnf_misc_->check_cursor_follows_scrollbar,
1370 lyxrc.cursor_follows_scrollbar);
1371 fl_set_counter_value(lnf_misc_->counter_autosave,
1373 fl_set_counter_value(lnf_misc_->counter_wm_jump,
1378 void FormPreferences::applyOutputsMisc() const
1380 lyxrc.ascii_linelen = static_cast<unsigned int>
1381 (fl_get_counter_value(outputs_misc_->counter_line_len));
1382 lyxrc.fontenc = fl_get_input(outputs_misc_->input_tex_encoding);
1385 fl_get_choice(outputs_misc_->choice_default_papersize) - 1;
1386 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1388 lyxrc.ascii_roff_command = fl_get_input(outputs_misc_->input_ascii_roff);
1389 lyxrc.chktex_command = fl_get_input(outputs_misc_->input_checktex);
1393 void FormPreferences::buildOutputsMisc()
1395 outputs_misc_ = build_outputs_misc();
1397 fl_set_counter_return(outputs_misc_->counter_line_len,
1399 fl_set_input_return(outputs_misc_->input_tex_encoding,
1401 fl_set_input_return(outputs_misc_->input_ascii_roff,
1403 fl_set_input_return(outputs_misc_->input_checktex,
1405 fl_addto_choice(outputs_misc_->choice_default_papersize,
1406 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
1408 // set up the feedback mechanism
1409 fl_addto_form(outputs_misc_->form);
1411 setPostHandler( outputs_misc_->counter_line_len );
1412 setPostHandler( outputs_misc_->input_tex_encoding );
1413 setPostHandler( outputs_misc_->choice_default_papersize );
1414 setPostHandler( outputs_misc_->input_ascii_roff );
1415 setPostHandler( outputs_misc_->input_checktex );
1422 FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob) const
1426 //if( !ob ) return string();
1430 if (ob == outputs_misc_->counter_line_len )
1431 str = lyxrc.getDescription( LyXRC::RC_ASCII_LINELEN );
1432 else if (ob == outputs_misc_->input_tex_encoding )
1433 str = lyxrc.getDescription( LyXRC::RC_FONT_ENCODING );
1434 else if (ob == outputs_misc_->input_ascii_roff )
1435 str = lyxrc.getDescription( LyXRC::RC_ASCIIROFF_COMMAND );
1436 else if (ob == outputs_misc_->input_checktex )
1437 str = lyxrc.getDescription( LyXRC::RC_CHKTEX_COMMAND );
1438 else if (ob == outputs_misc_->choice_default_papersize )
1439 str = lyxrc.getDescription( LyXRC::RC_DEFAULT_PAPERSIZE );
1445 void FormPreferences::updateOutputsMisc()
1447 fl_set_counter_value(outputs_misc_->counter_line_len,
1448 lyxrc.ascii_linelen);
1449 fl_set_input(outputs_misc_->input_tex_encoding,
1450 lyxrc.fontenc.c_str());
1451 fl_set_choice(outputs_misc_->choice_default_papersize,
1452 lyxrc.default_papersize+1);
1453 fl_set_input(outputs_misc_->input_ascii_roff,
1454 lyxrc.ascii_roff_command.c_str());
1455 fl_set_input(outputs_misc_->input_checktex,
1456 lyxrc.chktex_command.c_str());
1460 void FormPreferences::applyPaths()
1462 lyxrc.document_path = fl_get_input(paths_->input_default_path);
1463 lyxrc.template_path = fl_get_input(paths_->input_template_path);
1465 int button = fl_get_button(paths_->check_use_temp_dir);
1466 string str = fl_get_input(paths_->input_temp_dir);
1467 if (!button ) str.erase();
1469 lyxrc.use_tempdir = button;
1470 lyxrc.tempdir_path = str;
1472 button = fl_get_button(paths_->check_last_files);
1473 str = fl_get_input(paths_->input_lastfiles);
1474 if (!button ) str.erase();
1476 lyxrc.check_lastfiles = button;
1477 lyxrc.lastfiles = str;
1478 lyxrc.num_lastfiles = static_cast<unsigned int>
1479 (fl_get_counter_value(paths_->counter_lastfiles));
1481 button = fl_get_button(paths_->check_make_backups);
1482 str = fl_get_input(paths_->input_backup_path);
1483 if (!button ) str.erase();
1485 lyxrc.make_backup = button;
1486 lyxrc.backupdir_path = str;
1488 lyxrc.lyxpipes = fl_get_input(paths_->input_serverpipe);
1495 void FormPreferences::buildPaths()
1497 paths_ = build_paths();
1499 fl_set_input_return(paths_->input_default_path, FL_RETURN_CHANGED);
1500 fl_set_input_return(paths_->input_template_path, FL_RETURN_CHANGED);
1501 fl_set_input_return(paths_->input_temp_dir, FL_RETURN_CHANGED);
1502 fl_set_input_return(paths_->input_lastfiles, FL_RETURN_CHANGED);
1503 fl_set_input_return(paths_->input_backup_path, FL_RETURN_CHANGED);
1504 fl_set_counter_return(paths_->counter_lastfiles, FL_RETURN_CHANGED);
1505 fl_set_input_return(paths_->input_serverpipe, FL_RETURN_CHANGED);
1507 // deactivate the browse buttons because they aren't implemented
1508 fl_deactivate_object(paths_->button_document_browse);
1509 fl_deactivate_object(paths_->button_template_browse);
1510 fl_deactivate_object(paths_->button_temp_dir_browse);
1511 fl_deactivate_object(paths_->button_lastfiles_browse);
1512 fl_deactivate_object(paths_->button_backup_path_browse);
1513 fl_deactivate_object(paths_->button_serverpipe_browse);
1514 fl_set_object_lcol(paths_->button_document_browse, FL_INACTIVE);
1515 fl_set_object_lcol(paths_->button_template_browse, FL_INACTIVE);
1516 fl_set_object_lcol(paths_->button_temp_dir_browse, FL_INACTIVE);
1517 fl_set_object_lcol(paths_->button_lastfiles_browse, FL_INACTIVE);
1518 fl_set_object_lcol(paths_->button_backup_path_browse, FL_INACTIVE);
1519 fl_set_object_lcol(paths_->button_serverpipe_browse, FL_INACTIVE);
1521 // set up the feedback mechanism
1522 fl_addto_form(paths_->form);
1524 setPostHandler( paths_->input_default_path );
1525 setPostHandler( paths_->button_document_browse );
1526 setPostHandler( paths_->counter_lastfiles );
1527 setPostHandler( paths_->input_template_path );
1528 setPostHandler( paths_->button_template_browse );
1529 setPostHandler( paths_->check_last_files );
1530 setPostHandler( paths_->button_temp_dir_browse );
1531 setPostHandler( paths_->input_lastfiles );
1532 setPostHandler( paths_->button_lastfiles_browse );
1533 setPostHandler( paths_->check_make_backups );
1534 setPostHandler( paths_->input_backup_path );
1535 setPostHandler( paths_->button_backup_path_browse );
1536 setPostHandler( paths_->input_serverpipe );
1537 setPostHandler( paths_->button_serverpipe_browse );
1538 setPostHandler( paths_->input_temp_dir );
1539 setPostHandler( paths_->check_use_temp_dir );
1545 string const FormPreferences::feedbackPaths( FL_OBJECT const * const ob ) const
1549 //if( !ob ) return string();
1553 if (ob == paths_->input_default_path )
1554 str = lyxrc.getDescription( LyXRC::RC_DOCUMENTPATH );
1555 else if (ob == paths_->input_template_path )
1556 str = lyxrc.getDescription( LyXRC::RC_TEMPLATEPATH );
1557 else if (ob == paths_->check_use_temp_dir )
1558 str = lyxrc.getDescription( LyXRC::RC_USETEMPDIR );
1559 else if (ob == paths_->input_temp_dir )
1560 str = lyxrc.getDescription( LyXRC::RC_TEMPDIRPATH );
1561 else if (ob == paths_->check_last_files )
1562 str = lyxrc.getDescription( LyXRC::RC_CHECKLASTFILES );
1563 else if (ob == paths_->input_lastfiles )
1564 str = lyxrc.getDescription( LyXRC::RC_LASTFILES );
1565 else if (ob == paths_->counter_lastfiles )
1566 str = lyxrc.getDescription( LyXRC::RC_NUMLASTFILES );
1567 else if (ob == paths_->check_make_backups )
1568 str = lyxrc.getDescription( LyXRC::RC_MAKE_BACKUP );
1569 else if (ob == paths_->input_backup_path )
1570 str = lyxrc.getDescription( LyXRC::RC_BACKUPDIR_PATH );
1571 else if (ob == paths_->input_serverpipe )
1572 str = lyxrc.getDescription( LyXRC::RC_SERVERPIPE );
1578 bool FormPreferences::inputPaths( FL_OBJECT const * const ob )
1580 // what kind of coding is this? Do you plan for a ob == NULL?
1581 // When is that allowed? (Lgb)
1584 bool activate = true;
1586 if (!ob || ob == paths_->check_use_temp_dir) {
1587 if (fl_get_button(paths_->check_use_temp_dir)) {
1588 fl_activate_object(paths_->input_temp_dir);
1589 fl_set_object_lcol(paths_->input_temp_dir,
1592 fl_deactivate_object(paths_->input_temp_dir);
1593 fl_set_object_lcol(paths_->input_temp_dir,
1598 if (!ob || ob == paths_->check_last_files) {
1599 if (fl_get_button(paths_->check_last_files)) {
1600 fl_activate_object(paths_->input_lastfiles);
1601 fl_set_object_lcol(paths_->input_lastfiles,
1604 fl_deactivate_object(paths_->input_lastfiles);
1605 fl_set_object_lcol(paths_->input_lastfiles,
1610 if (!ob || ob == paths_->check_make_backups) {
1611 if (fl_get_button(paths_->check_make_backups)) {
1612 fl_activate_object(paths_->input_backup_path);
1613 fl_set_object_lcol(paths_->input_backup_path,
1616 fl_deactivate_object(paths_->input_backup_path);
1617 fl_set_object_lcol(paths_->input_backup_path,
1622 if (!ob || ob == paths_->input_default_path) {
1623 string name = fl_get_input(paths_->input_default_path);
1624 if (!WriteableDir(name) )
1628 if (!ob || ob == paths_->input_template_path) {
1629 string name = fl_get_input(paths_->input_template_path);
1630 if (!ReadableDir(name) )
1634 if (!ob || ob == paths_->input_temp_dir) {
1635 string name = fl_get_input(paths_->input_temp_dir);
1636 if (fl_get_button(paths_->check_make_backups)
1638 && !WriteableDir(name) )
1642 if (!ob || ob == paths_->input_backup_path) {
1643 string name = fl_get_input(paths_->input_backup_path);
1644 if (fl_get_button(paths_->check_make_backups)
1646 && !WriteableDir(name) )
1650 if (!ob || ob == paths_->input_lastfiles) {
1651 string name = fl_get_input(paths_->input_lastfiles);
1652 if (fl_get_button(paths_->check_last_files)
1654 && !WriteableFile(name) )
1658 if (!ob || ob == paths_->input_serverpipe) {
1659 string name = fl_get_input(paths_->input_serverpipe);
1660 if (!name.empty()) {
1661 if (!WriteableFile(name, ".in"))
1663 if (!WriteableFile(name, ".out"))
1672 void FormPreferences::updatePaths()
1674 fl_set_input(paths_->input_default_path,
1675 lyxrc.document_path.c_str());
1676 fl_set_input(paths_->input_template_path,
1677 lyxrc.template_path.c_str());
1680 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
1682 fl_set_button(paths_->check_make_backups,
1684 fl_set_input(paths_->input_backup_path, str.c_str());
1687 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
1689 fl_set_button(paths_->check_use_temp_dir,
1691 fl_set_input(paths_->input_temp_dir, str.c_str());
1694 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
1696 fl_set_button(paths_->check_last_files,
1697 lyxrc.check_lastfiles);
1698 fl_set_input(paths_->input_lastfiles, str.c_str());
1699 fl_set_counter_value(paths_->counter_lastfiles,
1700 lyxrc.num_lastfiles);
1702 fl_set_input(paths_->input_serverpipe, lyxrc.lyxpipes.c_str());
1704 // Activate/Deactivate the input fields dependent on the state of the
1710 void FormPreferences::applyPrinter() const
1712 lyxrc.print_adapt_output = fl_get_button(printer_->check_adapt_output);
1713 lyxrc.print_command = fl_get_input(printer_->input_command);
1714 lyxrc.print_pagerange_flag = fl_get_input(printer_->input_page_range);
1715 lyxrc.print_copies_flag = fl_get_input(printer_->input_copies);
1716 lyxrc.print_reverse_flag = fl_get_input(printer_->input_reverse);
1717 lyxrc.print_to_printer = fl_get_input(printer_->input_to_printer);
1718 lyxrc.print_file_extension =
1719 fl_get_input(printer_->input_file_extension);
1720 lyxrc.print_spool_command =
1721 fl_get_input(printer_->input_spool_command);
1722 lyxrc.print_paper_flag = fl_get_input(printer_->input_paper_type);
1723 lyxrc.print_evenpage_flag = fl_get_input(printer_->input_even_pages);
1724 lyxrc.print_oddpage_flag = fl_get_input(printer_->input_odd_pages);
1725 lyxrc.print_collcopies_flag = fl_get_input(printer_->input_collated);
1726 lyxrc.print_landscape_flag = fl_get_input(printer_->input_landscape);
1727 lyxrc.print_to_file = fl_get_input(printer_->input_to_file);
1728 lyxrc.print_extra_options =
1729 fl_get_input(printer_->input_extra_options);
1730 lyxrc.print_spool_printerprefix =
1731 fl_get_input(printer_->input_spool_prefix);
1732 lyxrc.print_paper_dimension_flag =
1733 fl_get_input(printer_->input_paper_size);
1734 lyxrc.printer = fl_get_input(printer_->input_name);
1739 FormPreferences::feedbackPrinter(FL_OBJECT const * const ob) const
1743 //if( !ob ) return string();
1747 if (ob == printer_->input_command )
1748 str = lyxrc.getDescription( LyXRC::RC_PRINT_COMMAND );
1749 else if (ob == printer_->check_adapt_output )
1750 str = lyxrc.getDescription( LyXRC::RC_PRINT_ADAPTOUTPUT );
1751 else if (ob == printer_->input_to_printer )
1752 str = lyxrc.getDescription( LyXRC::RC_PRINTTOPRINTER );
1753 else if (ob == printer_->input_to_file )
1754 str = lyxrc.getDescription( LyXRC::RC_PRINTTOFILE );
1755 else if (ob == printer_->input_file_extension )
1756 str = lyxrc.getDescription( LyXRC::RC_PRINTFILEEXTENSION );
1757 else if (ob == printer_->input_extra_options )
1758 str = lyxrc.getDescription( LyXRC::RC_PRINTEXSTRAOPTIONS );
1759 else if (ob == printer_->input_spool_command )
1760 str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_COMMAND );
1761 else if (ob == printer_->input_spool_prefix )
1762 str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_PRINTERPREFIX );
1763 else if (ob == printer_->input_name )
1764 str = lyxrc.getDescription( LyXRC::RC_PRINTER );
1765 else if (ob == printer_->input_even_pages )
1766 str = lyxrc.getDescription( LyXRC::RC_PRINTEVENPAGEFLAG );
1767 else if (ob == printer_->input_odd_pages )
1768 str = lyxrc.getDescription( LyXRC::RC_PRINTODDPAGEFLAG );
1769 else if (ob == printer_->input_page_range )
1770 str = lyxrc.getDescription( LyXRC::RC_PRINTPAGERANGEFLAG );
1771 else if (ob == printer_->input_reverse )
1772 str = lyxrc.getDescription( LyXRC::RC_PRINTREVERSEFLAG );
1773 else if (ob == printer_->input_landscape )
1774 str = lyxrc.getDescription( LyXRC::RC_PRINTLANDSCAPEFLAG );
1775 else if (ob == printer_->input_copies )
1776 str = lyxrc.getDescription( LyXRC::RC_PRINTCOLLCOPIESFLAG );
1777 else if (ob == printer_->input_collated )
1778 str = lyxrc.getDescription( LyXRC::RC_PRINTCOPIESFLAG );
1779 else if (ob == printer_->input_paper_type )
1780 str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERFLAG );
1781 else if (ob == printer_->input_paper_size )
1782 str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERDIMENSIONFLAG );
1788 void FormPreferences::buildPrinter()
1790 printer_ = build_printer();
1792 fl_set_input_return(printer_->input_command, FL_RETURN_CHANGED);
1793 fl_set_input_return(printer_->input_page_range, FL_RETURN_CHANGED);
1794 fl_set_input_return(printer_->input_copies, FL_RETURN_CHANGED);
1795 fl_set_input_return(printer_->input_reverse, FL_RETURN_CHANGED);
1796 fl_set_input_return(printer_->input_to_printer, FL_RETURN_CHANGED);
1797 fl_set_input_return(printer_->input_file_extension, FL_RETURN_CHANGED);
1798 fl_set_input_return(printer_->input_spool_command, FL_RETURN_CHANGED);
1799 fl_set_input_return(printer_->input_paper_type, FL_RETURN_CHANGED);
1800 fl_set_input_return(printer_->input_even_pages, FL_RETURN_CHANGED);
1801 fl_set_input_return(printer_->input_odd_pages, FL_RETURN_CHANGED);
1802 fl_set_input_return(printer_->input_collated, FL_RETURN_CHANGED);
1803 fl_set_input_return(printer_->input_landscape, FL_RETURN_CHANGED);
1804 fl_set_input_return(printer_->input_to_file, FL_RETURN_CHANGED);
1805 fl_set_input_return(printer_->input_extra_options, FL_RETURN_CHANGED);
1806 fl_set_input_return(printer_->input_spool_prefix, FL_RETURN_CHANGED);
1807 fl_set_input_return(printer_->input_paper_size, FL_RETURN_CHANGED);
1808 fl_set_input_return(printer_->input_name, FL_RETURN_CHANGED);
1810 // set up the feedback mechanism
1811 fl_addto_form(printer_->form);
1813 setPostHandler( printer_->input_command );
1814 setPostHandler( printer_->input_page_range );
1815 setPostHandler( printer_->input_copies );
1816 setPostHandler( printer_->input_reverse );
1817 setPostHandler( printer_->input_to_printer );
1818 setPostHandler( printer_->input_file_extension );
1819 setPostHandler( printer_->input_spool_command );
1820 setPostHandler( printer_->input_paper_type );
1821 setPostHandler( printer_->input_even_pages );
1822 setPostHandler( printer_->input_odd_pages );
1823 setPostHandler( printer_->input_collated );
1824 setPostHandler( printer_->input_landscape );
1825 setPostHandler( printer_->input_to_file );
1826 setPostHandler( printer_->input_extra_options );
1827 setPostHandler( printer_->input_spool_prefix );
1828 setPostHandler( printer_->input_paper_size );
1829 setPostHandler( printer_->input_name );
1830 setPostHandler( printer_->check_adapt_output );
1836 void FormPreferences::updatePrinter()
1838 fl_set_button(printer_->check_adapt_output,
1839 lyxrc.print_adapt_output);
1840 fl_set_input(printer_->input_command,
1841 lyxrc.print_command.c_str());
1842 fl_set_input(printer_->input_page_range,
1843 lyxrc.print_pagerange_flag.c_str());
1844 fl_set_input(printer_->input_copies,
1845 lyxrc.print_copies_flag.c_str());
1846 fl_set_input(printer_->input_reverse,
1847 lyxrc.print_reverse_flag.c_str());
1848 fl_set_input(printer_->input_to_printer,
1849 lyxrc.print_to_printer.c_str());
1850 fl_set_input(printer_->input_file_extension,
1851 lyxrc.print_file_extension.c_str());
1852 fl_set_input(printer_->input_spool_command,
1853 lyxrc.print_spool_command.c_str());
1854 fl_set_input(printer_->input_paper_type,
1855 lyxrc.print_paper_flag.c_str());
1856 fl_set_input(printer_->input_even_pages,
1857 lyxrc.print_evenpage_flag.c_str());
1858 fl_set_input(printer_->input_odd_pages,
1859 lyxrc.print_oddpage_flag.c_str());
1860 fl_set_input(printer_->input_collated,
1861 lyxrc.print_collcopies_flag.c_str());
1862 fl_set_input(printer_->input_landscape,
1863 lyxrc.print_landscape_flag.c_str());
1864 fl_set_input(printer_->input_to_file,
1865 lyxrc.print_to_file.c_str());
1866 fl_set_input(printer_->input_extra_options,
1867 lyxrc.print_extra_options.c_str());
1868 fl_set_input(printer_->input_spool_prefix,
1869 lyxrc.print_spool_printerprefix.c_str());
1870 fl_set_input(printer_->input_paper_size,
1871 lyxrc.print_paper_dimension_flag.c_str());
1872 fl_set_input(printer_->input_name,
1873 lyxrc.printer.c_str());
1877 void FormPreferences::applyScreenFonts() const
1879 bool changed = false;
1881 string str = fl_get_input(screen_fonts_->input_roman);
1882 if (lyxrc.roman_font_name != str) {
1884 lyxrc.roman_font_name = str;
1887 str = fl_get_input(screen_fonts_->input_sans);
1888 if (lyxrc.sans_font_name != str) {
1890 lyxrc.sans_font_name = str;
1893 str = fl_get_input(screen_fonts_->input_typewriter);
1894 if (lyxrc.typewriter_font_name != str) {
1896 lyxrc.typewriter_font_name = str;
1899 str = fl_get_input(screen_fonts_->input_screen_encoding);
1900 if (lyxrc.font_norm != str) {
1902 lyxrc.font_norm = str;
1905 bool button = fl_get_button(screen_fonts_->check_scalable);
1906 if (lyxrc.use_scalable_fonts != button) {
1908 lyxrc.use_scalable_fonts = button;
1911 unsigned int ivalue = static_cast<unsigned int>
1912 (fl_get_counter_value(screen_fonts_->counter_zoom));
1913 if (lyxrc.zoom != ivalue) {
1915 lyxrc.zoom = ivalue;
1918 ivalue = static_cast<unsigned int>
1919 (fl_get_counter_value(screen_fonts_->counter_dpi));
1920 if (lyxrc.dpi != ivalue) {
1925 double dvalue = strToDbl(fl_get_input(screen_fonts_->input_tiny));
1926 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
1928 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
1931 dvalue = strToDbl(fl_get_input(screen_fonts_->input_script));
1932 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
1934 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
1937 dvalue = strToDbl(fl_get_input(screen_fonts_->input_footnote));
1938 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
1940 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
1943 dvalue = strToDbl(fl_get_input(screen_fonts_->input_small));
1944 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
1946 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
1949 dvalue = strToDbl(fl_get_input(screen_fonts_->input_normal));
1950 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
1952 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
1955 dvalue = strToDbl(fl_get_input(screen_fonts_->input_large));
1956 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
1958 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
1961 dvalue = strToDbl(fl_get_input(screen_fonts_->input_larger));
1962 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
1964 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
1967 dvalue = strToDbl(fl_get_input(screen_fonts_->input_largest));
1968 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
1970 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
1973 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huge));
1974 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
1976 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
1979 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huger));
1980 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
1982 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
1986 // Now update the buffers
1987 // Can anything below here affect the redraw process?
1988 lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
1993 void FormPreferences::buildScreenFonts()
1995 screen_fonts_ = build_screen_fonts();
1997 fl_set_input_return(screen_fonts_->input_roman, FL_RETURN_CHANGED);
1998 fl_set_input_return(screen_fonts_->input_sans, FL_RETURN_CHANGED);
1999 fl_set_input_return(screen_fonts_->input_typewriter,
2001 fl_set_input_return(screen_fonts_->input_screen_encoding,
2003 fl_set_counter_return(screen_fonts_->counter_zoom, FL_RETURN_CHANGED);
2004 fl_set_counter_return(screen_fonts_->counter_dpi, FL_RETURN_CHANGED);
2005 fl_set_input_return(screen_fonts_->input_tiny, FL_RETURN_CHANGED);
2006 fl_set_input_return(screen_fonts_->input_script, FL_RETURN_CHANGED);
2007 fl_set_input_return(screen_fonts_->input_footnote, FL_RETURN_CHANGED);
2008 fl_set_input_return(screen_fonts_->input_small, FL_RETURN_CHANGED);
2009 fl_set_input_return(screen_fonts_->input_normal, FL_RETURN_CHANGED);
2010 fl_set_input_return(screen_fonts_->input_large, FL_RETURN_CHANGED);
2011 fl_set_input_return(screen_fonts_->input_larger, FL_RETURN_CHANGED);
2012 fl_set_input_return(screen_fonts_->input_largest, FL_RETURN_CHANGED);
2013 fl_set_input_return(screen_fonts_->input_huge, FL_RETURN_CHANGED);
2014 fl_set_input_return(screen_fonts_->input_huger, FL_RETURN_CHANGED);
2016 fl_set_input_filter(screen_fonts_->input_tiny,
2017 fl_unsigned_int_filter);
2018 fl_set_input_filter(screen_fonts_->input_script,
2019 fl_unsigned_int_filter);
2020 fl_set_input_filter(screen_fonts_->input_footnote,
2021 fl_unsigned_int_filter);
2022 fl_set_input_filter(screen_fonts_->input_small,
2023 fl_unsigned_int_filter);
2024 fl_set_input_filter(screen_fonts_->input_normal,
2025 fl_unsigned_int_filter);
2026 fl_set_input_filter(screen_fonts_->input_large,
2027 fl_unsigned_int_filter);
2028 fl_set_input_filter(screen_fonts_->input_larger,
2029 fl_unsigned_int_filter);
2030 fl_set_input_filter(screen_fonts_->input_largest,
2031 fl_unsigned_int_filter);
2032 fl_set_input_filter(screen_fonts_->input_huge,
2033 fl_unsigned_int_filter);
2034 fl_set_input_filter(screen_fonts_->input_huger,
2035 fl_unsigned_int_filter);
2037 // set up the feedback mechanism
2038 fl_addto_form(screen_fonts_->form);
2040 setPostHandler( screen_fonts_->input_roman );
2041 setPostHandler( screen_fonts_->input_sans );
2042 setPostHandler( screen_fonts_->input_typewriter );
2043 setPostHandler( screen_fonts_->counter_zoom );
2044 setPostHandler( screen_fonts_->counter_dpi );
2045 setPostHandler( screen_fonts_->check_scalable );
2046 setPostHandler( screen_fonts_->input_screen_encoding );
2047 setPostHandler( screen_fonts_->input_tiny );
2048 setPostHandler( screen_fonts_->input_script );
2049 setPostHandler( screen_fonts_->input_footnote );
2050 setPostHandler( screen_fonts_->input_small );
2051 setPostHandler( screen_fonts_->input_large );
2052 setPostHandler( screen_fonts_->input_larger );
2053 setPostHandler( screen_fonts_->input_largest );
2054 setPostHandler( screen_fonts_->input_normal );
2055 setPostHandler( screen_fonts_->input_huge );
2056 setPostHandler( screen_fonts_->input_huger );
2063 FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob ) const
2067 //if( !ob ) return string();
2071 if (ob == screen_fonts_->input_roman )
2072 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ROMAN );
2073 else if (ob == screen_fonts_->input_sans )
2074 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SANS );
2075 else if (ob == screen_fonts_->input_typewriter )
2076 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_TYPEWRITER );
2077 else if (ob == screen_fonts_->check_scalable )
2078 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SCALABLE );
2079 else if (ob == screen_fonts_->input_screen_encoding )
2080 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING );
2081 else if (ob == screen_fonts_->counter_zoom )
2082 str = lyxrc.getDescription( LyXRC::RC_SCREEN_ZOOM );
2083 else if (ob == screen_fonts_->counter_dpi )
2084 str = lyxrc.getDescription( LyXRC::RC_SCREEN_DPI );
2085 else if (ob == screen_fonts_->input_tiny
2086 || ob == screen_fonts_->input_script
2087 || ob == screen_fonts_->input_footnote
2088 || ob == screen_fonts_->input_small
2089 || ob == screen_fonts_->input_large
2090 || ob == screen_fonts_->input_larger
2091 || ob == screen_fonts_->input_larger
2092 || ob == screen_fonts_->input_largest
2093 || ob == screen_fonts_->input_normal
2094 || ob == screen_fonts_->input_huge
2095 || ob == screen_fonts_->input_huger )
2096 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SIZES );
2102 bool FormPreferences::inputScreenFonts()
2104 bool activate = true;
2107 // Make sure that all fonts all have positive entries
2108 // Also note that an empty entry is returned as 0.0 by strToDbl
2109 if (0.0 >= strToDbl(fl_get_input(screen_fonts_->input_tiny))
2110 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_script))
2111 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_footnote))
2112 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_small))
2113 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_normal))
2114 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_large))
2115 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_larger))
2116 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_largest))
2117 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huge))
2118 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huger))) {
2120 str = N_("WARNING! Fonts must be positive!");
2122 // Fontsizes -- tiny < script < footnote etc.
2123 } else if (strToDbl(fl_get_input(screen_fonts_->input_tiny)) >
2124 strToDbl(fl_get_input(screen_fonts_->input_script)) ||
2125 strToDbl(fl_get_input(screen_fonts_->input_script)) >
2126 strToDbl(fl_get_input(screen_fonts_->input_footnote)) ||
2127 strToDbl(fl_get_input(screen_fonts_->input_footnote)) >
2128 strToDbl(fl_get_input(screen_fonts_->input_small)) ||
2129 strToDbl(fl_get_input(screen_fonts_->input_small)) >
2130 strToDbl(fl_get_input(screen_fonts_->input_normal)) ||
2131 strToDbl(fl_get_input(screen_fonts_->input_normal)) >
2132 strToDbl(fl_get_input(screen_fonts_->input_large)) ||
2133 strToDbl(fl_get_input(screen_fonts_->input_large)) >
2134 strToDbl(fl_get_input(screen_fonts_->input_larger)) ||
2135 strToDbl(fl_get_input(screen_fonts_->input_larger)) >
2136 strToDbl(fl_get_input(screen_fonts_->input_largest)) ||
2137 strToDbl(fl_get_input(screen_fonts_->input_largest)) >
2138 strToDbl(fl_get_input(screen_fonts_->input_huge)) ||
2139 strToDbl(fl_get_input(screen_fonts_->input_huge)) >
2140 strToDbl(fl_get_input(screen_fonts_->input_huger))) {
2143 str = N_("WARNING! Fonts must be input in the order tiny > script>\nfootnote > small > normal > large > larger > largest > huge > huger.");
2147 fl_set_object_label(dialog_->text_warning, str.c_str());
2148 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2155 void FormPreferences::updateScreenFonts()
2157 fl_set_input(screen_fonts_->input_roman,
2158 lyxrc.roman_font_name.c_str());
2159 fl_set_input(screen_fonts_->input_sans,
2160 lyxrc.sans_font_name.c_str());
2161 fl_set_input(screen_fonts_->input_typewriter,
2162 lyxrc.typewriter_font_name.c_str());
2163 fl_set_input(screen_fonts_->input_screen_encoding,
2164 lyxrc.font_norm.c_str());
2165 fl_set_button(screen_fonts_->check_scalable,
2166 lyxrc.use_scalable_fonts);
2167 fl_set_counter_value(screen_fonts_->counter_zoom, lyxrc.zoom);
2168 fl_set_counter_value(screen_fonts_->counter_dpi, lyxrc.dpi);
2169 fl_set_input(screen_fonts_->input_tiny,
2170 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2171 fl_set_input(screen_fonts_->input_script,
2172 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2173 fl_set_input(screen_fonts_->input_footnote,
2174 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2175 fl_set_input(screen_fonts_->input_small,
2176 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2177 fl_set_input(screen_fonts_->input_normal,
2178 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2179 fl_set_input(screen_fonts_->input_large,
2180 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2181 fl_set_input(screen_fonts_->input_larger,
2182 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2183 fl_set_input(screen_fonts_->input_largest,
2184 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2185 fl_set_input(screen_fonts_->input_huge,
2186 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2187 fl_set_input(screen_fonts_->input_huger,
2188 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2192 void FormPreferences::applySpellChecker()
2195 string choice = "none";
2196 switch (fl_get_choice(spellchecker_->choice_spell_command)) {
2209 lyxrc.isp_command = choice;
2211 // If spell checker == "none", all other input set to off.
2212 if (fl_get_choice(spellchecker_->choice_spell_command) == 1) {
2213 lyxrc.isp_use_alt_lang = false;
2214 lyxrc.isp_alt_lang.erase();
2216 lyxrc.isp_use_esc_chars = false;
2217 lyxrc.isp_esc_chars.erase();
2219 lyxrc.isp_use_pers_dict = false;
2220 lyxrc.isp_pers_dict.erase();
2222 lyxrc.isp_accept_compound = false;
2223 lyxrc.isp_use_input_encoding = false;
2225 int button = fl_get_button(spellchecker_->check_alt_lang);
2226 choice = fl_get_input(spellchecker_->input_alt_lang);
2227 if (button && choice.empty() ) button = 0;
2228 if (!button ) choice.erase();
2230 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2231 lyxrc.isp_alt_lang = choice;
2233 button = fl_get_button(spellchecker_->check_escape_chars);
2234 choice = fl_get_input(spellchecker_->input_escape_chars);
2235 if (button && choice.empty() ) button = 0;
2236 if (!button ) choice.erase();
2238 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2239 lyxrc.isp_esc_chars = choice;
2241 button = fl_get_button(spellchecker_->check_personal_dict);
2242 choice = fl_get_input(spellchecker_->input_personal_dict);
2243 if (button && choice.empty() ) button = 0;
2244 if (!button ) choice.erase();
2246 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2247 lyxrc.isp_pers_dict = choice;
2249 button = fl_get_button(spellchecker_->check_compound_words);
2250 lyxrc.isp_accept_compound = static_cast<bool>(button);
2252 button = fl_get_button(spellchecker_->check_input_enc);
2253 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2257 updateSpellChecker();
2261 void FormPreferences::buildSpellchecker()
2263 spellchecker_ = build_spellchecker();
2265 fl_addto_choice(spellchecker_->choice_spell_command,
2266 _(" none | ispell | aspell "));
2267 fl_set_input_return(spellchecker_->input_alt_lang,
2269 fl_set_input_return(spellchecker_->input_escape_chars,
2271 fl_set_input_return(spellchecker_->input_personal_dict,
2274 // deactivate the browse button because it isn't implemented
2275 fl_deactivate_object(spellchecker_->button_personal_dict);
2276 fl_set_object_lcol(spellchecker_->button_personal_dict,
2279 // set up the feedback mechanism
2280 fl_addto_form(spellchecker_->form);
2282 setPostHandler( spellchecker_->choice_spell_command );
2283 setPostHandler( spellchecker_->check_alt_lang );
2284 setPostHandler( spellchecker_->input_alt_lang );
2285 setPostHandler( spellchecker_->check_escape_chars );
2286 setPostHandler( spellchecker_->input_escape_chars );
2287 setPostHandler( spellchecker_->check_personal_dict );
2288 setPostHandler( spellchecker_->input_personal_dict );
2289 setPostHandler( spellchecker_->button_personal_dict );
2290 setPostHandler( spellchecker_->check_compound_words );
2291 setPostHandler( spellchecker_->check_input_enc );
2298 FormPreferences::feedbackSpellChecker(FL_OBJECT const * const ob) const
2302 //if( !ob ) return string();
2306 if (ob == spellchecker_->choice_spell_command )
2307 str = lyxrc.getDescription( LyXRC::RC_SPELL_COMMAND );
2308 else if (ob == spellchecker_->check_alt_lang )
2309 str = lyxrc.getDescription( LyXRC::RC_USE_ALT_LANG );
2310 else if (ob == spellchecker_->input_alt_lang )
2311 str = lyxrc.getDescription( LyXRC::RC_ALT_LANG );
2312 else if (ob == spellchecker_->check_escape_chars )
2313 str = lyxrc.getDescription( LyXRC::RC_USE_ESC_CHARS );
2314 else if (ob == spellchecker_->input_escape_chars )
2315 str = lyxrc.getDescription( LyXRC::RC_ESC_CHARS );
2316 else if (ob == spellchecker_->check_personal_dict )
2317 str = lyxrc.getDescription( LyXRC::RC_USE_PERS_DICT );
2318 else if (ob == spellchecker_->input_personal_dict )
2319 str = lyxrc.getDescription( LyXRC::RC_PERS_DICT );
2320 else if (ob == spellchecker_->check_compound_words )
2321 str = lyxrc.getDescription( LyXRC::RC_ACCEPT_COMPOUND );
2322 else if (ob == spellchecker_->check_input_enc )
2323 str = lyxrc.getDescription( LyXRC::RC_USE_INP_ENC );
2329 bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob )
2333 // Allow/dissallow input
2335 // If spell checker == "none", disable all input.
2336 if (!ob || ob == spellchecker_->choice_spell_command) {
2337 if (fl_get_choice(spellchecker_->choice_spell_command) == 1) {
2338 fl_deactivate_object( spellchecker_->check_alt_lang );
2339 fl_deactivate_object( spellchecker_->input_alt_lang );
2340 fl_deactivate_object( spellchecker_->check_escape_chars );
2341 fl_deactivate_object( spellchecker_->input_escape_chars );
2342 fl_deactivate_object( spellchecker_->check_personal_dict );
2343 fl_deactivate_object( spellchecker_->input_personal_dict );
2344 fl_deactivate_object( spellchecker_->check_compound_words );
2345 fl_deactivate_object( spellchecker_->check_input_enc );
2348 fl_activate_object( spellchecker_->check_alt_lang );
2349 fl_activate_object( spellchecker_->check_escape_chars );
2350 fl_activate_object( spellchecker_->check_personal_dict );
2351 fl_activate_object( spellchecker_->check_compound_words );
2352 fl_activate_object( spellchecker_->check_input_enc );
2356 if (!ob || ob == spellchecker_->check_alt_lang) {
2357 if (fl_get_button(spellchecker_->check_alt_lang)) {
2358 fl_activate_object(spellchecker_->input_alt_lang);
2359 fl_set_object_lcol(spellchecker_->input_alt_lang,
2362 fl_deactivate_object(spellchecker_->input_alt_lang);
2363 fl_set_object_lcol(spellchecker_->input_alt_lang,
2368 if (!ob || ob == spellchecker_->check_escape_chars) {
2369 if (fl_get_button(spellchecker_->check_escape_chars)) {
2370 fl_activate_object(spellchecker_->input_escape_chars);
2371 fl_set_object_lcol(spellchecker_->input_escape_chars,
2374 fl_deactivate_object(spellchecker_->input_escape_chars);
2375 fl_set_object_lcol(spellchecker_->input_escape_chars,
2380 if (!ob || ob == spellchecker_->check_personal_dict) {
2381 if (fl_get_button(spellchecker_->check_personal_dict)) {
2382 fl_activate_object(spellchecker_->input_personal_dict);
2383 fl_set_object_lcol(spellchecker_->input_personal_dict,
2386 fl_deactivate_object(spellchecker_->input_personal_dict);
2387 fl_set_object_lcol(spellchecker_->input_personal_dict,
2392 return true; // All input is valid!
2396 void FormPreferences::updateSpellChecker()
2399 if (lyxrc.isp_command == "none" )
2401 else if (lyxrc.isp_command == "ispell" )
2403 else if (lyxrc.isp_command == "aspell" )
2405 fl_set_choice(spellchecker_->choice_spell_command, choice);
2408 if (lyxrc.isp_use_alt_lang ) str = lyxrc.isp_alt_lang;
2410 fl_set_button(spellchecker_->check_alt_lang,
2411 lyxrc.isp_use_alt_lang);
2412 fl_set_input(spellchecker_->input_alt_lang, str.c_str());
2415 if (lyxrc.isp_use_esc_chars ) str = lyxrc.isp_esc_chars;
2417 fl_set_button(spellchecker_->check_escape_chars,
2418 lyxrc.isp_use_esc_chars);
2419 fl_set_input(spellchecker_->input_escape_chars, str.c_str());
2422 if (lyxrc.isp_use_pers_dict ) str = lyxrc.isp_pers_dict;
2424 fl_set_button(spellchecker_->check_personal_dict,
2425 lyxrc.isp_use_pers_dict);
2426 fl_set_input(spellchecker_->input_personal_dict, str.c_str());
2428 fl_set_button(spellchecker_->check_compound_words,
2429 lyxrc.isp_accept_compound);
2430 fl_set_button(spellchecker_->check_input_enc,
2431 lyxrc.isp_use_input_encoding);
2433 // Activate/Deactivate the input fields dependent on the state of the
2435 inputSpellChecker( 0 );
2439 bool FormPreferences::WriteableDir(string const & name) const
2441 bool success = true;
2444 if (!AbsolutePath(name)) {
2446 str = N_("WARNING! The absolute path is required.");
2449 FileInfo const tp(name);
2450 if (success && !tp.isDir()) {
2452 str = N_("WARNING! Directory does not exist.");
2455 if (success && !tp.writable()) {
2457 str = N_("WARNING! Cannot write to this directory.");
2461 fl_set_object_label(dialog_->text_warning, str.c_str());
2462 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2469 bool FormPreferences::ReadableDir(string const & name) const
2471 bool success = true;
2474 if (!AbsolutePath(name)) {
2476 str = N_("WARNING! The absolute path is required.");
2479 FileInfo const tp(name);
2480 if (success && !tp.isDir()) {
2482 str = N_("WARNING! Directory does not exist.");
2485 if (success && !tp.readable()) {
2487 str = N_("WARNING! Cannot read this directory.");
2491 fl_set_object_label(dialog_->text_warning, str.c_str());
2492 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2499 bool FormPreferences::WriteableFile(string const & name,
2500 string const & suffix) const
2502 // A writeable file is either:
2503 // * An existing file to which we have write access, or
2504 // * A file that doesn't yet exist but that would exist in a writeable
2507 bool success = true;
2512 str = N_("WARNING! No file input.");
2515 string const dir = OnlyPath(name);
2516 if (success && !AbsolutePath(dir)) {
2518 str = N_("WARNING! The absolute path is required.");
2522 // This is not a nice way to use FileInfo (Lgb)
2534 // This should be equivalent (Lgb)
2540 if (success && !d.isDir()) {
2542 str = N_("WARNING! Directory does not exist.");
2545 if (success && !d.writable()) {
2547 str = N_("WARNING! Cannot write to this directory.");
2550 FileInfo f(name+suffix);
2551 if (success && (dir == name || f.isDir())) {
2553 str = N_("WARNING! A file is required, not a directory.");
2556 if (success && (f.exist() && !f.writable())) {
2558 str = N_("WARNING! Cannot write to this file.");
2562 fl_set_object_label(dialog_->text_warning, str.c_str());
2563 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2570 void FormPreferences::ComboLanguageCB(int, void * v, Combox * combox)
2572 Assert(v && combox);
2573 FormPreferences * pre = static_cast<FormPreferences*>(v);
2574 // This is safe, as nothing is done to the pointer, other than
2575 // to use its address in a block-if statement.
2576 pre->bc_.valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
2580 // C functions for the timer callback used to give the user feedback
2581 C_GENERICCB(FormPreferences, FeedbackCB)
2584 void FormPreferences::FeedbackCB(FL_OBJECT * ob, long)
2590 FormPreferences * pre =
2591 static_cast<FormPreferences*>(ob->form->u_vdata);
2594 pre->feedback( pre->feedbackObj );
2599 int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event,
2600 FL_Coord, FL_Coord, int, void *)
2602 // can occur when form is being deleted. This seems an easier fix than
2603 // a call "fl_set_object_posthandler(ob, 0)" for each and every object
2604 // in the destructor.
2606 if (!ob->form ) return 0;
2608 FormPreferences * pre =
2609 static_cast<FormPreferences*>(ob->form->u_vdata);
2610 pre->feedbackPost(ob, event);
2615 // post_handler for feedback messages
2616 void FormPreferences::feedbackPost(FL_OBJECT * ob, int event)
2622 // We do not test for empty help here, since this can never happen
2623 if (event == FL_ENTER) {
2624 // Used as a placeholder for ob, so that we don't have to
2625 // a horrible reinterpret_cast to long and pass it as an
2626 // argument in fl_set_object_callback.
2628 fl_set_object_callback(dialog_->timer_feedback,
2629 C_FormPreferencesFeedbackCB,
2631 fl_set_timer(dialog_->timer_feedback, 0.5);
2632 } else if (event != FL_MOTION) {
2633 fl_set_timer(dialog_->timer_feedback, 0);
2635 fl_set_object_label(dialog_->text_warning, "");
2640 void FormPreferences::setPostHandler(FL_OBJECT * ob) const
2646 fl_set_object_posthandler(ob, C_FormPreferencesFeedbackPost);