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 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;
446 while( iss.good() ) {
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()
576 void FormPreferences::applyConverters() const
581 void FormPreferences::buildConverters()
583 converters_ = build_converters();
588 string FormPreferences::feedbackConverters( FL_OBJECT const * const ) const
594 void FormPreferences::updateConverters()
599 void FormPreferences::applyFormats() const
604 void FormPreferences::buildFormats()
606 formats_ = build_formats();
608 fl_set_input_return(formats_->input_format, FL_RETURN_CHANGED);
609 fl_set_input_return(formats_->input_viewer, FL_RETURN_CHANGED);
610 fl_set_input_return(formats_->input_gui_name, FL_RETURN_CHANGED);
611 fl_set_input_return(formats_->input_extension, FL_RETURN_CHANGED);
613 fl_set_input_filter(formats_->input_format, fl_lowercase_filter);
617 string FormPreferences::feedbackFormats( FL_OBJECT const * const ) const
625 bool FormPreferences::inputFormats( FL_OBJECT const * const )
631 void FormPreferences::updateFormats()
636 void FormPreferences::applyInputsMisc() const
638 lyxrc.date_insert_format = fl_get_input(inputs_misc_->input_date_format);
642 void FormPreferences::buildInputsMisc()
644 inputs_misc_ = build_inputs_misc();
646 fl_set_input_return(inputs_misc_->input_date_format,
649 // set up the feedback mechanism
650 fl_addto_form(inputs_misc_->form);
652 setPostHandler( inputs_misc_->input_date_format );
658 string FormPreferences::feedbackInputsMisc( FL_OBJECT const * const ob ) const
662 if( ob == inputs_misc_->input_date_format )
663 str = lyxrc.getDescription( LyXRC::RC_DATE_INSERT_FORMAT );
669 void FormPreferences::updateInputsMisc()
671 fl_set_input(inputs_misc_->input_date_format,
672 lyxrc.date_insert_format.c_str());
676 void FormPreferences::applyInterface() const
678 lyxrc.popup_font_name =
679 fl_get_input(interface_->input_popup_font);
680 lyxrc.menu_font_name = fl_get_input(interface_->input_menu_font);
681 lyxrc.font_norm_menu =
682 fl_get_input(interface_->input_popup_encoding);
683 lyxrc.bind_file = fl_get_input(interface_->input_bind_file);
684 lyxrc.ui_file = fl_get_input(interface_->input_ui_file);
685 lyxrc.override_x_deadkeys =
686 fl_get_button(interface_->check_override_x_dead_keys);
690 void FormPreferences::buildInterface()
692 interface_ = build_interface();
694 fl_set_input_return(interface_->input_popup_font, FL_RETURN_CHANGED);
695 fl_set_input_return(interface_->input_menu_font, FL_RETURN_CHANGED);
696 fl_set_input_return(interface_->input_popup_encoding,
698 fl_set_input_return(interface_->input_bind_file, FL_RETURN_CHANGED);
699 fl_set_input_return(interface_->input_ui_file, FL_RETURN_CHANGED);
701 // deactivate the browse buttons because they aren't implemented
702 fl_deactivate_object(interface_->button_bind_file_browse);
703 fl_deactivate_object(interface_->button_ui_file_browse);
704 fl_set_object_lcol(interface_->button_bind_file_browse, FL_INACTIVE);
705 fl_set_object_lcol(interface_->button_ui_file_browse, FL_INACTIVE);
707 // set up the feedback mechanism
708 fl_addto_form(interface_->form);
710 setPostHandler( interface_->input_popup_font );
711 setPostHandler( interface_->input_menu_font );
712 setPostHandler( interface_->input_popup_encoding );
713 setPostHandler( interface_->input_bind_file );
714 setPostHandler( interface_->button_bind_file_browse );
715 setPostHandler( interface_->input_ui_file );
716 setPostHandler( interface_->button_ui_file_browse );
717 setPostHandler( interface_->check_override_x_dead_keys );
724 string FormPreferences::feedbackInterface( FL_OBJECT const * const ob ) const
728 if( ob == interface_->input_popup_font )
729 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_POPUP );
730 else if ( ob == interface_->input_menu_font )
731 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_MENU );
732 else if ( ob == interface_->input_popup_encoding )
733 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING_MENU );
734 else if ( ob == interface_->input_bind_file )
735 str = lyxrc.getDescription( LyXRC::RC_BINDFILE );
736 else if ( ob == interface_->input_ui_file )
737 str = lyxrc.getDescription( LyXRC::RC_UIFILE );
738 else if ( ob == interface_->check_override_x_dead_keys )
739 str = lyxrc.getDescription( LyXRC::RC_OVERRIDE_X_DEADKEYS );
745 void FormPreferences::updateInterface()
747 fl_set_input(interface_->input_popup_font,
748 lyxrc.popup_font_name.c_str());
749 fl_set_input(interface_->input_menu_font,
750 lyxrc.menu_font_name.c_str());
751 fl_set_input(interface_->input_popup_encoding,
752 lyxrc.font_norm_menu.c_str());
753 fl_set_input(interface_->input_bind_file,
754 lyxrc.bind_file.c_str());
755 fl_set_input(interface_->input_ui_file,
756 lyxrc.ui_file.c_str());
757 fl_set_button(interface_->check_override_x_dead_keys,
758 lyxrc.override_x_deadkeys);
762 void FormPreferences::applyLanguage() const
764 lyxrc.default_language = combo_default_lang->getline();
766 int button = fl_get_button(language_->check_use_kbmap);
767 lyxrc.use_kbmap = static_cast<bool>(button);
770 lyxrc.primary_kbmap = combo_kbmap_1->getline();
771 lyxrc.secondary_kbmap = combo_kbmap_2->getline();
774 button = fl_get_button(language_->check_rtl_support);
775 lyxrc.rtl_support = static_cast<bool>(button);
777 button = fl_get_button(language_->check_auto_begin);
778 lyxrc.language_auto_begin = static_cast<bool>(button);
780 button = fl_get_button(language_->check_auto_end);
781 lyxrc.language_auto_end = static_cast<bool>(button);
783 button = fl_get_button(language_->check_mark_foreign);
784 lyxrc.mark_foreign_language = static_cast<bool>(button);
786 lyxrc.language_package = fl_get_input(language_->input_package);
787 lyxrc.language_command_begin = fl_get_input(language_->input_command_begin);
788 lyxrc.language_command_end = fl_get_input(language_->input_command_end);
792 void FormPreferences::buildLanguage()
794 language_ = build_language();
796 fl_set_input_return(language_->input_package, FL_RETURN_CHANGED);
797 fl_set_input_return(language_->input_command_begin, FL_RETURN_CHANGED);
798 fl_set_input_return(language_->input_command_end, FL_RETURN_CHANGED);
800 // The default_language is a combo-box and has to be inserted manually
801 fl_freeze_form(language_->form);
802 fl_addto_form(language_->form);
804 FL_OBJECT * obj = language_->choice_default_lang;
805 fl_deactivate_object(language_->choice_default_lang);
806 combo_default_lang = new Combox(FL_COMBOX_DROPLIST);
807 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
808 combo_default_lang->shortcut("#L",1);
809 combo_default_lang->setcallback(ComboLanguageCB, this);
810 LanguagesAdd( *combo_default_lang );
813 obj = language_->choice_kbmap_1;
814 fl_deactivate_object(language_->choice_kbmap_1);
815 combo_kbmap_1 = new Combox(FL_COMBOX_DROPLIST);
816 combo_kbmap_1->add(obj->x, obj->y, obj->w, obj->h, 400);
817 combo_kbmap_1->shortcut("#1",1);
818 combo_kbmap_1->setcallback(ComboLanguageCB, this);
819 LanguagesAdd( *combo_kbmap_1 );
822 obj = language_->choice_kbmap_2;
823 fl_deactivate_object(language_->choice_kbmap_2);
824 combo_kbmap_2 = new Combox(FL_COMBOX_DROPLIST);
825 combo_kbmap_2->add(obj->x, obj->y, obj->w, obj->h, 400);
826 combo_kbmap_2->shortcut("#2",1);
827 combo_kbmap_2->setcallback(ComboLanguageCB, this);
828 LanguagesAdd( *combo_kbmap_2 );
831 fl_unfreeze_form(language_->form);
833 // set up the feedback mechanism
834 fl_addto_form(language_->form);
836 setPostHandler( language_->input_package );
837 setPostHandler( language_->check_use_kbmap );
839 // This is safe, as nothing is done to the pointer, other than
840 // to use its address in a block-if statement.
841 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_default_lang) );
842 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_1) );
843 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_2) );
845 setPostHandler( language_->check_rtl_support );
846 setPostHandler( language_->check_mark_foreign );
847 setPostHandler( language_->check_auto_begin );
848 setPostHandler( language_->check_auto_end );
849 setPostHandler( language_->input_command_begin );
850 setPostHandler( language_->input_command_end );
856 string FormPreferences::feedbackLanguage( FL_OBJECT const * const ob ) const
860 if( reinterpret_cast<Combox const *>(ob) == combo_default_lang )
861 str = lyxrc.getDescription( LyXRC::RC_DEFAULT_LANGUAGE );
862 else if( ob == language_->check_use_kbmap )
863 str = lyxrc.getDescription( LyXRC::RC_KBMAP );
864 else if( reinterpret_cast<Combox const *>(ob) == combo_kbmap_1)
865 str = lyxrc.getDescription( LyXRC::RC_KBMAP_PRIMARY );
866 else if( reinterpret_cast<Combox const *>(ob) == combo_kbmap_2 )
867 str = lyxrc.getDescription( LyXRC::RC_KBMAP_SECONDARY );
868 else if( ob == language_->check_rtl_support )
869 str = lyxrc.getDescription( LyXRC::RC_RTL_SUPPORT );
870 else if( ob == language_->check_auto_begin )
871 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_BEGIN );
872 else if( ob == language_->check_auto_end )
873 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_END );
874 else if( ob == language_->check_mark_foreign )
875 str = lyxrc.getDescription( LyXRC::RC_MARK_FOREIGN_LANGUAGE );
876 else if( ob == language_->input_package )
877 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_PACKAGE );
878 else if( ob == language_->input_command_begin )
879 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_BEGIN );
880 else if( ob == language_->input_command_end )
881 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_END );
887 bool FormPreferences::inputLanguage( FL_OBJECT const * const ob )
889 bool activate = true;
891 if( !ob || ob == language_->check_use_kbmap ) {
892 if( fl_get_button(language_->check_use_kbmap) ) {
893 combo_kbmap_1->activate();
894 combo_kbmap_2->activate();
896 combo_kbmap_1->deactivate();
897 combo_kbmap_2->deactivate();
905 void FormPreferences::updateLanguage()
907 fl_set_button(language_->check_use_kbmap,
910 combo_default_lang->select_text( lyxrc.default_language );
912 if( lyxrc.use_kbmap ) {
913 combo_kbmap_1->select_text( lyxrc.primary_kbmap );
914 combo_kbmap_2->select_text( lyxrc.secondary_kbmap );
916 combo_kbmap_1->select_text( lyxrc.default_language );
917 combo_kbmap_2->select_text( lyxrc.default_language );
920 fl_set_button(language_->check_rtl_support, lyxrc.rtl_support);
921 fl_set_button(language_->check_auto_begin, lyxrc.language_auto_begin);
922 fl_set_button(language_->check_auto_end, lyxrc.language_auto_end);
923 fl_set_button(language_->check_mark_foreign,
924 lyxrc.mark_foreign_language);
926 fl_set_input(language_->input_package,
927 lyxrc.language_package.c_str());
928 fl_set_input(language_->input_command_begin,
929 lyxrc.language_command_begin.c_str());
930 fl_set_input(language_->input_command_end,
931 lyxrc.language_command_end.c_str());
933 // Activate/Deactivate the input fields dependent on the state of the
939 void FormPreferences::LanguagesAdd( Combox & combo ) const
941 for(Languages::const_iterator cit = languages.begin();
942 cit != languages.end(); cit++) {
943 combo.addto((*cit).second.lang());
948 void FormPreferences::applyLnFmisc() const
950 lyxrc.show_banner = fl_get_button(lnf_misc_->check_banner);
951 lyxrc.auto_region_delete = fl_get_button(lnf_misc_->
952 check_auto_region_delete);
953 lyxrc.exit_confirmation = fl_get_button(lnf_misc_->check_exit_confirm);
954 lyxrc.display_shortcuts =
955 fl_get_button(lnf_misc_->check_display_shortcuts);
956 lyxrc.new_ask_filename = fl_get_button(lnf_misc_->check_ask_new_file);
957 lyxrc.cursor_follows_scrollbar =
958 fl_get_button(lnf_misc_->check_cursor_follows_scrollbar);
959 lyxrc.autosave = static_cast<unsigned int>
960 (fl_get_counter_value(lnf_misc_->counter_autosave));
961 lyxrc.wheel_jump = static_cast<unsigned int>
962 (fl_get_counter_value(lnf_misc_->counter_wm_jump));
966 void FormPreferences::buildLnFmisc()
968 lnf_misc_ = build_lnf_misc();
970 fl_set_counter_return(lnf_misc_->counter_autosave,
972 fl_set_counter_return(lnf_misc_->counter_wm_jump,
975 // set up the feedback mechanism
976 fl_addto_form(lnf_misc_->form);
978 setPostHandler( lnf_misc_->check_banner );
979 setPostHandler( lnf_misc_->check_auto_region_delete );
980 setPostHandler( lnf_misc_->check_exit_confirm );
981 setPostHandler( lnf_misc_->check_display_shortcuts );
982 setPostHandler( lnf_misc_->counter_autosave );
983 setPostHandler( lnf_misc_->check_ask_new_file );
984 setPostHandler( lnf_misc_->check_cursor_follows_scrollbar );
985 setPostHandler( lnf_misc_->counter_wm_jump );
991 string FormPreferences::feedbackLnFmisc( FL_OBJECT const * const ob ) const
995 if( ob == lnf_misc_->check_banner )
996 str = lyxrc.getDescription( LyXRC::RC_SHOW_BANNER );
997 else if( ob == lnf_misc_->check_auto_region_delete )
998 str = lyxrc.getDescription( LyXRC::RC_AUTOREGIONDELETE );
999 else if( ob == lnf_misc_->check_exit_confirm )
1000 str = lyxrc.getDescription( LyXRC::RC_EXIT_CONFIRMATION );
1001 else if( ob == lnf_misc_->check_display_shortcuts )
1002 str = lyxrc.getDescription( LyXRC::RC_DISPLAY_SHORTCUTS );
1003 else if( ob == lnf_misc_->check_ask_new_file )
1004 str = lyxrc.getDescription( LyXRC::RC_NEW_ASK_FILENAME );
1005 else if( ob == lnf_misc_->check_cursor_follows_scrollbar )
1006 str = lyxrc.getDescription( LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR );
1007 else if( ob == lnf_misc_->counter_autosave )
1008 str = lyxrc.getDescription( LyXRC::RC_AUTOSAVE );
1009 else if( ob == lnf_misc_->counter_wm_jump )
1010 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 );
1079 string FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob ) const
1083 if( ob == outputs_misc_->counter_line_len )
1084 str = lyxrc.getDescription( LyXRC::RC_ASCII_LINELEN );
1085 else if( ob == outputs_misc_->input_tex_encoding )
1086 str = lyxrc.getDescription( LyXRC::RC_FONT_ENCODING );
1087 else if( ob == outputs_misc_->input_ascii_roff )
1088 str = lyxrc.getDescription( LyXRC::RC_ASCIIROFF_COMMAND );
1089 else if( ob == outputs_misc_->input_checktex )
1090 str = lyxrc.getDescription( LyXRC::RC_CHKTEX_COMMAND );
1091 else if( ob == outputs_misc_->choice_default_papersize )
1092 str = lyxrc.getDescription( LyXRC::RC_DEFAULT_PAPERSIZE );
1098 void FormPreferences::updateOutputsMisc()
1100 fl_set_counter_value(outputs_misc_->counter_line_len,
1101 lyxrc.ascii_linelen);
1102 fl_set_input(outputs_misc_->input_tex_encoding,
1103 lyxrc.fontenc.c_str());
1104 fl_set_choice(outputs_misc_->choice_default_papersize,
1105 lyxrc.default_papersize+1);
1106 fl_set_input(outputs_misc_->input_ascii_roff,
1107 lyxrc.ascii_roff_command.c_str());
1108 fl_set_input(outputs_misc_->input_checktex,
1109 lyxrc.chktex_command.c_str());
1113 void FormPreferences::applyPaths()
1115 lyxrc.document_path = fl_get_input(paths_->input_default_path);
1116 lyxrc.template_path = fl_get_input(paths_->input_template_path);
1118 int button = fl_get_button(paths_->check_use_temp_dir);
1119 string str = fl_get_input(paths_->input_temp_dir);
1120 if( !button ) str.erase();
1122 lyxrc.use_tempdir = button;
1123 lyxrc.tempdir_path = str;
1125 button = fl_get_button(paths_->check_last_files);
1126 str = fl_get_input(paths_->input_lastfiles);
1127 if( !button ) str.erase();
1129 lyxrc.check_lastfiles = button;
1130 lyxrc.lastfiles = str;
1131 lyxrc.num_lastfiles = static_cast<unsigned int>
1132 (fl_get_counter_value(paths_->counter_lastfiles));
1134 button = fl_get_button(paths_->check_make_backups);
1135 str = fl_get_input(paths_->input_backup_path);
1136 if( !button ) str.erase();
1138 lyxrc.make_backup = button;
1139 lyxrc.backupdir_path = str;
1141 lyxrc.lyxpipes = fl_get_input(paths_->input_serverpipe);
1148 void FormPreferences::buildPaths()
1150 paths_ = build_paths();
1152 fl_set_input_return(paths_->input_default_path, FL_RETURN_CHANGED);
1153 fl_set_input_return(paths_->input_template_path, FL_RETURN_CHANGED);
1154 fl_set_input_return(paths_->input_temp_dir, FL_RETURN_CHANGED);
1155 fl_set_input_return(paths_->input_lastfiles, FL_RETURN_CHANGED);
1156 fl_set_input_return(paths_->input_backup_path, FL_RETURN_CHANGED);
1157 fl_set_counter_return(paths_->counter_lastfiles, FL_RETURN_CHANGED);
1158 fl_set_input_return(paths_->input_serverpipe, FL_RETURN_CHANGED);
1160 // deactivate the browse buttons because they aren't implemented
1161 fl_deactivate_object(paths_->button_document_browse);
1162 fl_deactivate_object(paths_->button_template_browse);
1163 fl_deactivate_object(paths_->button_temp_dir_browse);
1164 fl_deactivate_object(paths_->button_lastfiles_browse);
1165 fl_deactivate_object(paths_->button_backup_path_browse);
1166 fl_deactivate_object(paths_->button_serverpipe_browse);
1167 fl_set_object_lcol(paths_->button_document_browse, FL_INACTIVE);
1168 fl_set_object_lcol(paths_->button_template_browse, FL_INACTIVE);
1169 fl_set_object_lcol(paths_->button_temp_dir_browse, FL_INACTIVE);
1170 fl_set_object_lcol(paths_->button_lastfiles_browse, FL_INACTIVE);
1171 fl_set_object_lcol(paths_->button_backup_path_browse, FL_INACTIVE);
1172 fl_set_object_lcol(paths_->button_serverpipe_browse, FL_INACTIVE);
1174 // set up the feedback mechanism
1175 fl_addto_form(paths_->form);
1177 setPostHandler( paths_->input_default_path );
1178 setPostHandler( paths_->button_document_browse );
1179 setPostHandler( paths_->counter_lastfiles );
1180 setPostHandler( paths_->input_template_path );
1181 setPostHandler( paths_->button_template_browse );
1182 setPostHandler( paths_->check_last_files );
1183 setPostHandler( paths_->button_temp_dir_browse );
1184 setPostHandler( paths_->input_lastfiles );
1185 setPostHandler( paths_->button_lastfiles_browse );
1186 setPostHandler( paths_->check_make_backups );
1187 setPostHandler( paths_->input_backup_path );
1188 setPostHandler( paths_->button_backup_path_browse );
1189 setPostHandler( paths_->input_serverpipe );
1190 setPostHandler( paths_->button_serverpipe_browse );
1191 setPostHandler( paths_->input_temp_dir );
1192 setPostHandler( paths_->check_use_temp_dir );
1198 string FormPreferences::feedbackPaths( FL_OBJECT const * const ob ) const
1202 if( ob == paths_->input_default_path )
1203 str = lyxrc.getDescription( LyXRC::RC_DOCUMENTPATH );
1204 else if ( ob == paths_->input_template_path )
1205 str = lyxrc.getDescription( LyXRC::RC_TEMPLATEPATH );
1206 else if ( ob == paths_->check_use_temp_dir )
1207 str = lyxrc.getDescription( LyXRC::RC_USETEMPDIR );
1208 else if ( ob == paths_->input_temp_dir )
1209 str = lyxrc.getDescription( LyXRC::RC_TEMPDIRPATH );
1210 else if ( ob == paths_->check_last_files )
1211 str = lyxrc.getDescription( LyXRC::RC_CHECKLASTFILES );
1212 else if ( ob == paths_->input_lastfiles )
1213 str = lyxrc.getDescription( LyXRC::RC_LASTFILES );
1214 else if ( ob == paths_->counter_lastfiles )
1215 str = lyxrc.getDescription( LyXRC::RC_NUMLASTFILES );
1216 else if ( ob == paths_->check_make_backups )
1217 str = lyxrc.getDescription( LyXRC::RC_MAKE_BACKUP );
1218 else if ( ob == paths_->input_backup_path )
1219 str = lyxrc.getDescription( LyXRC::RC_BACKUPDIR_PATH );
1220 else if ( ob == paths_->input_serverpipe )
1221 str = lyxrc.getDescription( LyXRC::RC_SERVERPIPE );
1227 bool FormPreferences::inputPaths( FL_OBJECT const * const ob )
1229 bool activate = true;
1231 if( !ob || ob == paths_->check_use_temp_dir ) {
1232 if( fl_get_button(paths_->check_use_temp_dir) ) {
1233 fl_activate_object(paths_->input_temp_dir);
1234 fl_set_object_lcol(paths_->input_temp_dir,
1237 fl_deactivate_object(paths_->input_temp_dir);
1238 fl_set_object_lcol(paths_->input_temp_dir,
1243 if( !ob || ob == paths_->check_last_files ) {
1244 if( fl_get_button(paths_->check_last_files) ) {
1245 fl_activate_object(paths_->input_lastfiles);
1246 fl_set_object_lcol(paths_->input_lastfiles,
1249 fl_deactivate_object(paths_->input_lastfiles);
1250 fl_set_object_lcol(paths_->input_lastfiles,
1255 if( !ob || ob == paths_->check_make_backups ) {
1256 if( fl_get_button(paths_->check_make_backups) ) {
1257 fl_activate_object(paths_->input_backup_path);
1258 fl_set_object_lcol(paths_->input_backup_path,
1261 fl_deactivate_object(paths_->input_backup_path);
1262 fl_set_object_lcol(paths_->input_backup_path,
1267 if( !ob || ob == paths_->input_default_path ) {
1268 string name = fl_get_input(paths_->input_default_path);
1269 if( !WriteableDir(name) )
1273 if( !ob || ob == paths_->input_template_path ) {
1274 string name = fl_get_input(paths_->input_template_path);
1275 if( !ReadableDir(name) )
1279 if( !ob || ob == paths_->input_temp_dir ) {
1280 string name = fl_get_input(paths_->input_temp_dir);
1281 if( fl_get_button(paths_->check_make_backups)
1283 && !WriteableDir(name) )
1287 if( !ob || ob == paths_->input_backup_path ) {
1288 string name = fl_get_input(paths_->input_backup_path);
1289 if( fl_get_button(paths_->check_make_backups)
1291 && !WriteableDir(name) )
1295 if( !ob || ob == paths_->input_lastfiles ) {
1296 string name = fl_get_input(paths_->input_lastfiles);
1297 if( fl_get_button(paths_->check_last_files)
1299 && !WriteableFile(name) )
1303 if( !ob || ob == paths_->input_serverpipe ) {
1304 string name = fl_get_input(paths_->input_serverpipe);
1305 if( !name.empty() ) {
1306 if( !WriteableFile(name, ".in") )
1308 if( !WriteableFile(name, ".out") )
1317 void FormPreferences::updatePaths()
1319 fl_set_input(paths_->input_default_path,
1320 lyxrc.document_path.c_str());
1321 fl_set_input(paths_->input_template_path,
1322 lyxrc.template_path.c_str());
1324 string str = string();
1325 if( lyxrc.make_backup ) str = lyxrc.backupdir_path;
1327 fl_set_button(paths_->check_make_backups,
1329 fl_set_input(paths_->input_backup_path, str.c_str());
1332 if( lyxrc.use_tempdir ) str = lyxrc.tempdir_path;
1334 fl_set_button(paths_->check_use_temp_dir,
1336 fl_set_input(paths_->input_temp_dir, str.c_str());
1339 if( lyxrc.check_lastfiles ) str = lyxrc.lastfiles;
1341 fl_set_button(paths_->check_last_files,
1342 lyxrc.check_lastfiles);
1343 fl_set_input(paths_->input_lastfiles, str.c_str());
1344 fl_set_counter_value(paths_->counter_lastfiles,
1345 lyxrc.num_lastfiles);
1347 fl_set_input(paths_->input_serverpipe, lyxrc.lyxpipes.c_str());
1349 // Activate/Deactivate the input fields dependent on the state of the
1355 void FormPreferences::applyPrinter() const
1357 lyxrc.print_adapt_output = fl_get_button(printer_->check_adapt_output);
1358 lyxrc.print_command = fl_get_input(printer_->input_command);
1359 lyxrc.print_pagerange_flag = fl_get_input(printer_->input_page_range);
1360 lyxrc.print_copies_flag = fl_get_input(printer_->input_copies);
1361 lyxrc.print_reverse_flag = fl_get_input(printer_->input_reverse);
1362 lyxrc.print_to_printer = fl_get_input(printer_->input_to_printer);
1363 lyxrc.print_file_extension =
1364 fl_get_input(printer_->input_file_extension);
1365 lyxrc.print_spool_command =
1366 fl_get_input(printer_->input_spool_command);
1367 lyxrc.print_paper_flag = fl_get_input(printer_->input_paper_type);
1368 lyxrc.print_evenpage_flag = fl_get_input(printer_->input_even_pages);
1369 lyxrc.print_oddpage_flag = fl_get_input(printer_->input_odd_pages);
1370 lyxrc.print_collcopies_flag = fl_get_input(printer_->input_collated);
1371 lyxrc.print_landscape_flag = fl_get_input(printer_->input_landscape);
1372 lyxrc.print_to_file = fl_get_input(printer_->input_to_file);
1373 lyxrc.print_extra_options =
1374 fl_get_input(printer_->input_extra_options);
1375 lyxrc.print_spool_printerprefix =
1376 fl_get_input(printer_->input_spool_prefix);
1377 lyxrc.print_paper_dimension_flag =
1378 fl_get_input(printer_->input_paper_size);
1379 lyxrc.printer = fl_get_input(printer_->input_name);
1383 string FormPreferences::feedbackPrinter( FL_OBJECT const * const ob ) const
1387 if( ob == printer_->input_command )
1388 str = lyxrc.getDescription( LyXRC::RC_PRINT_COMMAND );
1389 else if( ob == printer_->check_adapt_output )
1390 str = lyxrc.getDescription( LyXRC::RC_PRINT_ADAPTOUTPUT );
1391 else if( ob == printer_->input_to_printer )
1392 str = lyxrc.getDescription( LyXRC::RC_PRINTTOPRINTER );
1393 else if( ob == printer_->input_to_file )
1394 str = lyxrc.getDescription( LyXRC::RC_PRINTTOFILE );
1395 else if( ob == printer_->input_file_extension )
1396 str = lyxrc.getDescription( LyXRC::RC_PRINTFILEEXTENSION );
1397 else if( ob == printer_->input_extra_options )
1398 str = lyxrc.getDescription( LyXRC::RC_PRINTEXSTRAOPTIONS );
1399 else if( ob == printer_->input_spool_command )
1400 str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_COMMAND );
1401 else if( ob == printer_->input_spool_prefix )
1402 str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_PRINTERPREFIX );
1403 else if( ob == printer_->input_name )
1404 str = lyxrc.getDescription( LyXRC::RC_PRINTER );
1405 else if( ob == printer_->input_even_pages )
1406 str = lyxrc.getDescription( LyXRC::RC_PRINTEVENPAGEFLAG );
1407 else if( ob == printer_->input_odd_pages )
1408 str = lyxrc.getDescription( LyXRC::RC_PRINTODDPAGEFLAG );
1409 else if( ob == printer_->input_page_range )
1410 str = lyxrc.getDescription( LyXRC::RC_PRINTPAGERANGEFLAG );
1411 else if( ob == printer_->input_reverse )
1412 str = lyxrc.getDescription( LyXRC::RC_PRINTREVERSEFLAG );
1413 else if( ob == printer_->input_landscape )
1414 str = lyxrc.getDescription( LyXRC::RC_PRINTLANDSCAPEFLAG );
1415 else if( ob == printer_->input_copies )
1416 str = lyxrc.getDescription( LyXRC::RC_PRINTCOLLCOPIESFLAG );
1417 else if( ob == printer_->input_collated )
1418 str = lyxrc.getDescription( LyXRC::RC_PRINTCOPIESFLAG );
1419 else if( ob == printer_->input_paper_type )
1420 str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERFLAG );
1421 else if( ob == printer_->input_paper_size )
1422 str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERDIMENSIONFLAG );
1428 void FormPreferences::buildPrinter()
1430 printer_ = build_printer();
1432 fl_set_input_return(printer_->input_command, FL_RETURN_CHANGED);
1433 fl_set_input_return(printer_->input_page_range, FL_RETURN_CHANGED);
1434 fl_set_input_return(printer_->input_copies, FL_RETURN_CHANGED);
1435 fl_set_input_return(printer_->input_reverse, FL_RETURN_CHANGED);
1436 fl_set_input_return(printer_->input_to_printer, FL_RETURN_CHANGED);
1437 fl_set_input_return(printer_->input_file_extension, FL_RETURN_CHANGED);
1438 fl_set_input_return(printer_->input_spool_command, FL_RETURN_CHANGED);
1439 fl_set_input_return(printer_->input_paper_type, FL_RETURN_CHANGED);
1440 fl_set_input_return(printer_->input_even_pages, FL_RETURN_CHANGED);
1441 fl_set_input_return(printer_->input_odd_pages, FL_RETURN_CHANGED);
1442 fl_set_input_return(printer_->input_collated, FL_RETURN_CHANGED);
1443 fl_set_input_return(printer_->input_landscape, FL_RETURN_CHANGED);
1444 fl_set_input_return(printer_->input_to_file, FL_RETURN_CHANGED);
1445 fl_set_input_return(printer_->input_extra_options, FL_RETURN_CHANGED);
1446 fl_set_input_return(printer_->input_spool_prefix, FL_RETURN_CHANGED);
1447 fl_set_input_return(printer_->input_paper_size, FL_RETURN_CHANGED);
1448 fl_set_input_return(printer_->input_name, FL_RETURN_CHANGED);
1450 // set up the feedback mechanism
1451 fl_addto_form(printer_->form);
1453 setPostHandler( printer_->input_command );
1454 setPostHandler( printer_->input_page_range );
1455 setPostHandler( printer_->input_copies );
1456 setPostHandler( printer_->input_reverse );
1457 setPostHandler( printer_->input_to_printer );
1458 setPostHandler( printer_->input_file_extension );
1459 setPostHandler( printer_->input_spool_command );
1460 setPostHandler( printer_->input_paper_type );
1461 setPostHandler( printer_->input_even_pages );
1462 setPostHandler( printer_->input_odd_pages );
1463 setPostHandler( printer_->input_collated );
1464 setPostHandler( printer_->input_landscape );
1465 setPostHandler( printer_->input_to_file );
1466 setPostHandler( printer_->input_extra_options );
1467 setPostHandler( printer_->input_spool_prefix );
1468 setPostHandler( printer_->input_paper_size );
1469 setPostHandler( printer_->input_name );
1470 setPostHandler( printer_->check_adapt_output );
1476 void FormPreferences::updatePrinter()
1478 fl_set_button(printer_->check_adapt_output,
1479 lyxrc.print_adapt_output);
1480 fl_set_input(printer_->input_command,
1481 lyxrc.print_command.c_str());
1482 fl_set_input(printer_->input_page_range,
1483 lyxrc.print_pagerange_flag.c_str());
1484 fl_set_input(printer_->input_copies,
1485 lyxrc.print_copies_flag.c_str());
1486 fl_set_input(printer_->input_reverse,
1487 lyxrc.print_reverse_flag.c_str());
1488 fl_set_input(printer_->input_to_printer,
1489 lyxrc.print_to_printer.c_str());
1490 fl_set_input(printer_->input_file_extension,
1491 lyxrc.print_file_extension.c_str());
1492 fl_set_input(printer_->input_spool_command,
1493 lyxrc.print_spool_command.c_str());
1494 fl_set_input(printer_->input_paper_type,
1495 lyxrc.print_paper_flag.c_str());
1496 fl_set_input(printer_->input_even_pages,
1497 lyxrc.print_evenpage_flag.c_str());
1498 fl_set_input(printer_->input_odd_pages,
1499 lyxrc.print_oddpage_flag.c_str());
1500 fl_set_input(printer_->input_collated,
1501 lyxrc.print_collcopies_flag.c_str());
1502 fl_set_input(printer_->input_landscape,
1503 lyxrc.print_landscape_flag.c_str());
1504 fl_set_input(printer_->input_to_file,
1505 lyxrc.print_to_file.c_str());
1506 fl_set_input(printer_->input_extra_options,
1507 lyxrc.print_extra_options.c_str());
1508 fl_set_input(printer_->input_spool_prefix,
1509 lyxrc.print_spool_printerprefix.c_str());
1510 fl_set_input(printer_->input_paper_size,
1511 lyxrc.print_paper_dimension_flag.c_str());
1512 fl_set_input(printer_->input_name,
1513 lyxrc.printer.c_str());
1517 void FormPreferences::applyScreenFonts() const
1519 bool changed = false;
1521 string str = fl_get_input(screen_fonts_->input_roman);
1522 if( lyxrc.roman_font_name != str ) {
1524 lyxrc.roman_font_name = str;
1527 str = fl_get_input(screen_fonts_->input_sans);
1528 if( lyxrc.sans_font_name != str ) {
1530 lyxrc.sans_font_name = str;
1533 str = fl_get_input(screen_fonts_->input_typewriter);
1534 if( lyxrc.typewriter_font_name != str ) {
1536 lyxrc.typewriter_font_name = str;
1539 str = fl_get_input(screen_fonts_->input_screen_encoding);
1540 if( lyxrc.font_norm != str ) {
1542 lyxrc.font_norm = str;
1545 bool button = fl_get_button(screen_fonts_->check_scalable);
1546 if( lyxrc.use_scalable_fonts != button ) {
1548 lyxrc.use_scalable_fonts = button;
1551 unsigned int ivalue = static_cast<unsigned int>
1552 (fl_get_counter_value(screen_fonts_->counter_zoom));
1553 if( lyxrc.zoom != ivalue) {
1555 lyxrc.zoom = ivalue;
1558 ivalue = static_cast<unsigned int>
1559 (fl_get_counter_value(screen_fonts_->counter_dpi));
1560 if (lyxrc.dpi != ivalue) {
1565 double dvalue = strToDbl(fl_get_input(screen_fonts_->input_tiny));
1566 if( lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue ) {
1568 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
1571 dvalue = strToDbl(fl_get_input(screen_fonts_->input_script));
1572 if( lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue ) {
1574 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
1577 dvalue = strToDbl(fl_get_input(screen_fonts_->input_footnote));
1578 if( lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue ) {
1580 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
1583 dvalue = strToDbl(fl_get_input(screen_fonts_->input_small));
1584 if( lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue ) {
1586 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
1589 dvalue = strToDbl(fl_get_input(screen_fonts_->input_normal));
1590 if( lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue ) {
1592 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
1595 dvalue = strToDbl(fl_get_input(screen_fonts_->input_large));
1596 if( lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue ) {
1598 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
1601 dvalue = strToDbl(fl_get_input(screen_fonts_->input_larger));
1602 if( lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue ) {
1604 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
1607 dvalue = strToDbl(fl_get_input(screen_fonts_->input_largest));
1608 if( lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue ) {
1610 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
1613 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huge));
1614 if( lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue ) {
1616 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
1619 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huger));
1620 if( lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue ) {
1622 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
1626 // Now update the buffers
1627 // Can anything below here affect the redraw process?
1628 lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
1633 void FormPreferences::buildScreenFonts()
1635 screen_fonts_ = build_screen_fonts();
1637 fl_set_input_return(screen_fonts_->input_roman, FL_RETURN_CHANGED);
1638 fl_set_input_return(screen_fonts_->input_sans, FL_RETURN_CHANGED);
1639 fl_set_input_return(screen_fonts_->input_typewriter,
1641 fl_set_input_return(screen_fonts_->input_screen_encoding,
1643 fl_set_counter_return(screen_fonts_->counter_zoom, FL_RETURN_CHANGED);
1644 fl_set_counter_return(screen_fonts_->counter_dpi, FL_RETURN_CHANGED);
1645 fl_set_input_return(screen_fonts_->input_tiny, FL_RETURN_CHANGED);
1646 fl_set_input_return(screen_fonts_->input_script, FL_RETURN_CHANGED);
1647 fl_set_input_return(screen_fonts_->input_footnote, FL_RETURN_CHANGED);
1648 fl_set_input_return(screen_fonts_->input_small, FL_RETURN_CHANGED);
1649 fl_set_input_return(screen_fonts_->input_normal, FL_RETURN_CHANGED);
1650 fl_set_input_return(screen_fonts_->input_large, FL_RETURN_CHANGED);
1651 fl_set_input_return(screen_fonts_->input_larger, FL_RETURN_CHANGED);
1652 fl_set_input_return(screen_fonts_->input_largest, FL_RETURN_CHANGED);
1653 fl_set_input_return(screen_fonts_->input_huge, FL_RETURN_CHANGED);
1654 fl_set_input_return(screen_fonts_->input_huger, FL_RETURN_CHANGED);
1656 fl_set_input_filter(screen_fonts_->input_tiny,
1657 fl_unsigned_int_filter);
1658 fl_set_input_filter(screen_fonts_->input_script,
1659 fl_unsigned_int_filter);
1660 fl_set_input_filter(screen_fonts_->input_footnote,
1661 fl_unsigned_int_filter);
1662 fl_set_input_filter(screen_fonts_->input_small,
1663 fl_unsigned_int_filter);
1664 fl_set_input_filter(screen_fonts_->input_normal,
1665 fl_unsigned_int_filter);
1666 fl_set_input_filter(screen_fonts_->input_large,
1667 fl_unsigned_int_filter);
1668 fl_set_input_filter(screen_fonts_->input_larger,
1669 fl_unsigned_int_filter);
1670 fl_set_input_filter(screen_fonts_->input_largest,
1671 fl_unsigned_int_filter);
1672 fl_set_input_filter(screen_fonts_->input_huge,
1673 fl_unsigned_int_filter);
1674 fl_set_input_filter(screen_fonts_->input_huger,
1675 fl_unsigned_int_filter);
1677 // set up the feedback mechanism
1678 fl_addto_form(screen_fonts_->form);
1680 setPostHandler( screen_fonts_->input_roman );
1681 setPostHandler( screen_fonts_->input_sans );
1682 setPostHandler( screen_fonts_->input_typewriter );
1683 setPostHandler( screen_fonts_->counter_zoom );
1684 setPostHandler( screen_fonts_->counter_dpi );
1685 setPostHandler( screen_fonts_->check_scalable );
1686 setPostHandler( screen_fonts_->input_screen_encoding );
1687 setPostHandler( screen_fonts_->input_tiny );
1688 setPostHandler( screen_fonts_->input_script );
1689 setPostHandler( screen_fonts_->input_footnote );
1690 setPostHandler( screen_fonts_->input_small );
1691 setPostHandler( screen_fonts_->input_large );
1692 setPostHandler( screen_fonts_->input_larger );
1693 setPostHandler( screen_fonts_->input_largest );
1694 setPostHandler( screen_fonts_->input_normal );
1695 setPostHandler( screen_fonts_->input_huge );
1696 setPostHandler( screen_fonts_->input_huger );
1702 string FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob ) const
1706 if( ob == screen_fonts_->input_roman )
1707 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ROMAN );
1708 else if( ob == screen_fonts_->input_sans )
1709 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SANS );
1710 else if( ob == screen_fonts_->input_typewriter )
1711 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_TYPEWRITER );
1712 else if( ob == screen_fonts_->check_scalable )
1713 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SCALABLE );
1714 else if( ob == screen_fonts_->input_screen_encoding )
1715 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING );
1716 else if( ob == screen_fonts_->counter_zoom )
1717 str = lyxrc.getDescription( LyXRC::RC_SCREEN_ZOOM );
1718 else if( ob == screen_fonts_->counter_dpi )
1719 str = lyxrc.getDescription( LyXRC::RC_SCREEN_DPI );
1720 else if( ob == screen_fonts_->input_tiny
1721 || ob == screen_fonts_->input_script
1722 || ob == screen_fonts_->input_footnote
1723 || ob == screen_fonts_->input_small
1724 || ob == screen_fonts_->input_large
1725 || ob == screen_fonts_->input_larger
1726 || ob == screen_fonts_->input_larger
1727 || ob == screen_fonts_->input_largest
1728 || ob == screen_fonts_->input_normal
1729 || ob == screen_fonts_->input_huge
1730 || ob == screen_fonts_->input_huger )
1731 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SIZES );
1737 bool FormPreferences::inputScreenFonts()
1739 bool activate = true;
1742 // Make sure that all fonts all have positive entries
1743 // Also note that an empty entry is returned as 0.0 by strToDbl
1744 if (0.0 >= strToDbl(fl_get_input(screen_fonts_->input_tiny))
1745 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_script))
1746 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_footnote))
1747 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_small))
1748 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_normal))
1749 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_large))
1750 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_larger))
1751 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_largest))
1752 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huge))
1753 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huger))) {
1755 str = N_("WARNING! Fonts must be positive!");
1757 // Fontsizes -- tiny < script < footnote etc.
1758 } else if (strToDbl(fl_get_input(screen_fonts_->input_tiny)) >
1759 strToDbl(fl_get_input(screen_fonts_->input_script)) ||
1760 strToDbl(fl_get_input(screen_fonts_->input_script)) >
1761 strToDbl(fl_get_input(screen_fonts_->input_footnote)) ||
1762 strToDbl(fl_get_input(screen_fonts_->input_footnote)) >
1763 strToDbl(fl_get_input(screen_fonts_->input_small)) ||
1764 strToDbl(fl_get_input(screen_fonts_->input_small)) >
1765 strToDbl(fl_get_input(screen_fonts_->input_normal)) ||
1766 strToDbl(fl_get_input(screen_fonts_->input_normal)) >
1767 strToDbl(fl_get_input(screen_fonts_->input_large)) ||
1768 strToDbl(fl_get_input(screen_fonts_->input_large)) >
1769 strToDbl(fl_get_input(screen_fonts_->input_larger)) ||
1770 strToDbl(fl_get_input(screen_fonts_->input_larger)) >
1771 strToDbl(fl_get_input(screen_fonts_->input_largest)) ||
1772 strToDbl(fl_get_input(screen_fonts_->input_largest)) >
1773 strToDbl(fl_get_input(screen_fonts_->input_huge)) ||
1774 strToDbl(fl_get_input(screen_fonts_->input_huge)) >
1775 strToDbl(fl_get_input(screen_fonts_->input_huger))) {
1778 str = N_("WARNING! Fonts must be input in the order tiny > script>\nfootnote > small > normal > large > larger > largest > huge > huger.");
1782 fl_set_object_label(dialog_->text_warning, str.c_str());
1783 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
1790 void FormPreferences::updateScreenFonts()
1792 fl_set_input(screen_fonts_->input_roman,
1793 lyxrc.roman_font_name.c_str());
1794 fl_set_input(screen_fonts_->input_sans,
1795 lyxrc.sans_font_name.c_str());
1796 fl_set_input(screen_fonts_->input_typewriter,
1797 lyxrc.typewriter_font_name.c_str());
1798 fl_set_input(screen_fonts_->input_screen_encoding,
1799 lyxrc.font_norm.c_str());
1800 fl_set_button(screen_fonts_->check_scalable,
1801 lyxrc.use_scalable_fonts);
1802 fl_set_counter_value(screen_fonts_->counter_zoom, lyxrc.zoom);
1803 fl_set_counter_value(screen_fonts_->counter_dpi, lyxrc.dpi);
1804 fl_set_input(screen_fonts_->input_tiny,
1805 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
1806 fl_set_input(screen_fonts_->input_script,
1807 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
1808 fl_set_input(screen_fonts_->input_footnote,
1809 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
1810 fl_set_input(screen_fonts_->input_small,
1811 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
1812 fl_set_input(screen_fonts_->input_normal,
1813 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
1814 fl_set_input(screen_fonts_->input_large,
1815 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
1816 fl_set_input(screen_fonts_->input_larger,
1817 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
1818 fl_set_input(screen_fonts_->input_largest,
1819 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
1820 fl_set_input(screen_fonts_->input_huge,
1821 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
1822 fl_set_input(screen_fonts_->input_huger,
1823 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
1827 void FormPreferences::applySpellChecker()
1830 string choice = "none";
1831 switch(fl_get_choice(spellchecker_->choice_spell_command)) {
1844 lyxrc.isp_command = choice;
1846 // If spell checker == "none", all other input set to off.
1847 if( fl_get_choice(spellchecker_->choice_spell_command) == 1 ) {
1848 lyxrc.isp_use_alt_lang = false;
1849 lyxrc.isp_alt_lang.erase();
1851 lyxrc.isp_use_esc_chars = false;
1852 lyxrc.isp_esc_chars.erase();
1854 lyxrc.isp_use_pers_dict = false;
1855 lyxrc.isp_pers_dict.erase();
1857 lyxrc.isp_accept_compound = false;
1858 lyxrc.isp_use_input_encoding = false;
1860 int button = fl_get_button(spellchecker_->check_alt_lang);
1861 choice = fl_get_input(spellchecker_->input_alt_lang);
1862 if( button && choice.empty() ) button = 0;
1863 if( !button ) choice.erase();
1865 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
1866 lyxrc.isp_alt_lang = choice;
1868 button = fl_get_button(spellchecker_->check_escape_chars);
1869 choice = fl_get_input(spellchecker_->input_escape_chars);
1870 if( button && choice.empty() ) button = 0;
1871 if( !button ) choice.erase();
1873 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
1874 lyxrc.isp_esc_chars = choice;
1876 button = fl_get_button(spellchecker_->check_personal_dict);
1877 choice = fl_get_input(spellchecker_->input_personal_dict);
1878 if( button && choice.empty() ) button = 0;
1879 if( !button ) choice.erase();
1881 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
1882 lyxrc.isp_pers_dict = choice;
1884 button = fl_get_button(spellchecker_->check_compound_words);
1885 lyxrc.isp_accept_compound = static_cast<bool>(button);
1887 button = fl_get_button(spellchecker_->check_input_enc);
1888 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
1892 updateSpellChecker();
1896 void FormPreferences::buildSpellchecker()
1898 spellchecker_ = build_spellchecker();
1900 fl_addto_choice(spellchecker_->choice_spell_command,
1901 _(" none | ispell | aspell "));
1902 fl_set_input_return(spellchecker_->input_alt_lang,
1904 fl_set_input_return(spellchecker_->input_escape_chars,
1906 fl_set_input_return(spellchecker_->input_personal_dict,
1909 // deactivate the browse button because it isn't implemented
1910 fl_deactivate_object(spellchecker_->button_personal_dict);
1911 fl_set_object_lcol(spellchecker_->button_personal_dict,
1914 // set up the feedback mechanism
1915 fl_addto_form(spellchecker_->form);
1917 setPostHandler( spellchecker_->choice_spell_command );
1918 setPostHandler( spellchecker_->check_alt_lang );
1919 setPostHandler( spellchecker_->input_alt_lang );
1920 setPostHandler( spellchecker_->check_escape_chars );
1921 setPostHandler( spellchecker_->input_escape_chars );
1922 setPostHandler( spellchecker_->check_personal_dict );
1923 setPostHandler( spellchecker_->input_personal_dict );
1924 setPostHandler( spellchecker_->button_personal_dict );
1925 setPostHandler( spellchecker_->check_compound_words );
1926 setPostHandler( spellchecker_->check_input_enc );
1932 string FormPreferences::feedbackSpellChecker( FL_OBJECT const * const ob ) const
1936 if( ob == spellchecker_->choice_spell_command )
1937 str = lyxrc.getDescription( LyXRC::RC_SPELL_COMMAND );
1938 else if( ob == spellchecker_->check_alt_lang )
1939 str = lyxrc.getDescription( LyXRC::RC_USE_ALT_LANG );
1940 else if( ob == spellchecker_->input_alt_lang )
1941 str = lyxrc.getDescription( LyXRC::RC_ALT_LANG );
1942 else if( ob == spellchecker_->check_escape_chars )
1943 str = lyxrc.getDescription( LyXRC::RC_USE_ESC_CHARS );
1944 else if( ob == spellchecker_->input_escape_chars )
1945 str = lyxrc.getDescription( LyXRC::RC_ESC_CHARS );
1946 else if( ob == spellchecker_->check_personal_dict )
1947 str = lyxrc.getDescription( LyXRC::RC_USE_PERS_DICT );
1948 else if( ob == spellchecker_->input_personal_dict )
1949 str = lyxrc.getDescription( LyXRC::RC_PERS_DICT );
1950 else if( ob == spellchecker_->check_compound_words )
1951 str = lyxrc.getDescription( LyXRC::RC_ACCEPT_COMPOUND );
1952 else if( ob == spellchecker_->check_input_enc )
1953 str = lyxrc.getDescription( LyXRC::RC_USE_INP_ENC );
1959 bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob )
1961 // Allow/dissallow input
1963 // If spell checker == "none", disable all input.
1964 if( !ob || ob == spellchecker_->choice_spell_command ) {
1965 if( fl_get_choice(spellchecker_->choice_spell_command) == 1 ) {
1966 fl_deactivate_object( spellchecker_->check_alt_lang );
1967 fl_deactivate_object( spellchecker_->input_alt_lang );
1968 fl_deactivate_object( spellchecker_->check_escape_chars );
1969 fl_deactivate_object( spellchecker_->input_escape_chars );
1970 fl_deactivate_object( spellchecker_->check_personal_dict );
1971 fl_deactivate_object( spellchecker_->input_personal_dict );
1972 fl_deactivate_object( spellchecker_->check_compound_words );
1973 fl_deactivate_object( spellchecker_->check_input_enc );
1976 fl_activate_object( spellchecker_->check_alt_lang );
1977 fl_activate_object( spellchecker_->check_escape_chars );
1978 fl_activate_object( spellchecker_->check_personal_dict );
1979 fl_activate_object( spellchecker_->check_compound_words );
1980 fl_activate_object( spellchecker_->check_input_enc );
1984 if( !ob || ob == spellchecker_->check_alt_lang ) {
1985 if( fl_get_button(spellchecker_->check_alt_lang) ) {
1986 fl_activate_object(spellchecker_->input_alt_lang);
1987 fl_set_object_lcol(spellchecker_->input_alt_lang,
1990 fl_deactivate_object(spellchecker_->input_alt_lang);
1991 fl_set_object_lcol(spellchecker_->input_alt_lang,
1996 if( !ob || ob == spellchecker_->check_escape_chars ) {
1997 if( fl_get_button(spellchecker_->check_escape_chars) ) {
1998 fl_activate_object(spellchecker_->input_escape_chars);
1999 fl_set_object_lcol(spellchecker_->input_escape_chars,
2002 fl_deactivate_object(spellchecker_->input_escape_chars);
2003 fl_set_object_lcol(spellchecker_->input_escape_chars,
2008 if( !ob || ob == spellchecker_->check_personal_dict ) {
2009 if( fl_get_button(spellchecker_->check_personal_dict) ) {
2010 fl_activate_object(spellchecker_->input_personal_dict);
2011 fl_set_object_lcol(spellchecker_->input_personal_dict,
2014 fl_deactivate_object(spellchecker_->input_personal_dict);
2015 fl_set_object_lcol(spellchecker_->input_personal_dict,
2020 return true; // All input is valid!
2024 void FormPreferences::updateSpellChecker()
2027 if( lyxrc.isp_command == "none" )
2029 else if( lyxrc.isp_command == "ispell" )
2031 else if( lyxrc.isp_command == "aspell" )
2033 fl_set_choice(spellchecker_->choice_spell_command, choice);
2035 string str = string();
2036 if( lyxrc.isp_use_alt_lang ) str = lyxrc.isp_alt_lang;
2038 fl_set_button(spellchecker_->check_alt_lang,
2039 lyxrc.isp_use_alt_lang);
2040 fl_set_input(spellchecker_->input_alt_lang, str.c_str());
2043 if( lyxrc.isp_use_esc_chars ) str = lyxrc.isp_esc_chars;
2045 fl_set_button(spellchecker_->check_escape_chars,
2046 lyxrc.isp_use_esc_chars);
2047 fl_set_input(spellchecker_->input_escape_chars, str.c_str());
2050 if( lyxrc.isp_use_pers_dict ) str = lyxrc.isp_pers_dict;
2052 fl_set_button(spellchecker_->check_personal_dict,
2053 lyxrc.isp_use_pers_dict);
2054 fl_set_input(spellchecker_->input_personal_dict, str.c_str());
2056 fl_set_button(spellchecker_->check_compound_words,
2057 lyxrc.isp_accept_compound);
2058 fl_set_button(spellchecker_->check_input_enc,
2059 lyxrc.isp_use_input_encoding);
2061 // Activate/Deactivate the input fields dependent on the state of the
2063 inputSpellChecker( 0 );
2067 bool FormPreferences::WriteableDir( string const & name ) const
2069 bool success = true;
2072 if( !AbsolutePath(name) ) {
2074 str = N_("WARNING! The absolute path is required.");
2078 if( success && !tp.isDir() ) {
2080 str = N_("WARNING! Directory does not exist.");
2083 if( success && !tp.writable() ) {
2085 str = N_("WARNING! Cannot write to this directory.");
2089 fl_set_object_label(dialog_->text_warning, str.c_str());
2090 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2097 bool FormPreferences::ReadableDir( string const & name ) const
2099 bool success = true;
2102 if( !AbsolutePath(name) ) {
2104 str = N_("WARNING! The absolute path is required.");
2108 if( success && !tp.isDir() ) {
2110 str = N_("WARNING! Directory does not exist.");
2113 if( success && !tp.readable() ) {
2115 str = N_("WARNING! Cannot read this directory.");
2119 fl_set_object_label(dialog_->text_warning, str.c_str());
2120 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2127 bool FormPreferences::WriteableFile( string const & name, string const & suffix ) const
2129 // A writeable file is either:
2130 // * An existing file to which we have write access, or
2131 // * A file that doesn't yet exist but that would exist in a writeable
2134 bool success = true;
2137 if( name.empty() ) {
2139 str = N_("WARNING! No file input.");
2142 string dir = OnlyPath(name);
2143 if( success && !AbsolutePath(dir) ) {
2145 str = N_("WARNING! The absolute path is required.");
2158 if( success && !d.isDir()) {
2160 str = N_("WARNING! Directory does not exist.");
2163 if( success && !d.writable() ) {
2165 str = N_("WARNING! Cannot write to this directory.");
2168 FileInfo f(name+suffix);
2169 if( success && (dir == name || f.isDir()) ) {
2171 str = N_("WARNING! A file is required, not a directory.");
2174 if( success && (f.exist() && !f.writable()) ) {
2176 str = N_("WARNING! Cannot write to this file.");
2180 fl_set_object_label(dialog_->text_warning, str.c_str());
2181 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2188 void FormPreferences::ComboLanguageCB(int, void * v, Combox * combox)
2190 FormPreferences * pre = static_cast<FormPreferences*>(v);
2191 // This is safe, as nothing is done to the pointer, other than
2192 // to use its address in a block-if statement.
2193 pre->bc_.valid( pre->input( reinterpret_cast<FL_OBJECT *>(combox), 0 ));
2197 // C functions for the timer callback used to give the user feedback
2198 C_GENERICCB(FormPreferences, FeedbackCB)
2200 void FormPreferences::FeedbackCB(FL_OBJECT * ob, long)
2202 FormPreferences * pre =
2203 static_cast<FormPreferences*>(ob->form->u_vdata);
2204 pre->feedback( pre->feedbackObj );
2207 extern "C" int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event,
2208 FL_Coord, FL_Coord, int, void *)
2210 // can occur when form is being deleted. This seems an easier fix than
2211 // a call "fl_set_object_posthandler(ob, 0)" for each and every object
2212 // in the destructor.
2213 if( !ob->form ) return 0;
2215 FormPreferences * pre =
2216 static_cast<FormPreferences*>(ob->form->u_vdata);
2217 pre->feedbackPost(ob, event);
2222 // post_handler for feedback messages
2223 void FormPreferences::feedbackPost(FL_OBJECT *ob, int event)
2225 // We do not test for empty help here, since this can never happen
2226 if(event == FL_ENTER){
2227 // Used as a placeholder for ob, so that we don't have to
2228 // a horrible reinterpret_cast to long and pass it as an
2229 // argument in fl_set_object_callback.
2231 fl_set_object_callback(dialog_->timer_feedback,
2232 C_FormPreferencesFeedbackCB,
2234 fl_set_timer(dialog_->timer_feedback, 0.5);
2236 else if(event != FL_MOTION){
2237 fl_set_timer(dialog_->timer_feedback, 0);
2239 fl_set_object_label(dialog_->text_warning, "");
2244 void FormPreferences::setPostHandler( FL_OBJECT * ob ) const
2246 fl_set_object_posthandler(ob, C_FormPreferencesFeedbackPost);