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, vector<int> > 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),
54 dialog_(0), outputs_tab_(0), look_n_feel_tab_(0), inputs_tab_(0),
55 usage_tab_(0), colours_(0), formats_(0), inputs_misc_(0),
56 interface_(0), language_(0), lnf_misc_(0), outputs_misc_(0),
57 paths_(0), printer_(0), screen_fonts_(0), spellchecker_(0),
58 combo_default_lang(0), combo_kbmap_1(0), combo_kbmap_2(0),
61 // let the dialog be shown
62 // This is a permanent connection so we won't bother
63 // storing a copy because we won't be disconnecting.
64 d->showPreferences.connect(slot(this, &FormPreferences::show));
68 FormPreferences::~FormPreferences()
70 delete combo_default_lang;
74 delete look_n_feel_tab_;
90 // Must delete dialog last or we'll end up with a SIGSEGV trying to
91 // access dialog_->timer_feedback in feedbackPost().
96 FL_FORM * FormPreferences::form() const
98 if (dialog_) return dialog_->form;
103 void FormPreferences::ok()
106 lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
110 void FormPreferences::hide()
112 // We need to hide the active tabfolder otherwise we get a
113 // BadDrawable error from X windows and LyX crashes without saving.
114 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
116 && outer_form->visible) {
117 fl_hide_form(outer_form);
123 void FormPreferences::build()
125 dialog_ = build_preferences();
127 // manage the restore, save, apply and cancel/close buttons
128 bc_.setOK(dialog_->button_ok);
129 bc_.setApply(dialog_->button_apply);
130 bc_.setCancel(dialog_->button_cancel);
131 bc_.setUndoAll(dialog_->button_restore);
134 // Workaround dumb xforms sizing bug
138 // build the tab folders
139 outputs_tab_ = build_outer_tab();
140 look_n_feel_tab_ = build_outer_tab();
141 inputs_tab_ = build_outer_tab();
142 usage_tab_ = build_outer_tab();
144 // build actual tabfolder contents
145 // these will become nested tabfolders
158 // Now add them to the tabfolder
159 fl_addto_tabfolder(dialog_->tabfolder_prefs,
161 look_n_feel_tab_->form);
162 fl_addto_tabfolder(dialog_->tabfolder_prefs,
165 fl_addto_tabfolder(dialog_->tabfolder_prefs,
168 fl_addto_tabfolder(dialog_->tabfolder_prefs,
172 // now build the nested tabfolders
173 // Starting with look and feel
174 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
176 screen_fonts_->form);
177 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
180 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
183 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
188 // Paths should probably go in a few outer_tab called Files
189 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
192 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
196 // then building outputs
197 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
200 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
203 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
205 outputs_misc_->form);
207 // then building usage
208 fl_addto_tabfolder(usage_tab_->tabfolder_outer,
210 spellchecker_->form);
211 fl_addto_tabfolder(usage_tab_->tabfolder_outer,
217 void FormPreferences::apply()
219 // set the new lyxrc entries
220 // many of these need to trigger other functions when the assignment
221 // is made. For example, screen zoom and font types. These could be
222 // handled either by signals/slots in lyxrc or just directly call the
223 // associated functions here.
224 // There are other problems with this scheme. We really should check
225 // what we copy to make sure that it really is necessary to do things
226 // like update the screen fonts because that flushes the textcache
227 // and other stuff which may cost us a lot on slower/high-load machines.
243 void FormPreferences::feedback( FL_OBJECT * ob )
247 if( ob->form->fdui == colours_ ) {
248 str = feedbackColours( ob );
249 } else if( ob->form->fdui == formats_ ) {
250 str = feedbackFormats( ob );
251 } else if( ob->form->fdui == inputs_misc_ ) {
252 str = feedbackInputsMisc( ob );
253 } else if( ob->form->fdui == interface_ ) {
254 str = feedbackInterface( ob );
255 } else if( ob->form->fdui == language_ ) {
256 str = feedbackLanguage( ob );
257 } else if( ob->form->fdui == lnf_misc_ ) {
258 str = feedbackLnFmisc( ob );
259 } else if( ob->form->fdui == outputs_misc_ ) {
260 str = feedbackOutputsMisc( ob );
261 } else if( ob->form->fdui == paths_ ) {
262 str = feedbackPaths( ob );
263 } else if( ob->form->fdui == printer_ ) {
264 str = feedbackPrinter( ob );
265 } else if( ob->form->fdui == screen_fonts_ ) {
266 str = feedbackScreenFonts( ob );
267 } else if( ob->form->fdui == spellchecker_ ) {
268 str = feedbackSpellChecker( ob );
271 str = formatted( str, dialog_->text_warning->w-10,
272 FL_SMALL_SIZE, FL_NORMAL_STYLE );
274 fl_set_object_label(dialog_->text_warning, str.c_str());
275 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
279 bool FormPreferences::input(FL_OBJECT * ob, long)
281 bool activate = true;
283 // whatever checks you need to ensure the user hasn't entered
284 // some totally ridiculous value somewhere. Change activate to suit.
285 // comments before each test describe what is _valid_
287 if( ob->form->fdui == colours_ ) {
288 if( ! inputColours( ob ) )
290 } else if( ob->form->fdui == language_ ) {
291 if( ! inputLanguage( ob ) )
293 } else if( ob->form->fdui == paths_ ) {
294 if( ! inputPaths( ob ) )
296 } else if( ob->form->fdui == screen_fonts_ ) {
297 if( ! inputScreenFonts() )
299 } else if( ob->form->fdui == spellchecker_ ) {
300 if( ! inputSpellChecker( ob ) )
308 void FormPreferences::update()
310 if (!dialog_) return;
312 // read lyxrc entries
323 updateSpellChecker();
327 void FormPreferences::applyColours() const
332 void FormPreferences::buildColours()
334 colours_ = build_colours();
337 obj = colours_->valslider_red;
338 fl_set_slider_bounds(obj, 0, 255);
339 fl_set_slider_precision(obj, 0);
340 fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
342 obj = colours_->valslider_green;
343 fl_set_slider_bounds(obj, 0, 255);
344 fl_set_slider_precision(obj, 0);
345 fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
347 obj = colours_->valslider_blue;
348 fl_set_slider_bounds(obj, 0, 255);
349 fl_set_slider_precision(obj, 0);
350 fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
352 fl_set_object_color(colours_->button_colour,
353 FL_FREE_COL4, FL_FREE_COL4);
355 fl_set_input_return(colours_->input_name, FL_RETURN_END_CHANGED);
357 if( loadColourBrowser(colourFile) )
358 fl_set_input(colours_->input_name, colourFile.c_str());
360 fl_set_input(colours_->input_name, N_("No file found"));
362 // deactivate the browse button because it isn't implemented
363 fl_deactivate_object(colours_->button_browse);
364 fl_set_object_lcol(colours_->button_browse, FL_INACTIVE);
368 bool FormPreferences::loadColourBrowser( string const & filename )
372 if (!lex.setFile(filename))
375 vector<int> oldrgb(3);
376 oldrgb[0] = -1; oldrgb[1] = -1; oldrgb[2] = -1;
378 istream & is = lex.getStream();
386 if( line[0] != '!' ) {
390 istringstream iss(line);
391 iss >> rgb[0] >> rgb[1] >> rgb[2];
392 while( iss.good() ) {
398 // remove redundant entries on the fly
399 if( oldrgb != rgb ) {
401 name = lowercase( name );
402 if( name == "gray0" ) name = "black";
403 if( name == "gray100" ) name = "white";
404 X11Colour pa( name, rgb );
405 colourDB.push_back(pa);
411 FL_OBJECT * colbr = colours_->browser_x11;
412 fl_freeze_form(colours_->form);
413 fl_clear_browser( colbr );
415 for( vector<X11Colour>::const_iterator cit = colourDB.begin();
416 cit != colourDB.end(); ++cit ) {
417 vector<int> rgb = (*cit).second;
418 string name = fmt("%3d %3d %3d ", rgb[0], rgb[1], rgb[2]) +
420 fl_addto_browser(colbr, name.c_str());
423 fl_set_browser_topline(colbr, 1);
424 fl_select_browser_line(colbr, 1);
425 updateColoursBrowser(0);
426 fl_unfreeze_form(colours_->form);
432 string FormPreferences::feedbackColours( FL_OBJECT const * const ) const
438 bool FormPreferences::inputColours( FL_OBJECT const * const ob )
440 bool activate = true;
442 if( ob == colours_->browser_x11 ) {
443 int i = fl_get_browser(colours_->browser_x11);
445 updateColoursBrowser(i-1);
448 } else if( ob == colours_->valslider_red
449 || ob == colours_->valslider_green
450 || ob == colours_->valslider_blue ) {
453 } else if( ob == colours_->input_name) {
454 string file = fl_get_input(colours_->input_name);
455 if( loadColourBrowser(file) )
456 fl_set_input(colours_->input_name, file.c_str());
457 else if( loadColourBrowser(colourFile) )
458 fl_set_input(colours_->input_name, colourFile.c_str());
460 fl_set_input(colours_->input_name, N_("No file found"));
467 void FormPreferences::updateColoursBrowser( int i )
469 fl_freeze_form(colours_->form);
471 vector<int> rgb = colourDB[i].second;
473 fl_mapcolor(FL_FREE_COL4+i, rgb[0], rgb[1], rgb[2]);
474 fl_mapcolor(FL_FREE_COL4, rgb[0], rgb[1], rgb[2]);
475 fl_set_slider_value(colours_->valslider_red, rgb[0]);
476 fl_set_slider_value(colours_->valslider_green, rgb[1]);
477 fl_set_slider_value(colours_->valslider_blue, rgb[2]);
478 fl_redraw_object(colours_->button_colour);
480 fl_unfreeze_form(colours_->form);
484 void FormPreferences::updateColoursRGB()
486 fl_freeze_form(colours_->form);
489 rgb[0] = fl_get_slider_value(colours_->valslider_red);
490 rgb[1] = fl_get_slider_value(colours_->valslider_green);
491 rgb[2] = fl_get_slider_value(colours_->valslider_blue);
493 fl_mapcolor(FL_FREE_COL4, rgb[0], rgb[1], rgb[2]);
494 fl_redraw_object(colours_->button_colour);
496 int top = fl_get_browser_topline(colours_->browser_x11);
497 int i = searchColourEntry( rgb );
498 // change topline only if necessary
499 if(i < top || i > (top+15))
500 fl_set_browser_topline(colours_->browser_x11,
502 fl_select_browser_line(colours_->browser_x11, i + 1);
504 fl_unfreeze_form(colours_->form);
508 int FormPreferences::searchColourEntry(vector<int> const & rgb ) const
510 int mindiff = 0x7fffffff;
511 vector<X11Colour>::const_iterator mincit = colourDB.begin();
513 for( vector<X11Colour>::const_iterator cit = colourDB.begin();
514 cit != colourDB.end(); ++cit ) {
515 vector<int> rgbDB = (*cit).second;
517 diff[0] = rgb[0] - rgbDB[0];
518 diff[1] = rgb[1] - rgbDB[1];
519 diff[2] = rgb[2] - rgbDB[2];
521 int d = (2 * (diff[0] * diff[0]) +
522 3 * (diff[1] * diff[1]) +
523 (diff[2] * diff[2]));
530 return static_cast<int>(mincit - colourDB.begin());
534 void FormPreferences::updateColours()
539 void FormPreferences::applyFormats() const
544 void FormPreferences::buildFormats()
546 formats_ = build_formats();
548 fl_set_input_return(formats_->input_format, FL_RETURN_CHANGED);
549 fl_set_input_return(formats_->input_viewer, FL_RETURN_CHANGED);
550 fl_set_input_return(formats_->input_gui_name, FL_RETURN_CHANGED);
551 fl_set_input_return(formats_->input_extension, FL_RETURN_CHANGED);
553 fl_set_input_filter(formats_->input_format, fl_lowercase_filter);
557 string FormPreferences::feedbackFormats( FL_OBJECT const * const ) const
565 bool FormPreferences::inputFormats( FL_OBJECT const * const )
571 void FormPreferences::updateFormats()
576 void FormPreferences::applyInputsMisc() const
578 lyxrc.date_insert_format = fl_get_input(inputs_misc_->input_date_format);
582 void FormPreferences::buildInputsMisc()
584 inputs_misc_ = build_inputs_misc();
586 fl_set_input_return(inputs_misc_->input_date_format,
589 // set up the feedback mechanism
590 fl_addto_form(inputs_misc_->form);
592 setPostHandler( inputs_misc_->input_date_format );
598 string FormPreferences::feedbackInputsMisc( FL_OBJECT const * const ob ) const
602 if( ob == inputs_misc_->input_date_format )
603 str = lyxrc.getDescription( LyXRC::RC_DATE_INSERT_FORMAT );
609 void FormPreferences::updateInputsMisc()
611 fl_set_input(inputs_misc_->input_date_format,
612 lyxrc.date_insert_format.c_str());
616 void FormPreferences::applyInterface() const
618 lyxrc.popup_font_name =
619 fl_get_input(interface_->input_popup_font);
620 lyxrc.menu_font_name = fl_get_input(interface_->input_menu_font);
621 lyxrc.font_norm_menu =
622 fl_get_input(interface_->input_popup_encoding);
623 lyxrc.bind_file = fl_get_input(interface_->input_bind_file);
624 lyxrc.ui_file = fl_get_input(interface_->input_ui_file);
625 lyxrc.override_x_deadkeys =
626 fl_get_button(interface_->check_override_x_dead_keys);
630 void FormPreferences::buildInterface()
632 interface_ = build_interface();
634 fl_set_input_return(interface_->input_popup_font, FL_RETURN_CHANGED);
635 fl_set_input_return(interface_->input_menu_font, FL_RETURN_CHANGED);
636 fl_set_input_return(interface_->input_popup_encoding,
638 fl_set_input_return(interface_->input_bind_file, FL_RETURN_CHANGED);
639 fl_set_input_return(interface_->input_ui_file, FL_RETURN_CHANGED);
641 // deactivate the browse buttons because they aren't implemented
642 fl_deactivate_object(interface_->button_bind_file_browse);
643 fl_deactivate_object(interface_->button_ui_file_browse);
644 fl_set_object_lcol(interface_->button_bind_file_browse, FL_INACTIVE);
645 fl_set_object_lcol(interface_->button_ui_file_browse, FL_INACTIVE);
647 // set up the feedback mechanism
648 fl_addto_form(interface_->form);
650 setPostHandler( interface_->input_popup_font );
651 setPostHandler( interface_->input_menu_font );
652 setPostHandler( interface_->input_popup_encoding );
653 setPostHandler( interface_->input_bind_file );
654 setPostHandler( interface_->button_bind_file_browse );
655 setPostHandler( interface_->input_ui_file );
656 setPostHandler( interface_->button_ui_file_browse );
657 setPostHandler( interface_->check_override_x_dead_keys );
664 string FormPreferences::feedbackInterface( FL_OBJECT const * const ob ) const
668 if( ob == interface_->input_popup_font )
669 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_POPUP );
670 else if ( ob == interface_->input_menu_font )
671 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_MENU );
672 else if ( ob == interface_->input_popup_encoding )
673 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING_MENU );
674 else if ( ob == interface_->input_bind_file )
675 str = lyxrc.getDescription( LyXRC::RC_BINDFILE );
676 else if ( ob == interface_->input_ui_file )
677 str = lyxrc.getDescription( LyXRC::RC_UIFILE );
678 else if ( ob == interface_->check_override_x_dead_keys )
679 str = lyxrc.getDescription( LyXRC::RC_OVERRIDE_X_DEADKEYS );
685 void FormPreferences::updateInterface()
687 fl_set_input(interface_->input_popup_font,
688 lyxrc.popup_font_name.c_str());
689 fl_set_input(interface_->input_menu_font,
690 lyxrc.menu_font_name.c_str());
691 fl_set_input(interface_->input_popup_encoding,
692 lyxrc.font_norm_menu.c_str());
693 fl_set_input(interface_->input_bind_file,
694 lyxrc.bind_file.c_str());
695 fl_set_input(interface_->input_ui_file,
696 lyxrc.ui_file.c_str());
697 fl_set_button(interface_->check_override_x_dead_keys,
698 lyxrc.override_x_deadkeys);
702 void FormPreferences::applyLanguage() const
704 lyxrc.default_language = combo_default_lang->getline();
706 int button = fl_get_button(language_->check_use_kbmap);
707 lyxrc.use_kbmap = static_cast<bool>(button);
710 lyxrc.primary_kbmap = combo_kbmap_1->getline();
711 lyxrc.secondary_kbmap = combo_kbmap_2->getline();
714 button = fl_get_button(language_->check_rtl_support);
715 lyxrc.rtl_support = static_cast<bool>(button);
717 button = fl_get_button(language_->check_auto_begin);
718 lyxrc.language_auto_begin = static_cast<bool>(button);
720 button = fl_get_button(language_->check_auto_end);
721 lyxrc.language_auto_end = static_cast<bool>(button);
723 button = fl_get_button(language_->check_mark_foreign);
724 lyxrc.mark_foreign_language = static_cast<bool>(button);
726 lyxrc.language_package = fl_get_input(language_->input_package);
727 lyxrc.language_command_begin = fl_get_input(language_->input_command_begin);
728 lyxrc.language_command_end = fl_get_input(language_->input_command_end);
732 void FormPreferences::buildLanguage()
734 language_ = build_language();
736 fl_set_input_return(language_->input_package, FL_RETURN_CHANGED);
737 fl_set_input_return(language_->input_command_begin, FL_RETURN_CHANGED);
738 fl_set_input_return(language_->input_command_end, FL_RETURN_CHANGED);
740 // The default_language is a combo-box and has to be inserted manually
741 fl_freeze_form(language_->form);
742 fl_addto_form(language_->form);
744 FL_OBJECT * obj = language_->choice_default_lang;
745 fl_deactivate_object(language_->choice_default_lang);
746 combo_default_lang = new Combox(FL_COMBOX_DROPLIST);
747 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
748 combo_default_lang->shortcut("#L",1);
749 combo_default_lang->setcallback(ComboLanguageCB, this);
750 addLanguages( *combo_default_lang );
753 obj = language_->choice_kbmap_1;
754 fl_deactivate_object(language_->choice_kbmap_1);
755 combo_kbmap_1 = new Combox(FL_COMBOX_DROPLIST);
756 combo_kbmap_1->add(obj->x, obj->y, obj->w, obj->h, 400);
757 combo_kbmap_1->shortcut("#1",1);
758 combo_kbmap_1->setcallback(ComboLanguageCB, this);
759 addLanguages( *combo_kbmap_1 );
762 obj = language_->choice_kbmap_2;
763 fl_deactivate_object(language_->choice_kbmap_2);
764 combo_kbmap_2 = new Combox(FL_COMBOX_DROPLIST);
765 combo_kbmap_2->add(obj->x, obj->y, obj->w, obj->h, 400);
766 combo_kbmap_2->shortcut("#2",1);
767 combo_kbmap_2->setcallback(ComboLanguageCB, this);
768 addLanguages( *combo_kbmap_2 );
771 fl_unfreeze_form(language_->form);
773 // set up the feedback mechanism
774 fl_addto_form(language_->form);
776 setPostHandler( language_->input_package );
777 setPostHandler( language_->check_use_kbmap );
779 // This is safe, as nothing is done to the pointer, other than
780 // to use its address in a block-if statement.
781 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_default_lang) );
782 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_1) );
783 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_2) );
785 setPostHandler( language_->check_rtl_support );
786 setPostHandler( language_->check_mark_foreign );
787 setPostHandler( language_->check_auto_begin );
788 setPostHandler( language_->check_auto_end );
789 setPostHandler( language_->input_command_begin );
790 setPostHandler( language_->input_command_end );
796 void FormPreferences::addLanguages( Combox & combo ) const
798 for(Languages::const_iterator cit = languages.begin();
799 cit != languages.end(); cit++) {
800 combo.addto((*cit).second.lang());
805 string FormPreferences::feedbackLanguage( FL_OBJECT const * const ob ) const
809 if( reinterpret_cast<Combox const *>(ob) == combo_default_lang )
810 str = lyxrc.getDescription( LyXRC::RC_DEFAULT_LANGUAGE );
811 else if( ob == language_->check_use_kbmap )
812 str = lyxrc.getDescription( LyXRC::RC_KBMAP );
813 else if( reinterpret_cast<Combox const *>(ob) == combo_kbmap_1)
814 str = lyxrc.getDescription( LyXRC::RC_KBMAP_PRIMARY );
815 else if( reinterpret_cast<Combox const *>(ob) == combo_kbmap_2 )
816 str = lyxrc.getDescription( LyXRC::RC_KBMAP_SECONDARY );
817 else if( ob == language_->check_rtl_support )
818 str = lyxrc.getDescription( LyXRC::RC_RTL_SUPPORT );
819 else if( ob == language_->check_auto_begin )
820 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_BEGIN );
821 else if( ob == language_->check_auto_end )
822 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_END );
823 else if( ob == language_->check_mark_foreign )
824 str = lyxrc.getDescription( LyXRC::RC_MARK_FOREIGN_LANGUAGE );
825 else if( ob == language_->input_package )
826 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_PACKAGE );
827 else if( ob == language_->input_command_begin )
828 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_BEGIN );
829 else if( ob == language_->input_command_end )
830 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_END );
836 bool FormPreferences::inputLanguage( FL_OBJECT const * const ob )
838 bool activate = true;
840 if( !ob || ob == language_->check_use_kbmap ) {
841 if( fl_get_button(language_->check_use_kbmap) ) {
842 combo_kbmap_1->activate();
843 combo_kbmap_2->activate();
845 combo_kbmap_1->deactivate();
846 combo_kbmap_2->deactivate();
854 void FormPreferences::updateLanguage()
856 fl_set_button(language_->check_use_kbmap,
859 combo_default_lang->select_text( lyxrc.default_language );
861 if( lyxrc.use_kbmap ) {
862 combo_kbmap_1->select_text( lyxrc.primary_kbmap );
863 combo_kbmap_2->select_text( lyxrc.secondary_kbmap );
865 combo_kbmap_1->select_text( lyxrc.default_language );
866 combo_kbmap_2->select_text( lyxrc.default_language );
869 fl_set_button(language_->check_rtl_support, lyxrc.rtl_support);
870 fl_set_button(language_->check_auto_begin, lyxrc.language_auto_begin);
871 fl_set_button(language_->check_auto_end, lyxrc.language_auto_end);
872 fl_set_button(language_->check_mark_foreign,
873 lyxrc.mark_foreign_language);
875 fl_set_input(language_->input_package,
876 lyxrc.language_package.c_str());
877 fl_set_input(language_->input_command_begin,
878 lyxrc.language_command_begin.c_str());
879 fl_set_input(language_->input_command_end,
880 lyxrc.language_command_end.c_str());
882 // Activate/Deactivate the input fields dependent on the state of the
888 void FormPreferences::applyLnFmisc() const
890 lyxrc.show_banner = fl_get_button(lnf_misc_->check_banner);
891 lyxrc.auto_region_delete = fl_get_button(lnf_misc_->
892 check_auto_region_delete);
893 lyxrc.exit_confirmation = fl_get_button(lnf_misc_->check_exit_confirm);
894 lyxrc.display_shortcuts =
895 fl_get_button(lnf_misc_->check_display_shortcuts);
896 lyxrc.new_ask_filename = fl_get_button(lnf_misc_->check_ask_new_file);
897 lyxrc.cursor_follows_scrollbar =
898 fl_get_button(lnf_misc_->check_cursor_follows_scrollbar);
899 lyxrc.autosave = static_cast<unsigned int>
900 (fl_get_counter_value(lnf_misc_->counter_autosave));
901 lyxrc.wheel_jump = static_cast<unsigned int>
902 (fl_get_counter_value(lnf_misc_->counter_wm_jump));
906 void FormPreferences::buildLnFmisc()
908 lnf_misc_ = build_lnf_misc();
910 fl_set_counter_return(lnf_misc_->counter_autosave,
912 fl_set_counter_return(lnf_misc_->counter_wm_jump,
915 // set up the feedback mechanism
916 fl_addto_form(lnf_misc_->form);
918 setPostHandler( lnf_misc_->check_banner );
919 setPostHandler( lnf_misc_->check_auto_region_delete );
920 setPostHandler( lnf_misc_->check_exit_confirm );
921 setPostHandler( lnf_misc_->check_display_shortcuts );
922 setPostHandler( lnf_misc_->counter_autosave );
923 setPostHandler( lnf_misc_->check_ask_new_file );
924 setPostHandler( lnf_misc_->check_cursor_follows_scrollbar );
925 setPostHandler( lnf_misc_->counter_wm_jump );
931 string FormPreferences::feedbackLnFmisc( FL_OBJECT const * const ob ) const
935 if( ob == lnf_misc_->check_banner )
936 str = lyxrc.getDescription( LyXRC::RC_SHOW_BANNER );
937 else if( ob == lnf_misc_->check_auto_region_delete )
938 str = lyxrc.getDescription( LyXRC::RC_AUTOREGIONDELETE );
939 else if( ob == lnf_misc_->check_exit_confirm )
940 str = lyxrc.getDescription( LyXRC::RC_EXIT_CONFIRMATION );
941 else if( ob == lnf_misc_->check_display_shortcuts )
942 str = lyxrc.getDescription( LyXRC::RC_DISPLAY_SHORTCUTS );
943 else if( ob == lnf_misc_->check_ask_new_file )
944 str = lyxrc.getDescription( LyXRC::RC_NEW_ASK_FILENAME );
945 else if( ob == lnf_misc_->check_cursor_follows_scrollbar )
946 str = lyxrc.getDescription( LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR );
947 else if( ob == lnf_misc_->counter_autosave )
948 str = lyxrc.getDescription( LyXRC::RC_AUTOSAVE );
949 else if( ob == lnf_misc_->counter_wm_jump )
950 str = lyxrc.getDescription( LyXRC::RC_WHEEL_JUMP );
955 void FormPreferences::updateLnFmisc()
957 fl_set_button(lnf_misc_->check_banner,
959 fl_set_button(lnf_misc_->check_auto_region_delete,
960 lyxrc.auto_region_delete);
961 fl_set_button(lnf_misc_->check_exit_confirm,
962 lyxrc.exit_confirmation);
963 fl_set_button(lnf_misc_->check_display_shortcuts,
964 lyxrc.display_shortcuts);
965 fl_set_button(lnf_misc_->check_ask_new_file,
966 lyxrc.new_ask_filename);
967 fl_set_button(lnf_misc_->check_cursor_follows_scrollbar,
968 lyxrc.cursor_follows_scrollbar);
969 fl_set_counter_value(lnf_misc_->counter_autosave,
971 fl_set_counter_value(lnf_misc_->counter_wm_jump,
976 void FormPreferences::applyOutputsMisc() const
978 lyxrc.ascii_linelen = static_cast<unsigned int>
979 (fl_get_counter_value(outputs_misc_->counter_line_len));
980 lyxrc.fontenc = fl_get_input(outputs_misc_->input_tex_encoding);
983 fl_get_choice(outputs_misc_->choice_default_papersize) - 1;
984 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
986 lyxrc.ascii_roff_command = fl_get_input(outputs_misc_->input_ascii_roff);
987 lyxrc.chktex_command = fl_get_input(outputs_misc_->input_checktex);
991 void FormPreferences::buildOutputsMisc()
993 outputs_misc_ = build_outputs_misc();
995 fl_set_counter_return(outputs_misc_->counter_line_len,
997 fl_set_input_return(outputs_misc_->input_tex_encoding,
999 fl_set_input_return(outputs_misc_->input_ascii_roff,
1001 fl_set_input_return(outputs_misc_->input_checktex,
1003 fl_addto_choice(outputs_misc_->choice_default_papersize,
1004 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
1006 // set up the feedback mechanism
1007 fl_addto_form(outputs_misc_->form);
1009 setPostHandler( outputs_misc_->counter_line_len );
1010 setPostHandler( outputs_misc_->input_tex_encoding );
1011 setPostHandler( outputs_misc_->choice_default_papersize );
1012 setPostHandler( outputs_misc_->input_ascii_roff );
1013 setPostHandler( outputs_misc_->input_checktex );
1019 string FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob ) const
1023 if( ob == outputs_misc_->counter_line_len )
1024 str = lyxrc.getDescription( LyXRC::RC_ASCII_LINELEN );
1025 else if( ob == outputs_misc_->input_tex_encoding )
1026 str = lyxrc.getDescription( LyXRC::RC_FONT_ENCODING );
1027 else if( ob == outputs_misc_->input_ascii_roff )
1028 str = lyxrc.getDescription( LyXRC::RC_ASCIIROFF_COMMAND );
1029 else if( ob == outputs_misc_->input_checktex )
1030 str = lyxrc.getDescription( LyXRC::RC_CHKTEX_COMMAND );
1031 else if( ob == outputs_misc_->choice_default_papersize )
1032 str = lyxrc.getDescription( LyXRC::RC_DEFAULT_PAPERSIZE );
1038 void FormPreferences::updateOutputsMisc()
1040 fl_set_counter_value(outputs_misc_->counter_line_len,
1041 lyxrc.ascii_linelen);
1042 fl_set_input(outputs_misc_->input_tex_encoding,
1043 lyxrc.fontenc.c_str());
1044 fl_set_choice(outputs_misc_->choice_default_papersize,
1045 lyxrc.default_papersize+1);
1046 fl_set_input(outputs_misc_->input_ascii_roff,
1047 lyxrc.ascii_roff_command.c_str());
1048 fl_set_input(outputs_misc_->input_checktex,
1049 lyxrc.chktex_command.c_str());
1053 void FormPreferences::applyPaths()
1055 lyxrc.document_path = fl_get_input(paths_->input_default_path);
1056 lyxrc.template_path = fl_get_input(paths_->input_template_path);
1058 int button = fl_get_button(paths_->check_use_temp_dir);
1059 string str = fl_get_input(paths_->input_temp_dir);
1060 if( !button ) str.erase();
1062 lyxrc.use_tempdir = button;
1063 lyxrc.tempdir_path = str;
1065 button = fl_get_button(paths_->check_last_files);
1066 str = fl_get_input(paths_->input_lastfiles);
1067 if( !button ) str.erase();
1069 lyxrc.check_lastfiles = button;
1070 lyxrc.lastfiles = str;
1071 lyxrc.num_lastfiles = static_cast<unsigned int>
1072 (fl_get_counter_value(paths_->counter_lastfiles));
1074 button = fl_get_button(paths_->check_make_backups);
1075 str = fl_get_input(paths_->input_backup_path);
1076 if( !button ) str.erase();
1078 lyxrc.make_backup = button;
1079 lyxrc.backupdir_path = str;
1081 lyxrc.lyxpipes = fl_get_input(paths_->input_serverpipe);
1088 void FormPreferences::buildPaths()
1090 paths_ = build_paths();
1092 fl_set_input_return(paths_->input_default_path, FL_RETURN_CHANGED);
1093 fl_set_input_return(paths_->input_template_path, FL_RETURN_CHANGED);
1094 fl_set_input_return(paths_->input_temp_dir, FL_RETURN_CHANGED);
1095 fl_set_input_return(paths_->input_lastfiles, FL_RETURN_CHANGED);
1096 fl_set_input_return(paths_->input_backup_path, FL_RETURN_CHANGED);
1097 fl_set_counter_return(paths_->counter_lastfiles, FL_RETURN_CHANGED);
1098 fl_set_input_return(paths_->input_serverpipe, FL_RETURN_CHANGED);
1100 // deactivate the browse buttons because they aren't implemented
1101 fl_deactivate_object(paths_->button_document_browse);
1102 fl_deactivate_object(paths_->button_template_browse);
1103 fl_deactivate_object(paths_->button_temp_dir_browse);
1104 fl_deactivate_object(paths_->button_lastfiles_browse);
1105 fl_deactivate_object(paths_->button_backup_path_browse);
1106 fl_deactivate_object(paths_->button_serverpipe_browse);
1107 fl_set_object_lcol(paths_->button_document_browse, FL_INACTIVE);
1108 fl_set_object_lcol(paths_->button_template_browse, FL_INACTIVE);
1109 fl_set_object_lcol(paths_->button_temp_dir_browse, FL_INACTIVE);
1110 fl_set_object_lcol(paths_->button_lastfiles_browse, FL_INACTIVE);
1111 fl_set_object_lcol(paths_->button_backup_path_browse, FL_INACTIVE);
1112 fl_set_object_lcol(paths_->button_serverpipe_browse, FL_INACTIVE);
1114 // set up the feedback mechanism
1115 fl_addto_form(paths_->form);
1117 setPostHandler( paths_->input_default_path );
1118 setPostHandler( paths_->button_document_browse );
1119 setPostHandler( paths_->counter_lastfiles );
1120 setPostHandler( paths_->input_template_path );
1121 setPostHandler( paths_->button_template_browse );
1122 setPostHandler( paths_->check_last_files );
1123 setPostHandler( paths_->button_temp_dir_browse );
1124 setPostHandler( paths_->input_lastfiles );
1125 setPostHandler( paths_->button_lastfiles_browse );
1126 setPostHandler( paths_->check_make_backups );
1127 setPostHandler( paths_->input_backup_path );
1128 setPostHandler( paths_->button_backup_path_browse );
1129 setPostHandler( paths_->input_serverpipe );
1130 setPostHandler( paths_->button_serverpipe_browse );
1131 setPostHandler( paths_->input_temp_dir );
1132 setPostHandler( paths_->check_use_temp_dir );
1138 string FormPreferences::feedbackPaths( FL_OBJECT const * const ob ) const
1142 if( ob == paths_->input_default_path )
1143 str = lyxrc.getDescription( LyXRC::RC_DOCUMENTPATH );
1144 else if ( ob == paths_->input_template_path )
1145 str = lyxrc.getDescription( LyXRC::RC_TEMPLATEPATH );
1146 else if ( ob == paths_->check_use_temp_dir )
1147 str = lyxrc.getDescription( LyXRC::RC_USETEMPDIR );
1148 else if ( ob == paths_->input_temp_dir )
1149 str = lyxrc.getDescription( LyXRC::RC_TEMPDIRPATH );
1150 else if ( ob == paths_->check_last_files )
1151 str = lyxrc.getDescription( LyXRC::RC_CHECKLASTFILES );
1152 else if ( ob == paths_->input_lastfiles )
1153 str = lyxrc.getDescription( LyXRC::RC_LASTFILES );
1154 else if ( ob == paths_->counter_lastfiles )
1155 str = lyxrc.getDescription( LyXRC::RC_NUMLASTFILES );
1156 else if ( ob == paths_->check_make_backups )
1157 str = lyxrc.getDescription( LyXRC::RC_MAKE_BACKUP );
1158 else if ( ob == paths_->input_backup_path )
1159 str = lyxrc.getDescription( LyXRC::RC_BACKUPDIR_PATH );
1160 else if ( ob == paths_->input_serverpipe )
1161 str = lyxrc.getDescription( LyXRC::RC_SERVERPIPE );
1167 bool FormPreferences::inputPaths( FL_OBJECT const * const ob )
1169 bool activate = true;
1171 if( !ob || ob == paths_->check_use_temp_dir ) {
1172 if( fl_get_button(paths_->check_use_temp_dir) ) {
1173 fl_activate_object(paths_->input_temp_dir);
1174 fl_set_object_lcol(paths_->input_temp_dir,
1177 fl_deactivate_object(paths_->input_temp_dir);
1178 fl_set_object_lcol(paths_->input_temp_dir,
1183 if( !ob || ob == paths_->check_last_files ) {
1184 if( fl_get_button(paths_->check_last_files) ) {
1185 fl_activate_object(paths_->input_lastfiles);
1186 fl_set_object_lcol(paths_->input_lastfiles,
1189 fl_deactivate_object(paths_->input_lastfiles);
1190 fl_set_object_lcol(paths_->input_lastfiles,
1195 if( !ob || ob == paths_->check_make_backups ) {
1196 if( fl_get_button(paths_->check_make_backups) ) {
1197 fl_activate_object(paths_->input_backup_path);
1198 fl_set_object_lcol(paths_->input_backup_path,
1201 fl_deactivate_object(paths_->input_backup_path);
1202 fl_set_object_lcol(paths_->input_backup_path,
1207 if( !ob || ob == paths_->input_default_path ) {
1208 string name = fl_get_input(paths_->input_default_path);
1209 if( !WriteableDir(name) )
1213 if( !ob || ob == paths_->input_template_path ) {
1214 string name = fl_get_input(paths_->input_template_path);
1215 if( !ReadableDir(name) )
1219 if( !ob || ob == paths_->input_temp_dir ) {
1220 string name = fl_get_input(paths_->input_temp_dir);
1221 if( fl_get_button(paths_->check_make_backups)
1223 && !WriteableDir(name) )
1227 if( !ob || ob == paths_->input_backup_path ) {
1228 string name = fl_get_input(paths_->input_backup_path);
1229 if( fl_get_button(paths_->check_make_backups)
1231 && !WriteableDir(name) )
1235 if( !ob || ob == paths_->input_lastfiles ) {
1236 string name = fl_get_input(paths_->input_lastfiles);
1237 if( fl_get_button(paths_->check_last_files)
1239 && !WriteableFile(name) )
1243 if( !ob || ob == paths_->input_serverpipe ) {
1244 string name = fl_get_input(paths_->input_serverpipe);
1245 if( !name.empty() ) {
1246 if( !WriteableFile(name, ".in") )
1248 if( !WriteableFile(name, ".out") )
1257 void FormPreferences::updatePaths()
1259 fl_set_input(paths_->input_default_path,
1260 lyxrc.document_path.c_str());
1261 fl_set_input(paths_->input_template_path,
1262 lyxrc.template_path.c_str());
1264 string str = string();
1265 if( lyxrc.make_backup ) str = lyxrc.backupdir_path;
1267 fl_set_button(paths_->check_make_backups,
1269 fl_set_input(paths_->input_backup_path, str.c_str());
1272 if( lyxrc.use_tempdir ) str = lyxrc.tempdir_path;
1274 fl_set_button(paths_->check_use_temp_dir,
1276 fl_set_input(paths_->input_temp_dir, str.c_str());
1279 if( lyxrc.check_lastfiles ) str = lyxrc.lastfiles;
1281 fl_set_button(paths_->check_last_files,
1282 lyxrc.check_lastfiles);
1283 fl_set_input(paths_->input_lastfiles, str.c_str());
1284 fl_set_counter_value(paths_->counter_lastfiles,
1285 lyxrc.num_lastfiles);
1287 fl_set_input(paths_->input_serverpipe, lyxrc.lyxpipes.c_str());
1289 // Activate/Deactivate the input fields dependent on the state of the
1295 void FormPreferences::applyPrinter() const
1297 lyxrc.print_adapt_output = fl_get_button(printer_->check_adapt_output);
1298 lyxrc.print_command = fl_get_input(printer_->input_command);
1299 lyxrc.print_pagerange_flag = fl_get_input(printer_->input_page_range);
1300 lyxrc.print_copies_flag = fl_get_input(printer_->input_copies);
1301 lyxrc.print_reverse_flag = fl_get_input(printer_->input_reverse);
1302 lyxrc.print_to_printer = fl_get_input(printer_->input_to_printer);
1303 lyxrc.print_file_extension =
1304 fl_get_input(printer_->input_file_extension);
1305 lyxrc.print_spool_command =
1306 fl_get_input(printer_->input_spool_command);
1307 lyxrc.print_paper_flag = fl_get_input(printer_->input_paper_type);
1308 lyxrc.print_evenpage_flag = fl_get_input(printer_->input_even_pages);
1309 lyxrc.print_oddpage_flag = fl_get_input(printer_->input_odd_pages);
1310 lyxrc.print_collcopies_flag = fl_get_input(printer_->input_collated);
1311 lyxrc.print_landscape_flag = fl_get_input(printer_->input_landscape);
1312 lyxrc.print_to_file = fl_get_input(printer_->input_to_file);
1313 lyxrc.print_extra_options =
1314 fl_get_input(printer_->input_extra_options);
1315 lyxrc.print_spool_printerprefix =
1316 fl_get_input(printer_->input_spool_prefix);
1317 lyxrc.print_paper_dimension_flag =
1318 fl_get_input(printer_->input_paper_size);
1319 lyxrc.printer = fl_get_input(printer_->input_name);
1323 string FormPreferences::feedbackPrinter( FL_OBJECT const * const ob ) const
1327 if( ob == printer_->input_command )
1328 str = lyxrc.getDescription( LyXRC::RC_PRINT_COMMAND );
1329 else if( ob == printer_->check_adapt_output )
1330 str = lyxrc.getDescription( LyXRC::RC_PRINT_ADAPTOUTPUT );
1331 else if( ob == printer_->input_to_printer )
1332 str = lyxrc.getDescription( LyXRC::RC_PRINTTOPRINTER );
1333 else if( ob == printer_->input_to_file )
1334 str = lyxrc.getDescription( LyXRC::RC_PRINTTOFILE );
1335 else if( ob == printer_->input_file_extension )
1336 str = lyxrc.getDescription( LyXRC::RC_PRINTFILEEXTENSION );
1337 else if( ob == printer_->input_extra_options )
1338 str = lyxrc.getDescription( LyXRC::RC_PRINTEXSTRAOPTIONS );
1339 else if( ob == printer_->input_spool_command )
1340 str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_COMMAND );
1341 else if( ob == printer_->input_spool_prefix )
1342 str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_PRINTERPREFIX );
1343 else if( ob == printer_->input_name )
1344 str = lyxrc.getDescription( LyXRC::RC_PRINTER );
1345 else if( ob == printer_->input_even_pages )
1346 str = lyxrc.getDescription( LyXRC::RC_PRINTEVENPAGEFLAG );
1347 else if( ob == printer_->input_odd_pages )
1348 str = lyxrc.getDescription( LyXRC::RC_PRINTODDPAGEFLAG );
1349 else if( ob == printer_->input_page_range )
1350 str = lyxrc.getDescription( LyXRC::RC_PRINTPAGERANGEFLAG );
1351 else if( ob == printer_->input_reverse )
1352 str = lyxrc.getDescription( LyXRC::RC_PRINTREVERSEFLAG );
1353 else if( ob == printer_->input_landscape )
1354 str = lyxrc.getDescription( LyXRC::RC_PRINTLANDSCAPEFLAG );
1355 else if( ob == printer_->input_copies )
1356 str = lyxrc.getDescription( LyXRC::RC_PRINTCOLLCOPIESFLAG );
1357 else if( ob == printer_->input_collated )
1358 str = lyxrc.getDescription( LyXRC::RC_PRINTCOPIESFLAG );
1359 else if( ob == printer_->input_paper_type )
1360 str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERFLAG );
1361 else if( ob == printer_->input_paper_size )
1362 str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERDIMENSIONFLAG );
1368 void FormPreferences::buildPrinter()
1370 printer_ = build_printer();
1372 fl_set_input_return(printer_->input_command, FL_RETURN_CHANGED);
1373 fl_set_input_return(printer_->input_page_range, FL_RETURN_CHANGED);
1374 fl_set_input_return(printer_->input_copies, FL_RETURN_CHANGED);
1375 fl_set_input_return(printer_->input_reverse, FL_RETURN_CHANGED);
1376 fl_set_input_return(printer_->input_to_printer, FL_RETURN_CHANGED);
1377 fl_set_input_return(printer_->input_file_extension, FL_RETURN_CHANGED);
1378 fl_set_input_return(printer_->input_spool_command, FL_RETURN_CHANGED);
1379 fl_set_input_return(printer_->input_paper_type, FL_RETURN_CHANGED);
1380 fl_set_input_return(printer_->input_even_pages, FL_RETURN_CHANGED);
1381 fl_set_input_return(printer_->input_odd_pages, FL_RETURN_CHANGED);
1382 fl_set_input_return(printer_->input_collated, FL_RETURN_CHANGED);
1383 fl_set_input_return(printer_->input_landscape, FL_RETURN_CHANGED);
1384 fl_set_input_return(printer_->input_to_file, FL_RETURN_CHANGED);
1385 fl_set_input_return(printer_->input_extra_options, FL_RETURN_CHANGED);
1386 fl_set_input_return(printer_->input_spool_prefix, FL_RETURN_CHANGED);
1387 fl_set_input_return(printer_->input_paper_size, FL_RETURN_CHANGED);
1388 fl_set_input_return(printer_->input_name, FL_RETURN_CHANGED);
1390 // set up the feedback mechanism
1391 fl_addto_form(printer_->form);
1393 setPostHandler( printer_->input_command );
1394 setPostHandler( printer_->input_page_range );
1395 setPostHandler( printer_->input_copies );
1396 setPostHandler( printer_->input_reverse );
1397 setPostHandler( printer_->input_to_printer );
1398 setPostHandler( printer_->input_file_extension );
1399 setPostHandler( printer_->input_spool_command );
1400 setPostHandler( printer_->input_paper_type );
1401 setPostHandler( printer_->input_even_pages );
1402 setPostHandler( printer_->input_odd_pages );
1403 setPostHandler( printer_->input_collated );
1404 setPostHandler( printer_->input_landscape );
1405 setPostHandler( printer_->input_to_file );
1406 setPostHandler( printer_->input_extra_options );
1407 setPostHandler( printer_->input_spool_prefix );
1408 setPostHandler( printer_->input_paper_size );
1409 setPostHandler( printer_->input_name );
1410 setPostHandler( printer_->check_adapt_output );
1416 void FormPreferences::updatePrinter()
1418 fl_set_button(printer_->check_adapt_output,
1419 lyxrc.print_adapt_output);
1420 fl_set_input(printer_->input_command,
1421 lyxrc.print_command.c_str());
1422 fl_set_input(printer_->input_page_range,
1423 lyxrc.print_pagerange_flag.c_str());
1424 fl_set_input(printer_->input_copies,
1425 lyxrc.print_copies_flag.c_str());
1426 fl_set_input(printer_->input_reverse,
1427 lyxrc.print_reverse_flag.c_str());
1428 fl_set_input(printer_->input_to_printer,
1429 lyxrc.print_to_printer.c_str());
1430 fl_set_input(printer_->input_file_extension,
1431 lyxrc.print_file_extension.c_str());
1432 fl_set_input(printer_->input_spool_command,
1433 lyxrc.print_spool_command.c_str());
1434 fl_set_input(printer_->input_paper_type,
1435 lyxrc.print_paper_flag.c_str());
1436 fl_set_input(printer_->input_even_pages,
1437 lyxrc.print_evenpage_flag.c_str());
1438 fl_set_input(printer_->input_odd_pages,
1439 lyxrc.print_oddpage_flag.c_str());
1440 fl_set_input(printer_->input_collated,
1441 lyxrc.print_collcopies_flag.c_str());
1442 fl_set_input(printer_->input_landscape,
1443 lyxrc.print_landscape_flag.c_str());
1444 fl_set_input(printer_->input_to_file,
1445 lyxrc.print_to_file.c_str());
1446 fl_set_input(printer_->input_extra_options,
1447 lyxrc.print_extra_options.c_str());
1448 fl_set_input(printer_->input_spool_prefix,
1449 lyxrc.print_spool_printerprefix.c_str());
1450 fl_set_input(printer_->input_paper_size,
1451 lyxrc.print_paper_dimension_flag.c_str());
1452 fl_set_input(printer_->input_name,
1453 lyxrc.printer.c_str());
1457 void FormPreferences::applyScreenFonts() const
1459 bool changed = false;
1461 string str = fl_get_input(screen_fonts_->input_roman);
1462 if( lyxrc.roman_font_name != str ) {
1464 lyxrc.roman_font_name = str;
1467 str = fl_get_input(screen_fonts_->input_sans);
1468 if( lyxrc.sans_font_name != str ) {
1470 lyxrc.sans_font_name = str;
1473 str = fl_get_input(screen_fonts_->input_typewriter);
1474 if( lyxrc.typewriter_font_name != str ) {
1476 lyxrc.typewriter_font_name = str;
1479 str = fl_get_input(screen_fonts_->input_screen_encoding);
1480 if( lyxrc.font_norm != str ) {
1482 lyxrc.font_norm = str;
1485 bool button = fl_get_button(screen_fonts_->check_scalable);
1486 if( lyxrc.use_scalable_fonts != button ) {
1488 lyxrc.use_scalable_fonts = button;
1491 unsigned int ivalue = static_cast<unsigned int>
1492 (fl_get_counter_value(screen_fonts_->counter_zoom));
1493 if( lyxrc.zoom != ivalue) {
1495 lyxrc.zoom = ivalue;
1498 ivalue = static_cast<unsigned int>
1499 (fl_get_counter_value(screen_fonts_->counter_dpi));
1500 if (lyxrc.dpi != ivalue) {
1505 double dvalue = strToDbl(fl_get_input(screen_fonts_->input_tiny));
1506 if( lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue ) {
1508 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
1511 dvalue = strToDbl(fl_get_input(screen_fonts_->input_script));
1512 if( lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue ) {
1514 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
1517 dvalue = strToDbl(fl_get_input(screen_fonts_->input_footnote));
1518 if( lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue ) {
1520 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
1523 dvalue = strToDbl(fl_get_input(screen_fonts_->input_small));
1524 if( lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue ) {
1526 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
1529 dvalue = strToDbl(fl_get_input(screen_fonts_->input_normal));
1530 if( lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue ) {
1532 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
1535 dvalue = strToDbl(fl_get_input(screen_fonts_->input_large));
1536 if( lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue ) {
1538 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
1541 dvalue = strToDbl(fl_get_input(screen_fonts_->input_larger));
1542 if( lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue ) {
1544 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
1547 dvalue = strToDbl(fl_get_input(screen_fonts_->input_largest));
1548 if( lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue ) {
1550 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
1553 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huge));
1554 if( lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue ) {
1556 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
1559 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huger));
1560 if( lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue ) {
1562 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
1566 // Now update the buffers
1567 // Can anything below here affect the redraw process?
1568 lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
1573 void FormPreferences::buildScreenFonts()
1575 screen_fonts_ = build_screen_fonts();
1577 fl_set_input_return(screen_fonts_->input_roman, FL_RETURN_CHANGED);
1578 fl_set_input_return(screen_fonts_->input_sans, FL_RETURN_CHANGED);
1579 fl_set_input_return(screen_fonts_->input_typewriter,
1581 fl_set_input_return(screen_fonts_->input_screen_encoding,
1583 fl_set_counter_return(screen_fonts_->counter_zoom, FL_RETURN_CHANGED);
1584 fl_set_counter_return(screen_fonts_->counter_dpi, FL_RETURN_CHANGED);
1585 fl_set_input_return(screen_fonts_->input_tiny, FL_RETURN_CHANGED);
1586 fl_set_input_return(screen_fonts_->input_script, FL_RETURN_CHANGED);
1587 fl_set_input_return(screen_fonts_->input_footnote, FL_RETURN_CHANGED);
1588 fl_set_input_return(screen_fonts_->input_small, FL_RETURN_CHANGED);
1589 fl_set_input_return(screen_fonts_->input_normal, FL_RETURN_CHANGED);
1590 fl_set_input_return(screen_fonts_->input_large, FL_RETURN_CHANGED);
1591 fl_set_input_return(screen_fonts_->input_larger, FL_RETURN_CHANGED);
1592 fl_set_input_return(screen_fonts_->input_largest, FL_RETURN_CHANGED);
1593 fl_set_input_return(screen_fonts_->input_huge, FL_RETURN_CHANGED);
1594 fl_set_input_return(screen_fonts_->input_huger, FL_RETURN_CHANGED);
1596 fl_set_input_filter(screen_fonts_->input_tiny,
1597 fl_unsigned_int_filter);
1598 fl_set_input_filter(screen_fonts_->input_script,
1599 fl_unsigned_int_filter);
1600 fl_set_input_filter(screen_fonts_->input_footnote,
1601 fl_unsigned_int_filter);
1602 fl_set_input_filter(screen_fonts_->input_small,
1603 fl_unsigned_int_filter);
1604 fl_set_input_filter(screen_fonts_->input_normal,
1605 fl_unsigned_int_filter);
1606 fl_set_input_filter(screen_fonts_->input_large,
1607 fl_unsigned_int_filter);
1608 fl_set_input_filter(screen_fonts_->input_larger,
1609 fl_unsigned_int_filter);
1610 fl_set_input_filter(screen_fonts_->input_largest,
1611 fl_unsigned_int_filter);
1612 fl_set_input_filter(screen_fonts_->input_huge,
1613 fl_unsigned_int_filter);
1614 fl_set_input_filter(screen_fonts_->input_huger,
1615 fl_unsigned_int_filter);
1617 // set up the feedback mechanism
1618 fl_addto_form(screen_fonts_->form);
1620 setPostHandler( screen_fonts_->input_roman );
1621 setPostHandler( screen_fonts_->input_sans );
1622 setPostHandler( screen_fonts_->input_typewriter );
1623 setPostHandler( screen_fonts_->counter_zoom );
1624 setPostHandler( screen_fonts_->counter_dpi );
1625 setPostHandler( screen_fonts_->check_scalable );
1626 setPostHandler( screen_fonts_->input_screen_encoding );
1627 setPostHandler( screen_fonts_->input_tiny );
1628 setPostHandler( screen_fonts_->input_script );
1629 setPostHandler( screen_fonts_->input_footnote );
1630 setPostHandler( screen_fonts_->input_small );
1631 setPostHandler( screen_fonts_->input_large );
1632 setPostHandler( screen_fonts_->input_larger );
1633 setPostHandler( screen_fonts_->input_largest );
1634 setPostHandler( screen_fonts_->input_normal );
1635 setPostHandler( screen_fonts_->input_huge );
1636 setPostHandler( screen_fonts_->input_huger );
1642 string FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob ) const
1646 if( ob == screen_fonts_->input_roman )
1647 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ROMAN );
1648 else if( ob == screen_fonts_->input_sans )
1649 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SANS );
1650 else if( ob == screen_fonts_->input_typewriter )
1651 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_TYPEWRITER );
1652 else if( ob == screen_fonts_->check_scalable )
1653 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SCALABLE );
1654 else if( ob == screen_fonts_->input_screen_encoding )
1655 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING );
1656 else if( ob == screen_fonts_->counter_zoom )
1657 str = lyxrc.getDescription( LyXRC::RC_SCREEN_ZOOM );
1658 else if( ob == screen_fonts_->counter_dpi )
1659 str = lyxrc.getDescription( LyXRC::RC_SCREEN_DPI );
1660 else if( ob == screen_fonts_->input_tiny
1661 || ob == screen_fonts_->input_script
1662 || ob == screen_fonts_->input_footnote
1663 || ob == screen_fonts_->input_small
1664 || ob == screen_fonts_->input_large
1665 || ob == screen_fonts_->input_larger
1666 || ob == screen_fonts_->input_larger
1667 || ob == screen_fonts_->input_largest
1668 || ob == screen_fonts_->input_normal
1669 || ob == screen_fonts_->input_huge
1670 || ob == screen_fonts_->input_huger )
1671 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SIZES );
1677 bool FormPreferences::inputScreenFonts()
1679 bool activate = true;
1682 // Make sure that all fonts all have positive entries
1683 // Also note that an empty entry is returned as 0.0 by strToDbl
1684 if (0.0 >= strToDbl(fl_get_input(screen_fonts_->input_tiny))
1685 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_script))
1686 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_footnote))
1687 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_small))
1688 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_normal))
1689 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_large))
1690 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_larger))
1691 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_largest))
1692 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huge))
1693 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huger))) {
1695 str = N_("WARNING! Fonts must be positive!");
1697 // Fontsizes -- tiny < script < footnote etc.
1698 } else if (strToDbl(fl_get_input(screen_fonts_->input_tiny)) >
1699 strToDbl(fl_get_input(screen_fonts_->input_script)) ||
1700 strToDbl(fl_get_input(screen_fonts_->input_script)) >
1701 strToDbl(fl_get_input(screen_fonts_->input_footnote)) ||
1702 strToDbl(fl_get_input(screen_fonts_->input_footnote)) >
1703 strToDbl(fl_get_input(screen_fonts_->input_small)) ||
1704 strToDbl(fl_get_input(screen_fonts_->input_small)) >
1705 strToDbl(fl_get_input(screen_fonts_->input_normal)) ||
1706 strToDbl(fl_get_input(screen_fonts_->input_normal)) >
1707 strToDbl(fl_get_input(screen_fonts_->input_large)) ||
1708 strToDbl(fl_get_input(screen_fonts_->input_large)) >
1709 strToDbl(fl_get_input(screen_fonts_->input_larger)) ||
1710 strToDbl(fl_get_input(screen_fonts_->input_larger)) >
1711 strToDbl(fl_get_input(screen_fonts_->input_largest)) ||
1712 strToDbl(fl_get_input(screen_fonts_->input_largest)) >
1713 strToDbl(fl_get_input(screen_fonts_->input_huge)) ||
1714 strToDbl(fl_get_input(screen_fonts_->input_huge)) >
1715 strToDbl(fl_get_input(screen_fonts_->input_huger))) {
1718 str = N_("WARNING! Fonts must be input in the order tiny > script>\nfootnote > small > normal > large > larger > largest > huge > huger.");
1722 fl_set_object_label(dialog_->text_warning, str.c_str());
1723 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
1730 void FormPreferences::updateScreenFonts()
1732 fl_set_input(screen_fonts_->input_roman,
1733 lyxrc.roman_font_name.c_str());
1734 fl_set_input(screen_fonts_->input_sans,
1735 lyxrc.sans_font_name.c_str());
1736 fl_set_input(screen_fonts_->input_typewriter,
1737 lyxrc.typewriter_font_name.c_str());
1738 fl_set_input(screen_fonts_->input_screen_encoding,
1739 lyxrc.font_norm.c_str());
1740 fl_set_button(screen_fonts_->check_scalable,
1741 lyxrc.use_scalable_fonts);
1742 fl_set_counter_value(screen_fonts_->counter_zoom, lyxrc.zoom);
1743 fl_set_counter_value(screen_fonts_->counter_dpi, lyxrc.dpi);
1744 fl_set_input(screen_fonts_->input_tiny,
1745 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
1746 fl_set_input(screen_fonts_->input_script,
1747 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
1748 fl_set_input(screen_fonts_->input_footnote,
1749 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
1750 fl_set_input(screen_fonts_->input_small,
1751 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
1752 fl_set_input(screen_fonts_->input_normal,
1753 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
1754 fl_set_input(screen_fonts_->input_large,
1755 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
1756 fl_set_input(screen_fonts_->input_larger,
1757 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
1758 fl_set_input(screen_fonts_->input_largest,
1759 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
1760 fl_set_input(screen_fonts_->input_huge,
1761 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
1762 fl_set_input(screen_fonts_->input_huger,
1763 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
1767 void FormPreferences::applySpellChecker()
1770 string choice = "none";
1771 switch(fl_get_choice(spellchecker_->choice_spell_command)) {
1784 lyxrc.isp_command = choice;
1786 // If spell checker == "none", all other input set to off.
1787 if( fl_get_choice(spellchecker_->choice_spell_command) == 1 ) {
1788 lyxrc.isp_use_alt_lang = false;
1789 lyxrc.isp_alt_lang.erase();
1791 lyxrc.isp_use_esc_chars = false;
1792 lyxrc.isp_esc_chars.erase();
1794 lyxrc.isp_use_pers_dict = false;
1795 lyxrc.isp_pers_dict.erase();
1797 lyxrc.isp_accept_compound = false;
1798 lyxrc.isp_use_input_encoding = false;
1800 int button = fl_get_button(spellchecker_->check_alt_lang);
1801 choice = fl_get_input(spellchecker_->input_alt_lang);
1802 if( button && choice.empty() ) button = 0;
1803 if( !button ) choice.erase();
1805 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
1806 lyxrc.isp_alt_lang = choice;
1808 button = fl_get_button(spellchecker_->check_escape_chars);
1809 choice = fl_get_input(spellchecker_->input_escape_chars);
1810 if( button && choice.empty() ) button = 0;
1811 if( !button ) choice.erase();
1813 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
1814 lyxrc.isp_esc_chars = choice;
1816 button = fl_get_button(spellchecker_->check_personal_dict);
1817 choice = fl_get_input(spellchecker_->input_personal_dict);
1818 if( button && choice.empty() ) button = 0;
1819 if( !button ) choice.erase();
1821 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
1822 lyxrc.isp_pers_dict = choice;
1824 button = fl_get_button(spellchecker_->check_compound_words);
1825 lyxrc.isp_accept_compound = static_cast<bool>(button);
1827 button = fl_get_button(spellchecker_->check_input_enc);
1828 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
1832 updateSpellChecker();
1836 void FormPreferences::buildSpellchecker()
1838 spellchecker_ = build_spellchecker();
1840 fl_addto_choice(spellchecker_->choice_spell_command,
1841 _(" none | ispell | aspell "));
1842 fl_set_input_return(spellchecker_->input_alt_lang,
1844 fl_set_input_return(spellchecker_->input_escape_chars,
1846 fl_set_input_return(spellchecker_->input_personal_dict,
1849 // deactivate the browse button because it isn't implemented
1850 fl_deactivate_object(spellchecker_->button_personal_dict);
1851 fl_set_object_lcol(spellchecker_->button_personal_dict,
1854 // set up the feedback mechanism
1855 fl_addto_form(spellchecker_->form);
1857 setPostHandler( spellchecker_->choice_spell_command );
1858 setPostHandler( spellchecker_->check_alt_lang );
1859 setPostHandler( spellchecker_->input_alt_lang );
1860 setPostHandler( spellchecker_->check_escape_chars );
1861 setPostHandler( spellchecker_->input_escape_chars );
1862 setPostHandler( spellchecker_->check_personal_dict );
1863 setPostHandler( spellchecker_->input_personal_dict );
1864 setPostHandler( spellchecker_->button_personal_dict );
1865 setPostHandler( spellchecker_->check_compound_words );
1866 setPostHandler( spellchecker_->check_input_enc );
1872 string FormPreferences::feedbackSpellChecker( FL_OBJECT const * const ob ) const
1876 if( ob == spellchecker_->choice_spell_command )
1877 str = lyxrc.getDescription( LyXRC::RC_SPELL_COMMAND );
1878 else if( ob == spellchecker_->check_alt_lang )
1879 str = lyxrc.getDescription( LyXRC::RC_USE_ALT_LANG );
1880 else if( ob == spellchecker_->input_alt_lang )
1881 str = lyxrc.getDescription( LyXRC::RC_ALT_LANG );
1882 else if( ob == spellchecker_->check_escape_chars )
1883 str = lyxrc.getDescription( LyXRC::RC_USE_ESC_CHARS );
1884 else if( ob == spellchecker_->input_escape_chars )
1885 str = lyxrc.getDescription( LyXRC::RC_ESC_CHARS );
1886 else if( ob == spellchecker_->check_personal_dict )
1887 str = lyxrc.getDescription( LyXRC::RC_USE_PERS_DICT );
1888 else if( ob == spellchecker_->input_personal_dict )
1889 str = lyxrc.getDescription( LyXRC::RC_PERS_DICT );
1890 else if( ob == spellchecker_->check_compound_words )
1891 str = lyxrc.getDescription( LyXRC::RC_ACCEPT_COMPOUND );
1892 else if( ob == spellchecker_->check_input_enc )
1893 str = lyxrc.getDescription( LyXRC::RC_USE_INP_ENC );
1899 bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob )
1901 // Allow/dissallow input
1903 // If spell checker == "none", disable all input.
1904 if( !ob || ob == spellchecker_->choice_spell_command ) {
1905 if( fl_get_choice(spellchecker_->choice_spell_command) == 1 ) {
1906 fl_deactivate_object( spellchecker_->check_alt_lang );
1907 fl_deactivate_object( spellchecker_->input_alt_lang );
1908 fl_deactivate_object( spellchecker_->check_escape_chars );
1909 fl_deactivate_object( spellchecker_->input_escape_chars );
1910 fl_deactivate_object( spellchecker_->check_personal_dict );
1911 fl_deactivate_object( spellchecker_->input_personal_dict );
1912 fl_deactivate_object( spellchecker_->check_compound_words );
1913 fl_deactivate_object( spellchecker_->check_input_enc );
1916 fl_activate_object( spellchecker_->check_alt_lang );
1917 fl_activate_object( spellchecker_->check_escape_chars );
1918 fl_activate_object( spellchecker_->check_personal_dict );
1919 fl_activate_object( spellchecker_->check_compound_words );
1920 fl_activate_object( spellchecker_->check_input_enc );
1924 if( !ob || ob == spellchecker_->check_alt_lang ) {
1925 if( fl_get_button(spellchecker_->check_alt_lang) ) {
1926 fl_activate_object(spellchecker_->input_alt_lang);
1927 fl_set_object_lcol(spellchecker_->input_alt_lang,
1930 fl_deactivate_object(spellchecker_->input_alt_lang);
1931 fl_set_object_lcol(spellchecker_->input_alt_lang,
1936 if( !ob || ob == spellchecker_->check_escape_chars ) {
1937 if( fl_get_button(spellchecker_->check_escape_chars) ) {
1938 fl_activate_object(spellchecker_->input_escape_chars);
1939 fl_set_object_lcol(spellchecker_->input_escape_chars,
1942 fl_deactivate_object(spellchecker_->input_escape_chars);
1943 fl_set_object_lcol(spellchecker_->input_escape_chars,
1948 if( !ob || ob == spellchecker_->check_personal_dict ) {
1949 if( fl_get_button(spellchecker_->check_personal_dict) ) {
1950 fl_activate_object(spellchecker_->input_personal_dict);
1951 fl_set_object_lcol(spellchecker_->input_personal_dict,
1954 fl_deactivate_object(spellchecker_->input_personal_dict);
1955 fl_set_object_lcol(spellchecker_->input_personal_dict,
1960 return true; // All input is valid!
1964 void FormPreferences::updateSpellChecker()
1967 if( lyxrc.isp_command == "none" )
1969 else if( lyxrc.isp_command == "ispell" )
1971 else if( lyxrc.isp_command == "aspell" )
1973 fl_set_choice(spellchecker_->choice_spell_command, choice);
1975 string str = string();
1976 if( lyxrc.isp_use_alt_lang ) str = lyxrc.isp_alt_lang;
1978 fl_set_button(spellchecker_->check_alt_lang,
1979 lyxrc.isp_use_alt_lang);
1980 fl_set_input(spellchecker_->input_alt_lang, str.c_str());
1983 if( lyxrc.isp_use_esc_chars ) str = lyxrc.isp_esc_chars;
1985 fl_set_button(spellchecker_->check_escape_chars,
1986 lyxrc.isp_use_esc_chars);
1987 fl_set_input(spellchecker_->input_escape_chars, str.c_str());
1990 if( lyxrc.isp_use_pers_dict ) str = lyxrc.isp_pers_dict;
1992 fl_set_button(spellchecker_->check_personal_dict,
1993 lyxrc.isp_use_pers_dict);
1994 fl_set_input(spellchecker_->input_personal_dict, str.c_str());
1996 fl_set_button(spellchecker_->check_compound_words,
1997 lyxrc.isp_accept_compound);
1998 fl_set_button(spellchecker_->check_input_enc,
1999 lyxrc.isp_use_input_encoding);
2001 // Activate/Deactivate the input fields dependent on the state of the
2003 inputSpellChecker( 0 );
2007 bool FormPreferences::WriteableDir( string const & name ) const
2009 bool success = true;
2012 if( !AbsolutePath(name) ) {
2014 str = N_("WARNING! The absolute path is required.");
2018 if( success && !tp.isDir() ) {
2020 str = N_("WARNING! Directory does not exist.");
2023 if( success && !tp.writable() ) {
2025 str = N_("WARNING! Cannot write to this directory.");
2029 fl_set_object_label(dialog_->text_warning, str.c_str());
2030 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2037 bool FormPreferences::ReadableDir( string const & name ) const
2039 bool success = true;
2042 if( !AbsolutePath(name) ) {
2044 str = N_("WARNING! The absolute path is required.");
2048 if( success && !tp.isDir() ) {
2050 str = N_("WARNING! Directory does not exist.");
2053 if( success && !tp.readable() ) {
2055 str = N_("WARNING! Cannot read this directory.");
2059 fl_set_object_label(dialog_->text_warning, str.c_str());
2060 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2067 bool FormPreferences::WriteableFile( string const & name, string const & suffix ) const
2069 // A writeable file is either:
2070 // * An existing file to which we have write access, or
2071 // * A file that doesn't yet exist but that would exist in a writeable
2074 bool success = true;
2077 if( name.empty() ) {
2079 str = N_("WARNING! No file input.");
2082 string dir = OnlyPath(name);
2083 if( success && !AbsolutePath(dir) ) {
2085 str = N_("WARNING! The absolute path is required.");
2098 if( success && !d.isDir()) {
2100 str = N_("WARNING! Directory does not exist.");
2103 if( success && !d.writable() ) {
2105 str = N_("WARNING! Cannot write to this directory.");
2108 FileInfo f(name+suffix);
2109 if( success && (dir == name || f.isDir()) ) {
2111 str = N_("WARNING! A file is required, not a directory.");
2114 if( success && (f.exist() && !f.writable()) ) {
2116 str = N_("WARNING! Cannot write to this file.");
2120 fl_set_object_label(dialog_->text_warning, str.c_str());
2121 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
2128 void FormPreferences::ComboLanguageCB(int, void * v, Combox * combox)
2130 FormPreferences * pre = static_cast<FormPreferences*>(v);
2131 // This is safe, as nothing is done to the pointer, other than
2132 // to use its address in a block-if statement.
2133 pre->bc_.valid( pre->input( reinterpret_cast<FL_OBJECT *>(combox), 0 ));
2137 // C functions for the timer callback used to give the user feedback
2138 C_GENERICCB(FormPreferences, FeedbackCB)
2140 void FormPreferences::FeedbackCB(FL_OBJECT * ob, long)
2142 FormPreferences * pre =
2143 static_cast<FormPreferences*>(ob->form->u_vdata);
2144 pre->feedback( pre->feedbackObj );
2147 extern "C" int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event,
2148 FL_Coord, FL_Coord, int, void *)
2150 // can occur when form is being deleted. This seems an easier fix than
2151 // a call "fl_set_object_posthandler(ob, 0)" for each and every object
2152 // in the destructor.
2153 if( !ob->form ) return 0;
2155 FormPreferences * pre =
2156 static_cast<FormPreferences*>(ob->form->u_vdata);
2157 pre->feedbackPost(ob, event);
2162 // post_handler for feedback messages
2163 void FormPreferences::feedbackPost(FL_OBJECT *ob, int event)
2165 // We do not test for empty help here, since this can never happen
2166 if(event == FL_ENTER){
2167 // Used as a placeholder for ob, so that we don't have to
2168 // a horrible reinterpret_cast to long and pass it as an
2169 // argument in fl_set_object_callback.
2171 fl_set_object_callback(dialog_->timer_feedback,
2172 C_FormPreferencesFeedbackCB,
2174 fl_set_timer(dialog_->timer_feedback, 0.5);
2176 else if(event != FL_MOTION){
2177 fl_set_timer(dialog_->timer_feedback, 0);
2179 fl_set_object_label(dialog_->text_warning, "");
2184 void FormPreferences::setPostHandler( FL_OBJECT * ob ) const
2186 fl_set_object_posthandler(ob, C_FormPreferencesFeedbackPost);