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"
33 #ifdef SIGC_CXX_NAMESPACES
43 extern string fmt(char const * fmtstr ...);
44 extern Languages languages;
46 typedef pair<string, FormPreferences::RGB> X11Colour;
48 static vector<X11Colour> colourDB;
49 static string const colourFile("/usr/lib/X11/rgb.txt");
52 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
53 : FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
55 converters_tab_(0), inputs_tab_(0), look_n_feel_tab_(0),
56 outputs_tab_(0), usage_tab_(0),
57 colours_(0), converters_(0), formats_(0), inputs_misc_(0),
58 interface_(0), language_(0), lnf_misc_(0), outputs_misc_(0),
59 paths_(0), printer_(0), screen_fonts_(0), spellchecker_(0),
60 combo_default_lang(0), combo_kbmap_1(0), combo_kbmap_2(0),
63 // let the dialog be shown
64 // This is a permanent connection so we won't bother
65 // storing a copy because we won't be disconnecting.
66 d->showPreferences.connect(slot(this, &FormPreferences::show));
70 FormPreferences::~FormPreferences()
72 delete combo_default_lang;
76 delete converters_tab_;
78 delete look_n_feel_tab_;
95 // Must delete dialog last or we'll end up with a SIGSEGV trying to
96 // access dialog_->timer_feedback in feedbackPost().
101 FL_FORM * FormPreferences::form() const
103 if (dialog_) return dialog_->form;
108 void FormPreferences::ok()
111 lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
115 void FormPreferences::hide()
117 // We need to hide the active tabfolder otherwise we get a
118 // BadDrawable error from X windows and LyX crashes without saving.
119 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
121 && outer_form->visible) {
122 fl_hide_form(outer_form);
128 void FormPreferences::build()
130 dialog_ = build_preferences();
132 // manage the restore, save, apply and cancel/close buttons
133 bc_.setOK(dialog_->button_ok);
134 bc_.setApply(dialog_->button_apply);
135 bc_.setCancel(dialog_->button_cancel);
136 bc_.setUndoAll(dialog_->button_restore);
139 // Workaround dumb xforms sizing bug
143 // build the tab folders
144 converters_tab_ = build_outer_tab();
145 look_n_feel_tab_ = build_outer_tab();
146 inputs_tab_ = build_outer_tab();
147 outputs_tab_ = build_outer_tab();
148 usage_tab_ = build_outer_tab();
150 // build actual tabfolder contents
151 // these will become nested tabfolders
165 // Now add them to the tabfolder
166 fl_addto_tabfolder(dialog_->tabfolder_prefs,
168 look_n_feel_tab_->form);
169 fl_addto_tabfolder(dialog_->tabfolder_prefs,
172 fl_addto_tabfolder(dialog_->tabfolder_prefs,
174 converters_tab_->form);
175 fl_addto_tabfolder(dialog_->tabfolder_prefs,
178 fl_addto_tabfolder(dialog_->tabfolder_prefs,
182 // now build the nested tabfolders
183 // Starting with look and feel
184 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
186 screen_fonts_->form);
187 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
190 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
193 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
197 // then build converters
198 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
201 fl_addto_tabfolder(converters_tab_->tabfolder_outer,
206 // Paths should probably go in a few outer_tab called Files
207 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
210 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
214 // then building outputs
215 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
218 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
220 outputs_misc_->form);
222 // then building usage
223 fl_addto_tabfolder(usage_tab_->tabfolder_outer,
225 spellchecker_->form);
226 fl_addto_tabfolder(usage_tab_->tabfolder_outer,
232 void FormPreferences::apply()
234 // set the new lyxrc entries
235 // many of these need to trigger other functions when the assignment
236 // is made. For example, screen zoom and font types. These could be
237 // handled either by signals/slots in lyxrc or just directly call the
238 // associated functions here.
239 // There are other problems with this scheme. We really should check
240 // what we copy to make sure that it really is necessary to do things
241 // like update the screen fonts because that flushes the textcache
242 // and other stuff which may cost us a lot on slower/high-load machines.
259 void FormPreferences::feedback( FL_OBJECT * ob )
263 if (ob->form->fdui == colours_) {
264 str = feedbackColours( ob );
265 } else if (ob->form->fdui == converters_) {
266 str = feedbackConverters( ob );
267 } else if (ob->form->fdui == formats_) {
268 str = feedbackFormats( ob );
269 } else if (ob->form->fdui == inputs_misc_) {
270 str = feedbackInputsMisc( ob );
271 } else if (ob->form->fdui == interface_) {
272 str = feedbackInterface( ob );
273 } else if (ob->form->fdui == language_) {
274 str = feedbackLanguage( ob );
275 } else if (ob->form->fdui == lnf_misc_) {
276 str = feedbackLnFmisc( ob );
277 } else if (ob->form->fdui == outputs_misc_) {
278 str = feedbackOutputsMisc( ob );
279 } else if (ob->form->fdui == paths_) {
280 str = feedbackPaths( ob );
281 } else if (ob->form->fdui == printer_) {
282 str = feedbackPrinter( ob );
283 } else if (ob->form->fdui == screen_fonts_) {
284 str = feedbackScreenFonts( ob );
285 } else if (ob->form->fdui == spellchecker_) {
286 str = feedbackSpellChecker( ob );
289 str = formatted( str, dialog_->text_warning->w-10,
290 FL_SMALL_SIZE, FL_NORMAL_STYLE );
292 fl_set_object_label(dialog_->text_warning, str.c_str());
293 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
297 bool FormPreferences::input(FL_OBJECT * ob, long)
299 bool activate = true;
301 // whatever checks you need to ensure the user hasn't entered
302 // some totally ridiculous value somewhere. Change activate to suit.
303 // comments before each test describe what is _valid_
305 if (ob->form->fdui == colours_) {
306 if (! inputColours( ob ) )
308 } else if (ob->form->fdui == language_) {
309 if (! inputLanguage( ob ) )
311 } else if (ob->form->fdui == paths_) {
312 if (! inputPaths( ob ) )
314 } else if (ob->form->fdui == screen_fonts_) {
315 if (! inputScreenFonts() )
317 } else if (ob->form->fdui == spellchecker_) {
318 if (! inputSpellChecker( 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();
356 obj = colours_->valslider_red;
357 fl_set_slider_bounds(obj, 0, 255);
358 fl_set_slider_precision(obj, 0);
359 fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
361 obj = colours_->valslider_green;
362 fl_set_slider_bounds(obj, 0, 255);
363 fl_set_slider_precision(obj, 0);
364 fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
366 obj = colours_->valslider_blue;
367 fl_set_slider_bounds(obj, 0, 255);
368 fl_set_slider_precision(obj, 0);
369 fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
371 fl_set_object_color(colours_->button_colour,
372 FL_FREE_COL4, FL_FREE_COL4);
374 fl_set_input_return(colours_->input_name, FL_RETURN_END_CHANGED);
376 if (ColoursLoadBrowser(colourFile) )
377 fl_set_input(colours_->input_name, colourFile.c_str());
379 fl_set_input(colours_->input_name, N_("No file found"));
381 // deactivate the browse button because it isn't implemented
382 fl_deactivate_object(colours_->button_browse);
383 fl_set_object_lcol(colours_->button_browse, FL_INACTIVE);
387 string const FormPreferences::feedbackColours( FL_OBJECT const * const ) const
393 bool FormPreferences::inputColours( FL_OBJECT const * const ob )
395 bool activate = true;
397 if (ob == colours_->browser_x11) {
398 int i = fl_get_browser(colours_->browser_x11);
400 ColoursUpdateBrowser(i-1);
403 } else if (ob == colours_->valslider_red
404 || ob == colours_->valslider_green
405 || ob == colours_->valslider_blue) {
408 } else if (ob == colours_->input_name) {
409 string file = fl_get_input(colours_->input_name);
410 if (ColoursLoadBrowser(file) )
411 fl_set_input(colours_->input_name, file.c_str());
412 else if (ColoursLoadBrowser(colourFile) )
413 fl_set_input(colours_->input_name, colourFile.c_str());
415 fl_set_input(colours_->input_name, N_("No file found"));
422 bool FormPreferences::ColoursLoadBrowser(string const & filename)
426 if (!lex.setFile(filename))
429 istream & is = lex.getStream();
433 vector<string> names;
440 if (line[0] != '!') {
444 istringstream iss(line);
445 iss >> col.r >> col.g >> col.b;
449 if (!name.empty() ) name += " ";
453 // remove redundant entries on the fly
454 bool add = cols.empty();
456 vector<RGB>::const_iterator it =
457 find( cols.begin(), cols.end(), col );
458 add = (it == cols.end());
462 name = lowercase( name );
463 if (name == "gray0" ) name = "black";
464 if (name == "gray100" ) name = "white";
466 if (name == "black" || name == "white") {
467 cols.insert(cols.begin(), col);
468 names.insert(names.begin(), name);
471 names.push_back(name);
477 vector<string>::iterator sit = names.begin();
478 for (vector<RGB>::const_iterator iit = cols.begin();
479 iit != cols.end(); ++iit, ++sit) {
480 colourDB.push_back( X11Colour(*sit, *iit) );
483 FL_OBJECT * colbr = colours_->browser_x11;
484 fl_freeze_form(colours_->form);
485 fl_clear_browser( colbr );
487 for (vector<X11Colour>::const_iterator cit = colourDB.begin();
488 cit != colourDB.end(); ++cit) {
489 string name = (*cit).first;
490 //RGB col = (*cit).second;
491 //name += " (" + tostr(col.r) + ", " + tostr(col.g) +
492 // ", " + tostr(col.b) + ")";
493 fl_addto_browser(colbr, name.c_str());
496 fl_set_browser_topline(colbr, 1);
497 fl_select_browser_line(colbr, 1);
498 ColoursUpdateBrowser(0);
499 fl_unfreeze_form(colours_->form);
505 int FormPreferences::ColoursSearchEntry(RGB const & col) const
507 int mindiff = 0x7fffffff;
508 vector<X11Colour>::const_iterator mincit = colourDB.begin();
510 for (vector<X11Colour>::const_iterator cit = colourDB.begin();
511 cit != colourDB.end(); ++cit) {
512 RGB colDB = (*cit).second;
514 diff.r = col.r - colDB.r;
515 diff.g = col.g - colDB.g;
516 diff.b = col.b - colDB.b;
518 int d = (2 * (diff.r * diff.r) +
519 3 * (diff.g * diff.g) +
527 return static_cast<int>(mincit - colourDB.begin());
531 void FormPreferences::ColoursUpdateBrowser( int i )
533 fl_freeze_form(colours_->form);
535 RGB col = colourDB[i].second;
537 fl_mapcolor(FL_FREE_COL4+i, col.r, col.g, col.b);
538 fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
539 fl_set_slider_value(colours_->valslider_red, col.r);
540 fl_set_slider_value(colours_->valslider_green, col.g);
541 fl_set_slider_value(colours_->valslider_blue, col.b);
542 fl_redraw_object(colours_->button_colour);
544 fl_unfreeze_form(colours_->form);
548 void FormPreferences::ColoursUpdateRGB()
550 fl_freeze_form(colours_->form);
553 col.r = int(fl_get_slider_value(colours_->valslider_red));
554 col.g = int(fl_get_slider_value(colours_->valslider_green));
555 col.b = int(fl_get_slider_value(colours_->valslider_blue));
557 fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
558 fl_redraw_object(colours_->button_colour);
560 int i = ColoursSearchEntry( col );
561 // change topline only if necessary
562 // int top = fl_get_browser_topline(colours_->browser_x11);
563 // if (i < top || i > (top+15))
564 fl_set_browser_topline(colours_->browser_x11, i-5);
565 fl_select_browser_line(colours_->browser_x11, i + 1);
567 fl_unfreeze_form(colours_->form);
571 void FormPreferences::updateColours()
575 void FormPreferences::applyConverters() const
579 void FormPreferences::buildConverters()
581 converters_ = build_converters();
587 FormPreferences::feedbackConverters( FL_OBJECT const * const ) const
593 void FormPreferences::updateConverters()
597 void FormPreferences::applyFormats() const
601 void FormPreferences::buildFormats()
603 formats_ = build_formats();
605 fl_set_input_return(formats_->input_format, FL_RETURN_CHANGED);
606 fl_set_input_return(formats_->input_viewer, FL_RETURN_CHANGED);
607 fl_set_input_return(formats_->input_gui_name, FL_RETURN_CHANGED);
608 fl_set_input_return(formats_->input_extension, FL_RETURN_CHANGED);
610 fl_set_input_filter(formats_->input_format, fl_lowercase_filter);
614 string const FormPreferences::feedbackFormats( FL_OBJECT const * const ) const
622 bool FormPreferences::inputFormats( FL_OBJECT const * const )
628 void FormPreferences::updateFormats()
632 void FormPreferences::applyInputsMisc() const
634 lyxrc.date_insert_format =
635 fl_get_input(inputs_misc_->input_date_format);
639 void FormPreferences::buildInputsMisc()
641 inputs_misc_ = build_inputs_misc();
643 fl_set_input_return(inputs_misc_->input_date_format,
646 // set up the feedback mechanism
647 fl_addto_form(inputs_misc_->form);
649 setPostHandler( inputs_misc_->input_date_format );
656 FormPreferences::feedbackInputsMisc(FL_OBJECT const * const ob) const
660 if (ob == inputs_misc_->input_date_format )
661 str = lyxrc.getDescription( LyXRC::RC_DATE_INSERT_FORMAT );
667 void FormPreferences::updateInputsMisc()
669 fl_set_input(inputs_misc_->input_date_format,
670 lyxrc.date_insert_format.c_str());
674 void FormPreferences::applyInterface() const
676 lyxrc.popup_font_name =
677 fl_get_input(interface_->input_popup_font);
678 lyxrc.menu_font_name = fl_get_input(interface_->input_menu_font);
679 lyxrc.font_norm_menu =
680 fl_get_input(interface_->input_popup_encoding);
681 lyxrc.bind_file = fl_get_input(interface_->input_bind_file);
682 lyxrc.ui_file = fl_get_input(interface_->input_ui_file);
683 lyxrc.override_x_deadkeys =
684 fl_get_button(interface_->check_override_x_dead_keys);
688 void FormPreferences::buildInterface()
690 interface_ = build_interface();
692 fl_set_input_return(interface_->input_popup_font, FL_RETURN_CHANGED);
693 fl_set_input_return(interface_->input_menu_font, FL_RETURN_CHANGED);
694 fl_set_input_return(interface_->input_popup_encoding,
696 fl_set_input_return(interface_->input_bind_file, FL_RETURN_CHANGED);
697 fl_set_input_return(interface_->input_ui_file, FL_RETURN_CHANGED);
699 // deactivate the browse buttons because they aren't implemented
700 fl_deactivate_object(interface_->button_bind_file_browse);
701 fl_deactivate_object(interface_->button_ui_file_browse);
702 fl_set_object_lcol(interface_->button_bind_file_browse, FL_INACTIVE);
703 fl_set_object_lcol(interface_->button_ui_file_browse, FL_INACTIVE);
705 // set up the feedback mechanism
706 fl_addto_form(interface_->form);
708 setPostHandler( interface_->input_popup_font );
709 setPostHandler( interface_->input_menu_font );
710 setPostHandler( interface_->input_popup_encoding );
711 setPostHandler( interface_->input_bind_file );
712 setPostHandler( interface_->button_bind_file_browse );
713 setPostHandler( interface_->input_ui_file );
714 setPostHandler( interface_->button_ui_file_browse );
715 setPostHandler( interface_->check_override_x_dead_keys );
722 FormPreferences::feedbackInterface( FL_OBJECT const * const ob ) const
726 if (ob == interface_->input_popup_font )
727 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_POPUP );
728 else if (ob == interface_->input_menu_font )
729 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_MENU );
730 else if (ob == interface_->input_popup_encoding )
731 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING_MENU );
732 else if (ob == interface_->input_bind_file )
733 str = lyxrc.getDescription( LyXRC::RC_BINDFILE );
734 else if (ob == interface_->input_ui_file )
735 str = lyxrc.getDescription( LyXRC::RC_UIFILE );
736 else if (ob == interface_->check_override_x_dead_keys )
737 str = lyxrc.getDescription( LyXRC::RC_OVERRIDE_X_DEADKEYS );
743 void FormPreferences::updateInterface()
745 fl_set_input(interface_->input_popup_font,
746 lyxrc.popup_font_name.c_str());
747 fl_set_input(interface_->input_menu_font,
748 lyxrc.menu_font_name.c_str());
749 fl_set_input(interface_->input_popup_encoding,
750 lyxrc.font_norm_menu.c_str());
751 fl_set_input(interface_->input_bind_file,
752 lyxrc.bind_file.c_str());
753 fl_set_input(interface_->input_ui_file,
754 lyxrc.ui_file.c_str());
755 fl_set_button(interface_->check_override_x_dead_keys,
756 lyxrc.override_x_deadkeys);
760 void FormPreferences::applyLanguage() const
762 lyxrc.default_language = combo_default_lang->getline();
764 int button = fl_get_button(language_->check_use_kbmap);
765 lyxrc.use_kbmap = static_cast<bool>(button);
768 lyxrc.primary_kbmap = combo_kbmap_1->getline();
769 lyxrc.secondary_kbmap = combo_kbmap_2->getline();
772 button = fl_get_button(language_->check_rtl_support);
773 lyxrc.rtl_support = static_cast<bool>(button);
775 button = fl_get_button(language_->check_auto_begin);
776 lyxrc.language_auto_begin = static_cast<bool>(button);
778 button = fl_get_button(language_->check_auto_end);
779 lyxrc.language_auto_end = static_cast<bool>(button);
781 button = fl_get_button(language_->check_mark_foreign);
782 lyxrc.mark_foreign_language = static_cast<bool>(button);
784 lyxrc.language_package = fl_get_input(language_->input_package);
785 lyxrc.language_command_begin = fl_get_input(language_->input_command_begin);
786 lyxrc.language_command_end = fl_get_input(language_->input_command_end);
790 void FormPreferences::buildLanguage()
792 language_ = build_language();
794 fl_set_input_return(language_->input_package, FL_RETURN_CHANGED);
795 fl_set_input_return(language_->input_command_begin, FL_RETURN_CHANGED);
796 fl_set_input_return(language_->input_command_end, FL_RETURN_CHANGED);
798 // The default_language is a combo-box and has to be inserted manually
799 fl_freeze_form(language_->form);
800 fl_addto_form(language_->form);
802 FL_OBJECT * obj = language_->choice_default_lang;
803 fl_deactivate_object(language_->choice_default_lang);
804 combo_default_lang = new Combox(FL_COMBOX_DROPLIST);
805 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
806 combo_default_lang->shortcut("#L",1);
807 combo_default_lang->setcallback(ComboLanguageCB, this);
808 LanguagesAdd( *combo_default_lang );
811 obj = language_->choice_kbmap_1;
812 fl_deactivate_object(language_->choice_kbmap_1);
813 combo_kbmap_1 = new Combox(FL_COMBOX_DROPLIST);
814 combo_kbmap_1->add(obj->x, obj->y, obj->w, obj->h, 400);
815 combo_kbmap_1->shortcut("#1",1);
816 combo_kbmap_1->setcallback(ComboLanguageCB, this);
817 LanguagesAdd( *combo_kbmap_1 );
820 obj = language_->choice_kbmap_2;
821 fl_deactivate_object(language_->choice_kbmap_2);
822 combo_kbmap_2 = new Combox(FL_COMBOX_DROPLIST);
823 combo_kbmap_2->add(obj->x, obj->y, obj->w, obj->h, 400);
824 combo_kbmap_2->shortcut("#2",1);
825 combo_kbmap_2->setcallback(ComboLanguageCB, this);
826 LanguagesAdd( *combo_kbmap_2 );
829 fl_unfreeze_form(language_->form);
831 // set up the feedback mechanism
832 fl_addto_form(language_->form);
834 setPostHandler( language_->input_package );
835 setPostHandler( language_->check_use_kbmap );
837 // This is safe, as nothing is done to the pointer, other than
838 // to use its address in a block-if statement.
839 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_default_lang) );
840 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_1) );
841 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_2) );
843 setPostHandler( language_->check_rtl_support );
844 setPostHandler( language_->check_mark_foreign );
845 setPostHandler( language_->check_auto_begin );
846 setPostHandler( language_->check_auto_end );
847 setPostHandler( language_->input_command_begin );
848 setPostHandler( language_->input_command_end );
855 FormPreferences::feedbackLanguage(FL_OBJECT const * const ob) const
859 if (reinterpret_cast<Combox const *>(ob) == combo_default_lang )
860 str = lyxrc.getDescription( LyXRC::RC_DEFAULT_LANGUAGE );
861 else if (ob == language_->check_use_kbmap )
862 str = lyxrc.getDescription( LyXRC::RC_KBMAP );
863 else if (reinterpret_cast<Combox const *>(ob) == combo_kbmap_1)
864 str = lyxrc.getDescription( LyXRC::RC_KBMAP_PRIMARY );
865 else if (reinterpret_cast<Combox const *>(ob) == combo_kbmap_2 )
866 str = lyxrc.getDescription( LyXRC::RC_KBMAP_SECONDARY );
867 else if (ob == language_->check_rtl_support )
868 str = lyxrc.getDescription( LyXRC::RC_RTL_SUPPORT );
869 else if (ob == language_->check_auto_begin )
870 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_BEGIN );
871 else if (ob == language_->check_auto_end )
872 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_END );
873 else if (ob == language_->check_mark_foreign )
874 str = lyxrc.getDescription( LyXRC::RC_MARK_FOREIGN_LANGUAGE );
875 else if (ob == language_->input_package )
876 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_PACKAGE );
877 else if (ob == language_->input_command_begin )
878 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_BEGIN );
879 else if (ob == language_->input_command_end )
880 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_END );
886 bool FormPreferences::inputLanguage( FL_OBJECT const * const ob )
888 bool activate = true;
890 if (!ob || ob == language_->check_use_kbmap) {
891 if (fl_get_button(language_->check_use_kbmap)) {
892 combo_kbmap_1->activate();
893 combo_kbmap_2->activate();
895 combo_kbmap_1->deactivate();
896 combo_kbmap_2->deactivate();
904 void FormPreferences::updateLanguage()
906 fl_set_button(language_->check_use_kbmap,
909 combo_default_lang->select_text( lyxrc.default_language );
911 if (lyxrc.use_kbmap) {
912 combo_kbmap_1->select_text( lyxrc.primary_kbmap );
913 combo_kbmap_2->select_text( lyxrc.secondary_kbmap );
915 combo_kbmap_1->select_text( lyxrc.default_language );
916 combo_kbmap_2->select_text( lyxrc.default_language );
919 fl_set_button(language_->check_rtl_support, lyxrc.rtl_support);
920 fl_set_button(language_->check_auto_begin, lyxrc.language_auto_begin);
921 fl_set_button(language_->check_auto_end, lyxrc.language_auto_end);
922 fl_set_button(language_->check_mark_foreign,
923 lyxrc.mark_foreign_language);
925 fl_set_input(language_->input_package,
926 lyxrc.language_package.c_str());
927 fl_set_input(language_->input_command_begin,
928 lyxrc.language_command_begin.c_str());
929 fl_set_input(language_->input_command_end,
930 lyxrc.language_command_end.c_str());
932 // Activate/Deactivate the input fields dependent on the state of the
938 void FormPreferences::LanguagesAdd( Combox & combo ) const
940 for (Languages::const_iterator cit = languages.begin();
941 cit != languages.end(); cit++) {
942 combo.addto((*cit).second.lang());
947 void FormPreferences::applyLnFmisc() const
949 lyxrc.show_banner = fl_get_button(lnf_misc_->check_banner);
950 lyxrc.auto_region_delete = fl_get_button(lnf_misc_->
951 check_auto_region_delete);
952 lyxrc.exit_confirmation = fl_get_button(lnf_misc_->check_exit_confirm);
953 lyxrc.display_shortcuts =
954 fl_get_button(lnf_misc_->check_display_shortcuts);
955 lyxrc.new_ask_filename = fl_get_button(lnf_misc_->check_ask_new_file);
956 lyxrc.cursor_follows_scrollbar =
957 fl_get_button(lnf_misc_->check_cursor_follows_scrollbar);
958 lyxrc.autosave = static_cast<unsigned int>
959 (fl_get_counter_value(lnf_misc_->counter_autosave));
960 lyxrc.wheel_jump = static_cast<unsigned int>
961 (fl_get_counter_value(lnf_misc_->counter_wm_jump));
965 void FormPreferences::buildLnFmisc()
967 lnf_misc_ = build_lnf_misc();
969 fl_set_counter_return(lnf_misc_->counter_autosave,
971 fl_set_counter_return(lnf_misc_->counter_wm_jump,
974 // set up the feedback mechanism
975 fl_addto_form(lnf_misc_->form);
977 setPostHandler( lnf_misc_->check_banner );
978 setPostHandler( lnf_misc_->check_auto_region_delete );
979 setPostHandler( lnf_misc_->check_exit_confirm );
980 setPostHandler( lnf_misc_->check_display_shortcuts );
981 setPostHandler( lnf_misc_->counter_autosave );
982 setPostHandler( lnf_misc_->check_ask_new_file );
983 setPostHandler( lnf_misc_->check_cursor_follows_scrollbar );
984 setPostHandler( lnf_misc_->counter_wm_jump );
990 string const FormPreferences::feedbackLnFmisc(FL_OBJECT const * const ob) const
994 if (ob == lnf_misc_->check_banner )
995 str = lyxrc.getDescription( LyXRC::RC_SHOW_BANNER );
996 else if (ob == lnf_misc_->check_auto_region_delete )
997 str = lyxrc.getDescription( LyXRC::RC_AUTOREGIONDELETE );
998 else if (ob == lnf_misc_->check_exit_confirm )
999 str = lyxrc.getDescription( LyXRC::RC_EXIT_CONFIRMATION );
1000 else if (ob == lnf_misc_->check_display_shortcuts )
1001 str = lyxrc.getDescription( LyXRC::RC_DISPLAY_SHORTCUTS );
1002 else if (ob == lnf_misc_->check_ask_new_file )
1003 str = lyxrc.getDescription( LyXRC::RC_NEW_ASK_FILENAME );
1004 else if (ob == lnf_misc_->check_cursor_follows_scrollbar )
1005 str = lyxrc.getDescription( LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR );
1006 else if (ob == lnf_misc_->counter_autosave )
1007 str = lyxrc.getDescription( LyXRC::RC_AUTOSAVE );
1008 else if (ob == lnf_misc_->counter_wm_jump )
1009 str = lyxrc.getDescription( LyXRC::RC_WHEEL_JUMP );
1015 void FormPreferences::updateLnFmisc()
1017 fl_set_button(lnf_misc_->check_banner,
1019 fl_set_button(lnf_misc_->check_auto_region_delete,
1020 lyxrc.auto_region_delete);
1021 fl_set_button(lnf_misc_->check_exit_confirm,
1022 lyxrc.exit_confirmation);
1023 fl_set_button(lnf_misc_->check_display_shortcuts,
1024 lyxrc.display_shortcuts);
1025 fl_set_button(lnf_misc_->check_ask_new_file,
1026 lyxrc.new_ask_filename);
1027 fl_set_button(lnf_misc_->check_cursor_follows_scrollbar,
1028 lyxrc.cursor_follows_scrollbar);
1029 fl_set_counter_value(lnf_misc_->counter_autosave,
1031 fl_set_counter_value(lnf_misc_->counter_wm_jump,
1036 void FormPreferences::applyOutputsMisc() const
1038 lyxrc.ascii_linelen = static_cast<unsigned int>
1039 (fl_get_counter_value(outputs_misc_->counter_line_len));
1040 lyxrc.fontenc = fl_get_input(outputs_misc_->input_tex_encoding);
1043 fl_get_choice(outputs_misc_->choice_default_papersize) - 1;
1044 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
1046 lyxrc.ascii_roff_command = fl_get_input(outputs_misc_->input_ascii_roff);
1047 lyxrc.chktex_command = fl_get_input(outputs_misc_->input_checktex);
1051 void FormPreferences::buildOutputsMisc()
1053 outputs_misc_ = build_outputs_misc();
1055 fl_set_counter_return(outputs_misc_->counter_line_len,
1057 fl_set_input_return(outputs_misc_->input_tex_encoding,
1059 fl_set_input_return(outputs_misc_->input_ascii_roff,
1061 fl_set_input_return(outputs_misc_->input_checktex,
1063 fl_addto_choice(outputs_misc_->choice_default_papersize,
1064 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
1066 // set up the feedback mechanism
1067 fl_addto_form(outputs_misc_->form);
1069 setPostHandler( outputs_misc_->counter_line_len );
1070 setPostHandler( outputs_misc_->input_tex_encoding );
1071 setPostHandler( outputs_misc_->choice_default_papersize );
1072 setPostHandler( outputs_misc_->input_ascii_roff );
1073 setPostHandler( outputs_misc_->input_checktex );
1080 FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob) const
1084 if (ob == outputs_misc_->counter_line_len )
1085 str = lyxrc.getDescription( LyXRC::RC_ASCII_LINELEN );
1086 else if (ob == outputs_misc_->input_tex_encoding )
1087 str = lyxrc.getDescription( LyXRC::RC_FONT_ENCODING );
1088 else if (ob == outputs_misc_->input_ascii_roff )
1089 str = lyxrc.getDescription( LyXRC::RC_ASCIIROFF_COMMAND );
1090 else if (ob == outputs_misc_->input_checktex )
1091 str = lyxrc.getDescription( LyXRC::RC_CHKTEX_COMMAND );
1092 else if (ob == outputs_misc_->choice_default_papersize )
1093 str = lyxrc.getDescription( LyXRC::RC_DEFAULT_PAPERSIZE );
1099 void FormPreferences::updateOutputsMisc()
1101 fl_set_counter_value(outputs_misc_->counter_line_len,
1102 lyxrc.ascii_linelen);
1103 fl_set_input(outputs_misc_->input_tex_encoding,
1104 lyxrc.fontenc.c_str());
1105 fl_set_choice(outputs_misc_->choice_default_papersize,
1106 lyxrc.default_papersize+1);
1107 fl_set_input(outputs_misc_->input_ascii_roff,
1108 lyxrc.ascii_roff_command.c_str());
1109 fl_set_input(outputs_misc_->input_checktex,
1110 lyxrc.chktex_command.c_str());
1114 void FormPreferences::applyPaths()
1116 lyxrc.document_path = fl_get_input(paths_->input_default_path);
1117 lyxrc.template_path = fl_get_input(paths_->input_template_path);
1119 int button = fl_get_button(paths_->check_use_temp_dir);
1120 string str = fl_get_input(paths_->input_temp_dir);
1121 if (!button ) str.erase();
1123 lyxrc.use_tempdir = button;
1124 lyxrc.tempdir_path = str;
1126 button = fl_get_button(paths_->check_last_files);
1127 str = fl_get_input(paths_->input_lastfiles);
1128 if (!button ) str.erase();
1130 lyxrc.check_lastfiles = button;
1131 lyxrc.lastfiles = str;
1132 lyxrc.num_lastfiles = static_cast<unsigned int>
1133 (fl_get_counter_value(paths_->counter_lastfiles));
1135 button = fl_get_button(paths_->check_make_backups);
1136 str = fl_get_input(paths_->input_backup_path);
1137 if (!button ) str.erase();
1139 lyxrc.make_backup = button;
1140 lyxrc.backupdir_path = str;
1142 lyxrc.lyxpipes = fl_get_input(paths_->input_serverpipe);
1149 void FormPreferences::buildPaths()
1151 paths_ = build_paths();
1153 fl_set_input_return(paths_->input_default_path, FL_RETURN_CHANGED);
1154 fl_set_input_return(paths_->input_template_path, FL_RETURN_CHANGED);
1155 fl_set_input_return(paths_->input_temp_dir, FL_RETURN_CHANGED);
1156 fl_set_input_return(paths_->input_lastfiles, FL_RETURN_CHANGED);
1157 fl_set_input_return(paths_->input_backup_path, FL_RETURN_CHANGED);
1158 fl_set_counter_return(paths_->counter_lastfiles, FL_RETURN_CHANGED);
1159 fl_set_input_return(paths_->input_serverpipe, FL_RETURN_CHANGED);
1161 // deactivate the browse buttons because they aren't implemented
1162 fl_deactivate_object(paths_->button_document_browse);
1163 fl_deactivate_object(paths_->button_template_browse);
1164 fl_deactivate_object(paths_->button_temp_dir_browse);
1165 fl_deactivate_object(paths_->button_lastfiles_browse);
1166 fl_deactivate_object(paths_->button_backup_path_browse);
1167 fl_deactivate_object(paths_->button_serverpipe_browse);
1168 fl_set_object_lcol(paths_->button_document_browse, FL_INACTIVE);
1169 fl_set_object_lcol(paths_->button_template_browse, FL_INACTIVE);
1170 fl_set_object_lcol(paths_->button_temp_dir_browse, FL_INACTIVE);
1171 fl_set_object_lcol(paths_->button_lastfiles_browse, FL_INACTIVE);
1172 fl_set_object_lcol(paths_->button_backup_path_browse, FL_INACTIVE);
1173 fl_set_object_lcol(paths_->button_serverpipe_browse, FL_INACTIVE);
1175 // set up the feedback mechanism
1176 fl_addto_form(paths_->form);
1178 setPostHandler( paths_->input_default_path );
1179 setPostHandler( paths_->button_document_browse );
1180 setPostHandler( paths_->counter_lastfiles );
1181 setPostHandler( paths_->input_template_path );
1182 setPostHandler( paths_->button_template_browse );
1183 setPostHandler( paths_->check_last_files );
1184 setPostHandler( paths_->button_temp_dir_browse );
1185 setPostHandler( paths_->input_lastfiles );
1186 setPostHandler( paths_->button_lastfiles_browse );
1187 setPostHandler( paths_->check_make_backups );
1188 setPostHandler( paths_->input_backup_path );
1189 setPostHandler( paths_->button_backup_path_browse );
1190 setPostHandler( paths_->input_serverpipe );
1191 setPostHandler( paths_->button_serverpipe_browse );
1192 setPostHandler( paths_->input_temp_dir );
1193 setPostHandler( paths_->check_use_temp_dir );
1199 string const FormPreferences::feedbackPaths( FL_OBJECT const * const ob ) const
1203 if (ob == paths_->input_default_path )
1204 str = lyxrc.getDescription( LyXRC::RC_DOCUMENTPATH );
1205 else if (ob == paths_->input_template_path )
1206 str = lyxrc.getDescription( LyXRC::RC_TEMPLATEPATH );
1207 else if (ob == paths_->check_use_temp_dir )
1208 str = lyxrc.getDescription( LyXRC::RC_USETEMPDIR );
1209 else if (ob == paths_->input_temp_dir )
1210 str = lyxrc.getDescription( LyXRC::RC_TEMPDIRPATH );
1211 else if (ob == paths_->check_last_files )
1212 str = lyxrc.getDescription( LyXRC::RC_CHECKLASTFILES );
1213 else if (ob == paths_->input_lastfiles )
1214 str = lyxrc.getDescription( LyXRC::RC_LASTFILES );
1215 else if (ob == paths_->counter_lastfiles )
1216 str = lyxrc.getDescription( LyXRC::RC_NUMLASTFILES );
1217 else if (ob == paths_->check_make_backups )
1218 str = lyxrc.getDescription( LyXRC::RC_MAKE_BACKUP );
1219 else if (ob == paths_->input_backup_path )
1220 str = lyxrc.getDescription( LyXRC::RC_BACKUPDIR_PATH );
1221 else if (ob == paths_->input_serverpipe )
1222 str = lyxrc.getDescription( LyXRC::RC_SERVERPIPE );
1228 bool FormPreferences::inputPaths( FL_OBJECT const * const ob )
1230 bool activate = true;
1232 if (!ob || ob == paths_->check_use_temp_dir) {
1233 if (fl_get_button(paths_->check_use_temp_dir)) {
1234 fl_activate_object(paths_->input_temp_dir);
1235 fl_set_object_lcol(paths_->input_temp_dir,
1238 fl_deactivate_object(paths_->input_temp_dir);
1239 fl_set_object_lcol(paths_->input_temp_dir,
1244 if (!ob || ob == paths_->check_last_files) {
1245 if (fl_get_button(paths_->check_last_files)) {
1246 fl_activate_object(paths_->input_lastfiles);
1247 fl_set_object_lcol(paths_->input_lastfiles,
1250 fl_deactivate_object(paths_->input_lastfiles);
1251 fl_set_object_lcol(paths_->input_lastfiles,
1256 if (!ob || ob == paths_->check_make_backups) {
1257 if (fl_get_button(paths_->check_make_backups)) {
1258 fl_activate_object(paths_->input_backup_path);
1259 fl_set_object_lcol(paths_->input_backup_path,
1262 fl_deactivate_object(paths_->input_backup_path);
1263 fl_set_object_lcol(paths_->input_backup_path,
1268 if (!ob || ob == paths_->input_default_path) {
1269 string name = fl_get_input(paths_->input_default_path);
1270 if (!WriteableDir(name) )
1274 if (!ob || ob == paths_->input_template_path) {
1275 string name = fl_get_input(paths_->input_template_path);
1276 if (!ReadableDir(name) )
1280 if (!ob || ob == paths_->input_temp_dir) {
1281 string name = fl_get_input(paths_->input_temp_dir);
1282 if (fl_get_button(paths_->check_make_backups)
1284 && !WriteableDir(name) )
1288 if (!ob || ob == paths_->input_backup_path) {
1289 string name = fl_get_input(paths_->input_backup_path);
1290 if (fl_get_button(paths_->check_make_backups)
1292 && !WriteableDir(name) )
1296 if (!ob || ob == paths_->input_lastfiles) {
1297 string name = fl_get_input(paths_->input_lastfiles);
1298 if (fl_get_button(paths_->check_last_files)
1300 && !WriteableFile(name) )
1304 if (!ob || ob == paths_->input_serverpipe) {
1305 string name = fl_get_input(paths_->input_serverpipe);
1306 if (!name.empty()) {
1307 if (!WriteableFile(name, ".in"))
1309 if (!WriteableFile(name, ".out"))
1318 void FormPreferences::updatePaths()
1320 fl_set_input(paths_->input_default_path,
1321 lyxrc.document_path.c_str());
1322 fl_set_input(paths_->input_template_path,
1323 lyxrc.template_path.c_str());
1326 if (lyxrc.make_backup) str = lyxrc.backupdir_path;
1328 fl_set_button(paths_->check_make_backups,
1330 fl_set_input(paths_->input_backup_path, str.c_str());
1333 if (lyxrc.use_tempdir) str = lyxrc.tempdir_path;
1335 fl_set_button(paths_->check_use_temp_dir,
1337 fl_set_input(paths_->input_temp_dir, str.c_str());
1340 if (lyxrc.check_lastfiles) str = lyxrc.lastfiles;
1342 fl_set_button(paths_->check_last_files,
1343 lyxrc.check_lastfiles);
1344 fl_set_input(paths_->input_lastfiles, str.c_str());
1345 fl_set_counter_value(paths_->counter_lastfiles,
1346 lyxrc.num_lastfiles);
1348 fl_set_input(paths_->input_serverpipe, lyxrc.lyxpipes.c_str());
1350 // Activate/Deactivate the input fields dependent on the state of the
1356 void FormPreferences::applyPrinter() const
1358 lyxrc.print_adapt_output = fl_get_button(printer_->check_adapt_output);
1359 lyxrc.print_command = fl_get_input(printer_->input_command);
1360 lyxrc.print_pagerange_flag = fl_get_input(printer_->input_page_range);
1361 lyxrc.print_copies_flag = fl_get_input(printer_->input_copies);
1362 lyxrc.print_reverse_flag = fl_get_input(printer_->input_reverse);
1363 lyxrc.print_to_printer = fl_get_input(printer_->input_to_printer);
1364 lyxrc.print_file_extension =
1365 fl_get_input(printer_->input_file_extension);
1366 lyxrc.print_spool_command =
1367 fl_get_input(printer_->input_spool_command);
1368 lyxrc.print_paper_flag = fl_get_input(printer_->input_paper_type);
1369 lyxrc.print_evenpage_flag = fl_get_input(printer_->input_even_pages);
1370 lyxrc.print_oddpage_flag = fl_get_input(printer_->input_odd_pages);
1371 lyxrc.print_collcopies_flag = fl_get_input(printer_->input_collated);
1372 lyxrc.print_landscape_flag = fl_get_input(printer_->input_landscape);
1373 lyxrc.print_to_file = fl_get_input(printer_->input_to_file);
1374 lyxrc.print_extra_options =
1375 fl_get_input(printer_->input_extra_options);
1376 lyxrc.print_spool_printerprefix =
1377 fl_get_input(printer_->input_spool_prefix);
1378 lyxrc.print_paper_dimension_flag =
1379 fl_get_input(printer_->input_paper_size);
1380 lyxrc.printer = fl_get_input(printer_->input_name);
1384 string const FormPreferences::feedbackPrinter(FL_OBJECT const * const ob) const
1388 if (ob == printer_->input_command )
1389 str = lyxrc.getDescription( LyXRC::RC_PRINT_COMMAND );
1390 else if (ob == printer_->check_adapt_output )
1391 str = lyxrc.getDescription( LyXRC::RC_PRINT_ADAPTOUTPUT );
1392 else if (ob == printer_->input_to_printer )
1393 str = lyxrc.getDescription( LyXRC::RC_PRINTTOPRINTER );
1394 else if (ob == printer_->input_to_file )
1395 str = lyxrc.getDescription( LyXRC::RC_PRINTTOFILE );
1396 else if (ob == printer_->input_file_extension )
1397 str = lyxrc.getDescription( LyXRC::RC_PRINTFILEEXTENSION );
1398 else if (ob == printer_->input_extra_options )
1399 str = lyxrc.getDescription( LyXRC::RC_PRINTEXSTRAOPTIONS );
1400 else if (ob == printer_->input_spool_command )
1401 str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_COMMAND );
1402 else if (ob == printer_->input_spool_prefix )
1403 str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_PRINTERPREFIX );
1404 else if (ob == printer_->input_name )
1405 str = lyxrc.getDescription( LyXRC::RC_PRINTER );
1406 else if (ob == printer_->input_even_pages )
1407 str = lyxrc.getDescription( LyXRC::RC_PRINTEVENPAGEFLAG );
1408 else if (ob == printer_->input_odd_pages )
1409 str = lyxrc.getDescription( LyXRC::RC_PRINTODDPAGEFLAG );
1410 else if (ob == printer_->input_page_range )
1411 str = lyxrc.getDescription( LyXRC::RC_PRINTPAGERANGEFLAG );
1412 else if (ob == printer_->input_reverse )
1413 str = lyxrc.getDescription( LyXRC::RC_PRINTREVERSEFLAG );
1414 else if (ob == printer_->input_landscape )
1415 str = lyxrc.getDescription( LyXRC::RC_PRINTLANDSCAPEFLAG );
1416 else if (ob == printer_->input_copies )
1417 str = lyxrc.getDescription( LyXRC::RC_PRINTCOLLCOPIESFLAG );
1418 else if (ob == printer_->input_collated )
1419 str = lyxrc.getDescription( LyXRC::RC_PRINTCOPIESFLAG );
1420 else if (ob == printer_->input_paper_type )
1421 str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERFLAG );
1422 else if (ob == printer_->input_paper_size )
1423 str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERDIMENSIONFLAG );
1429 void FormPreferences::buildPrinter()
1431 printer_ = build_printer();
1433 fl_set_input_return(printer_->input_command, FL_RETURN_CHANGED);
1434 fl_set_input_return(printer_->input_page_range, FL_RETURN_CHANGED);
1435 fl_set_input_return(printer_->input_copies, FL_RETURN_CHANGED);
1436 fl_set_input_return(printer_->input_reverse, FL_RETURN_CHANGED);
1437 fl_set_input_return(printer_->input_to_printer, FL_RETURN_CHANGED);
1438 fl_set_input_return(printer_->input_file_extension, FL_RETURN_CHANGED);
1439 fl_set_input_return(printer_->input_spool_command, FL_RETURN_CHANGED);
1440 fl_set_input_return(printer_->input_paper_type, FL_RETURN_CHANGED);
1441 fl_set_input_return(printer_->input_even_pages, FL_RETURN_CHANGED);
1442 fl_set_input_return(printer_->input_odd_pages, FL_RETURN_CHANGED);
1443 fl_set_input_return(printer_->input_collated, FL_RETURN_CHANGED);
1444 fl_set_input_return(printer_->input_landscape, FL_RETURN_CHANGED);
1445 fl_set_input_return(printer_->input_to_file, FL_RETURN_CHANGED);
1446 fl_set_input_return(printer_->input_extra_options, FL_RETURN_CHANGED);
1447 fl_set_input_return(printer_->input_spool_prefix, FL_RETURN_CHANGED);
1448 fl_set_input_return(printer_->input_paper_size, FL_RETURN_CHANGED);
1449 fl_set_input_return(printer_->input_name, FL_RETURN_CHANGED);
1451 // set up the feedback mechanism
1452 fl_addto_form(printer_->form);
1454 setPostHandler( printer_->input_command );
1455 setPostHandler( printer_->input_page_range );
1456 setPostHandler( printer_->input_copies );
1457 setPostHandler( printer_->input_reverse );
1458 setPostHandler( printer_->input_to_printer );
1459 setPostHandler( printer_->input_file_extension );
1460 setPostHandler( printer_->input_spool_command );
1461 setPostHandler( printer_->input_paper_type );
1462 setPostHandler( printer_->input_even_pages );
1463 setPostHandler( printer_->input_odd_pages );
1464 setPostHandler( printer_->input_collated );
1465 setPostHandler( printer_->input_landscape );
1466 setPostHandler( printer_->input_to_file );
1467 setPostHandler( printer_->input_extra_options );
1468 setPostHandler( printer_->input_spool_prefix );
1469 setPostHandler( printer_->input_paper_size );
1470 setPostHandler( printer_->input_name );
1471 setPostHandler( printer_->check_adapt_output );
1477 void FormPreferences::updatePrinter()
1479 fl_set_button(printer_->check_adapt_output,
1480 lyxrc.print_adapt_output);
1481 fl_set_input(printer_->input_command,
1482 lyxrc.print_command.c_str());
1483 fl_set_input(printer_->input_page_range,
1484 lyxrc.print_pagerange_flag.c_str());
1485 fl_set_input(printer_->input_copies,
1486 lyxrc.print_copies_flag.c_str());
1487 fl_set_input(printer_->input_reverse,
1488 lyxrc.print_reverse_flag.c_str());
1489 fl_set_input(printer_->input_to_printer,
1490 lyxrc.print_to_printer.c_str());
1491 fl_set_input(printer_->input_file_extension,
1492 lyxrc.print_file_extension.c_str());
1493 fl_set_input(printer_->input_spool_command,
1494 lyxrc.print_spool_command.c_str());
1495 fl_set_input(printer_->input_paper_type,
1496 lyxrc.print_paper_flag.c_str());
1497 fl_set_input(printer_->input_even_pages,
1498 lyxrc.print_evenpage_flag.c_str());
1499 fl_set_input(printer_->input_odd_pages,
1500 lyxrc.print_oddpage_flag.c_str());
1501 fl_set_input(printer_->input_collated,
1502 lyxrc.print_collcopies_flag.c_str());
1503 fl_set_input(printer_->input_landscape,
1504 lyxrc.print_landscape_flag.c_str());
1505 fl_set_input(printer_->input_to_file,
1506 lyxrc.print_to_file.c_str());
1507 fl_set_input(printer_->input_extra_options,
1508 lyxrc.print_extra_options.c_str());
1509 fl_set_input(printer_->input_spool_prefix,
1510 lyxrc.print_spool_printerprefix.c_str());
1511 fl_set_input(printer_->input_paper_size,
1512 lyxrc.print_paper_dimension_flag.c_str());
1513 fl_set_input(printer_->input_name,
1514 lyxrc.printer.c_str());
1518 void FormPreferences::applyScreenFonts() const
1520 bool changed = false;
1522 string str = fl_get_input(screen_fonts_->input_roman);
1523 if (lyxrc.roman_font_name != str) {
1525 lyxrc.roman_font_name = str;
1528 str = fl_get_input(screen_fonts_->input_sans);
1529 if (lyxrc.sans_font_name != str) {
1531 lyxrc.sans_font_name = str;
1534 str = fl_get_input(screen_fonts_->input_typewriter);
1535 if (lyxrc.typewriter_font_name != str) {
1537 lyxrc.typewriter_font_name = str;
1540 str = fl_get_input(screen_fonts_->input_screen_encoding);
1541 if (lyxrc.font_norm != str) {
1543 lyxrc.font_norm = str;
1546 bool button = fl_get_button(screen_fonts_->check_scalable);
1547 if (lyxrc.use_scalable_fonts != button) {
1549 lyxrc.use_scalable_fonts = button;
1552 unsigned int ivalue = static_cast<unsigned int>
1553 (fl_get_counter_value(screen_fonts_->counter_zoom));
1554 if (lyxrc.zoom != ivalue) {
1556 lyxrc.zoom = ivalue;
1559 ivalue = static_cast<unsigned int>
1560 (fl_get_counter_value(screen_fonts_->counter_dpi));
1561 if (lyxrc.dpi != ivalue) {
1566 double dvalue = strToDbl(fl_get_input(screen_fonts_->input_tiny));
1567 if (lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue) {
1569 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
1572 dvalue = strToDbl(fl_get_input(screen_fonts_->input_script));
1573 if (lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue) {
1575 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
1578 dvalue = strToDbl(fl_get_input(screen_fonts_->input_footnote));
1579 if (lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue) {
1581 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
1584 dvalue = strToDbl(fl_get_input(screen_fonts_->input_small));
1585 if (lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue) {
1587 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
1590 dvalue = strToDbl(fl_get_input(screen_fonts_->input_normal));
1591 if (lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue) {
1593 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
1596 dvalue = strToDbl(fl_get_input(screen_fonts_->input_large));
1597 if (lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue) {
1599 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
1602 dvalue = strToDbl(fl_get_input(screen_fonts_->input_larger));
1603 if (lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue) {
1605 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
1608 dvalue = strToDbl(fl_get_input(screen_fonts_->input_largest));
1609 if (lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue) {
1611 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
1614 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huge));
1615 if (lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue) {
1617 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
1620 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huger));
1621 if (lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue) {
1623 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
1627 // Now update the buffers
1628 // Can anything below here affect the redraw process?
1629 lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
1634 void FormPreferences::buildScreenFonts()
1636 screen_fonts_ = build_screen_fonts();
1638 fl_set_input_return(screen_fonts_->input_roman, FL_RETURN_CHANGED);
1639 fl_set_input_return(screen_fonts_->input_sans, FL_RETURN_CHANGED);
1640 fl_set_input_return(screen_fonts_->input_typewriter,
1642 fl_set_input_return(screen_fonts_->input_screen_encoding,
1644 fl_set_counter_return(screen_fonts_->counter_zoom, FL_RETURN_CHANGED);
1645 fl_set_counter_return(screen_fonts_->counter_dpi, FL_RETURN_CHANGED);
1646 fl_set_input_return(screen_fonts_->input_tiny, FL_RETURN_CHANGED);
1647 fl_set_input_return(screen_fonts_->input_script, FL_RETURN_CHANGED);
1648 fl_set_input_return(screen_fonts_->input_footnote, FL_RETURN_CHANGED);
1649 fl_set_input_return(screen_fonts_->input_small, FL_RETURN_CHANGED);
1650 fl_set_input_return(screen_fonts_->input_normal, FL_RETURN_CHANGED);
1651 fl_set_input_return(screen_fonts_->input_large, FL_RETURN_CHANGED);
1652 fl_set_input_return(screen_fonts_->input_larger, FL_RETURN_CHANGED);
1653 fl_set_input_return(screen_fonts_->input_largest, FL_RETURN_CHANGED);
1654 fl_set_input_return(screen_fonts_->input_huge, FL_RETURN_CHANGED);
1655 fl_set_input_return(screen_fonts_->input_huger, FL_RETURN_CHANGED);
1657 fl_set_input_filter(screen_fonts_->input_tiny,
1658 fl_unsigned_int_filter);
1659 fl_set_input_filter(screen_fonts_->input_script,
1660 fl_unsigned_int_filter);
1661 fl_set_input_filter(screen_fonts_->input_footnote,
1662 fl_unsigned_int_filter);
1663 fl_set_input_filter(screen_fonts_->input_small,
1664 fl_unsigned_int_filter);
1665 fl_set_input_filter(screen_fonts_->input_normal,
1666 fl_unsigned_int_filter);
1667 fl_set_input_filter(screen_fonts_->input_large,
1668 fl_unsigned_int_filter);
1669 fl_set_input_filter(screen_fonts_->input_larger,
1670 fl_unsigned_int_filter);
1671 fl_set_input_filter(screen_fonts_->input_largest,
1672 fl_unsigned_int_filter);
1673 fl_set_input_filter(screen_fonts_->input_huge,
1674 fl_unsigned_int_filter);
1675 fl_set_input_filter(screen_fonts_->input_huger,
1676 fl_unsigned_int_filter);
1678 // set up the feedback mechanism
1679 fl_addto_form(screen_fonts_->form);
1681 setPostHandler( screen_fonts_->input_roman );
1682 setPostHandler( screen_fonts_->input_sans );
1683 setPostHandler( screen_fonts_->input_typewriter );
1684 setPostHandler( screen_fonts_->counter_zoom );
1685 setPostHandler( screen_fonts_->counter_dpi );
1686 setPostHandler( screen_fonts_->check_scalable );
1687 setPostHandler( screen_fonts_->input_screen_encoding );
1688 setPostHandler( screen_fonts_->input_tiny );
1689 setPostHandler( screen_fonts_->input_script );
1690 setPostHandler( screen_fonts_->input_footnote );
1691 setPostHandler( screen_fonts_->input_small );
1692 setPostHandler( screen_fonts_->input_large );
1693 setPostHandler( screen_fonts_->input_larger );
1694 setPostHandler( screen_fonts_->input_largest );
1695 setPostHandler( screen_fonts_->input_normal );
1696 setPostHandler( screen_fonts_->input_huge );
1697 setPostHandler( screen_fonts_->input_huger );
1704 FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob ) const
1708 if (ob == screen_fonts_->input_roman )
1709 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ROMAN );
1710 else if (ob == screen_fonts_->input_sans )
1711 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SANS );
1712 else if (ob == screen_fonts_->input_typewriter )
1713 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_TYPEWRITER );
1714 else if (ob == screen_fonts_->check_scalable )
1715 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SCALABLE );
1716 else if (ob == screen_fonts_->input_screen_encoding )
1717 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING );
1718 else if (ob == screen_fonts_->counter_zoom )
1719 str = lyxrc.getDescription( LyXRC::RC_SCREEN_ZOOM );
1720 else if (ob == screen_fonts_->counter_dpi )
1721 str = lyxrc.getDescription( LyXRC::RC_SCREEN_DPI );
1722 else if (ob == screen_fonts_->input_tiny
1723 || ob == screen_fonts_->input_script
1724 || ob == screen_fonts_->input_footnote
1725 || ob == screen_fonts_->input_small
1726 || ob == screen_fonts_->input_large
1727 || ob == screen_fonts_->input_larger
1728 || ob == screen_fonts_->input_larger
1729 || ob == screen_fonts_->input_largest
1730 || ob == screen_fonts_->input_normal
1731 || ob == screen_fonts_->input_huge
1732 || ob == screen_fonts_->input_huger )
1733 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SIZES );
1739 bool FormPreferences::inputScreenFonts()
1741 bool activate = true;
1744 // Make sure that all fonts all have positive entries
1745 // Also note that an empty entry is returned as 0.0 by strToDbl
1746 if (0.0 >= strToDbl(fl_get_input(screen_fonts_->input_tiny))
1747 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_script))
1748 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_footnote))
1749 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_small))
1750 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_normal))
1751 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_large))
1752 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_larger))
1753 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_largest))
1754 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huge))
1755 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huger))) {
1757 str = N_("WARNING! Fonts must be positive!");
1759 // Fontsizes -- tiny < script < footnote etc.
1760 } else if (strToDbl(fl_get_input(screen_fonts_->input_tiny)) >
1761 strToDbl(fl_get_input(screen_fonts_->input_script)) ||
1762 strToDbl(fl_get_input(screen_fonts_->input_script)) >
1763 strToDbl(fl_get_input(screen_fonts_->input_footnote)) ||
1764 strToDbl(fl_get_input(screen_fonts_->input_footnote)) >
1765 strToDbl(fl_get_input(screen_fonts_->input_small)) ||
1766 strToDbl(fl_get_input(screen_fonts_->input_small)) >
1767 strToDbl(fl_get_input(screen_fonts_->input_normal)) ||
1768 strToDbl(fl_get_input(screen_fonts_->input_normal)) >
1769 strToDbl(fl_get_input(screen_fonts_->input_large)) ||
1770 strToDbl(fl_get_input(screen_fonts_->input_large)) >
1771 strToDbl(fl_get_input(screen_fonts_->input_larger)) ||
1772 strToDbl(fl_get_input(screen_fonts_->input_larger)) >
1773 strToDbl(fl_get_input(screen_fonts_->input_largest)) ||
1774 strToDbl(fl_get_input(screen_fonts_->input_largest)) >
1775 strToDbl(fl_get_input(screen_fonts_->input_huge)) ||
1776 strToDbl(fl_get_input(screen_fonts_->input_huge)) >
1777 strToDbl(fl_get_input(screen_fonts_->input_huger))) {
1780 str = N_("WARNING! Fonts must be input in the order tiny > script>\nfootnote > small > normal > large > larger > largest > huge > huger.");
1784 fl_set_object_label(dialog_->text_warning, str.c_str());
1785 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
1792 void FormPreferences::updateScreenFonts()
1794 fl_set_input(screen_fonts_->input_roman,
1795 lyxrc.roman_font_name.c_str());
1796 fl_set_input(screen_fonts_->input_sans,
1797 lyxrc.sans_font_name.c_str());
1798 fl_set_input(screen_fonts_->input_typewriter,
1799 lyxrc.typewriter_font_name.c_str());
1800 fl_set_input(screen_fonts_->input_screen_encoding,
1801 lyxrc.font_norm.c_str());
1802 fl_set_button(screen_fonts_->check_scalable,
1803 lyxrc.use_scalable_fonts);
1804 fl_set_counter_value(screen_fonts_->counter_zoom, lyxrc.zoom);
1805 fl_set_counter_value(screen_fonts_->counter_dpi, lyxrc.dpi);
1806 fl_set_input(screen_fonts_->input_tiny,
1807 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
1808 fl_set_input(screen_fonts_->input_script,
1809 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
1810 fl_set_input(screen_fonts_->input_footnote,
1811 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
1812 fl_set_input(screen_fonts_->input_small,
1813 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
1814 fl_set_input(screen_fonts_->input_normal,
1815 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
1816 fl_set_input(screen_fonts_->input_large,
1817 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
1818 fl_set_input(screen_fonts_->input_larger,
1819 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
1820 fl_set_input(screen_fonts_->input_largest,
1821 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
1822 fl_set_input(screen_fonts_->input_huge,
1823 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
1824 fl_set_input(screen_fonts_->input_huger,
1825 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
1829 void FormPreferences::applySpellChecker()
1832 string choice = "none";
1833 switch (fl_get_choice(spellchecker_->choice_spell_command)) {
1846 lyxrc.isp_command = choice;
1848 // If spell checker == "none", all other input set to off.
1849 if (fl_get_choice(spellchecker_->choice_spell_command) == 1) {
1850 lyxrc.isp_use_alt_lang = false;
1851 lyxrc.isp_alt_lang.erase();
1853 lyxrc.isp_use_esc_chars = false;
1854 lyxrc.isp_esc_chars.erase();
1856 lyxrc.isp_use_pers_dict = false;
1857 lyxrc.isp_pers_dict.erase();
1859 lyxrc.isp_accept_compound = false;
1860 lyxrc.isp_use_input_encoding = false;
1862 int button = fl_get_button(spellchecker_->check_alt_lang);
1863 choice = fl_get_input(spellchecker_->input_alt_lang);
1864 if (button && choice.empty() ) button = 0;
1865 if (!button ) choice.erase();
1867 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
1868 lyxrc.isp_alt_lang = choice;
1870 button = fl_get_button(spellchecker_->check_escape_chars);
1871 choice = fl_get_input(spellchecker_->input_escape_chars);
1872 if (button && choice.empty() ) button = 0;
1873 if (!button ) choice.erase();
1875 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
1876 lyxrc.isp_esc_chars = choice;
1878 button = fl_get_button(spellchecker_->check_personal_dict);
1879 choice = fl_get_input(spellchecker_->input_personal_dict);
1880 if (button && choice.empty() ) button = 0;
1881 if (!button ) choice.erase();
1883 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
1884 lyxrc.isp_pers_dict = choice;
1886 button = fl_get_button(spellchecker_->check_compound_words);
1887 lyxrc.isp_accept_compound = static_cast<bool>(button);
1889 button = fl_get_button(spellchecker_->check_input_enc);
1890 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
1894 updateSpellChecker();
1898 void FormPreferences::buildSpellchecker()
1900 spellchecker_ = build_spellchecker();
1902 fl_addto_choice(spellchecker_->choice_spell_command,
1903 _(" none | ispell | aspell "));
1904 fl_set_input_return(spellchecker_->input_alt_lang,
1906 fl_set_input_return(spellchecker_->input_escape_chars,
1908 fl_set_input_return(spellchecker_->input_personal_dict,
1911 // deactivate the browse button because it isn't implemented
1912 fl_deactivate_object(spellchecker_->button_personal_dict);
1913 fl_set_object_lcol(spellchecker_->button_personal_dict,
1916 // set up the feedback mechanism
1917 fl_addto_form(spellchecker_->form);
1919 setPostHandler( spellchecker_->choice_spell_command );
1920 setPostHandler( spellchecker_->check_alt_lang );
1921 setPostHandler( spellchecker_->input_alt_lang );
1922 setPostHandler( spellchecker_->check_escape_chars );
1923 setPostHandler( spellchecker_->input_escape_chars );
1924 setPostHandler( spellchecker_->check_personal_dict );
1925 setPostHandler( spellchecker_->input_personal_dict );
1926 setPostHandler( spellchecker_->button_personal_dict );
1927 setPostHandler( spellchecker_->check_compound_words );
1928 setPostHandler( spellchecker_->check_input_enc );
1935 FormPreferences::feedbackSpellChecker(FL_OBJECT const * const ob) const
1939 if (ob == spellchecker_->choice_spell_command )
1940 str = lyxrc.getDescription( LyXRC::RC_SPELL_COMMAND );
1941 else if (ob == spellchecker_->check_alt_lang )
1942 str = lyxrc.getDescription( LyXRC::RC_USE_ALT_LANG );
1943 else if (ob == spellchecker_->input_alt_lang )
1944 str = lyxrc.getDescription( LyXRC::RC_ALT_LANG );
1945 else if (ob == spellchecker_->check_escape_chars )
1946 str = lyxrc.getDescription( LyXRC::RC_USE_ESC_CHARS );
1947 else if (ob == spellchecker_->input_escape_chars )
1948 str = lyxrc.getDescription( LyXRC::RC_ESC_CHARS );
1949 else if (ob == spellchecker_->check_personal_dict )
1950 str = lyxrc.getDescription( LyXRC::RC_USE_PERS_DICT );
1951 else if (ob == spellchecker_->input_personal_dict )
1952 str = lyxrc.getDescription( LyXRC::RC_PERS_DICT );
1953 else if (ob == spellchecker_->check_compound_words )
1954 str = lyxrc.getDescription( LyXRC::RC_ACCEPT_COMPOUND );
1955 else if (ob == spellchecker_->check_input_enc )
1956 str = lyxrc.getDescription( LyXRC::RC_USE_INP_ENC );
1962 bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob )
1964 // Allow/dissallow input
1966 // If spell checker == "none", disable all input.
1967 if (!ob || ob == spellchecker_->choice_spell_command) {
1968 if (fl_get_choice(spellchecker_->choice_spell_command) == 1) {
1969 fl_deactivate_object( spellchecker_->check_alt_lang );
1970 fl_deactivate_object( spellchecker_->input_alt_lang );
1971 fl_deactivate_object( spellchecker_->check_escape_chars );
1972 fl_deactivate_object( spellchecker_->input_escape_chars );
1973 fl_deactivate_object( spellchecker_->check_personal_dict );
1974 fl_deactivate_object( spellchecker_->input_personal_dict );
1975 fl_deactivate_object( spellchecker_->check_compound_words );
1976 fl_deactivate_object( spellchecker_->check_input_enc );
1979 fl_activate_object( spellchecker_->check_alt_lang );
1980 fl_activate_object( spellchecker_->check_escape_chars );
1981 fl_activate_object( spellchecker_->check_personal_dict );
1982 fl_activate_object( spellchecker_->check_compound_words );
1983 fl_activate_object( spellchecker_->check_input_enc );
1987 if (!ob || ob == spellchecker_->check_alt_lang) {
1988 if (fl_get_button(spellchecker_->check_alt_lang)) {
1989 fl_activate_object(spellchecker_->input_alt_lang);
1990 fl_set_object_lcol(spellchecker_->input_alt_lang,
1993 fl_deactivate_object(spellchecker_->input_alt_lang);
1994 fl_set_object_lcol(spellchecker_->input_alt_lang,
1999 if (!ob || ob == spellchecker_->check_escape_chars) {
2000 if (fl_get_button(spellchecker_->check_escape_chars)) {
2001 fl_activate_object(spellchecker_->input_escape_chars);
2002 fl_set_object_lcol(spellchecker_->input_escape_chars,
2005 fl_deactivate_object(spellchecker_->input_escape_chars);
2006 fl_set_object_lcol(spellchecker_->input_escape_chars,
2011 if (!ob || ob == spellchecker_->check_personal_dict) {
2012 if (fl_get_button(spellchecker_->check_personal_dict)) {
2013 fl_activate_object(spellchecker_->input_personal_dict);
2014 fl_set_object_lcol(spellchecker_->input_personal_dict,
2017 fl_deactivate_object(spellchecker_->input_personal_dict);
2018 fl_set_object_lcol(spellchecker_->input_personal_dict,
2023 return true; // All input is valid!
2027 void FormPreferences::updateSpellChecker()
2030 if (lyxrc.isp_command == "none" )
2032 else if (lyxrc.isp_command == "ispell" )
2034 else if (lyxrc.isp_command == "aspell" )
2036 fl_set_choice(spellchecker_->choice_spell_command, choice);
2038 string str = string();
2039 if (lyxrc.isp_use_alt_lang ) str = lyxrc.isp_alt_lang;
2041 fl_set_button(spellchecker_->check_alt_lang,
2042 lyxrc.isp_use_alt_lang);
2043 fl_set_input(spellchecker_->input_alt_lang, str.c_str());
2046 if (lyxrc.isp_use_esc_chars ) str = lyxrc.isp_esc_chars;
2048 fl_set_button(spellchecker_->check_escape_chars,
2049 lyxrc.isp_use_esc_chars);
2050 fl_set_input(spellchecker_->input_escape_chars, str.c_str());
2053 if (lyxrc.isp_use_pers_dict ) str = lyxrc.isp_pers_dict;
2055 fl_set_button(spellchecker_->check_personal_dict,
2056 lyxrc.isp_use_pers_dict);
2057 fl_set_input(spellchecker_->input_personal_dict, str.c_str());
2059 fl_set_button(spellchecker_->check_compound_words,
2060 lyxrc.isp_accept_compound);
2061 fl_set_button(spellchecker_->check_input_enc,
2062 lyxrc.isp_use_input_encoding);
2064 // Activate/Deactivate the input fields dependent on the state of the
2066 inputSpellChecker( 0 );
2070 bool FormPreferences::WriteableDir( string const & name ) const
2072 bool success = true;
2075 if (!AbsolutePath(name)) {
2077 str = N_("WARNING! The absolute path is required.");
2080 FileInfo const tp(name);
2081 if (success && !tp.isDir()) {
2083 str = N_("WARNING! Directory does not exist.");
2086 if (success && !tp.writable()) {
2088 str = N_("WARNING! Cannot write to this directory.");
2092 fl_set_object_label(dialog_->text_warning, str.c_str());
2093 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2100 bool FormPreferences::ReadableDir( string const & name ) const
2102 bool success = true;
2105 if (!AbsolutePath(name)) {
2107 str = N_("WARNING! The absolute path is required.");
2110 FileInfo const tp(name);
2111 if (success && !tp.isDir()) {
2113 str = N_("WARNING! Directory does not exist.");
2116 if (success && !tp.readable()) {
2118 str = N_("WARNING! Cannot read this directory.");
2122 fl_set_object_label(dialog_->text_warning, str.c_str());
2123 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2130 bool FormPreferences::WriteableFile(string const & name,
2131 string const & suffix) const
2133 // A writeable file is either:
2134 // * An existing file to which we have write access, or
2135 // * A file that doesn't yet exist but that would exist in a writeable
2138 bool success = true;
2143 str = N_("WARNING! No file input.");
2146 string const dir = OnlyPath(name);
2147 if (success && !AbsolutePath(dir)) {
2149 str = N_("WARNING! The absolute path is required.");
2152 // This is not a nice way to use FileInfo (Lgb)
2165 // This should be equivalent (Lgb)
2171 if (success && !d.isDir()) {
2173 str = N_("WARNING! Directory does not exist.");
2176 if (success && !d.writable()) {
2178 str = N_("WARNING! Cannot write to this directory.");
2181 FileInfo f(name+suffix);
2182 if (success && (dir == name || f.isDir())) {
2184 str = N_("WARNING! A file is required, not a directory.");
2187 if (success && (f.exist() && !f.writable())) {
2189 str = N_("WARNING! Cannot write to this file.");
2193 fl_set_object_label(dialog_->text_warning, str.c_str());
2194 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2201 void FormPreferences::ComboLanguageCB(int, void * v, Combox * combox)
2203 FormPreferences * pre = static_cast<FormPreferences*>(v);
2204 // This is safe, as nothing is done to the pointer, other than
2205 // to use its address in a block-if statement.
2206 pre->bc_.valid( pre->input( reinterpret_cast<FL_OBJECT *>(combox), 0 ));
2210 // C functions for the timer callback used to give the user feedback
2211 C_GENERICCB(FormPreferences, FeedbackCB)
2214 void FormPreferences::FeedbackCB(FL_OBJECT * ob, long)
2216 FormPreferences * pre =
2217 static_cast<FormPreferences*>(ob->form->u_vdata);
2218 pre->feedback( pre->feedbackObj );
2223 int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event,
2224 FL_Coord, FL_Coord, int, void *)
2226 // can occur when form is being deleted. This seems an easier fix than
2227 // a call "fl_set_object_posthandler(ob, 0)" for each and every object
2228 // in the destructor.
2229 if (!ob->form ) return 0;
2231 FormPreferences * pre =
2232 static_cast<FormPreferences*>(ob->form->u_vdata);
2233 pre->feedbackPost(ob, event);
2238 // post_handler for feedback messages
2239 void FormPreferences::feedbackPost(FL_OBJECT * ob, int event)
2241 // We do not test for empty help here, since this can never happen
2242 if (event == FL_ENTER){
2243 // Used as a placeholder for ob, so that we don't have to
2244 // a horrible reinterpret_cast to long and pass it as an
2245 // argument in fl_set_object_callback.
2247 fl_set_object_callback(dialog_->timer_feedback,
2248 C_FormPreferencesFeedbackCB,
2250 fl_set_timer(dialog_->timer_feedback, 0.5);
2252 else if (event != FL_MOTION){
2253 fl_set_timer(dialog_->timer_feedback, 0);
2255 fl_set_object_label(dialog_->text_warning, "");
2260 void FormPreferences::setPostHandler(FL_OBJECT * ob) const
2262 fl_set_object_posthandler(ob, C_FormPreferencesFeedbackPost);