2 * FormPreferences Interface Class Implementation
7 #include FORMS_H_LOCATION
10 #pragma implementation
13 #include "FormPreferences.h"
14 #include "form_preferences.h"
15 #include "input_validators.h"
23 #include "support/FileInfo.h"
24 #include "support/filetools.h"
25 #include "lyx_gui_misc.h"
26 #include "xform_helpers.h" // formatted()
27 #include "xform_macros.h"
29 #ifdef SIGC_CXX_NAMESPACES
36 extern Languages languages;
38 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
39 : FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
40 dialog_(0), outputs_tab_(0), look_n_feel_tab_(0), inputs_tab_(0),
41 usage_tab_(0), colours_(0), inputs_misc_(0), interface_(0),
42 language_(0), lnf_misc_(0), outputs_misc_(0), paths_(0), printer_(0),
43 screen_fonts_(0), spellchecker_(0),
44 combo_default_lang(0), combo_kbmap_1(0), combo_kbmap_2(0),
47 // let the dialog be shown
48 // This is a permanent connection so we won't bother
49 // storing a copy because we won't be disconnecting.
50 d->showPreferences.connect(slot(this, &FormPreferences::show));
54 FormPreferences::~FormPreferences()
56 delete combo_default_lang;
60 delete look_n_feel_tab_;
75 // Must be last to be deleted, or we'll get a SIGSEGV.
76 // Something to do with the Timer mechanism.
81 FL_FORM * FormPreferences::form() const
83 if (dialog_) return dialog_->form;
88 void FormPreferences::ok()
91 lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
95 void FormPreferences::restore()
98 // if I add an error message line to the dialog it'll have to be controlled
99 // within input(). I don't need it yet so I'll leave it commented out.
100 // bc_.valid(input(0));
104 void FormPreferences::hide()
106 // We need to hide the active tabfolder otherwise we get a
107 // BadDrawable error from X windows and LyX crashes without saving.
108 FL_FORM * outer_form = fl_get_active_folder(dialog_->tabfolder_prefs);
110 && outer_form->visible) {
111 fl_hide_form(outer_form);
117 void FormPreferences::build()
119 dialog_ = build_preferences();
121 // manage the restore, save, apply and cancel/close buttons
122 bc_.setOK(dialog_->button_ok);
123 bc_.setApply(dialog_->button_apply);
124 bc_.setCancel(dialog_->button_cancel);
125 bc_.setUndoAll(dialog_->button_restore);
128 // Workaround dumb xforms sizing bug
132 // build the tab folders
133 outputs_tab_ = build_outer_tab();
134 look_n_feel_tab_ = build_outer_tab();
135 inputs_tab_ = build_outer_tab();
136 usage_tab_ = build_outer_tab();
138 // build actual tabfolder contents
139 // these will become nested tabfolders
151 // Now add them to the tabfolder
152 fl_addto_tabfolder(dialog_->tabfolder_prefs,
154 look_n_feel_tab_->form);
155 fl_addto_tabfolder(dialog_->tabfolder_prefs,
158 fl_addto_tabfolder(dialog_->tabfolder_prefs,
161 fl_addto_tabfolder(dialog_->tabfolder_prefs,
165 // now build the nested tabfolders
166 // Starting with look and feel
167 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
169 screen_fonts_->form);
170 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
173 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
176 fl_addto_tabfolder(look_n_feel_tab_->tabfolder_outer,
181 // Paths should probably go in a few outer_tab called Files
182 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
185 fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
189 // then building outputs
190 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
193 fl_addto_tabfolder(outputs_tab_->tabfolder_outer,
195 outputs_misc_->form);
197 // then building usage
198 fl_addto_tabfolder(usage_tab_->tabfolder_outer,
200 spellchecker_->form);
201 fl_addto_tabfolder(usage_tab_->tabfolder_outer,
207 void FormPreferences::apply()
209 // set the new lyxrc entries
210 // many of these need to trigger other functions when the assignment
211 // is made. For example, screen zoom and font types. These could be
212 // handled either by signals/slots in lyxrc or just directly call the
213 // associated functions here.
214 // There are other problems with this scheme. We really should check
215 // what we copy to make sure that it really is necessary to do things
216 // like update the screen fonts because that flushes the textcache
217 // and other stuff which may cost us a lot on slower/high-load machines.
232 void FormPreferences::feedback( FL_OBJECT * ob )
236 if( ob->form->fdui == colours_ ) {
237 str = feedbackColours( ob );
238 } else if( ob->form->fdui == inputs_misc_ ) {
239 str = feedbackInputsMisc( ob );
240 } else if( ob->form->fdui == interface_ ) {
241 str = feedbackInterface( ob );
242 } else if( ob->form->fdui == language_ ) {
243 str = feedbackLanguage( ob );
244 } else if( ob->form->fdui == lnf_misc_ ) {
245 str = feedbackLnFmisc( ob );
246 } else if( ob->form->fdui == outputs_misc_ ) {
247 str = feedbackOutputsMisc( ob );
248 } else if( ob->form->fdui == paths_ ) {
249 str = feedbackPaths( ob );
250 } else if( ob->form->fdui == printer_ ) {
251 str = feedbackPrinter( ob );
252 } else if( ob->form->fdui == screen_fonts_ ) {
253 str = feedbackScreenFonts( ob );
254 } else if( ob->form->fdui == spellchecker_ ) {
255 str = feedbackSpellChecker( ob );
258 str = formatted( str, dialog_->text_warning->w-10,
259 FL_SMALL_SIZE, FL_NORMAL_STYLE );
261 fl_set_object_label(dialog_->text_warning, str.c_str());
262 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
266 bool FormPreferences::input(FL_OBJECT * ob, long)
268 bool activate = true;
270 // whatever checks you need to ensure the user hasn't entered
271 // some totally ridiculous value somewhere. Change activate to suit.
272 // comments before each test describe what is _valid_
274 if( ob->form->fdui == language_ ) {
275 if( ! inputLanguage( ob ) )
277 } else if( ob->form->fdui == paths_ ) {
278 if( ! inputPaths( ob ) )
280 } else if( ob->form->fdui == screen_fonts_ ) {
281 if( ! inputScreenFonts() )
283 } else if( ob->form->fdui == spellchecker_ ) {
284 if( ! inputSpellChecker( ob ) )
292 void FormPreferences::update()
294 if (!dialog_) return;
296 // read lyxrc entries
306 updateSpellChecker();
310 void FormPreferences::applyColours() const
315 void FormPreferences::buildColours()
317 colours_ = build_colours();
321 string FormPreferences::feedbackColours( FL_OBJECT const * const ) const
327 void FormPreferences::updateColours()
332 void FormPreferences::applyInputsMisc() const
334 lyxrc.date_insert_format = fl_get_input(inputs_misc_->input_date_format);
338 void FormPreferences::buildInputsMisc()
340 inputs_misc_ = build_inputs_misc();
342 fl_set_input_return(inputs_misc_->input_date_format,
345 // set up the feedback mechanism
346 fl_addto_form(inputs_misc_->form);
348 setPostHandler( inputs_misc_->input_date_format );
354 string FormPreferences::feedbackInputsMisc( FL_OBJECT const * const ob ) const
358 if( ob == inputs_misc_->input_date_format )
359 str = lyxrc.getDescription( LyXRC::RC_DATE_INSERT_FORMAT );
365 void FormPreferences::updateInputsMisc()
367 fl_set_input(inputs_misc_->input_date_format,
368 lyxrc.date_insert_format.c_str());
372 void FormPreferences::applyInterface() const
374 lyxrc.popup_font_name =
375 fl_get_input(interface_->input_popup_font);
376 lyxrc.menu_font_name = fl_get_input(interface_->input_menu_font);
377 lyxrc.font_norm_menu =
378 fl_get_input(interface_->input_popup_encoding);
379 lyxrc.bind_file = fl_get_input(interface_->input_bind_file);
380 lyxrc.ui_file = fl_get_input(interface_->input_ui_file);
381 lyxrc.override_x_deadkeys =
382 fl_get_button(interface_->check_override_x_dead_keys);
386 void FormPreferences::buildInterface()
388 interface_ = build_interface();
390 fl_set_input_return(interface_->input_popup_font, FL_RETURN_CHANGED);
391 fl_set_input_return(interface_->input_menu_font, FL_RETURN_CHANGED);
392 fl_set_input_return(interface_->input_popup_encoding,
394 fl_set_input_return(interface_->input_bind_file, FL_RETURN_CHANGED);
395 fl_set_input_return(interface_->input_ui_file, FL_RETURN_CHANGED);
397 // deactivate the browse buttons because they aren't implemented
398 fl_deactivate_object(interface_->button_bind_file_browse);
399 fl_deactivate_object(interface_->button_ui_file_browse);
400 fl_set_object_lcol(interface_->button_bind_file_browse, FL_INACTIVE);
401 fl_set_object_lcol(interface_->button_ui_file_browse, FL_INACTIVE);
403 // set up the feedback mechanism
404 fl_addto_form(interface_->form);
406 setPostHandler( interface_->input_popup_font );
407 setPostHandler( interface_->input_menu_font );
408 setPostHandler( interface_->input_popup_encoding );
409 setPostHandler( interface_->input_bind_file );
410 setPostHandler( interface_->button_bind_file_browse );
411 setPostHandler( interface_->input_ui_file );
412 setPostHandler( interface_->button_ui_file_browse );
413 setPostHandler( interface_->check_override_x_dead_keys );
420 string FormPreferences::feedbackInterface( FL_OBJECT const * const ob ) const
424 if( ob == interface_->input_popup_font )
425 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_POPUP );
426 else if ( ob == interface_->input_menu_font )
427 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_MENU );
428 else if ( ob == interface_->input_popup_encoding )
429 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING_MENU );
430 else if ( ob == interface_->input_bind_file )
431 str = lyxrc.getDescription( LyXRC::RC_BINDFILE );
432 else if ( ob == interface_->input_ui_file )
433 str = lyxrc.getDescription( LyXRC::RC_UIFILE );
434 else if ( ob == interface_->check_override_x_dead_keys )
435 str = lyxrc.getDescription( LyXRC::RC_OVERRIDE_X_DEADKEYS );
441 void FormPreferences::updateInterface()
443 fl_set_input(interface_->input_popup_font,
444 lyxrc.popup_font_name.c_str());
445 fl_set_input(interface_->input_menu_font,
446 lyxrc.menu_font_name.c_str());
447 fl_set_input(interface_->input_popup_encoding,
448 lyxrc.font_norm_menu.c_str());
449 fl_set_input(interface_->input_bind_file,
450 lyxrc.bind_file.c_str());
451 fl_set_input(interface_->input_ui_file,
452 lyxrc.ui_file.c_str());
453 fl_set_button(interface_->check_override_x_dead_keys,
454 lyxrc.override_x_deadkeys);
458 void FormPreferences::applyLanguage() const
460 lyxrc.default_language = combo_default_lang->getline();
462 int button = fl_get_button(language_->check_use_kbmap);
463 lyxrc.use_kbmap = static_cast<bool>(button);
466 lyxrc.primary_kbmap = combo_kbmap_1->getline();
467 lyxrc.secondary_kbmap = combo_kbmap_2->getline();
470 button = fl_get_button(language_->check_rtl_support);
471 lyxrc.rtl_support = static_cast<bool>(button);
473 button = fl_get_button(language_->check_auto_begin);
474 lyxrc.language_auto_begin = static_cast<bool>(button);
476 button = fl_get_button(language_->check_auto_end);
477 lyxrc.language_auto_end = static_cast<bool>(button);
479 button = fl_get_button(language_->check_mark_foreign);
480 lyxrc.mark_foreign_language = static_cast<bool>(button);
482 lyxrc.language_package = fl_get_input(language_->input_package);
483 lyxrc.language_command_begin = fl_get_input(language_->input_command_begin);
484 lyxrc.language_command_end = fl_get_input(language_->input_command_end);
488 void FormPreferences::buildLanguage()
490 language_ = build_language();
492 fl_set_input_return(language_->input_package, FL_RETURN_CHANGED);
493 fl_set_input_return(language_->input_command_begin, FL_RETURN_CHANGED);
494 fl_set_input_return(language_->input_command_end, FL_RETURN_CHANGED);
496 // The default_language is a combo-box and has to be inserted manually
497 fl_addto_form(language_->form);
499 FL_OBJECT * obj = language_->choice_default_lang;
500 combo_default_lang = new Combox(FL_COMBOX_DROPLIST);
501 combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
502 combo_default_lang->shortcut("#L",1);
503 combo_default_lang->setcallback(ComboLanguageCB, this);
504 addLanguages( *combo_default_lang );
507 obj = language_->choice_kbmap_1;
508 combo_kbmap_1 = new Combox(FL_COMBOX_DROPLIST);
509 combo_kbmap_1->add(obj->x, obj->y, obj->w, obj->h, 400);
510 combo_kbmap_1->shortcut("#1",1);
511 combo_kbmap_1->setcallback(ComboLanguageCB, this);
512 addLanguages( *combo_kbmap_1 );
515 obj = language_->choice_kbmap_2;
516 combo_kbmap_2 = new Combox(FL_COMBOX_DROPLIST);
517 combo_kbmap_2->add(obj->x, obj->y, obj->w, obj->h, 400);
518 combo_kbmap_2->shortcut("#2",1);
519 combo_kbmap_2->setcallback(ComboLanguageCB, this);
520 addLanguages( *combo_kbmap_2 );
524 // set up the feedback mechanism
525 fl_addto_form(language_->form);
527 setPostHandler( language_->input_package );
528 setPostHandler( language_->check_use_kbmap );
530 // This is safe, as nothing is done to the pointer, other than
531 // to use its address in a block-if statement.
532 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_default_lang) );
533 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_1) );
534 //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_2) );
536 setPostHandler( language_->check_rtl_support );
537 setPostHandler( language_->check_mark_foreign );
538 setPostHandler( language_->check_auto_begin );
539 setPostHandler( language_->check_auto_end );
540 setPostHandler( language_->input_command_begin );
541 setPostHandler( language_->input_command_end );
547 void FormPreferences::addLanguages( Combox & combo ) const
549 for(Languages::const_iterator cit = languages.begin();
550 cit != languages.end(); cit++) {
551 combo.addto((*cit).second.lang());
556 string FormPreferences::feedbackLanguage( FL_OBJECT const * const ob ) const
560 if( reinterpret_cast<Combox const *>(ob) == combo_default_lang )
561 str = lyxrc.getDescription( LyXRC::RC_DEFAULT_LANGUAGE );
562 else if( ob == language_->check_use_kbmap )
563 str = lyxrc.getDescription( LyXRC::RC_KBMAP );
564 else if( reinterpret_cast<Combox const *>(ob) == combo_kbmap_1)
565 str = lyxrc.getDescription( LyXRC::RC_KBMAP_PRIMARY );
566 else if( reinterpret_cast<Combox const *>(ob) == combo_kbmap_2 )
567 str = lyxrc.getDescription( LyXRC::RC_KBMAP_SECONDARY );
568 else if( ob == language_->check_rtl_support )
569 str = lyxrc.getDescription( LyXRC::RC_RTL_SUPPORT );
570 else if( ob == language_->check_auto_begin )
571 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_BEGIN );
572 else if( ob == language_->check_auto_end )
573 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_END );
574 else if( ob == language_->check_mark_foreign )
575 str = lyxrc.getDescription( LyXRC::RC_MARK_FOREIGN_LANGUAGE );
576 else if( ob == language_->input_package )
577 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_PACKAGE );
578 else if( ob == language_->input_command_begin )
579 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_BEGIN );
580 else if( ob == language_->input_command_end )
581 str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_END );
587 bool FormPreferences::inputLanguage( FL_OBJECT const * const ob )
589 bool activate = true;
591 if( !ob || ob == language_->check_use_kbmap ) {
592 if( fl_get_button(language_->check_use_kbmap) ) {
593 combo_kbmap_1->activate();
594 combo_kbmap_2->activate();
596 combo_kbmap_1->deactivate();
597 combo_kbmap_2->deactivate();
605 void FormPreferences::updateLanguage()
607 fl_set_button(language_->check_use_kbmap,
610 combo_default_lang->select_text( lyxrc.default_language );
612 if( lyxrc.use_kbmap ) {
613 combo_kbmap_1->select_text( lyxrc.primary_kbmap );
614 combo_kbmap_2->select_text( lyxrc.secondary_kbmap );
616 combo_kbmap_1->select_text( lyxrc.default_language );
617 combo_kbmap_2->select_text( lyxrc.default_language );
620 fl_set_button(language_->check_rtl_support, lyxrc.rtl_support);
621 fl_set_button(language_->check_auto_begin, lyxrc.language_auto_begin);
622 fl_set_button(language_->check_auto_end, lyxrc.language_auto_end);
623 fl_set_button(language_->check_mark_foreign,
624 lyxrc.mark_foreign_language);
626 fl_set_input(language_->input_package,
627 lyxrc.language_package.c_str());
628 fl_set_input(language_->input_command_begin,
629 lyxrc.language_command_begin.c_str());
630 fl_set_input(language_->input_command_end,
631 lyxrc.language_command_end.c_str());
633 // Activate/Deactivate the input fields dependent on the state of the
639 void FormPreferences::applyLnFmisc() const
641 lyxrc.show_banner = fl_get_button(lnf_misc_->check_banner);
642 lyxrc.auto_region_delete = fl_get_button(lnf_misc_->
643 check_auto_region_delete);
644 lyxrc.exit_confirmation = fl_get_button(lnf_misc_->check_exit_confirm);
645 lyxrc.display_shortcuts =
646 fl_get_button(lnf_misc_->check_display_shortcuts);
647 lyxrc.new_ask_filename = fl_get_button(lnf_misc_->check_ask_new_file);
648 lyxrc.cursor_follows_scrollbar =
649 fl_get_button(lnf_misc_->check_cursor_follows_scrollbar);
650 lyxrc.autosave = static_cast<unsigned int>
651 (fl_get_counter_value(lnf_misc_->counter_autosave));
652 lyxrc.wheel_jump = static_cast<unsigned int>
653 (fl_get_counter_value(lnf_misc_->counter_wm_jump));
657 void FormPreferences::buildLnFmisc()
659 lnf_misc_ = build_lnf_misc();
661 fl_set_counter_return(lnf_misc_->counter_autosave,
663 fl_set_counter_return(lnf_misc_->counter_wm_jump,
666 // set up the feedback mechanism
667 fl_addto_form(lnf_misc_->form);
669 setPostHandler( lnf_misc_->check_banner );
670 setPostHandler( lnf_misc_->check_auto_region_delete );
671 setPostHandler( lnf_misc_->check_exit_confirm );
672 setPostHandler( lnf_misc_->check_display_shortcuts );
673 setPostHandler( lnf_misc_->counter_autosave );
674 setPostHandler( lnf_misc_->check_ask_new_file );
675 setPostHandler( lnf_misc_->check_cursor_follows_scrollbar );
676 setPostHandler( lnf_misc_->counter_wm_jump );
682 string FormPreferences::feedbackLnFmisc( FL_OBJECT const * const ob ) const
686 if( ob == lnf_misc_->check_banner )
687 str = lyxrc.getDescription( LyXRC::RC_SHOW_BANNER );
688 else if( ob == lnf_misc_->check_auto_region_delete )
689 str = lyxrc.getDescription( LyXRC::RC_AUTOREGIONDELETE );
690 else if( ob == lnf_misc_->check_exit_confirm )
691 str = lyxrc.getDescription( LyXRC::RC_EXIT_CONFIRMATION );
692 else if( ob == lnf_misc_->check_display_shortcuts )
693 str = lyxrc.getDescription( LyXRC::RC_DISPLAY_SHORTCUTS );
694 else if( ob == lnf_misc_->check_ask_new_file )
695 str = lyxrc.getDescription( LyXRC::RC_NEW_ASK_FILENAME );
696 else if( ob == lnf_misc_->check_cursor_follows_scrollbar )
697 str = lyxrc.getDescription( LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR );
698 else if( ob == lnf_misc_->counter_autosave )
699 str = lyxrc.getDescription( LyXRC::RC_AUTOSAVE );
700 else if( ob == lnf_misc_->counter_wm_jump )
701 str = lyxrc.getDescription( LyXRC::RC_WHEEL_JUMP );
706 void FormPreferences::updateLnFmisc()
708 fl_set_button(lnf_misc_->check_banner,
710 fl_set_button(lnf_misc_->check_auto_region_delete,
711 lyxrc.auto_region_delete);
712 fl_set_button(lnf_misc_->check_exit_confirm,
713 lyxrc.exit_confirmation);
714 fl_set_button(lnf_misc_->check_display_shortcuts,
715 lyxrc.display_shortcuts);
716 fl_set_button(lnf_misc_->check_ask_new_file,
717 lyxrc.new_ask_filename);
718 fl_set_button(lnf_misc_->check_cursor_follows_scrollbar,
719 lyxrc.cursor_follows_scrollbar);
720 fl_set_counter_value(lnf_misc_->counter_autosave,
722 fl_set_counter_value(lnf_misc_->counter_wm_jump,
727 void FormPreferences::applyOutputsMisc() const
729 lyxrc.ascii_linelen = static_cast<unsigned int>
730 (fl_get_counter_value(outputs_misc_->counter_line_len));
731 lyxrc.fontenc = fl_get_input(outputs_misc_->input_tex_encoding);
734 fl_get_choice(outputs_misc_->choice_default_papersize) - 1;
735 lyxrc.default_papersize = static_cast<BufferParams::PAPER_SIZE>(choice);
737 lyxrc.ascii_roff_command = fl_get_input(outputs_misc_->input_ascii_roff);
738 lyxrc.chktex_command = fl_get_input(outputs_misc_->input_checktex);
742 void FormPreferences::buildOutputsMisc()
744 outputs_misc_ = build_outputs_misc();
746 fl_set_counter_return(outputs_misc_->counter_line_len,
748 fl_set_input_return(outputs_misc_->input_tex_encoding,
750 fl_set_input_return(outputs_misc_->input_ascii_roff,
752 fl_set_input_return(outputs_misc_->input_checktex,
754 fl_addto_choice(outputs_misc_->choice_default_papersize,
755 _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
757 // set up the feedback mechanism
758 fl_addto_form(outputs_misc_->form);
760 setPostHandler( outputs_misc_->counter_line_len );
761 setPostHandler( outputs_misc_->input_tex_encoding );
762 setPostHandler( outputs_misc_->choice_default_papersize );
763 setPostHandler( outputs_misc_->input_ascii_roff );
764 setPostHandler( outputs_misc_->input_checktex );
770 string FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob ) const
774 if( ob == outputs_misc_->counter_line_len )
775 str = lyxrc.getDescription( LyXRC::RC_ASCII_LINELEN );
776 else if( ob == outputs_misc_->input_tex_encoding )
777 str = lyxrc.getDescription( LyXRC::RC_FONT_ENCODING );
778 else if( ob == outputs_misc_->input_ascii_roff )
779 str = lyxrc.getDescription( LyXRC::RC_ASCIIROFF_COMMAND );
780 else if( ob == outputs_misc_->input_checktex )
781 str = lyxrc.getDescription( LyXRC::RC_CHKTEX_COMMAND );
782 else if( ob == outputs_misc_->choice_default_papersize )
783 str = lyxrc.getDescription( LyXRC::RC_DEFAULT_PAPERSIZE );
789 void FormPreferences::updateOutputsMisc()
791 fl_set_counter_value(outputs_misc_->counter_line_len,
792 lyxrc.ascii_linelen);
793 fl_set_input(outputs_misc_->input_tex_encoding,
794 lyxrc.fontenc.c_str());
795 fl_set_choice(outputs_misc_->choice_default_papersize,
796 lyxrc.default_papersize+1);
797 fl_set_input(outputs_misc_->input_ascii_roff,
798 lyxrc.ascii_roff_command.c_str());
799 fl_set_input(outputs_misc_->input_checktex,
800 lyxrc.chktex_command.c_str());
804 void FormPreferences::applyPaths()
806 lyxrc.document_path = fl_get_input(paths_->input_default_path);
807 lyxrc.template_path = fl_get_input(paths_->input_template_path);
809 int button = fl_get_button(paths_->check_use_temp_dir);
810 string str = fl_get_input(paths_->input_temp_dir);
811 if( !button ) str.erase();
813 lyxrc.use_tempdir = button;
814 lyxrc.tempdir_path = str;
816 button = fl_get_button(paths_->check_last_files);
817 str = fl_get_input(paths_->input_lastfiles);
818 if( !button ) str.erase();
820 lyxrc.check_lastfiles = button;
821 lyxrc.lastfiles = str;
822 lyxrc.num_lastfiles = static_cast<unsigned int>
823 (fl_get_counter_value(paths_->counter_lastfiles));
825 button = fl_get_button(paths_->check_make_backups);
826 str = fl_get_input(paths_->input_backup_path);
827 if( !button ) str.erase();
829 lyxrc.make_backup = button;
830 lyxrc.backupdir_path = str;
832 lyxrc.lyxpipes = fl_get_input(paths_->input_serverpipe);
839 void FormPreferences::buildPaths()
841 paths_ = build_paths();
843 fl_set_input_return(paths_->input_default_path, FL_RETURN_CHANGED);
844 fl_set_input_return(paths_->input_template_path, FL_RETURN_CHANGED);
845 fl_set_input_return(paths_->input_temp_dir, FL_RETURN_CHANGED);
846 fl_set_input_return(paths_->input_lastfiles, FL_RETURN_CHANGED);
847 fl_set_input_return(paths_->input_backup_path, FL_RETURN_CHANGED);
848 fl_set_counter_return(paths_->counter_lastfiles, FL_RETURN_CHANGED);
849 fl_set_input_return(paths_->input_serverpipe, FL_RETURN_CHANGED);
851 // deactivate the browse buttons because they aren't implemented
852 fl_deactivate_object(paths_->button_document_browse);
853 fl_deactivate_object(paths_->button_template_browse);
854 fl_deactivate_object(paths_->button_temp_dir_browse);
855 fl_deactivate_object(paths_->button_lastfiles_browse);
856 fl_deactivate_object(paths_->button_backup_path_browse);
857 fl_deactivate_object(paths_->button_serverpipe_browse);
858 fl_set_object_lcol(paths_->button_document_browse, FL_INACTIVE);
859 fl_set_object_lcol(paths_->button_template_browse, FL_INACTIVE);
860 fl_set_object_lcol(paths_->button_temp_dir_browse, FL_INACTIVE);
861 fl_set_object_lcol(paths_->button_lastfiles_browse, FL_INACTIVE);
862 fl_set_object_lcol(paths_->button_backup_path_browse, FL_INACTIVE);
863 fl_set_object_lcol(paths_->button_serverpipe_browse, FL_INACTIVE);
865 // set up the feedback mechanism
866 fl_addto_form(paths_->form);
868 setPostHandler( paths_->input_default_path );
869 setPostHandler( paths_->button_document_browse );
870 setPostHandler( paths_->counter_lastfiles );
871 setPostHandler( paths_->input_template_path );
872 setPostHandler( paths_->button_template_browse );
873 setPostHandler( paths_->check_last_files );
874 setPostHandler( paths_->button_temp_dir_browse );
875 setPostHandler( paths_->input_lastfiles );
876 setPostHandler( paths_->button_lastfiles_browse );
877 setPostHandler( paths_->check_make_backups );
878 setPostHandler( paths_->input_backup_path );
879 setPostHandler( paths_->button_backup_path_browse );
880 setPostHandler( paths_->input_serverpipe );
881 setPostHandler( paths_->button_serverpipe_browse );
882 setPostHandler( paths_->input_temp_dir );
883 setPostHandler( paths_->check_use_temp_dir );
889 string FormPreferences::feedbackPaths( FL_OBJECT const * const ob ) const
893 if( ob == paths_->input_default_path )
894 str = lyxrc.getDescription( LyXRC::RC_DOCUMENTPATH );
895 else if ( ob == paths_->input_template_path )
896 str = lyxrc.getDescription( LyXRC::RC_TEMPLATEPATH );
897 else if ( ob == paths_->check_use_temp_dir )
898 str = lyxrc.getDescription( LyXRC::RC_USETEMPDIR );
899 else if ( ob == paths_->input_temp_dir )
900 str = lyxrc.getDescription( LyXRC::RC_TEMPDIRPATH );
901 else if ( ob == paths_->check_last_files )
902 str = lyxrc.getDescription( LyXRC::RC_CHECKLASTFILES );
903 else if ( ob == paths_->input_lastfiles )
904 str = lyxrc.getDescription( LyXRC::RC_LASTFILES );
905 else if ( ob == paths_->counter_lastfiles )
906 str = lyxrc.getDescription( LyXRC::RC_NUMLASTFILES );
907 else if ( ob == paths_->check_make_backups )
908 str = lyxrc.getDescription( LyXRC::RC_MAKE_BACKUP );
909 else if ( ob == paths_->input_backup_path )
910 str = lyxrc.getDescription( LyXRC::RC_BACKUPDIR_PATH );
911 else if ( ob == paths_->input_serverpipe )
912 str = lyxrc.getDescription( LyXRC::RC_SERVERPIPE );
918 bool FormPreferences::inputPaths( FL_OBJECT const * const ob )
920 bool activate = true;
922 if( !ob || ob == paths_->check_use_temp_dir ) {
923 if( fl_get_button(paths_->check_use_temp_dir) ) {
924 fl_activate_object(paths_->input_temp_dir);
925 fl_set_object_lcol(paths_->input_temp_dir,
928 fl_deactivate_object(paths_->input_temp_dir);
929 fl_set_object_lcol(paths_->input_temp_dir,
934 if( !ob || ob == paths_->check_last_files ) {
935 if( fl_get_button(paths_->check_last_files) ) {
936 fl_activate_object(paths_->input_lastfiles);
937 fl_set_object_lcol(paths_->input_lastfiles,
940 fl_deactivate_object(paths_->input_lastfiles);
941 fl_set_object_lcol(paths_->input_lastfiles,
946 if( !ob || ob == paths_->check_make_backups ) {
947 if( fl_get_button(paths_->check_make_backups) ) {
948 fl_activate_object(paths_->input_backup_path);
949 fl_set_object_lcol(paths_->input_backup_path,
952 fl_deactivate_object(paths_->input_backup_path);
953 fl_set_object_lcol(paths_->input_backup_path,
958 if( !ob || ob == paths_->input_default_path ) {
959 string name = fl_get_input(paths_->input_default_path);
960 if( !WriteableDir(name) )
964 if( !ob || ob == paths_->input_template_path ) {
965 string name = fl_get_input(paths_->input_template_path);
966 if( !ReadableDir(name) )
970 if( !ob || ob == paths_->input_temp_dir ) {
971 string name = fl_get_input(paths_->input_temp_dir);
972 if( fl_get_button(paths_->check_make_backups)
974 && !WriteableDir(name) )
978 if( !ob || ob == paths_->input_backup_path ) {
979 string name = fl_get_input(paths_->input_backup_path);
980 if( fl_get_button(paths_->check_make_backups)
982 && !WriteableDir(name) )
986 if( !ob || ob == paths_->input_lastfiles ) {
987 string name = fl_get_input(paths_->input_lastfiles);
988 if( fl_get_button(paths_->check_last_files)
990 && !WriteableFile(name) )
994 if( !ob || ob == paths_->input_serverpipe ) {
995 string name = fl_get_input(paths_->input_serverpipe);
996 if( !name.empty() ) {
997 if( !WriteableFile(name, ".in") )
999 if( !WriteableFile(name, ".out") )
1008 void FormPreferences::updatePaths()
1010 fl_set_input(paths_->input_default_path,
1011 lyxrc.document_path.c_str());
1012 fl_set_input(paths_->input_template_path,
1013 lyxrc.template_path.c_str());
1015 string str = string();
1016 if( lyxrc.make_backup ) str = lyxrc.backupdir_path;
1018 fl_set_button(paths_->check_make_backups,
1020 fl_set_input(paths_->input_backup_path, str.c_str());
1023 if( lyxrc.use_tempdir ) str = lyxrc.tempdir_path;
1025 fl_set_button(paths_->check_use_temp_dir,
1027 fl_set_input(paths_->input_temp_dir, str.c_str());
1030 if( lyxrc.check_lastfiles ) str = lyxrc.lastfiles;
1032 fl_set_button(paths_->check_last_files,
1033 lyxrc.check_lastfiles);
1034 fl_set_input(paths_->input_lastfiles, str.c_str());
1035 fl_set_counter_value(paths_->counter_lastfiles,
1036 lyxrc.num_lastfiles);
1038 fl_set_input(paths_->input_serverpipe, lyxrc.lyxpipes.c_str());
1040 // Activate/Deactivate the input fields dependent on the state of the
1046 void FormPreferences::applyPrinter() const
1048 lyxrc.print_adapt_output = fl_get_button(printer_->check_adapt_output);
1049 lyxrc.print_command = fl_get_input(printer_->input_command);
1050 lyxrc.print_pagerange_flag = fl_get_input(printer_->input_page_range);
1051 lyxrc.print_copies_flag = fl_get_input(printer_->input_copies);
1052 lyxrc.print_reverse_flag = fl_get_input(printer_->input_reverse);
1053 lyxrc.print_to_printer = fl_get_input(printer_->input_to_printer);
1054 lyxrc.print_file_extension =
1055 fl_get_input(printer_->input_file_extension);
1056 lyxrc.print_spool_command =
1057 fl_get_input(printer_->input_spool_command);
1058 lyxrc.print_paper_flag = fl_get_input(printer_->input_paper_type);
1059 lyxrc.print_evenpage_flag = fl_get_input(printer_->input_even_pages);
1060 lyxrc.print_oddpage_flag = fl_get_input(printer_->input_odd_pages);
1061 lyxrc.print_collcopies_flag = fl_get_input(printer_->input_collated);
1062 lyxrc.print_landscape_flag = fl_get_input(printer_->input_landscape);
1063 lyxrc.print_to_file = fl_get_input(printer_->input_to_file);
1064 lyxrc.print_extra_options =
1065 fl_get_input(printer_->input_extra_options);
1066 lyxrc.print_spool_printerprefix =
1067 fl_get_input(printer_->input_spool_prefix);
1068 lyxrc.print_paper_dimension_flag =
1069 fl_get_input(printer_->input_paper_size);
1070 lyxrc.printer = fl_get_input(printer_->input_name);
1074 string FormPreferences::feedbackPrinter( FL_OBJECT const * const ob ) const
1078 if( ob == printer_->input_command )
1079 str = lyxrc.getDescription( LyXRC::RC_PRINT_COMMAND );
1080 else if( ob == printer_->check_adapt_output )
1081 str = lyxrc.getDescription( LyXRC::RC_PRINT_ADAPTOUTPUT );
1082 else if( ob == printer_->input_to_printer )
1083 str = lyxrc.getDescription( LyXRC::RC_PRINTTOPRINTER );
1084 else if( ob == printer_->input_to_file )
1085 str = lyxrc.getDescription( LyXRC::RC_PRINTTOFILE );
1086 else if( ob == printer_->input_file_extension )
1087 str = lyxrc.getDescription( LyXRC::RC_PRINTFILEEXTENSION );
1088 else if( ob == printer_->input_extra_options )
1089 str = lyxrc.getDescription( LyXRC::RC_PRINTEXSTRAOPTIONS );
1090 else if( ob == printer_->input_spool_command )
1091 str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_COMMAND );
1092 else if( ob == printer_->input_spool_prefix )
1093 str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_PRINTERPREFIX );
1094 else if( ob == printer_->input_name )
1095 str = lyxrc.getDescription( LyXRC::RC_PRINTER );
1096 else if( ob == printer_->input_even_pages )
1097 str = lyxrc.getDescription( LyXRC::RC_PRINTEVENPAGEFLAG );
1098 else if( ob == printer_->input_odd_pages )
1099 str = lyxrc.getDescription( LyXRC::RC_PRINTODDPAGEFLAG );
1100 else if( ob == printer_->input_page_range )
1101 str = lyxrc.getDescription( LyXRC::RC_PRINTPAGERANGEFLAG );
1102 else if( ob == printer_->input_reverse )
1103 str = lyxrc.getDescription( LyXRC::RC_PRINTREVERSEFLAG );
1104 else if( ob == printer_->input_landscape )
1105 str = lyxrc.getDescription( LyXRC::RC_PRINTLANDSCAPEFLAG );
1106 else if( ob == printer_->input_copies )
1107 str = lyxrc.getDescription( LyXRC::RC_PRINTCOLLCOPIESFLAG );
1108 else if( ob == printer_->input_collated )
1109 str = lyxrc.getDescription( LyXRC::RC_PRINTCOPIESFLAG );
1110 else if( ob == printer_->input_paper_type )
1111 str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERFLAG );
1112 else if( ob == printer_->input_paper_size )
1113 str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERDIMENSIONFLAG );
1119 void FormPreferences::buildPrinter()
1121 printer_ = build_printer();
1123 fl_set_input_return(printer_->input_command, FL_RETURN_CHANGED);
1124 fl_set_input_return(printer_->input_page_range, FL_RETURN_CHANGED);
1125 fl_set_input_return(printer_->input_copies, FL_RETURN_CHANGED);
1126 fl_set_input_return(printer_->input_reverse, FL_RETURN_CHANGED);
1127 fl_set_input_return(printer_->input_to_printer, FL_RETURN_CHANGED);
1128 fl_set_input_return(printer_->input_file_extension, FL_RETURN_CHANGED);
1129 fl_set_input_return(printer_->input_spool_command, FL_RETURN_CHANGED);
1130 fl_set_input_return(printer_->input_paper_type, FL_RETURN_CHANGED);
1131 fl_set_input_return(printer_->input_even_pages, FL_RETURN_CHANGED);
1132 fl_set_input_return(printer_->input_odd_pages, FL_RETURN_CHANGED);
1133 fl_set_input_return(printer_->input_collated, FL_RETURN_CHANGED);
1134 fl_set_input_return(printer_->input_landscape, FL_RETURN_CHANGED);
1135 fl_set_input_return(printer_->input_to_file, FL_RETURN_CHANGED);
1136 fl_set_input_return(printer_->input_extra_options, FL_RETURN_CHANGED);
1137 fl_set_input_return(printer_->input_spool_prefix, FL_RETURN_CHANGED);
1138 fl_set_input_return(printer_->input_paper_size, FL_RETURN_CHANGED);
1139 fl_set_input_return(printer_->input_name, FL_RETURN_CHANGED);
1141 // set up the feedback mechanism
1142 fl_addto_form(printer_->form);
1144 setPostHandler( printer_->input_command );
1145 setPostHandler( printer_->input_page_range );
1146 setPostHandler( printer_->input_copies );
1147 setPostHandler( printer_->input_reverse );
1148 setPostHandler( printer_->input_to_printer );
1149 setPostHandler( printer_->input_file_extension );
1150 setPostHandler( printer_->input_spool_command );
1151 setPostHandler( printer_->input_paper_type );
1152 setPostHandler( printer_->input_even_pages );
1153 setPostHandler( printer_->input_odd_pages );
1154 setPostHandler( printer_->input_collated );
1155 setPostHandler( printer_->input_landscape );
1156 setPostHandler( printer_->input_to_file );
1157 setPostHandler( printer_->input_extra_options );
1158 setPostHandler( printer_->input_spool_prefix );
1159 setPostHandler( printer_->input_paper_size );
1160 setPostHandler( printer_->input_name );
1161 setPostHandler( printer_->check_adapt_output );
1167 void FormPreferences::updatePrinter()
1169 fl_set_button(printer_->check_adapt_output,
1170 lyxrc.print_adapt_output);
1171 fl_set_input(printer_->input_command,
1172 lyxrc.print_command.c_str());
1173 fl_set_input(printer_->input_page_range,
1174 lyxrc.print_pagerange_flag.c_str());
1175 fl_set_input(printer_->input_copies,
1176 lyxrc.print_copies_flag.c_str());
1177 fl_set_input(printer_->input_reverse,
1178 lyxrc.print_reverse_flag.c_str());
1179 fl_set_input(printer_->input_to_printer,
1180 lyxrc.print_to_printer.c_str());
1181 fl_set_input(printer_->input_file_extension,
1182 lyxrc.print_file_extension.c_str());
1183 fl_set_input(printer_->input_spool_command,
1184 lyxrc.print_spool_command.c_str());
1185 fl_set_input(printer_->input_paper_type,
1186 lyxrc.print_paper_flag.c_str());
1187 fl_set_input(printer_->input_even_pages,
1188 lyxrc.print_evenpage_flag.c_str());
1189 fl_set_input(printer_->input_odd_pages,
1190 lyxrc.print_oddpage_flag.c_str());
1191 fl_set_input(printer_->input_collated,
1192 lyxrc.print_collcopies_flag.c_str());
1193 fl_set_input(printer_->input_landscape,
1194 lyxrc.print_landscape_flag.c_str());
1195 fl_set_input(printer_->input_to_file,
1196 lyxrc.print_to_file.c_str());
1197 fl_set_input(printer_->input_extra_options,
1198 lyxrc.print_extra_options.c_str());
1199 fl_set_input(printer_->input_spool_prefix,
1200 lyxrc.print_spool_printerprefix.c_str());
1201 fl_set_input(printer_->input_paper_size,
1202 lyxrc.print_paper_dimension_flag.c_str());
1203 fl_set_input(printer_->input_name,
1204 lyxrc.printer.c_str());
1208 void FormPreferences::applyScreenFonts() const
1210 bool changed = false;
1212 string str = fl_get_input(screen_fonts_->input_roman);
1213 if( lyxrc.roman_font_name != str ) {
1215 lyxrc.roman_font_name = str;
1218 str = fl_get_input(screen_fonts_->input_sans);
1219 if( lyxrc.sans_font_name != str ) {
1221 lyxrc.sans_font_name = str;
1224 str = fl_get_input(screen_fonts_->input_typewriter);
1225 if( lyxrc.typewriter_font_name != str ) {
1227 lyxrc.typewriter_font_name = str;
1230 str = fl_get_input(screen_fonts_->input_screen_encoding);
1231 if( lyxrc.font_norm != str ) {
1233 lyxrc.font_norm = str;
1236 bool button = fl_get_button(screen_fonts_->check_scalable);
1237 if( lyxrc.use_scalable_fonts != button ) {
1239 lyxrc.use_scalable_fonts = button;
1242 unsigned int ivalue = static_cast<unsigned int>
1243 (fl_get_counter_value(screen_fonts_->counter_zoom));
1244 if( lyxrc.zoom != ivalue) {
1246 lyxrc.zoom = ivalue;
1249 ivalue = static_cast<unsigned int>
1250 (fl_get_counter_value(screen_fonts_->counter_dpi));
1251 if (lyxrc.dpi != ivalue) {
1256 double dvalue = strToDbl(fl_get_input(screen_fonts_->input_tiny));
1257 if( lyxrc.font_sizes[LyXFont::SIZE_TINY] != dvalue ) {
1259 lyxrc.font_sizes[LyXFont::SIZE_TINY] = dvalue;
1262 dvalue = strToDbl(fl_get_input(screen_fonts_->input_script));
1263 if( lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] != dvalue ) {
1265 lyxrc.font_sizes[LyXFont::SIZE_SCRIPT] = dvalue;
1268 dvalue = strToDbl(fl_get_input(screen_fonts_->input_footnote));
1269 if( lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] != dvalue ) {
1271 lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE] = dvalue;
1274 dvalue = strToDbl(fl_get_input(screen_fonts_->input_small));
1275 if( lyxrc.font_sizes[LyXFont::SIZE_SMALL] != dvalue ) {
1277 lyxrc.font_sizes[LyXFont::SIZE_SMALL] = dvalue;
1280 dvalue = strToDbl(fl_get_input(screen_fonts_->input_normal));
1281 if( lyxrc.font_sizes[LyXFont::SIZE_NORMAL] != dvalue ) {
1283 lyxrc.font_sizes[LyXFont::SIZE_NORMAL] = dvalue;
1286 dvalue = strToDbl(fl_get_input(screen_fonts_->input_large));
1287 if( lyxrc.font_sizes[LyXFont::SIZE_LARGE] != dvalue ) {
1289 lyxrc.font_sizes[LyXFont::SIZE_LARGE] = dvalue;
1292 dvalue = strToDbl(fl_get_input(screen_fonts_->input_larger));
1293 if( lyxrc.font_sizes[LyXFont::SIZE_LARGER] != dvalue ) {
1295 lyxrc.font_sizes[LyXFont::SIZE_LARGER] = dvalue;
1298 dvalue = strToDbl(fl_get_input(screen_fonts_->input_largest));
1299 if( lyxrc.font_sizes[LyXFont::SIZE_LARGEST] != dvalue ) {
1301 lyxrc.font_sizes[LyXFont::SIZE_LARGEST] = dvalue;
1304 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huge));
1305 if( lyxrc.font_sizes[LyXFont::SIZE_HUGE] != dvalue ) {
1307 lyxrc.font_sizes[LyXFont::SIZE_HUGE] = dvalue;
1310 dvalue = strToDbl(fl_get_input(screen_fonts_->input_huger));
1311 if( lyxrc.font_sizes[LyXFont::SIZE_HUGER] != dvalue ) {
1313 lyxrc.font_sizes[LyXFont::SIZE_HUGER] = dvalue;
1317 // Now update the buffers
1318 // Can anything below here affect the redraw process?
1319 lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
1324 void FormPreferences::buildScreenFonts()
1326 screen_fonts_ = build_screen_fonts();
1328 fl_set_input_return(screen_fonts_->input_roman, FL_RETURN_CHANGED);
1329 fl_set_input_return(screen_fonts_->input_sans, FL_RETURN_CHANGED);
1330 fl_set_input_return(screen_fonts_->input_typewriter,
1332 fl_set_input_return(screen_fonts_->input_screen_encoding,
1334 fl_set_counter_return(screen_fonts_->counter_zoom, FL_RETURN_CHANGED);
1335 fl_set_counter_return(screen_fonts_->counter_dpi, FL_RETURN_CHANGED);
1336 fl_set_input_return(screen_fonts_->input_tiny, FL_RETURN_CHANGED);
1337 fl_set_input_return(screen_fonts_->input_script, FL_RETURN_CHANGED);
1338 fl_set_input_return(screen_fonts_->input_footnote, FL_RETURN_CHANGED);
1339 fl_set_input_return(screen_fonts_->input_small, FL_RETURN_CHANGED);
1340 fl_set_input_return(screen_fonts_->input_normal, FL_RETURN_CHANGED);
1341 fl_set_input_return(screen_fonts_->input_large, FL_RETURN_CHANGED);
1342 fl_set_input_return(screen_fonts_->input_larger, FL_RETURN_CHANGED);
1343 fl_set_input_return(screen_fonts_->input_largest, FL_RETURN_CHANGED);
1344 fl_set_input_return(screen_fonts_->input_huge, FL_RETURN_CHANGED);
1345 fl_set_input_return(screen_fonts_->input_huger, FL_RETURN_CHANGED);
1347 // set up the feedback mechanism
1348 fl_addto_form(screen_fonts_->form);
1350 setPostHandler( screen_fonts_->input_roman );
1351 setPostHandler( screen_fonts_->input_sans );
1352 setPostHandler( screen_fonts_->input_typewriter );
1353 setPostHandler( screen_fonts_->counter_zoom );
1354 setPostHandler( screen_fonts_->counter_dpi );
1355 setPostHandler( screen_fonts_->check_scalable );
1356 setPostHandler( screen_fonts_->input_screen_encoding );
1357 setPostHandler( screen_fonts_->input_tiny );
1358 setPostHandler( screen_fonts_->input_script );
1359 setPostHandler( screen_fonts_->input_footnote );
1360 setPostHandler( screen_fonts_->input_small );
1361 setPostHandler( screen_fonts_->input_large );
1362 setPostHandler( screen_fonts_->input_larger );
1363 setPostHandler( screen_fonts_->input_largest );
1364 setPostHandler( screen_fonts_->input_normal );
1365 setPostHandler( screen_fonts_->input_huge );
1366 setPostHandler( screen_fonts_->input_huger );
1372 string FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob ) const
1376 if( ob == screen_fonts_->input_roman )
1377 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ROMAN );
1378 else if( ob == screen_fonts_->input_sans )
1379 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SANS );
1380 else if( ob == screen_fonts_->input_typewriter )
1381 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_TYPEWRITER );
1382 else if( ob == screen_fonts_->check_scalable )
1383 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SCALABLE );
1384 else if( ob == screen_fonts_->input_screen_encoding )
1385 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING );
1386 else if( ob == screen_fonts_->counter_zoom )
1387 str = lyxrc.getDescription( LyXRC::RC_SCREEN_ZOOM );
1388 else if( ob == screen_fonts_->counter_dpi )
1389 str = lyxrc.getDescription( LyXRC::RC_SCREEN_DPI );
1390 else if( ob == screen_fonts_->input_tiny
1391 || ob == screen_fonts_->input_script
1392 || ob == screen_fonts_->input_footnote
1393 || ob == screen_fonts_->input_small
1394 || ob == screen_fonts_->input_large
1395 || ob == screen_fonts_->input_larger
1396 || ob == screen_fonts_->input_larger
1397 || ob == screen_fonts_->input_largest
1398 || ob == screen_fonts_->input_normal
1399 || ob == screen_fonts_->input_huge
1400 || ob == screen_fonts_->input_huger )
1401 str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SIZES );
1407 bool FormPreferences::inputScreenFonts()
1409 bool activate = true;
1412 // Make sure that all fonts all have positive entries
1413 // Also note that an empty entry is returned as 0.0 by strToDbl
1414 if (0.0 >= strToDbl(fl_get_input(screen_fonts_->input_tiny))
1415 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_script))
1416 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_footnote))
1417 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_small))
1418 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_normal))
1419 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_large))
1420 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_larger))
1421 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_largest))
1422 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huge))
1423 || 0.0 >= strToDbl(fl_get_input(screen_fonts_->input_huger))) {
1425 str = N_("WARNING! Fonts must be positive!");
1427 // Fontsizes -- tiny < script < footnote etc.
1428 } else if (strToDbl(fl_get_input(screen_fonts_->input_tiny)) >
1429 strToDbl(fl_get_input(screen_fonts_->input_script)) ||
1430 strToDbl(fl_get_input(screen_fonts_->input_script)) >
1431 strToDbl(fl_get_input(screen_fonts_->input_footnote)) ||
1432 strToDbl(fl_get_input(screen_fonts_->input_footnote)) >
1433 strToDbl(fl_get_input(screen_fonts_->input_small)) ||
1434 strToDbl(fl_get_input(screen_fonts_->input_small)) >
1435 strToDbl(fl_get_input(screen_fonts_->input_normal)) ||
1436 strToDbl(fl_get_input(screen_fonts_->input_normal)) >
1437 strToDbl(fl_get_input(screen_fonts_->input_large)) ||
1438 strToDbl(fl_get_input(screen_fonts_->input_large)) >
1439 strToDbl(fl_get_input(screen_fonts_->input_larger)) ||
1440 strToDbl(fl_get_input(screen_fonts_->input_larger)) >
1441 strToDbl(fl_get_input(screen_fonts_->input_largest)) ||
1442 strToDbl(fl_get_input(screen_fonts_->input_largest)) >
1443 strToDbl(fl_get_input(screen_fonts_->input_huge)) ||
1444 strToDbl(fl_get_input(screen_fonts_->input_huge)) >
1445 strToDbl(fl_get_input(screen_fonts_->input_huger))) {
1448 str = N_("WARNING! Fonts must be input in the order tiny > script>\nfootnote > small > normal > large > larger > largest > huge > huger.");
1452 fl_set_object_label(dialog_->text_warning, str.c_str());
1453 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
1460 void FormPreferences::updateScreenFonts()
1462 fl_set_input(screen_fonts_->input_roman,
1463 lyxrc.roman_font_name.c_str());
1464 fl_set_input(screen_fonts_->input_sans,
1465 lyxrc.sans_font_name.c_str());
1466 fl_set_input(screen_fonts_->input_typewriter,
1467 lyxrc.typewriter_font_name.c_str());
1468 fl_set_input(screen_fonts_->input_screen_encoding,
1469 lyxrc.font_norm.c_str());
1470 fl_set_button(screen_fonts_->check_scalable,
1471 lyxrc.use_scalable_fonts);
1472 fl_set_counter_value(screen_fonts_->counter_zoom, lyxrc.zoom);
1473 fl_set_counter_value(screen_fonts_->counter_dpi, lyxrc.dpi);
1474 fl_set_input(screen_fonts_->input_tiny,
1475 tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
1476 fl_set_input(screen_fonts_->input_script,
1477 tostr(lyxrc.font_sizes[LyXFont::SIZE_SCRIPT]).c_str());
1478 fl_set_input(screen_fonts_->input_footnote,
1479 tostr(lyxrc.font_sizes[LyXFont::SIZE_FOOTNOTE]).c_str());
1480 fl_set_input(screen_fonts_->input_small,
1481 tostr(lyxrc.font_sizes[LyXFont::SIZE_SMALL]).c_str());
1482 fl_set_input(screen_fonts_->input_normal,
1483 tostr(lyxrc.font_sizes[LyXFont::SIZE_NORMAL]).c_str());
1484 fl_set_input(screen_fonts_->input_large,
1485 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGE]).c_str());
1486 fl_set_input(screen_fonts_->input_larger,
1487 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGER]).c_str());
1488 fl_set_input(screen_fonts_->input_largest,
1489 tostr(lyxrc.font_sizes[LyXFont::SIZE_LARGEST]).c_str());
1490 fl_set_input(screen_fonts_->input_huge,
1491 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGE]).c_str());
1492 fl_set_input(screen_fonts_->input_huger,
1493 tostr(lyxrc.font_sizes[LyXFont::SIZE_HUGER]).c_str());
1497 void FormPreferences::applySpellChecker()
1500 string choice = "none";
1501 switch(fl_get_choice(spellchecker_->choice_spell_command)) {
1514 lyxrc.isp_command = choice;
1516 // If spell checker == "none", all other input set to off.
1517 if( fl_get_choice(spellchecker_->choice_spell_command) == 1 ) {
1518 lyxrc.isp_use_alt_lang = false;
1519 lyxrc.isp_alt_lang.erase();
1521 lyxrc.isp_use_esc_chars = false;
1522 lyxrc.isp_esc_chars.erase();
1524 lyxrc.isp_use_pers_dict = false;
1525 lyxrc.isp_pers_dict.erase();
1527 lyxrc.isp_accept_compound = false;
1528 lyxrc.isp_use_input_encoding = false;
1530 int button = fl_get_button(spellchecker_->check_alt_lang);
1531 choice = fl_get_input(spellchecker_->input_alt_lang);
1532 if( button && choice.empty() ) button = 0;
1533 if( !button ) choice.erase();
1535 lyxrc.isp_use_alt_lang = static_cast<bool>(button);
1536 lyxrc.isp_alt_lang = choice;
1538 button = fl_get_button(spellchecker_->check_escape_chars);
1539 choice = fl_get_input(spellchecker_->input_escape_chars);
1540 if( button && choice.empty() ) button = 0;
1541 if( !button ) choice.erase();
1543 lyxrc.isp_use_esc_chars = static_cast<bool>(button);
1544 lyxrc.isp_esc_chars = choice;
1546 button = fl_get_button(spellchecker_->check_personal_dict);
1547 choice = fl_get_input(spellchecker_->input_personal_dict);
1548 if( button && choice.empty() ) button = 0;
1549 if( !button ) choice.erase();
1551 lyxrc.isp_use_pers_dict = static_cast<bool>(button);
1552 lyxrc.isp_pers_dict = choice;
1554 button = fl_get_button(spellchecker_->check_compound_words);
1555 lyxrc.isp_accept_compound = static_cast<bool>(button);
1557 button = fl_get_button(spellchecker_->check_input_enc);
1558 lyxrc.isp_use_input_encoding = static_cast<bool>(button);
1562 updateSpellChecker();
1566 void FormPreferences::buildSpellchecker()
1568 spellchecker_ = build_spellchecker();
1570 fl_addto_choice(spellchecker_->choice_spell_command,
1571 _(" none | ispell | aspell "));
1572 fl_set_input_return(spellchecker_->input_alt_lang,
1574 fl_set_input_return(spellchecker_->input_escape_chars,
1576 fl_set_input_return(spellchecker_->input_personal_dict,
1579 // deactivate the browse button because it isn't implemented
1580 fl_deactivate_object(spellchecker_->button_personal_dict);
1581 fl_set_object_lcol(spellchecker_->button_personal_dict,
1584 // set up the feedback mechanism
1585 fl_addto_form(spellchecker_->form);
1587 setPostHandler( spellchecker_->choice_spell_command );
1588 setPostHandler( spellchecker_->check_alt_lang );
1589 setPostHandler( spellchecker_->input_alt_lang );
1590 setPostHandler( spellchecker_->check_escape_chars );
1591 setPostHandler( spellchecker_->input_escape_chars );
1592 setPostHandler( spellchecker_->check_personal_dict );
1593 setPostHandler( spellchecker_->input_personal_dict );
1594 setPostHandler( spellchecker_->button_personal_dict );
1595 setPostHandler( spellchecker_->check_compound_words );
1596 setPostHandler( spellchecker_->check_input_enc );
1602 string FormPreferences::feedbackSpellChecker( FL_OBJECT const * const ob ) const
1606 if( ob == spellchecker_->choice_spell_command )
1607 str = lyxrc.getDescription( LyXRC::RC_SPELL_COMMAND );
1608 else if( ob == spellchecker_->check_alt_lang )
1609 str = lyxrc.getDescription( LyXRC::RC_USE_ALT_LANG );
1610 else if( ob == spellchecker_->input_alt_lang )
1611 str = lyxrc.getDescription( LyXRC::RC_ALT_LANG );
1612 else if( ob == spellchecker_->check_escape_chars )
1613 str = lyxrc.getDescription( LyXRC::RC_USE_ESC_CHARS );
1614 else if( ob == spellchecker_->input_escape_chars )
1615 str = lyxrc.getDescription( LyXRC::RC_ESC_CHARS );
1616 else if( ob == spellchecker_->check_personal_dict )
1617 str = lyxrc.getDescription( LyXRC::RC_USE_PERS_DICT );
1618 else if( ob == spellchecker_->input_personal_dict )
1619 str = lyxrc.getDescription( LyXRC::RC_PERS_DICT );
1620 else if( ob == spellchecker_->check_compound_words )
1621 str = lyxrc.getDescription( LyXRC::RC_ACCEPT_COMPOUND );
1622 else if( ob == spellchecker_->check_input_enc )
1623 str = lyxrc.getDescription( LyXRC::RC_USE_INP_ENC );
1629 bool FormPreferences::inputSpellChecker( FL_OBJECT const * const ob )
1631 // Allow/dissallow input
1633 // If spell checker == "none", disable all input.
1634 if( !ob || ob == spellchecker_->choice_spell_command ) {
1635 if( fl_get_choice(spellchecker_->choice_spell_command) == 1 ) {
1636 fl_deactivate_object( spellchecker_->check_alt_lang );
1637 fl_deactivate_object( spellchecker_->input_alt_lang );
1638 fl_deactivate_object( spellchecker_->check_escape_chars );
1639 fl_deactivate_object( spellchecker_->input_escape_chars );
1640 fl_deactivate_object( spellchecker_->check_personal_dict );
1641 fl_deactivate_object( spellchecker_->input_personal_dict );
1642 fl_deactivate_object( spellchecker_->check_compound_words );
1643 fl_deactivate_object( spellchecker_->check_input_enc );
1646 fl_activate_object( spellchecker_->check_alt_lang );
1647 fl_activate_object( spellchecker_->check_escape_chars );
1648 fl_activate_object( spellchecker_->check_personal_dict );
1649 fl_activate_object( spellchecker_->check_compound_words );
1650 fl_activate_object( spellchecker_->check_input_enc );
1654 if( !ob || ob == spellchecker_->check_alt_lang ) {
1655 if( fl_get_button(spellchecker_->check_alt_lang) ) {
1656 fl_activate_object(spellchecker_->input_alt_lang);
1657 fl_set_object_lcol(spellchecker_->input_alt_lang,
1660 fl_deactivate_object(spellchecker_->input_alt_lang);
1661 fl_set_object_lcol(spellchecker_->input_alt_lang,
1666 if( !ob || ob == spellchecker_->check_escape_chars ) {
1667 if( fl_get_button(spellchecker_->check_escape_chars) ) {
1668 fl_activate_object(spellchecker_->input_escape_chars);
1669 fl_set_object_lcol(spellchecker_->input_escape_chars,
1672 fl_deactivate_object(spellchecker_->input_escape_chars);
1673 fl_set_object_lcol(spellchecker_->input_escape_chars,
1678 if( !ob || ob == spellchecker_->check_personal_dict ) {
1679 if( fl_get_button(spellchecker_->check_personal_dict) ) {
1680 fl_activate_object(spellchecker_->input_personal_dict);
1681 fl_set_object_lcol(spellchecker_->input_personal_dict,
1684 fl_deactivate_object(spellchecker_->input_personal_dict);
1685 fl_set_object_lcol(spellchecker_->input_personal_dict,
1690 return true; // all input is valid!
1694 void FormPreferences::updateSpellChecker()
1697 if( lyxrc.isp_command == "none" )
1699 else if( lyxrc.isp_command == "ispell" )
1701 else if( lyxrc.isp_command == "aspell" )
1703 fl_set_choice(spellchecker_->choice_spell_command, choice);
1705 string str = string();
1706 if( lyxrc.isp_use_alt_lang ) str = lyxrc.isp_alt_lang;
1708 fl_set_button(spellchecker_->check_alt_lang,
1709 lyxrc.isp_use_alt_lang);
1710 fl_set_input(spellchecker_->input_alt_lang, str.c_str());
1713 if( lyxrc.isp_use_esc_chars ) str = lyxrc.isp_esc_chars;
1715 fl_set_button(spellchecker_->check_escape_chars,
1716 lyxrc.isp_use_esc_chars);
1717 fl_set_input(spellchecker_->input_escape_chars, str.c_str());
1720 if( lyxrc.isp_use_pers_dict ) str = lyxrc.isp_pers_dict;
1722 fl_set_button(spellchecker_->check_personal_dict,
1723 lyxrc.isp_use_pers_dict);
1724 fl_set_input(spellchecker_->input_personal_dict, str.c_str());
1726 fl_set_button(spellchecker_->check_compound_words,
1727 lyxrc.isp_accept_compound);
1728 fl_set_button(spellchecker_->check_input_enc,
1729 lyxrc.isp_use_input_encoding);
1731 // Activate/Deactivate the input fields dependent on the state of the
1733 inputSpellChecker( 0 );
1737 bool FormPreferences::WriteableDir( string const & name ) const
1739 bool success = true;
1742 if( !AbsolutePath(name) ) {
1744 str = N_("WARNING! The absolute path is required.");
1748 if( success && !tp.isDir() ) {
1750 str = N_("WARNING! Directory does not exist.");
1753 if( success && !tp.writable() ) {
1755 str = N_("WARNING! Cannot write to this directory.");
1759 fl_set_object_label(dialog_->text_warning, str.c_str());
1760 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
1767 bool FormPreferences::ReadableDir( string const & name ) const
1769 bool success = true;
1772 if( !AbsolutePath(name) ) {
1774 str = N_("WARNING! The absolute path is required.");
1778 if( success && !tp.isDir() ) {
1780 str = N_("WARNING! Directory does not exist.");
1783 if( success && !tp.readable() ) {
1785 str = N_("WARNING! Cannot read this directory.");
1789 fl_set_object_label(dialog_->text_warning, str.c_str());
1790 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
1797 bool FormPreferences::WriteableFile( string const & name, string const & suffix ) const
1799 // A writeable file is either:
1800 // * An existing file to which we have write access, or
1801 // * A file that doesn't yet exist but that would exist in a writeable
1804 bool success = true;
1807 if( name.empty() ) {
1809 str = N_("WARNING! No file input.");
1812 string dir = OnlyPath(name);
1813 if( success && !AbsolutePath(dir) ) {
1815 str = N_("WARNING! The absolute path is required.");
1828 if( success && !d.isDir()) {
1830 str = N_("WARNING! Directory does not exist.");
1833 if( success && !d.writable() ) {
1835 str = N_("WARNING! Cannot write to this directory.");
1838 FileInfo f(name+suffix);
1839 if( success && (dir == name || f.isDir()) ) {
1841 str = N_("WARNING! A file is required, not a directory.");
1844 if( success && (f.exist() && !f.writable()) ) {
1846 str = N_("WARNING! Cannot write to this file.");
1850 fl_set_object_label(dialog_->text_warning, str.c_str());
1851 fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
1858 void FormPreferences::ComboLanguageCB(int, void * v, Combox * combox)
1860 FormPreferences * pre = static_cast<FormPreferences*>(v);
1861 // This is safe, as nothing is done to the pointer, other than
1862 // to use its address in a block-if statement.
1863 pre->bc_.valid( pre->input( reinterpret_cast<FL_OBJECT *>(combox), 0 ));
1867 // C functions for the timer callback used to give the user feedback
1868 C_GENERICCB(FormPreferences, FeedbackCB)
1870 void FormPreferences::FeedbackCB(FL_OBJECT * ob, long)
1872 FormPreferences * pre =
1873 static_cast<FormPreferences*>(ob->form->u_vdata);
1874 pre->feedback( pre->feedbackObj );
1877 extern "C" int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event,
1878 FL_Coord, FL_Coord, int, void *)
1880 FormPreferences * pre =
1881 static_cast<FormPreferences*>(ob->form->u_vdata);
1882 pre->feedbackPost(ob, event);
1887 // post_handler for feedback messages
1888 void FormPreferences::feedbackPost(FL_OBJECT *ob, int event)
1890 // We do not test for empty help here, since this can never happen
1891 if(event == FL_ENTER){
1892 // Used as a placeholder for ob, so that we don't have to
1893 // a horrible reinterpret_cast to long and pass it as an
1894 // argument in fl_set_object_callback.
1896 fl_set_object_callback(dialog_->timer_feedback,
1897 C_FormPreferencesFeedbackCB,
1899 fl_set_timer(dialog_->timer_feedback, 0.5);
1901 else if(event != FL_MOTION){
1902 fl_set_timer(dialog_->timer_feedback, 0);
1904 fl_set_object_label(dialog_->text_warning, "");
1909 void FormPreferences::setPostHandler( FL_OBJECT * ob ) const
1911 fl_set_object_posthandler(ob, C_FormPreferencesFeedbackPost);