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
48 extern string fmt(char const * fmtstr ...);
49 extern string system_lyxdir;
50 extern Languages languages;
52 static string const colourFile("/usr/lib/X11/rgb.txt");
53 vector<FormPreferences::X11Colour> FormPreferences::colourDB;
54 pair<vector<string>, vector<string> > FormPreferences::dirlist;
56 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
57 : FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
59 converters_tab_(0), inputs_tab_(0), look_n_feel_tab_(0),
60 outputs_tab_(0), usage_tab_(0),
61 colours_(0), converters_(0), formats_(0), inputs_misc_(0),
62 interface_(0), language_(0), lnf_misc_(0), outputs_misc_(0),
63 paths_(0), printer_(0), screen_fonts_(0), spellchecker_(0),
64 combo_default_lang(0), combo_kbmap_1(0), combo_kbmap_2(0),
67 // let the dialog be shown
68 // This is a permanent connection so we won't bother
69 // storing a copy because we won't be disconnecting.
70 d->showPreferences.connect(slot(this, &FormPreferences::show));
74 FormPreferences::~FormPreferences()
76 delete combo_default_lang;
80 delete converters_tab_;
82 delete look_n_feel_tab_;
99 // Must delete dialog last or we'll end up with a SIGSEGV trying to
100 // access dialog_->timer_feedback in feedbackPost().
105 FL_FORM * FormPreferences::form() const
107 if (dialog_) return dialog_->form;
112 void FormPreferences::ok()
115 lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
119 void FormPreferences::hide()
121 // We need to hide the active tabfolder otherwise we get a
122 // BadDrawable error from X windows and LyX crashes without saving.
123 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
125 && outer_form->visible) {
126 fl_hide_form(outer_form);
132 void FormPreferences::build()
134 dialog_ = build_preferences();
136 // manage the restore, save, apply and cancel/close buttons
137 bc_.setOK(dialog_->button_ok);
138 bc_.setApply(dialog_->button_apply);
139 bc_.setCancel(dialog_->button_cancel);
140 bc_.setUndoAll(dialog_->button_restore);
143 // Workaround dumb xforms sizing bug
147 // build the tab folders
148 converters_tab_ = build_outer_tab();
149 look_n_feel_tab_ = build_outer_tab();
150 inputs_tab_ = build_outer_tab();
151 outputs_tab_ = build_outer_tab();
152 usage_tab_ = build_outer_tab();
154 // build actual tabfolder contents
155 // these will become nested tabfolders
169 // Now add them to the tabfolder
170 fl_addto_tabfolder(dialog_->tabfolder_prefs,
172 look_n_feel_tab_->form);
173 fl_addto_tabfolder(dialog_->tabfolder_prefs,
176 fl_addto_tabfolder(dialog_->tabfolder_prefs,
178 converters_tab_->form);
179 fl_addto_tabfolder(dialog_->tabfolder_prefs,
182 fl_addto_tabfolder(dialog_->tabfolder_prefs,
186 // now build the nested tabfolders
187 // Starting with look and feel
188 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
190 screen_fonts_->form);
191 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
194 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
197 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
201 // then build converters
202 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
205 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
210 // Paths should probably go in a few outer_tab called Files
211 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
214 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
218 // then building outputs
219 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
222 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
224 outputs_misc_->form);
226 // then building usage
227 fl_addto_tabfolder(usage_tab_->tabfolder_outer,
229 spellchecker_->form);
230 fl_addto_tabfolder(usage_tab_->tabfolder_outer,
236 void FormPreferences::apply()
238 // set the new lyxrc entries
239 // many of these need to trigger other functions when the assignment
240 // is made. For example, screen zoom and font types. These could be
241 // handled either by signals/slots in lyxrc or just directly call the
242 // associated functions here.
243 // There are other problems with this scheme. We really should check
244 // what we copy to make sure that it really is necessary to do things
245 // like update the screen fonts because that flushes the textcache
246 // and other stuff which may cost us a lot on slower/high-load machines.
263 void FormPreferences::feedback( FL_OBJECT * ob )
269 if (ob->form->fdui == colours_) {
270 str = feedbackColours( ob );
271 } else if (ob->form->fdui == converters_) {
272 str = feedbackConverters( ob );
273 } else if (ob->form->fdui == formats_) {
274 str = feedbackFormats( ob );
275 } else if (ob->form->fdui == inputs_misc_) {
276 str = feedbackInputsMisc( ob );
277 } else if (ob->form->fdui == interface_) {
278 str = feedbackInterface( ob );
279 } else if (ob->form->fdui == language_) {
280 str = feedbackLanguage( ob );
281 } else if (ob->form->fdui == lnf_misc_) {
282 str = feedbackLnFmisc( ob );
283 } else if (ob->form->fdui == outputs_misc_) {
284 str = feedbackOutputsMisc( ob );
285 } else if (ob->form->fdui == paths_) {
286 str = feedbackPaths( ob );
287 } else if (ob->form->fdui == printer_) {
288 str = feedbackPrinter( ob );
289 } else if (ob->form->fdui == screen_fonts_) {
290 str = feedbackScreenFonts( ob );
291 } else if (ob->form->fdui == spellchecker_) {
292 str = feedbackSpellChecker( ob );
295 str = formatted( str, dialog_->text_warning->w-10,
296 FL_SMALL_SIZE, FL_NORMAL_STYLE );
298 fl_set_object_label(dialog_->text_warning, str.c_str());
299 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
303 bool FormPreferences::input(FL_OBJECT * ob, long)
307 // whatever checks you need to ensure the user hasn't entered
308 // some totally ridiculous value somewhere. Change activate to suit.
309 // comments before each test describe what is _valid_
311 if (ob->form->fdui == colours_)
312 return inputColours(ob);
313 else if (ob->form->fdui == language_)
314 return inputLanguage(ob);
315 else if (ob->form->fdui == paths_)
316 return inputPaths(ob);
317 else if (ob->form->fdui == screen_fonts_)
318 return inputScreenFonts();
319 else if (ob->form->fdui == spellchecker_)
320 return inputSpellChecker(ob);
321 else if (ob->form->fdui == formats_)
322 return inputFormats(ob);
328 void FormPreferences::update()
330 if (!dialog_) return;
332 // read lyxrc entries
344 updateSpellChecker();
348 void FormPreferences::applyColours() const
353 void FormPreferences::buildColours()
355 colours_ = build_colours();
357 FL_OBJECT * obj = colours_->valslider_red;
358 fl_set_slider_bounds(obj, 0, 255);
359 fl_set_slider_precision(obj, 0);
360 fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
362 obj = colours_->valslider_green;
363 fl_set_slider_bounds(obj, 0, 255);
364 fl_set_slider_precision(obj, 0);
365 fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
367 obj = colours_->valslider_blue;
368 fl_set_slider_bounds(obj, 0, 255);
369 fl_set_slider_precision(obj, 0);
370 fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
372 fl_set_object_color(colours_->button_colour,
373 FL_FREE_COL4, FL_FREE_COL4);
375 fl_set_input_return(colours_->input_name, FL_RETURN_END_CHANGED);
377 if (ColoursLoadBrowser(colourFile) )
378 fl_set_input(colours_->input_name, colourFile.c_str());
380 fl_set_input(colours_->input_name, N_("No file found"));
382 // deactivate the browse button because it isn't implemented
383 fl_deactivate_object(colours_->button_browse);
384 fl_set_object_lcol(colours_->button_browse, FL_INACTIVE);
389 FormPreferences::feedbackColours(FL_OBJECT const * const ob) const
396 bool FormPreferences::inputColours( FL_OBJECT const * const ob )
399 bool activate = true;
401 if (ob == colours_->browser_x11) {
402 int i = fl_get_browser(colours_->browser_x11);
404 ColoursUpdateBrowser(i-1);
407 } else if (ob == colours_->valslider_red
408 || ob == colours_->valslider_green
409 || ob == colours_->valslider_blue) {
412 } else if (ob == colours_->input_name) {
413 string file = fl_get_input(colours_->input_name);
414 if (ColoursLoadBrowser(file) )
415 fl_set_input(colours_->input_name, file.c_str());
416 else if (ColoursLoadBrowser(colourFile) )
417 fl_set_input(colours_->input_name, colourFile.c_str());
419 fl_set_input(colours_->input_name, N_("No file found"));
426 bool FormPreferences::ColoursLoadBrowser(string const & filename)
430 if (!lex.setFile(filename))
433 istream & is = lex.getStream();
437 vector<string> names;
444 if (line[0] != '!') {
448 istringstream iss(line.c_str());
449 iss >> col.r >> col.g >> col.b;
453 if (!name.empty() ) name += " ";
457 // remove redundant entries on the fly
458 bool add = cols.empty();
460 vector<RGB>::const_iterator it =
461 find( cols.begin(), cols.end(), col );
462 add = (it == cols.end());
466 name = lowercase( name );
467 if (name == "gray0" ) name = "black";
468 if (name == "gray100" ) name = "white";
470 if (name == "black" || name == "white") {
471 cols.insert(cols.begin(), col);
472 names.insert(names.begin(), name);
475 names.push_back(name);
481 vector<string>::iterator sit = names.begin();
482 for (vector<RGB>::const_iterator iit = cols.begin();
483 iit != cols.end(); ++iit, ++sit) {
484 colourDB.push_back( X11Colour(*sit, *iit) );
487 FL_OBJECT * colbr = colours_->browser_x11;
488 fl_freeze_form(colours_->form);
489 fl_clear_browser( colbr );
491 for (vector<X11Colour>::const_iterator cit = colourDB.begin();
492 cit != colourDB.end(); ++cit) {
493 string name = (*cit).first;
494 //RGB col = (*cit).second;
495 //name += " (" + tostr(col.r) + ", " + tostr(col.g) +
496 // ", " + tostr(col.b) + ")";
497 fl_addto_browser(colbr, name.c_str());
500 fl_set_browser_topline(colbr, 1);
501 fl_select_browser_line(colbr, 1);
502 ColoursUpdateBrowser(0);
503 fl_unfreeze_form(colours_->form);
509 int FormPreferences::ColoursSearchEntry(RGB const & col) const
511 int mindiff = 0x7fffffff;
512 vector<X11Colour>::const_iterator mincit = colourDB.begin();
514 for (vector<X11Colour>::const_iterator cit = colourDB.begin();
515 cit != colourDB.end(); ++cit) {
516 RGB colDB = (*cit).second;
518 diff.r = col.r - colDB.r;
519 diff.g = col.g - colDB.g;
520 diff.b = col.b - colDB.b;
522 int d = (2 * (diff.r * diff.r) +
523 3 * (diff.g * diff.g) +
531 return static_cast<int>(mincit - colourDB.begin());
535 void FormPreferences::ColoursUpdateBrowser(int i)
537 fl_freeze_form(colours_->form);
539 RGB col = colourDB[i].second;
541 fl_mapcolor(FL_FREE_COL4 + i, col.r, col.g, col.b);
542 fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
543 fl_set_slider_value(colours_->valslider_red, col.r);
544 fl_set_slider_value(colours_->valslider_green, col.g);
545 fl_set_slider_value(colours_->valslider_blue, col.b);
546 fl_redraw_object(colours_->button_colour);
548 fl_unfreeze_form(colours_->form);
552 void FormPreferences::ColoursUpdateRGB()
554 fl_freeze_form(colours_->form);
557 col.r = int(fl_get_slider_value(colours_->valslider_red));
558 col.g = int(fl_get_slider_value(colours_->valslider_green));
559 col.b = int(fl_get_slider_value(colours_->valslider_blue));
561 fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
562 fl_redraw_object(colours_->button_colour);
564 int const i = ColoursSearchEntry( col );
565 // change topline only if necessary
566 // int top = fl_get_browser_topline(colours_->browser_x11);
567 // if (i < top || i > (top+15))
568 fl_set_browser_topline(colours_->browser_x11, i - 5);
569 fl_select_browser_line(colours_->browser_x11, i + 1);
571 fl_unfreeze_form(colours_->form);
575 void FormPreferences::updateColours()
579 void FormPreferences::applyConverters() const
583 void FormPreferences::buildConverters()
585 converters_ = build_converters();
587 fl_set_input_return(converters_->input_converter, FL_RETURN_CHANGED);
588 fl_set_input_return(converters_->input_flags, FL_RETURN_CHANGED);
595 FormPreferences::feedbackConverters( FL_OBJECT const * const ob) const
602 void FormPreferences::updateConverters()
604 vector<Command> commands = Converter::GetAllCommands();
606 vector<string> names;
607 for(vector<Command>::const_iterator cit = commands.begin();
608 cit != commands.end(); ++cit) {
609 string from = cit->from->prettyname;
610 string to = cit->to->prettyname;
611 string name = from + " -> " + to;
612 names.push_back(name);
614 sort(names.begin(), names.end());
616 fl_clear_browser(converters_->browser_converters);
617 for (vector<string>::const_iterator cit = names.begin();
618 cit != names.end(); ++cit)
619 fl_addto_browser(converters_->browser_converters,
621 fl_deactivate_object(converters_->button_add);
622 fl_set_object_lcol(converters_->button_add, FL_INACTIVE);
624 fl_deactivate_object(converters_->button_delete);
625 fl_set_object_lcol(converters_->button_delete, FL_INACTIVE);
629 void FormPreferences::applyFormats() const
631 vector<Format> old = formats.GetAllFormats();
632 for (vector<Format>::const_iterator it = old.begin();
633 it != old.end(); ++it)
634 if (find_if(formats_vec.begin(),formats_vec.end(),
635 compare_memfun(&Format::getname, it->name))
636 == formats_vec.end()) {
637 formats.Add(it->name, string(), string(), string());
640 for (vector<Format>::const_iterator it = formats_vec.begin();
641 it != formats_vec.end(); ++it) {
642 formats.Add(it->name, it->extension, it->prettyname,
644 formats.SetViewer(it->name, it->viewer);
649 void FormPreferences::buildFormats()
651 formats_ = build_formats();
653 fl_set_input_return(formats_->input_format, FL_RETURN_CHANGED);
654 fl_set_input_return(formats_->input_viewer, FL_RETURN_CHANGED);
655 fl_set_input_return(formats_->input_shrtcut, FL_RETURN_CHANGED);
656 fl_set_input_return(formats_->input_gui_name, FL_RETURN_CHANGED);
657 fl_set_input_return(formats_->input_extension, FL_RETURN_CHANGED);
659 fl_set_input_filter(formats_->input_format, fl_lowercase_filter);
666 FormPreferences::feedbackFormats(FL_OBJECT const * const ob) const
678 bool FormPreferences::inputFormats(FL_OBJECT const * const ob)
682 //if( !ob ) return false;
684 if (ob == formats_->browser_formats) {
685 FormatsInputBrowser();
687 } else if (ob == formats_->input_format) {
690 } else if (ob == formats_->button_add) {
693 } else if (ob == formats_->button_delete) {
694 FormatsInputDelete();
700 void FormPreferences::updateFormats()
702 formats_vec = formats.GetAllFormats();
704 vector<string> names;
705 for (vector<Format>::const_iterator it = formats_vec.begin();
706 it != formats_vec.end(); ++it)
707 names.push_back( it->name.c_str() );
708 sort(names.begin(), names.end());
710 fl_clear_browser(formats_->browser_formats);
711 for (vector<string>::const_iterator it = names.begin();
712 it != names.end(); ++it)
713 fl_addto_browser(formats_->browser_formats, it->c_str());
715 fl_deactivate_object(formats_->button_add);
716 fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
718 fl_deactivate_object(formats_->button_delete);
719 fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
723 bool FormPreferences::FormatsInputAdd()
725 string name = fl_get_input(formats_->input_format);
726 string prettyname = fl_get_input(formats_->input_gui_name);
727 string extension = fl_get_input(formats_->input_extension);
728 string viewer = fl_get_input(formats_->input_viewer);
729 string shortcut = fl_get_input(formats_->input_shrtcut);
730 if (prettyname.empty())
733 Format format(name, extension, prettyname, shortcut, viewer);
734 vector<Format>::iterator it =
735 find_if(formats_vec.begin(), formats_vec.end(),
736 compare_memfun(&Format::getname, name));
738 if (it == formats_vec.end()) {
739 fl_freeze_form(formats_->form);
741 formats_vec.push_back(format);
743 vector<string> names;
744 for (vector<Format>::const_iterator it = formats_vec.begin();
745 it != formats_vec.end(); ++it)
746 names.push_back( it->name.c_str() );
748 sort( names.begin(), names.end() );
750 fl_clear_browser( formats_->browser_formats );
751 for (vector<string>::const_iterator it = names.begin();
752 it != names.end(); ++it)
753 fl_addto_browser(formats_->browser_formats,
756 fl_set_input(formats_->input_format, "");
757 fl_set_input(formats_->input_gui_name, "");
758 fl_set_input(formats_->input_shrtcut, "");
759 fl_set_input(formats_->input_extension, "");
760 fl_set_input(formats_->input_viewer, "");
762 fl_set_object_label( formats_->button_add,
764 fl_set_button_shortcut( formats_->button_add,
765 scex(_("Add|#A")), 1);
767 fl_deactivate_object(formats_->button_add);
768 fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
770 fl_deactivate_object(formats_->button_delete);
771 fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
773 fl_unfreeze_form(formats_->form);
784 bool FormPreferences::FormatsInputDelete()
786 string name = fl_get_input(formats_->input_format);
787 vector<Format>::iterator it =
788 find_if(formats_vec.begin(), formats_vec.end(),
789 compare_memfun(&Format::getname, name));
791 fl_freeze_form(formats_->form);
793 if (it == formats_vec.end()) {
794 fl_deactivate_object(formats_->button_delete);
795 fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
800 i < fl_get_browser_maxline(formats_->browser_formats);
802 string str = fl_get_browser_line( formats_->browser_formats, i+1 );
810 fl_delete_browser_line(formats_->browser_formats, sel );
812 fl_set_input(formats_->input_format, "");
813 fl_set_input(formats_->input_gui_name, "");
814 fl_set_input(formats_->input_shrtcut, "");
815 fl_set_input(formats_->input_extension, "");
816 fl_set_input(formats_->input_viewer, "");
818 fl_set_object_label( formats_->button_add,
820 fl_set_button_shortcut( formats_->button_add,
821 scex(_("Add|#A")), 1);
823 fl_deactivate_object(formats_->button_add);
824 fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
826 fl_deactivate_object(formats_->button_delete);
827 fl_set_object_lcol(formats_->button_delete,
832 fl_unfreeze_form(formats_->form);
838 bool FormPreferences::FormatsInputBrowser()
840 int const i = fl_get_browser(formats_->browser_formats);
841 if( i <= 0 ) return true;
843 string name = fl_get_browser_line(formats_->browser_formats, i);
844 vector<Format>::iterator it =
845 find_if(formats_vec.begin(), formats_vec.end(),
846 compare_memfun(&Format::getname, name));
848 if (it != formats_vec.end()) {
849 fl_freeze_form(formats_->form);
851 fl_set_input(formats_->input_format, it->name.c_str());
852 fl_set_input(formats_->input_gui_name, it->prettyname.c_str());
853 fl_set_input(formats_->input_shrtcut, it->shortcut.c_str());
854 fl_set_input(formats_->input_extension, it->extension.c_str());
855 fl_set_input(formats_->input_viewer, it->viewer.c_str());
857 fl_set_object_label( formats_->button_add,
858 idex(_("Modify|#M")) );
859 fl_set_button_shortcut( formats_->button_add,
860 scex(_("Modify|#M")), 1);
862 fl_activate_object(formats_->button_add);
863 fl_set_object_lcol(formats_->button_add, FL_BLACK);
865 fl_activate_object(formats_->button_delete);
866 fl_set_object_lcol(formats_->button_delete, FL_BLACK);
868 fl_unfreeze_form(formats_->form);
874 bool FormPreferences::FormatsInputInput()
876 string const name = fl_get_input(formats_->input_format);
877 vector<Format>::iterator it =
878 find_if(formats_vec.begin(), formats_vec.end(),
879 compare_memfun(&Format::getname, name));
881 fl_freeze_form(formats_->form);
883 if (it == formats_vec.end()) {
884 fl_set_object_label( formats_->button_add,
886 fl_set_button_shortcut( formats_->button_add,
887 scex(_("Add|#A")), 1);
890 fl_deactivate_object(formats_->button_add);
891 fl_set_object_lcol(formats_->button_add, FL_INACTIVE);
893 fl_activate_object(formats_->button_add);
894 fl_set_object_lcol(formats_->button_add, FL_BLACK);
897 fl_deselect_browser(formats_->browser_formats);
899 fl_deactivate_object(formats_->button_delete);
900 fl_set_object_lcol(formats_->button_delete, FL_INACTIVE);
903 fl_set_object_label( formats_->button_add,
904 idex(_("Modify|#M")) );
905 fl_set_button_shortcut( formats_->button_add,
906 scex(_("Modify|#M")), 1);
910 i < fl_get_browser_maxline(formats_->browser_formats);
912 string str = fl_get_browser_line( formats_->browser_formats, i+1 );
920 if( top < 1 ) top = 0;
921 fl_set_browser_topline(formats_->browser_formats, top);
922 fl_select_browser_line(formats_->browser_formats, sel);
924 fl_activate_object(formats_->button_add);
925 fl_set_object_lcol(formats_->button_add, FL_BLACK);
927 fl_activate_object(formats_->button_delete);
928 fl_set_object_lcol(formats_->button_delete, FL_BLACK);
931 fl_unfreeze_form(formats_->form);
936 void FormPreferences::applyInputsMisc() const
938 lyxrc.date_insert_format =
939 fl_get_input(inputs_misc_->input_date_format);
943 void FormPreferences::buildInputsMisc()
945 inputs_misc_ = build_inputs_misc();
947 fl_set_input_return(inputs_misc_->input_date_format,
950 // set up the feedback mechanism
951 fl_addto_form(inputs_misc_->form);
953 setPostHandler( inputs_misc_->input_date_format );
960 FormPreferences::feedbackInputsMisc(FL_OBJECT const * const ob) const
964 //if( !ob ) return string();
968 if (ob == inputs_misc_->input_date_format )
969 str = lyxrc.getDescription( LyXRC::RC_DATE_INSERT_FORMAT );
975 void FormPreferences::updateInputsMisc()
977 fl_set_input(inputs_misc_->input_date_format,
978 lyxrc.date_insert_format.c_str());
982 void FormPreferences::applyInterface() const
984 lyxrc.popup_font_name =
985 fl_get_input(interface_->input_popup_font);
986 lyxrc.menu_font_name = fl_get_input(interface_->input_menu_font);
987 lyxrc.font_norm_menu =
988 fl_get_input(interface_->input_popup_encoding);
989 lyxrc.bind_file = fl_get_input(interface_->input_bind_file);
990 lyxrc.ui_file = fl_get_input(interface_->input_ui_file);
991 lyxrc.override_x_deadkeys =
992 fl_get_button(interface_->check_override_x_dead_keys);
996 void FormPreferences::buildInterface()
998 interface_ = build_interface();
1000 fl_set_input_return(interface_->input_popup_font, FL_RETURN_CHANGED);
1001 fl_set_input_return(interface_->input_menu_font, FL_RETURN_CHANGED);
1002 fl_set_input_return(interface_->input_popup_encoding,
1004 fl_set_input_return(interface_->input_bind_file, FL_RETURN_CHANGED);
1005 fl_set_input_return(interface_->input_ui_file, FL_RETURN_CHANGED);
1007 // deactivate the browse buttons because they aren't implemented
1008 fl_deactivate_object(interface_->button_bind_file_browse);
1009 fl_deactivate_object(interface_->button_ui_file_browse);
1010 fl_set_object_lcol(interface_->button_bind_file_browse, FL_INACTIVE);
1011 fl_set_object_lcol(interface_->button_ui_file_browse, FL_INACTIVE);
1013 // set up the feedback mechanism
1014 fl_addto_form(interface_->form);
1016 setPostHandler( interface_->input_popup_font );
1017 setPostHandler( interface_->input_menu_font );
1018 setPostHandler( interface_->input_popup_encoding );
1019 setPostHandler( interface_->input_bind_file );
1020 setPostHandler( interface_->button_bind_file_browse );
1021 setPostHandler( interface_->input_ui_file );
1022 setPostHandler( interface_->button_ui_file_browse );
1023 setPostHandler( interface_->check_override_x_dead_keys );
1030 FormPreferences::feedbackInterface( FL_OBJECT const * const ob ) const
1034 //if( !ob ) return string();
1038 if (ob == interface_->input_popup_font )
1039 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_POPUP );
1040 else if (ob == interface_->input_menu_font )
1041 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_MENU );
1042 else if (ob == interface_->input_popup_encoding )
1043 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING_MENU );
1044 else if (ob == interface_->input_bind_file )
1045 str = lyxrc.getDescription( LyXRC::RC_BINDFILE );
1046 else if (ob == interface_->input_ui_file )
1047 str = lyxrc.getDescription( LyXRC::RC_UIFILE );
1048 else if (ob == interface_->check_override_x_dead_keys )
1049 str = lyxrc.getDescription( LyXRC::RC_OVERRIDE_X_DEADKEYS );
1055 void FormPreferences::updateInterface()
1057 fl_set_input(interface_->input_popup_font,
1058 lyxrc.popup_font_name.c_str());
1059 fl_set_input(interface_->input_menu_font,
1060 lyxrc.menu_font_name.c_str());
1061 fl_set_input(interface_->input_popup_encoding,
1062 lyxrc.font_norm_menu.c_str());
1063 fl_set_input(interface_->input_bind_file,
1064 lyxrc.bind_file.c_str());
1065 fl_set_input(interface_->input_ui_file,
1066 lyxrc.ui_file.c_str());
1067 fl_set_button(interface_->check_override_x_dead_keys,
1068 lyxrc.override_x_deadkeys);
1072 void FormPreferences::applyLanguage()
1074 lyxrc.default_language = combo_default_lang->getline();
1076 int button = fl_get_button(language_->check_use_kbmap);
1077 string name_1 = combo_kbmap_1->getline();
1078 string name_2 = combo_kbmap_2->getline();
1080 button = ( !name_1.empty() && !name_2.empty() );
1081 lyxrc.use_kbmap = static_cast<bool>(button);
1084 vector<string>::iterator it =
1085 find( dirlist.second.begin(), dirlist.second.end(),
1087 vector<string>::size_type sel = it - dirlist.second.begin();
1088 lyxrc.primary_kbmap = dirlist.first[sel];
1090 it = find( dirlist.second.begin(), dirlist.second.end(),
1092 sel = it - dirlist.second.begin();
1093 lyxrc.secondary_kbmap = dirlist.first[sel];
1096 button = fl_get_button(language_->check_rtl_support);
1097 lyxrc.rtl_support = static_cast<bool>(button);
1099 button = fl_get_button(language_->check_auto_begin);
1100 lyxrc.language_auto_begin = static_cast<bool>(button);
1102 button = fl_get_button(language_->check_auto_end);
1103 lyxrc.language_auto_end = static_cast<bool>(button);
1105 button = fl_get_button(language_->check_mark_foreign);
1106 lyxrc.mark_foreign_language = static_cast<bool>(button);
1108 lyxrc.language_package = fl_get_input(language_->input_package);
1109 lyxrc.language_command_begin = fl_get_input(language_->input_command_begin);
1110 lyxrc.language_command_end = fl_get_input(language_->input_command_end);
1112 // Ensure that all is self-consistent.
1117 void FormPreferences::buildLanguage()
1119 language_ = build_language();
1121 fl_set_input_return(language_->input_package, FL_RETURN_CHANGED);
1122 fl_set_input_return(language_->input_command_begin, FL_RETURN_CHANGED);
1123 fl_set_input_return(language_->input_command_end, FL_RETURN_CHANGED);
1125 // The default_language is a combo-box and has to be inserted manually
1126 fl_freeze_form(language_->form);
1127 fl_addto_form(language_->form);
1129 FL_OBJECT * obj = language_->choice_default_lang;
1130 fl_deactivate_object(language_->choice_default_lang);
1131 combo_default_lang = new Combox(FL_COMBOX_DROPLIST);
1132 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
1133 combo_default_lang->shortcut("#L",1);
1134 combo_default_lang->setcallback(ComboLanguageCB, this);
1136 for (Languages::const_iterator cit = languages.begin();
1137 cit != languages.end(); cit++) {
1138 combo_default_lang->addto((*cit).second.lang());
1142 string dir = AddPath(system_lyxdir, "kbd");
1143 vector<string> dirlist = DirList(dir , "kmap");
1145 obj = language_->choice_kbmap_1;
1146 fl_deactivate_object(language_->choice_kbmap_1);
1147 combo_kbmap_1 = new Combox(FL_COMBOX_DROPLIST);
1148 combo_kbmap_1->add(obj->x, obj->y, obj->w, obj->h, 400);
1149 combo_kbmap_1->shortcut("#1",1);
1150 combo_kbmap_1->setcallback(ComboLanguageCB, this);
1152 for (vector<string>::const_iterator cit = dirlist.begin();
1153 cit != dirlist.end(); cit++) {
1154 combo_kbmap_1->addto(*cit);
1158 obj = language_->choice_kbmap_2;
1159 fl_deactivate_object(language_->choice_kbmap_2);
1160 combo_kbmap_2 = new Combox(FL_COMBOX_DROPLIST);
1161 combo_kbmap_2->add(obj->x, obj->y, obj->w, obj->h, 400);
1162 combo_kbmap_2->shortcut("#2",1);
1163 combo_kbmap_2->setcallback(ComboLanguageCB, this);
1165 for (vector<string>::const_iterator cit = dirlist.begin();
1166 cit != dirlist.end(); cit++) {
1167 combo_kbmap_2->addto(*cit);
1171 fl_unfreeze_form(language_->form);
1173 // set up the feedback mechanism
1174 fl_addto_form(language_->form);
1176 setPostHandler( language_->input_package );
1177 setPostHandler( language_->check_use_kbmap );
1179 // This is safe, as nothing is done to the pointer, other than
1180 // to use its address in a block-if statement.
1181 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_default_lang) );
1182 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_1) );
1183 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_2) );
1185 setPostHandler( language_->check_rtl_support );
1186 setPostHandler( language_->check_mark_foreign );
1187 setPostHandler( language_->check_auto_begin );
1188 setPostHandler( language_->check_auto_end );
1189 setPostHandler( language_->input_command_begin );
1190 setPostHandler( language_->input_command_end );
1194 // Activate/Deactivate the input fields dependent on the state of the
1201 FormPreferences::feedbackLanguage(FL_OBJECT const * const ob) const
1205 //if( !ob ) return string();
1209 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang )
1210 str = lyxrc.getDescription( LyXRC::RC_DEFAULT_LANGUAGE );
1211 else if (ob == language_->check_use_kbmap )
1212 str = lyxrc.getDescription( LyXRC::RC_KBMAP );
1213 else if (reinterpret_cast<Combox const *>(ob) == combo_kbmap_1)
1214 str = lyxrc.getDescription( LyXRC::RC_KBMAP_PRIMARY );
1215 else if (reinterpret_cast<Combox const *>(ob) == combo_kbmap_2 )
1216 str = lyxrc.getDescription( LyXRC::RC_KBMAP_SECONDARY );
1217 else if (ob == language_->check_rtl_support )
1218 str = lyxrc.getDescription( LyXRC::RC_RTL_SUPPORT );
1219 else if (ob == language_->check_auto_begin )
1220 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_BEGIN );
1221 else if (ob == language_->check_auto_end )
1222 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_END );
1223 else if (ob == language_->check_mark_foreign )
1224 str = lyxrc.getDescription( LyXRC::RC_MARK_FOREIGN_LANGUAGE );
1225 else if (ob == language_->input_package )
1226 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_PACKAGE );
1227 else if (ob == language_->input_command_begin )
1228 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_BEGIN );
1229 else if (ob == language_->input_command_end )
1230 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_END );
1236 bool FormPreferences::inputLanguage( FL_OBJECT const * const ob )
1238 bool activate = true;
1240 if (!ob || ob == language_->check_use_kbmap) {
1241 if (fl_get_button(language_->check_use_kbmap)) {
1242 combo_kbmap_1->activate();
1243 combo_kbmap_2->activate();
1245 combo_kbmap_1->deactivate();
1246 combo_kbmap_2->deactivate();
1254 void FormPreferences::updateLanguage()
1256 fl_set_button(language_->check_use_kbmap,
1259 combo_default_lang->select_text( lyxrc.default_language );
1261 if (lyxrc.use_kbmap) {
1262 string fullpath = lyxrc.primary_kbmap;
1263 vector<string>::iterator it =
1264 find( dirlist.first.begin(), dirlist.first.end(),
1266 vector<string>::size_type sel = it - dirlist.first.begin();
1267 combo_kbmap_1->select_text( dirlist.second[sel] );
1269 fullpath = lyxrc.secondary_kbmap;
1270 it = find( dirlist.first.begin(), dirlist.first.end(),
1272 sel = it - dirlist.first.begin();
1273 combo_kbmap_2->select_text( dirlist.second[sel] );
1275 combo_kbmap_1->select_text( "" );
1276 combo_kbmap_2->select_text( "" );
1279 fl_set_button(language_->check_rtl_support, lyxrc.rtl_support);
1280 fl_set_button(language_->check_auto_begin, lyxrc.language_auto_begin);
1281 fl_set_button(language_->check_auto_end, lyxrc.language_auto_end);
1282 fl_set_button(language_->check_mark_foreign,
1283 lyxrc.mark_foreign_language);
1285 fl_set_input(language_->input_package,
1286 lyxrc.language_package.c_str());
1287 fl_set_input(language_->input_command_begin,
1288 lyxrc.language_command_begin.c_str());
1289 fl_set_input(language_->input_command_end,
1290 lyxrc.language_command_end.c_str());
1292 // Activate/Deactivate the input fields dependent on the state of the
1298 void FormPreferences::applyLnFmisc() const
1300 lyxrc.show_banner = fl_get_button(lnf_misc_->check_banner);
1301 lyxrc.auto_region_delete = fl_get_button(lnf_misc_->
1302 check_auto_region_delete);
1303 lyxrc.exit_confirmation = fl_get_button(lnf_misc_->check_exit_confirm);
1304 lyxrc.display_shortcuts =
1305 fl_get_button(lnf_misc_->check_display_shrtcuts);
1306 lyxrc.new_ask_filename = fl_get_button(lnf_misc_->check_ask_new_file);
1307 lyxrc.cursor_follows_scrollbar =
1308 fl_get_button(lnf_misc_->check_cursor_follows_scrollbar);
1309 lyxrc.autosave = static_cast<unsigned int>
1310 (fl_get_counter_value(lnf_misc_->counter_autosave));
1311 lyxrc.wheel_jump = static_cast<unsigned int>
1312 (fl_get_counter_value(lnf_misc_->counter_wm_jump));
1316 void FormPreferences::buildLnFmisc()
1318 lnf_misc_ = build_lnf_misc();
1320 fl_set_counter_return(lnf_misc_->counter_autosave,
1322 fl_set_counter_return(lnf_misc_->counter_wm_jump,
1325 // set up the feedback mechanism
1326 fl_addto_form(lnf_misc_->form);
1328 setPostHandler( lnf_misc_->check_banner );
1329 setPostHandler( lnf_misc_->check_auto_region_delete );
1330 setPostHandler( lnf_misc_->check_exit_confirm );
1331 setPostHandler( lnf_misc_->check_display_shrtcuts );
1332 setPostHandler( lnf_misc_->counter_autosave );
1333 setPostHandler( lnf_misc_->check_ask_new_file );
1334 setPostHandler( lnf_misc_->check_cursor_follows_scrollbar );
1335 setPostHandler( lnf_misc_->counter_wm_jump );
1341 string const FormPreferences::feedbackLnFmisc(FL_OBJECT const * const ob) const
1345 //if( !ob ) return string();
1349 if (ob == lnf_misc_->check_banner )
1350 str = lyxrc.getDescription( LyXRC::RC_SHOW_BANNER );
1351 else if (ob == lnf_misc_->check_auto_region_delete )
1352 str = lyxrc.getDescription( LyXRC::RC_AUTOREGIONDELETE );
1353 else if (ob == lnf_misc_->check_exit_confirm )
1354 str = lyxrc.getDescription( LyXRC::RC_EXIT_CONFIRMATION );
1355 else if (ob == lnf_misc_->check_display_shrtcuts )
1356 str = lyxrc.getDescription( LyXRC::RC_DISPLAY_SHORTCUTS );
1357 else if (ob == lnf_misc_->check_ask_new_file )
1358 str = lyxrc.getDescription( LyXRC::RC_NEW_ASK_FILENAME );
1359 else if (ob == lnf_misc_->check_cursor_follows_scrollbar )
1360 str = lyxrc.getDescription( LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR );
1361 else if (ob == lnf_misc_->counter_autosave )
1362 str = lyxrc.getDescription( LyXRC::RC_AUTOSAVE );
1363 else if (ob == lnf_misc_->counter_wm_jump )
1364 str = lyxrc.getDescription( LyXRC::RC_WHEEL_JUMP );
1370 void FormPreferences::updateLnFmisc()
1372 fl_set_button(lnf_misc_->check_banner,
1374 fl_set_button(lnf_misc_->check_auto_region_delete,
1375 lyxrc.auto_region_delete);
1376 fl_set_button(lnf_misc_->check_exit_confirm,
1377 lyxrc.exit_confirmation);
1378 fl_set_button(lnf_misc_->check_display_shrtcuts,
1379 lyxrc.display_shortcuts);
1380 fl_set_button(lnf_misc_->check_ask_new_file,
1381 lyxrc.new_ask_filename);
1382 fl_set_button(lnf_misc_->check_cursor_follows_scrollbar,
1383 lyxrc.cursor_follows_scrollbar);
1384 fl_set_counter_value(lnf_misc_->counter_autosave,
1386 fl_set_counter_value(lnf_misc_->counter_wm_jump,
1391 void FormPreferences::applyOutputsMisc() const
1393 lyxrc.ascii_linelen = static_cast<unsigned int>
1394 (fl_get_counter_value(outputs_misc_->counter_line_len));
1395 lyxrc.fontenc = fl_get_input(outputs_misc_->input_tex_encoding);
1398 fl_get_choice(outputs_misc_->choice_default_papersize) - 1;
1399 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1401 lyxrc.ascii_roff_command = fl_get_input(outputs_misc_->input_ascii_roff);
1402 lyxrc.chktex_command = fl_get_input(outputs_misc_->input_checktex);
1406 void FormPreferences::buildOutputsMisc()
1408 outputs_misc_ = build_outputs_misc();
1410 fl_set_counter_return(outputs_misc_->counter_line_len,
1412 fl_set_input_return(outputs_misc_->input_tex_encoding,
1414 fl_set_input_return(outputs_misc_->input_ascii_roff,
1416 fl_set_input_return(outputs_misc_->input_checktex,
1418 fl_addto_choice(outputs_misc_->choice_default_papersize,
1419 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
1421 // set up the feedback mechanism
1422 fl_addto_form(outputs_misc_->form);
1424 setPostHandler( outputs_misc_->counter_line_len );
1425 setPostHandler( outputs_misc_->input_tex_encoding );
1426 setPostHandler( outputs_misc_->choice_default_papersize );
1427 setPostHandler( outputs_misc_->input_ascii_roff );
1428 setPostHandler( outputs_misc_->input_checktex );
1435 FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob) const
1439 //if( !ob ) return string();
1443 if (ob == outputs_misc_->counter_line_len )
1444 str = lyxrc.getDescription( LyXRC::RC_ASCII_LINELEN );
1445 else if (ob == outputs_misc_->input_tex_encoding )
1446 str = lyxrc.getDescription( LyXRC::RC_FONT_ENCODING );
1447 else if (ob == outputs_misc_->input_ascii_roff )
1448 str = lyxrc.getDescription( LyXRC::RC_ASCIIROFF_COMMAND );
1449 else if (ob == outputs_misc_->input_checktex )
1450 str = lyxrc.getDescription( LyXRC::RC_CHKTEX_COMMAND );
1451 else if (ob == outputs_misc_->choice_default_papersize )
1452 str = lyxrc.getDescription( LyXRC::RC_DEFAULT_PAPERSIZE );
1458 void FormPreferences::updateOutputsMisc()
1460 fl_set_counter_value(outputs_misc_->counter_line_len,
1461 lyxrc.ascii_linelen);
1462 fl_set_input(outputs_misc_->input_tex_encoding,
1463 lyxrc.fontenc.c_str());
1464 fl_set_choice(outputs_misc_->choice_default_papersize,
1465 lyxrc.default_papersize+1);
1466 fl_set_input(outputs_misc_->input_ascii_roff,
1467 lyxrc.ascii_roff_command.c_str());
1468 fl_set_input(outputs_misc_->input_checktex,
1469 lyxrc.chktex_command.c_str());
1473 void FormPreferences::applyPaths()
1475 lyxrc.document_path = fl_get_input(paths_->input_default_path);
1476 lyxrc.template_path = fl_get_input(paths_->input_template_path);
1478 int button = fl_get_button(paths_->check_use_temp_dir);
1479 string str = fl_get_input(paths_->input_temp_dir);
1480 if (!button ) str.erase();
1482 lyxrc.use_tempdir = button;
1483 lyxrc.tempdir_path = str;
1485 button = fl_get_button(paths_->check_last_files);
1486 str = fl_get_input(paths_->input_lastfiles);
1487 if (!button ) str.erase();
1489 lyxrc.check_lastfiles = button;
1490 lyxrc.lastfiles = str;
1491 lyxrc.num_lastfiles = static_cast<unsigned int>
1492 (fl_get_counter_value(paths_->counter_lastfiles));
1494 button = fl_get_button(paths_->check_make_backups);
1495 str = fl_get_input(paths_->input_backup_path);
1496 if (!button ) str.erase();
1498 lyxrc.make_backup = button;
1499 lyxrc.backupdir_path = str;
1501 lyxrc.lyxpipes = fl_get_input(paths_->input_serverpipe);
1508 void FormPreferences::buildPaths()
1510 paths_ = build_paths();
1512 fl_set_input_return(paths_->input_default_path, FL_RETURN_CHANGED);
1513 fl_set_input_return(paths_->input_template_path, FL_RETURN_CHANGED);
1514 fl_set_input_return(paths_->input_temp_dir, FL_RETURN_CHANGED);
1515 fl_set_input_return(paths_->input_lastfiles, FL_RETURN_CHANGED);
1516 fl_set_input_return(paths_->input_backup_path, FL_RETURN_CHANGED);
1517 fl_set_counter_return(paths_->counter_lastfiles, FL_RETURN_CHANGED);
1518 fl_set_input_return(paths_->input_serverpipe, FL_RETURN_CHANGED);
1520 // deactivate the browse buttons because they aren't implemented
1521 fl_deactivate_object(paths_->button_document_browse);
1522 fl_deactivate_object(paths_->button_template_browse);
1523 fl_deactivate_object(paths_->button_temp_dir_browse);
1524 fl_deactivate_object(paths_->button_lastfiles_browse);
1525 fl_deactivate_object(paths_->button_backup_path_browse);
1526 fl_deactivate_object(paths_->button_serverpipe_browse);
1527 fl_set_object_lcol(paths_->button_document_browse, FL_INACTIVE);
1528 fl_set_object_lcol(paths_->button_template_browse, FL_INACTIVE);
1529 fl_set_object_lcol(paths_->button_temp_dir_browse, FL_INACTIVE);
1530 fl_set_object_lcol(paths_->button_lastfiles_browse, FL_INACTIVE);
1531 fl_set_object_lcol(paths_->button_backup_path_browse, FL_INACTIVE);
1532 fl_set_object_lcol(paths_->button_serverpipe_browse, FL_INACTIVE);
1534 // set up the feedback mechanism
1535 fl_addto_form(paths_->form);
1537 setPostHandler( paths_->input_default_path );
1538 setPostHandler( paths_->button_document_browse );
1539 setPostHandler( paths_->counter_lastfiles );
1540 setPostHandler( paths_->input_template_path );
1541 setPostHandler( paths_->button_template_browse );
1542 setPostHandler( paths_->check_last_files );
1543 setPostHandler( paths_->button_temp_dir_browse );
1544 setPostHandler( paths_->input_lastfiles );
1545 setPostHandler( paths_->button_lastfiles_browse );
1546 setPostHandler( paths_->check_make_backups );
1547 setPostHandler( paths_->input_backup_path );
1548 setPostHandler( paths_->button_backup_path_browse );
1549 setPostHandler( paths_->input_serverpipe );
1550 setPostHandler( paths_->button_serverpipe_browse );
1551 setPostHandler( paths_->input_temp_dir );
1552 setPostHandler( paths_->check_use_temp_dir );
1558 string const FormPreferences::feedbackPaths( FL_OBJECT const * const ob ) const
1562 //if( !ob ) return string();
1566 if (ob == paths_->input_default_path )
1567 str = lyxrc.getDescription( LyXRC::RC_DOCUMENTPATH );
1568 else if (ob == paths_->input_template_path )
1569 str = lyxrc.getDescription( LyXRC::RC_TEMPLATEPATH );
1570 else if (ob == paths_->check_use_temp_dir )
1571 str = lyxrc.getDescription( LyXRC::RC_USETEMPDIR );
1572 else if (ob == paths_->input_temp_dir )
1573 str = lyxrc.getDescription( LyXRC::RC_TEMPDIRPATH );
1574 else if (ob == paths_->check_last_files )
1575 str = lyxrc.getDescription( LyXRC::RC_CHECKLASTFILES );
1576 else if (ob == paths_->input_lastfiles )
1577 str = lyxrc.getDescription( LyXRC::RC_LASTFILES );
1578 else if (ob == paths_->counter_lastfiles )
1579 str = lyxrc.getDescription( LyXRC::RC_NUMLASTFILES );
1580 else if (ob == paths_->check_make_backups )
1581 str = lyxrc.getDescription( LyXRC::RC_MAKE_BACKUP );
1582 else if (ob == paths_->input_backup_path )
1583 str = lyxrc.getDescription( LyXRC::RC_BACKUPDIR_PATH );
1584 else if (ob == paths_->input_serverpipe )
1585 str = lyxrc.getDescription( LyXRC::RC_SERVERPIPE );
1591 bool FormPreferences::inputPaths( FL_OBJECT const * const ob )
1593 // what kind of coding is this? Do you plan for a ob == NULL?
1594 // When is that allowed? (Lgb)
1597 bool activate = true;
1599 if (!ob || ob == paths_->check_use_temp_dir) {
1600 if (fl_get_button(paths_->check_use_temp_dir)) {
1601 fl_activate_object(paths_->input_temp_dir);
1602 fl_set_object_lcol(paths_->input_temp_dir,
1605 fl_deactivate_object(paths_->input_temp_dir);
1606 fl_set_object_lcol(paths_->input_temp_dir,
1611 if (!ob || ob == paths_->check_last_files) {
1612 if (fl_get_button(paths_->check_last_files)) {
1613 fl_activate_object(paths_->input_lastfiles);
1614 fl_set_object_lcol(paths_->input_lastfiles,
1617 fl_deactivate_object(paths_->input_lastfiles);
1618 fl_set_object_lcol(paths_->input_lastfiles,
1623 if (!ob || ob == paths_->check_make_backups) {
1624 if (fl_get_button(paths_->check_make_backups)) {
1625 fl_activate_object(paths_->input_backup_path);
1626 fl_set_object_lcol(paths_->input_backup_path,
1629 fl_deactivate_object(paths_->input_backup_path);
1630 fl_set_object_lcol(paths_->input_backup_path,
1635 if (!ob || ob == paths_->input_default_path) {
1636 string name = fl_get_input(paths_->input_default_path);
1637 if (!WriteableDir(name) )
1641 if (!ob || ob == paths_->input_template_path) {
1642 string name = fl_get_input(paths_->input_template_path);
1643 if (!ReadableDir(name) )
1647 if (!ob || ob == paths_->input_temp_dir) {
1648 string name = fl_get_input(paths_->input_temp_dir);
1649 if (fl_get_button(paths_->check_make_backups)
1651 && !WriteableDir(name) )
1655 if (!ob || ob == paths_->input_backup_path) {
1656 string name = fl_get_input(paths_->input_backup_path);
1657 if (fl_get_button(paths_->check_make_backups)
1659 && !WriteableDir(name) )
1663 if (!ob || ob == paths_->input_lastfiles) {
1664 string name = fl_get_input(paths_->input_lastfiles);
1665 if (fl_get_button(paths_->check_last_files)
1667 && !WriteableFile(name) )
1671 if (!ob || ob == paths_->input_serverpipe) {
1672 string name = fl_get_input(paths_->input_serverpipe);
1673 if (!name.empty()) {
1674 if (!WriteableFile(name, ".in"))
1676 if (!WriteableFile(name, ".out"))
1685 void FormPreferences::updatePaths()
1687 fl_set_input(paths_->input_default_path,
1688 lyxrc.document_path.c_str());
1689 fl_set_input(paths_->input_template_path,
1690 lyxrc.template_path.c_str());
1693 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
1695 fl_set_button(paths_->check_make_backups,
1697 fl_set_input(paths_->input_backup_path, str.c_str());
1700 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
1702 fl_set_button(paths_->check_use_temp_dir,
1704 fl_set_input(paths_->input_temp_dir, str.c_str());
1707 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
1709 fl_set_button(paths_->check_last_files,
1710 lyxrc.check_lastfiles);
1711 fl_set_input(paths_->input_lastfiles, str.c_str());
1712 fl_set_counter_value(paths_->counter_lastfiles,
1713 lyxrc.num_lastfiles);
1715 fl_set_input(paths_->input_serverpipe, lyxrc.lyxpipes.c_str());
1717 // Activate/Deactivate the input fields dependent on the state of the
1723 void FormPreferences::applyPrinter() const
1725 lyxrc.print_adapt_output = fl_get_button(printer_->check_adapt_output);
1726 lyxrc.print_command = fl_get_input(printer_->input_command);
1727 lyxrc.print_pagerange_flag = fl_get_input(printer_->input_page_range);
1728 lyxrc.print_copies_flag = fl_get_input(printer_->input_copies);
1729 lyxrc.print_reverse_flag = fl_get_input(printer_->input_reverse);
1730 lyxrc.print_to_printer = fl_get_input(printer_->input_to_printer);
1731 lyxrc.print_file_extension =
1732 fl_get_input(printer_->input_file_extension);
1733 lyxrc.print_spool_command =
1734 fl_get_input(printer_->input_spool_command);
1735 lyxrc.print_paper_flag = fl_get_input(printer_->input_paper_type);
1736 lyxrc.print_evenpage_flag = fl_get_input(printer_->input_even_pages);
1737 lyxrc.print_oddpage_flag = fl_get_input(printer_->input_odd_pages);
1738 lyxrc.print_collcopies_flag = fl_get_input(printer_->input_collated);
1739 lyxrc.print_landscape_flag = fl_get_input(printer_->input_landscape);
1740 lyxrc.print_to_file = fl_get_input(printer_->input_to_file);
1741 lyxrc.print_extra_options =
1742 fl_get_input(printer_->input_extra_options);
1743 lyxrc.print_spool_printerprefix =
1744 fl_get_input(printer_->input_spool_prefix);
1745 lyxrc.print_paper_dimension_flag =
1746 fl_get_input(printer_->input_paper_size);
1747 lyxrc.printer = fl_get_input(printer_->input_name);
1752 FormPreferences::feedbackPrinter(FL_OBJECT const * const ob) const
1756 //if( !ob ) return string();
1760 if (ob == printer_->input_command )
1761 str = lyxrc.getDescription( LyXRC::RC_PRINT_COMMAND );
1762 else if (ob == printer_->check_adapt_output )
1763 str = lyxrc.getDescription( LyXRC::RC_PRINT_ADAPTOUTPUT );
1764 else if (ob == printer_->input_to_printer )
1765 str = lyxrc.getDescription( LyXRC::RC_PRINTTOPRINTER );
1766 else if (ob == printer_->input_to_file )
1767 str = lyxrc.getDescription( LyXRC::RC_PRINTTOFILE );
1768 else if (ob == printer_->input_file_extension )
1769 str = lyxrc.getDescription( LyXRC::RC_PRINTFILEEXTENSION );
1770 else if (ob == printer_->input_extra_options )
1771 str = lyxrc.getDescription( LyXRC::RC_PRINTEXSTRAOPTIONS );
1772 else if (ob == printer_->input_spool_command )
1773 str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_COMMAND );
1774 else if (ob == printer_->input_spool_prefix )
1775 str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_PRINTERPREFIX );
1776 else if (ob == printer_->input_name )
1777 str = lyxrc.getDescription( LyXRC::RC_PRINTER );
1778 else if (ob == printer_->input_even_pages )
1779 str = lyxrc.getDescription( LyXRC::RC_PRINTEVENPAGEFLAG );
1780 else if (ob == printer_->input_odd_pages )
1781 str = lyxrc.getDescription( LyXRC::RC_PRINTODDPAGEFLAG );
1782 else if (ob == printer_->input_page_range )
1783 str = lyxrc.getDescription( LyXRC::RC_PRINTPAGERANGEFLAG );
1784 else if (ob == printer_->input_reverse )
1785 str = lyxrc.getDescription( LyXRC::RC_PRINTREVERSEFLAG );
1786 else if (ob == printer_->input_landscape )
1787 str = lyxrc.getDescription( LyXRC::RC_PRINTLANDSCAPEFLAG );
1788 else if (ob == printer_->input_copies )
1789 str = lyxrc.getDescription( LyXRC::RC_PRINTCOLLCOPIESFLAG );
1790 else if (ob == printer_->input_collated )
1791 str = lyxrc.getDescription( LyXRC::RC_PRINTCOPIESFLAG );
1792 else if (ob == printer_->input_paper_type )
1793 str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERFLAG );
1794 else if (ob == printer_->input_paper_size )
1795 str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERDIMENSIONFLAG );
1801 void FormPreferences::buildPrinter()
1803 printer_ = build_printer();
1805 fl_set_input_return(printer_->input_command, FL_RETURN_CHANGED);
1806 fl_set_input_return(printer_->input_page_range, FL_RETURN_CHANGED);
1807 fl_set_input_return(printer_->input_copies, FL_RETURN_CHANGED);
1808 fl_set_input_return(printer_->input_reverse, FL_RETURN_CHANGED);
1809 fl_set_input_return(printer_->input_to_printer, FL_RETURN_CHANGED);
1810 fl_set_input_return(printer_->input_file_extension, FL_RETURN_CHANGED);
1811 fl_set_input_return(printer_->input_spool_command, FL_RETURN_CHANGED);
1812 fl_set_input_return(printer_->input_paper_type, FL_RETURN_CHANGED);
1813 fl_set_input_return(printer_->input_even_pages, FL_RETURN_CHANGED);
1814 fl_set_input_return(printer_->input_odd_pages, FL_RETURN_CHANGED);
1815 fl_set_input_return(printer_->input_collated, FL_RETURN_CHANGED);
1816 fl_set_input_return(printer_->input_landscape, FL_RETURN_CHANGED);
1817 fl_set_input_return(printer_->input_to_file, FL_RETURN_CHANGED);
1818 fl_set_input_return(printer_->input_extra_options, FL_RETURN_CHANGED);
1819 fl_set_input_return(printer_->input_spool_prefix, FL_RETURN_CHANGED);
1820 fl_set_input_return(printer_->input_paper_size, FL_RETURN_CHANGED);
1821 fl_set_input_return(printer_->input_name, FL_RETURN_CHANGED);
1823 // set up the feedback mechanism
1824 fl_addto_form(printer_->form);
1826 setPostHandler( printer_->input_command );
1827 setPostHandler( printer_->input_page_range );
1828 setPostHandler( printer_->input_copies );
1829 setPostHandler( printer_->input_reverse );
1830 setPostHandler( printer_->input_to_printer );
1831 setPostHandler( printer_->input_file_extension );
1832 setPostHandler( printer_->input_spool_command );
1833 setPostHandler( printer_->input_paper_type );
1834 setPostHandler( printer_->input_even_pages );
1835 setPostHandler( printer_->input_odd_pages );
1836 setPostHandler( printer_->input_collated );
1837 setPostHandler( printer_->input_landscape );
1838 setPostHandler( printer_->input_to_file );
1839 setPostHandler( printer_->input_extra_options );
1840 setPostHandler( printer_->input_spool_prefix );
1841 setPostHandler( printer_->input_paper_size );
1842 setPostHandler( printer_->input_name );
1843 setPostHandler( printer_->check_adapt_output );
1849 void FormPreferences::updatePrinter()
1851 fl_set_button(printer_->check_adapt_output,
1852 lyxrc.print_adapt_output);
1853 fl_set_input(printer_->input_command,
1854 lyxrc.print_command.c_str());
1855 fl_set_input(printer_->input_page_range,
1856 lyxrc.print_pagerange_flag.c_str());
1857 fl_set_input(printer_->input_copies,
1858 lyxrc.print_copies_flag.c_str());
1859 fl_set_input(printer_->input_reverse,
1860 lyxrc.print_reverse_flag.c_str());
1861 fl_set_input(printer_->input_to_printer,
1862 lyxrc.print_to_printer.c_str());
1863 fl_set_input(printer_->input_file_extension,
1864 lyxrc.print_file_extension.c_str());
1865 fl_set_input(printer_->input_spool_command,
1866 lyxrc.print_spool_command.c_str());
1867 fl_set_input(printer_->input_paper_type,
1868 lyxrc.print_paper_flag.c_str());
1869 fl_set_input(printer_->input_even_pages,
1870 lyxrc.print_evenpage_flag.c_str());
1871 fl_set_input(printer_->input_odd_pages,
1872 lyxrc.print_oddpage_flag.c_str());
1873 fl_set_input(printer_->input_collated,
1874 lyxrc.print_collcopies_flag.c_str());
1875 fl_set_input(printer_->input_landscape,
1876 lyxrc.print_landscape_flag.c_str());
1877 fl_set_input(printer_->input_to_file,
1878 lyxrc.print_to_file.c_str());
1879 fl_set_input(printer_->input_extra_options,
1880 lyxrc.print_extra_options.c_str());
1881 fl_set_input(printer_->input_spool_prefix,
1882 lyxrc.print_spool_printerprefix.c_str());
1883 fl_set_input(printer_->input_paper_size,
1884 lyxrc.print_paper_dimension_flag.c_str());
1885 fl_set_input(printer_->input_name,
1886 lyxrc.printer.c_str());
1890 void FormPreferences::applyScreenFonts() const
1892 bool changed = false;
1894 string str = fl_get_input(screen_fonts_->input_roman);
1895 if (lyxrc.roman_font_name != str) {
1897 lyxrc.roman_font_name = str;
1900 str = fl_get_input(screen_fonts_->input_sans);
1901 if (lyxrc.sans_font_name != str) {
1903 lyxrc.sans_font_name = str;
1906 str = fl_get_input(screen_fonts_->input_typewriter);
1907 if (lyxrc.typewriter_font_name != str) {
1909 lyxrc.typewriter_font_name = str;
1912 str = fl_get_input(screen_fonts_->input_screen_encoding);
1913 if (lyxrc.font_norm != str) {
1915 lyxrc.font_norm = str;
1918 bool button = fl_get_button(screen_fonts_->check_scalable);
1919 if (lyxrc.use_scalable_fonts != button) {
1921 lyxrc.use_scalable_fonts = button;
1924 unsigned int ivalue = static_cast<unsigned int>
1925 (fl_get_counter_value(screen_fonts_->counter_zoom));
1926 if (lyxrc.zoom != ivalue) {
1928 lyxrc.zoom = ivalue;
1931 ivalue = static_cast<unsigned int>
1932 (fl_get_counter_value(screen_fonts_->counter_dpi));
1933 if (lyxrc.dpi != ivalue) {
1938 double dvalue = strToDbl(fl_get_input(screen_fonts_->input_tiny));
1939 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
1941 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
1944 dvalue = strToDbl(fl_get_input(screen_fonts_->input_script));
1945 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
1947 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
1950 dvalue = strToDbl(fl_get_input(screen_fonts_->input_footnote));
1951 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
1953 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
1956 dvalue = strToDbl(fl_get_input(screen_fonts_->input_small));
1957 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
1959 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
1962 dvalue = strToDbl(fl_get_input(screen_fonts_->input_normal));
1963 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
1965 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
1968 dvalue = strToDbl(fl_get_input(screen_fonts_->input_large));
1969 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
1971 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
1974 dvalue = strToDbl(fl_get_input(screen_fonts_->input_larger));
1975 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
1977 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
1980 dvalue = strToDbl(fl_get_input(screen_fonts_->input_largest));
1981 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
1983 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
1986 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huge));
1987 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
1989 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
1992 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huger));
1993 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
1995 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
1999 // Now update the buffers
2000 // Can anything below here affect the redraw process?
2001 lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
2006 void FormPreferences::buildScreenFonts()
2008 screen_fonts_ = build_screen_fonts();
2010 fl_set_input_return(screen_fonts_->input_roman, FL_RETURN_CHANGED);
2011 fl_set_input_return(screen_fonts_->input_sans, FL_RETURN_CHANGED);
2012 fl_set_input_return(screen_fonts_->input_typewriter,
2014 fl_set_input_return(screen_fonts_->input_screen_encoding,
2016 fl_set_counter_return(screen_fonts_->counter_zoom, FL_RETURN_CHANGED);
2017 fl_set_counter_return(screen_fonts_->counter_dpi, FL_RETURN_CHANGED);
2018 fl_set_input_return(screen_fonts_->input_tiny, FL_RETURN_CHANGED);
2019 fl_set_input_return(screen_fonts_->input_script, FL_RETURN_CHANGED);
2020 fl_set_input_return(screen_fonts_->input_footnote, FL_RETURN_CHANGED);
2021 fl_set_input_return(screen_fonts_->input_small, FL_RETURN_CHANGED);
2022 fl_set_input_return(screen_fonts_->input_normal, FL_RETURN_CHANGED);
2023 fl_set_input_return(screen_fonts_->input_large, FL_RETURN_CHANGED);
2024 fl_set_input_return(screen_fonts_->input_larger, FL_RETURN_CHANGED);
2025 fl_set_input_return(screen_fonts_->input_largest, FL_RETURN_CHANGED);
2026 fl_set_input_return(screen_fonts_->input_huge, FL_RETURN_CHANGED);
2027 fl_set_input_return(screen_fonts_->input_huger, FL_RETURN_CHANGED);
2029 fl_set_input_filter(screen_fonts_->input_tiny,
2030 fl_unsigned_int_filter);
2031 fl_set_input_filter(screen_fonts_->input_script,
2032 fl_unsigned_int_filter);
2033 fl_set_input_filter(screen_fonts_->input_footnote,
2034 fl_unsigned_int_filter);
2035 fl_set_input_filter(screen_fonts_->input_small,
2036 fl_unsigned_int_filter);
2037 fl_set_input_filter(screen_fonts_->input_normal,
2038 fl_unsigned_int_filter);
2039 fl_set_input_filter(screen_fonts_->input_large,
2040 fl_unsigned_int_filter);
2041 fl_set_input_filter(screen_fonts_->input_larger,
2042 fl_unsigned_int_filter);
2043 fl_set_input_filter(screen_fonts_->input_largest,
2044 fl_unsigned_int_filter);
2045 fl_set_input_filter(screen_fonts_->input_huge,
2046 fl_unsigned_int_filter);
2047 fl_set_input_filter(screen_fonts_->input_huger,
2048 fl_unsigned_int_filter);
2050 // set up the feedback mechanism
2051 fl_addto_form(screen_fonts_->form);
2053 setPostHandler( screen_fonts_->input_roman );
2054 setPostHandler( screen_fonts_->input_sans );
2055 setPostHandler( screen_fonts_->input_typewriter );
2056 setPostHandler( screen_fonts_->counter_zoom );
2057 setPostHandler( screen_fonts_->counter_dpi );
2058 setPostHandler( screen_fonts_->check_scalable );
2059 setPostHandler( screen_fonts_->input_screen_encoding );
2060 setPostHandler( screen_fonts_->input_tiny );
2061 setPostHandler( screen_fonts_->input_script );
2062 setPostHandler( screen_fonts_->input_footnote );
2063 setPostHandler( screen_fonts_->input_small );
2064 setPostHandler( screen_fonts_->input_large );
2065 setPostHandler( screen_fonts_->input_larger );
2066 setPostHandler( screen_fonts_->input_largest );
2067 setPostHandler( screen_fonts_->input_normal );
2068 setPostHandler( screen_fonts_->input_huge );
2069 setPostHandler( screen_fonts_->input_huger );
2076 FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob ) const
2080 //if( !ob ) return string();
2084 if (ob == screen_fonts_->input_roman )
2085 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ROMAN );
2086 else if (ob == screen_fonts_->input_sans )
2087 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SANS );
2088 else if (ob == screen_fonts_->input_typewriter )
2089 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_TYPEWRITER );
2090 else if (ob == screen_fonts_->check_scalable )
2091 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SCALABLE );
2092 else if (ob == screen_fonts_->input_screen_encoding )
2093 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING );
2094 else if (ob == screen_fonts_->counter_zoom )
2095 str = lyxrc.getDescription( LyXRC::RC_SCREEN_ZOOM );
2096 else if (ob == screen_fonts_->counter_dpi )
2097 str = lyxrc.getDescription( LyXRC::RC_SCREEN_DPI );
2098 else if (ob == screen_fonts_->input_tiny
2099 || ob == screen_fonts_->input_script
2100 || ob == screen_fonts_->input_footnote
2101 || ob == screen_fonts_->input_small
2102 || ob == screen_fonts_->input_large
2103 || ob == screen_fonts_->input_larger
2104 || ob == screen_fonts_->input_larger
2105 || ob == screen_fonts_->input_largest
2106 || ob == screen_fonts_->input_normal
2107 || ob == screen_fonts_->input_huge
2108 || ob == screen_fonts_->input_huger )
2109 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SIZES );
2115 bool FormPreferences::inputScreenFonts()
2117 bool activate = true;
2120 // Make sure that all fonts all have positive entries
2121 // Also note that an empty entry is returned as 0.0 by strToDbl
2122 if (0.0 >= strToDbl(fl_get_input(screen_fonts_->input_tiny))
2123 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_script))
2124 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_footnote))
2125 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_small))
2126 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_normal))
2127 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_large))
2128 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_larger))
2129 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_largest))
2130 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huge))
2131 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huger))) {
2133 str = N_("WARNING! Fonts must be positive!");
2135 // Fontsizes -- tiny < script < footnote etc.
2136 } else if (strToDbl(fl_get_input(screen_fonts_->input_tiny)) >
2137 strToDbl(fl_get_input(screen_fonts_->input_script)) ||
2138 strToDbl(fl_get_input(screen_fonts_->input_script)) >
2139 strToDbl(fl_get_input(screen_fonts_->input_footnote)) ||
2140 strToDbl(fl_get_input(screen_fonts_->input_footnote)) >
2141 strToDbl(fl_get_input(screen_fonts_->input_small)) ||
2142 strToDbl(fl_get_input(screen_fonts_->input_small)) >
2143 strToDbl(fl_get_input(screen_fonts_->input_normal)) ||
2144 strToDbl(fl_get_input(screen_fonts_->input_normal)) >
2145 strToDbl(fl_get_input(screen_fonts_->input_large)) ||
2146 strToDbl(fl_get_input(screen_fonts_->input_large)) >
2147 strToDbl(fl_get_input(screen_fonts_->input_larger)) ||
2148 strToDbl(fl_get_input(screen_fonts_->input_larger)) >
2149 strToDbl(fl_get_input(screen_fonts_->input_largest)) ||
2150 strToDbl(fl_get_input(screen_fonts_->input_largest)) >
2151 strToDbl(fl_get_input(screen_fonts_->input_huge)) ||
2152 strToDbl(fl_get_input(screen_fonts_->input_huge)) >
2153 strToDbl(fl_get_input(screen_fonts_->input_huger))) {
2156 str = N_("WARNING! Fonts must be input in the order tiny > script>\nfootnote > small > normal > large > larger > largest > huge > huger.");
2160 fl_set_object_label(dialog_->text_warning, str.c_str());
2161 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2168 void FormPreferences::updateScreenFonts()
2170 fl_set_input(screen_fonts_->input_roman,
2171 lyxrc.roman_font_name.c_str());
2172 fl_set_input(screen_fonts_->input_sans,
2173 lyxrc.sans_font_name.c_str());
2174 fl_set_input(screen_fonts_->input_typewriter,
2175 lyxrc.typewriter_font_name.c_str());
2176 fl_set_input(screen_fonts_->input_screen_encoding,
2177 lyxrc.font_norm.c_str());
2178 fl_set_button(screen_fonts_->check_scalable,
2179 lyxrc.use_scalable_fonts);
2180 fl_set_counter_value(screen_fonts_->counter_zoom, lyxrc.zoom);
2181 fl_set_counter_value(screen_fonts_->counter_dpi, lyxrc.dpi);
2182 fl_set_input(screen_fonts_->input_tiny,
2183 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
2184 fl_set_input(screen_fonts_->input_script,
2185 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
2186 fl_set_input(screen_fonts_->input_footnote,
2187 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
2188 fl_set_input(screen_fonts_->input_small,
2189 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
2190 fl_set_input(screen_fonts_->input_normal,
2191 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
2192 fl_set_input(screen_fonts_->input_large,
2193 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
2194 fl_set_input(screen_fonts_->input_larger,
2195 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
2196 fl_set_input(screen_fonts_->input_largest,
2197 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
2198 fl_set_input(screen_fonts_->input_huge,
2199 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
2200 fl_set_input(screen_fonts_->input_huger,
2201 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
2205 void FormPreferences::applySpellChecker()
2208 string choice = "none";
2209 switch (fl_get_choice(spellchecker_->choice_spell_command)) {
2222 lyxrc.isp_command = choice;
2224 // If spell checker == "none", all other input set to off.
2225 if (fl_get_choice(spellchecker_->choice_spell_command) == 1) {
2226 lyxrc.isp_use_alt_lang = false;
2227 lyxrc.isp_alt_lang.erase();
2229 lyxrc.isp_use_esc_chars = false;
2230 lyxrc.isp_esc_chars.erase();
2232 lyxrc.isp_use_pers_dict = false;
2233 lyxrc.isp_pers_dict.erase();
2235 lyxrc.isp_accept_compound = false;
2236 lyxrc.isp_use_input_encoding = false;
2238 int button = fl_get_button(spellchecker_->check_alt_lang);
2239 choice = fl_get_input(spellchecker_->input_alt_lang);
2240 if (button && choice.empty() ) button = 0;
2241 if (!button ) choice.erase();
2243 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
2244 lyxrc.isp_alt_lang = choice;
2246 button = fl_get_button(spellchecker_->check_escape_chars);
2247 choice = fl_get_input(spellchecker_->input_escape_chars);
2248 if (button && choice.empty() ) button = 0;
2249 if (!button ) choice.erase();
2251 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
2252 lyxrc.isp_esc_chars = choice;
2254 button = fl_get_button(spellchecker_->check_personal_dict);
2255 choice = fl_get_input(spellchecker_->input_personal_dict);
2256 if (button && choice.empty() ) button = 0;
2257 if (!button ) choice.erase();
2259 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
2260 lyxrc.isp_pers_dict = choice;
2262 button = fl_get_button(spellchecker_->check_compound_words);
2263 lyxrc.isp_accept_compound = static_cast<bool>(button);
2265 button = fl_get_button(spellchecker_->check_input_enc);
2266 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
2270 updateSpellChecker();
2274 void FormPreferences::buildSpellchecker()
2276 spellchecker_ = build_spellchecker();
2278 fl_addto_choice(spellchecker_->choice_spell_command,
2279 _(" none | ispell | aspell "));
2280 fl_set_input_return(spellchecker_->input_alt_lang,
2282 fl_set_input_return(spellchecker_->input_escape_chars,
2284 fl_set_input_return(spellchecker_->input_personal_dict,
2287 // deactivate the browse button because it isn't implemented
2288 fl_deactivate_object(spellchecker_->button_personal_dict);
2289 fl_set_object_lcol(spellchecker_->button_personal_dict,
2292 // set up the feedback mechanism
2293 fl_addto_form(spellchecker_->form);
2295 setPostHandler( spellchecker_->choice_spell_command );
2296 setPostHandler( spellchecker_->check_alt_lang );
2297 setPostHandler( spellchecker_->input_alt_lang );
2298 setPostHandler( spellchecker_->check_escape_chars );
2299 setPostHandler( spellchecker_->input_escape_chars );
2300 setPostHandler( spellchecker_->check_personal_dict );
2301 setPostHandler( spellchecker_->input_personal_dict );
2302 setPostHandler( spellchecker_->button_personal_dict );
2303 setPostHandler( spellchecker_->check_compound_words );
2304 setPostHandler( spellchecker_->check_input_enc );
2311 FormPreferences::feedbackSpellChecker(FL_OBJECT const * const ob) const
2315 //if( !ob ) return string();
2319 if (ob == spellchecker_->choice_spell_command )
2320 str = lyxrc.getDescription( LyXRC::RC_SPELL_COMMAND );
2321 else if (ob == spellchecker_->check_alt_lang )
2322 str = lyxrc.getDescription( LyXRC::RC_USE_ALT_LANG );
2323 else if (ob == spellchecker_->input_alt_lang )
2324 str = lyxrc.getDescription( LyXRC::RC_ALT_LANG );
2325 else if (ob == spellchecker_->check_escape_chars )
2326 str = lyxrc.getDescription( LyXRC::RC_USE_ESC_CHARS );
2327 else if (ob == spellchecker_->input_escape_chars )
2328 str = lyxrc.getDescription( LyXRC::RC_ESC_CHARS );
2329 else if (ob == spellchecker_->check_personal_dict )
2330 str = lyxrc.getDescription( LyXRC::RC_USE_PERS_DICT );
2331 else if (ob == spellchecker_->input_personal_dict )
2332 str = lyxrc.getDescription( LyXRC::RC_PERS_DICT );
2333 else if (ob == spellchecker_->check_compound_words )
2334 str = lyxrc.getDescription( LyXRC::RC_ACCEPT_COMPOUND );
2335 else if (ob == spellchecker_->check_input_enc )
2336 str = lyxrc.getDescription( LyXRC::RC_USE_INP_ENC );
2342 bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob )
2346 // Allow/dissallow input
2348 // If spell checker == "none", disable all input.
2349 if (!ob || ob == spellchecker_->choice_spell_command) {
2350 if (fl_get_choice(spellchecker_->choice_spell_command) == 1) {
2351 fl_deactivate_object( spellchecker_->check_alt_lang );
2352 fl_deactivate_object( spellchecker_->input_alt_lang );
2353 fl_deactivate_object( spellchecker_->check_escape_chars );
2354 fl_deactivate_object( spellchecker_->input_escape_chars );
2355 fl_deactivate_object( spellchecker_->check_personal_dict );
2356 fl_deactivate_object( spellchecker_->input_personal_dict );
2357 fl_deactivate_object( spellchecker_->check_compound_words );
2358 fl_deactivate_object( spellchecker_->check_input_enc );
2361 fl_activate_object( spellchecker_->check_alt_lang );
2362 fl_activate_object( spellchecker_->check_escape_chars );
2363 fl_activate_object( spellchecker_->check_personal_dict );
2364 fl_activate_object( spellchecker_->check_compound_words );
2365 fl_activate_object( spellchecker_->check_input_enc );
2369 if (!ob || ob == spellchecker_->check_alt_lang) {
2370 if (fl_get_button(spellchecker_->check_alt_lang)) {
2371 fl_activate_object(spellchecker_->input_alt_lang);
2372 fl_set_object_lcol(spellchecker_->input_alt_lang,
2375 fl_deactivate_object(spellchecker_->input_alt_lang);
2376 fl_set_object_lcol(spellchecker_->input_alt_lang,
2381 if (!ob || ob == spellchecker_->check_escape_chars) {
2382 if (fl_get_button(spellchecker_->check_escape_chars)) {
2383 fl_activate_object(spellchecker_->input_escape_chars);
2384 fl_set_object_lcol(spellchecker_->input_escape_chars,
2387 fl_deactivate_object(spellchecker_->input_escape_chars);
2388 fl_set_object_lcol(spellchecker_->input_escape_chars,
2393 if (!ob || ob == spellchecker_->check_personal_dict) {
2394 if (fl_get_button(spellchecker_->check_personal_dict)) {
2395 fl_activate_object(spellchecker_->input_personal_dict);
2396 fl_set_object_lcol(spellchecker_->input_personal_dict,
2399 fl_deactivate_object(spellchecker_->input_personal_dict);
2400 fl_set_object_lcol(spellchecker_->input_personal_dict,
2405 return true; // All input is valid!
2409 void FormPreferences::updateSpellChecker()
2412 if (lyxrc.isp_command == "none" )
2414 else if (lyxrc.isp_command == "ispell" )
2416 else if (lyxrc.isp_command == "aspell" )
2418 fl_set_choice(spellchecker_->choice_spell_command, choice);
2421 if (lyxrc.isp_use_alt_lang ) str = lyxrc.isp_alt_lang;
2423 fl_set_button(spellchecker_->check_alt_lang,
2424 lyxrc.isp_use_alt_lang);
2425 fl_set_input(spellchecker_->input_alt_lang, str.c_str());
2428 if (lyxrc.isp_use_esc_chars ) str = lyxrc.isp_esc_chars;
2430 fl_set_button(spellchecker_->check_escape_chars,
2431 lyxrc.isp_use_esc_chars);
2432 fl_set_input(spellchecker_->input_escape_chars, str.c_str());
2435 if (lyxrc.isp_use_pers_dict ) str = lyxrc.isp_pers_dict;
2437 fl_set_button(spellchecker_->check_personal_dict,
2438 lyxrc.isp_use_pers_dict);
2439 fl_set_input(spellchecker_->input_personal_dict, str.c_str());
2441 fl_set_button(spellchecker_->check_compound_words,
2442 lyxrc.isp_accept_compound);
2443 fl_set_button(spellchecker_->check_input_enc,
2444 lyxrc.isp_use_input_encoding);
2446 // Activate/Deactivate the input fields dependent on the state of the
2448 inputSpellChecker( 0 );
2452 bool FormPreferences::WriteableDir(string const & name) const
2454 bool success = true;
2457 if (!AbsolutePath(name)) {
2459 str = N_("WARNING! The absolute path is required.");
2462 FileInfo const tp(name);
2463 if (success && !tp.isDir()) {
2465 str = N_("WARNING! Directory does not exist.");
2468 if (success && !tp.writable()) {
2470 str = N_("WARNING! Cannot write to this directory.");
2474 fl_set_object_label(dialog_->text_warning, str.c_str());
2475 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2482 bool FormPreferences::ReadableDir(string const & name) const
2484 bool success = true;
2487 if (!AbsolutePath(name)) {
2489 str = N_("WARNING! The absolute path is required.");
2492 FileInfo const tp(name);
2493 if (success && !tp.isDir()) {
2495 str = N_("WARNING! Directory does not exist.");
2498 if (success && !tp.readable()) {
2500 str = N_("WARNING! Cannot read this directory.");
2504 fl_set_object_label(dialog_->text_warning, str.c_str());
2505 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2512 bool FormPreferences::WriteableFile(string const & name,
2513 string const & suffix) const
2515 // A writeable file is either:
2516 // * An existing file to which we have write access, or
2517 // * A file that doesn't yet exist but that would exist in a writeable
2520 bool success = true;
2525 str = N_("WARNING! No file input.");
2528 string const dir = OnlyPath(name);
2529 if (success && !AbsolutePath(dir)) {
2531 str = N_("WARNING! The absolute path is required.");
2535 // This is not a nice way to use FileInfo (Lgb)
2547 // This should be equivalent (Lgb)
2553 if (success && !d.isDir()) {
2555 str = N_("WARNING! Directory does not exist.");
2558 if (success && !d.writable()) {
2560 str = N_("WARNING! Cannot write to this directory.");
2563 FileInfo f(name+suffix);
2564 if (success && (dir == name || f.isDir())) {
2566 str = N_("WARNING! A file is required, not a directory.");
2569 if (success && (f.exist() && !f.writable())) {
2571 str = N_("WARNING! Cannot write to this file.");
2575 fl_set_object_label(dialog_->text_warning, str.c_str());
2576 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2583 void FormPreferences::ComboLanguageCB(int, void * v, Combox * combox)
2585 Assert(v && combox);
2586 FormPreferences * pre = static_cast<FormPreferences*>(v);
2587 // This is safe, as nothing is done to the pointer, other than
2588 // to use its address in a block-if statement.
2589 pre->bc_.valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
2593 // C functions for the timer callback used to give the user feedback
2594 C_GENERICCB(FormPreferences, FeedbackCB)
2597 void FormPreferences::FeedbackCB(FL_OBJECT * ob, long)
2603 FormPreferences * pre =
2604 static_cast<FormPreferences*>(ob->form->u_vdata);
2607 pre->feedback( pre->feedbackObj );
2612 int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event,
2613 FL_Coord, FL_Coord, int, void *)
2615 // can occur when form is being deleted. This seems an easier fix than
2616 // a call "fl_set_object_posthandler(ob, 0)" for each and every object
2617 // in the destructor.
2619 if (!ob->form ) return 0;
2621 FormPreferences * pre =
2622 static_cast<FormPreferences*>(ob->form->u_vdata);
2623 pre->feedbackPost(ob, event);
2628 // post_handler for feedback messages
2629 void FormPreferences::feedbackPost(FL_OBJECT * ob, int event)
2635 // We do not test for empty help here, since this can never happen
2636 if (event == FL_ENTER) {
2637 // Used as a placeholder for ob, so that we don't have to
2638 // a horrible reinterpret_cast to long and pass it as an
2639 // argument in fl_set_object_callback.
2641 fl_set_object_callback(dialog_->timer_feedback,
2642 C_FormPreferencesFeedbackCB,
2644 fl_set_timer(dialog_->timer_feedback, 0.5);
2645 } else if (event != FL_MOTION) {
2646 fl_set_timer(dialog_->timer_feedback, 0);
2648 fl_set_object_label(dialog_->text_warning, "");
2653 void FormPreferences::setPostHandler(FL_OBJECT * ob) const
2659 fl_set_object_posthandler(ob, C_FormPreferencesFeedbackPost);