* FormPreferences Interface Class Implementation
*/
+#include <utility>
#include <config.h>
#include FORMS_H_LOCATION
#pragma implementation
#endif
-#include <vector>
-
+#include "Lsstream.h"
#include "FormPreferences.h"
#include "form_preferences.h"
#include "input_validators.h"
#include "lyxfunc.h"
#include "Dialogs.h"
#include "lyxrc.h"
+#include "combox.h"
#include "debug.h"
#include "support/FileInfo.h"
#include "support/filetools.h"
#include "lyx_gui_misc.h"
+#include "lyxlex.h"
+#include "input_validators.h"
+#include "xform_helpers.h" // formatted()
+#include "xform_macros.h"
#ifdef SIGC_CXX_NAMESPACES
using SigC::slot;
#endif
using std::find;
+using std::getline;
+using std::istream;
+using std::pair;
using std::vector;
+extern string fmt(char const * fmtstr ...);
extern Languages languages;
-static vector<string> languageNames;
+
+typedef pair<string, FormPreferences::RGB> X11Colour;
+
+static vector<X11Colour> colourDB;
+static string const colourFile = "/usr/lib/X11/rgb.txt";
+
FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
: FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
- dialog_(0), outputs_tab_(0), look_n_feel_tab_(0), inputs_tab_(0),
- usage_tab_(0), colours_(0), inputs_misc_(0), interface_(0),
- language_(0), lnf_misc_(0), outputs_misc_(0), paths_(0), printer_(0),
- screen_fonts_(0), spellchecker_(0)
+ dialog_(0),
+ converters_tab_(0), inputs_tab_(0), look_n_feel_tab_(0),
+ outputs_tab_(0), usage_tab_(0),
+ colours_(0), converters_(0), formats_(0), inputs_misc_(0),
+ interface_(0), language_(0), lnf_misc_(0), outputs_misc_(0),
+ paths_(0), printer_(0), screen_fonts_(0), spellchecker_(0),
+ combo_default_lang(0), combo_kbmap_1(0), combo_kbmap_2(0),
+ feedbackObj(0)
{
// let the dialog be shown
// This is a permanent connection so we won't bother
FormPreferences::~FormPreferences()
{
- delete dialog_;
- delete look_n_feel_tab_;
+ delete combo_default_lang;
+ delete combo_kbmap_1;
+ delete combo_kbmap_2;
+
+ delete converters_tab_;
delete inputs_tab_;
+ delete look_n_feel_tab_;
delete outputs_tab_;
delete usage_tab_;
+
delete colours_;
+ delete converters_;
+ delete formats_;
delete inputs_misc_;
delete interface_;
delete language_;
delete printer_;
delete screen_fonts_;
delete spellchecker_;
+
+ // Must delete dialog last or we'll end up with a SIGSEGV trying to
+ // access dialog_->timer_feedback in feedbackPost().
+ delete dialog_;
}
}
-void FormPreferences::restore()
-{
- update();
-// if I add an error message line to the dialog it'll have to be controlled
-// within input(). I don't need it yet so I'll leave it commented out.
-// bc_.valid(input(0));
-}
-
-
void FormPreferences::hide()
{
// We need to hide the active tabfolder otherwise we get a
minh_ = form()->h;
// build the tab folders
- outputs_tab_ = build_outer_tab();
+ converters_tab_ = build_outer_tab();
look_n_feel_tab_ = build_outer_tab();
inputs_tab_ = build_outer_tab();
+ outputs_tab_ = build_outer_tab();
usage_tab_ = build_outer_tab();
// build actual tabfolder contents
// these will become nested tabfolders
buildColours();
+ buildConverters();
+ buildFormats();
buildInputsMisc();
buildInterface();
buildLanguage();
fl_addto_tabfolder(dialog_->tabfolder_prefs,
_("Look and Feel"),
look_n_feel_tab_->form);
+ fl_addto_tabfolder(dialog_->tabfolder_prefs,
+ _("Usage"),
+ usage_tab_->form);
+ fl_addto_tabfolder(dialog_->tabfolder_prefs,
+ _("Converters"),
+ converters_tab_->form);
fl_addto_tabfolder(dialog_->tabfolder_prefs,
_("Inputs"),
inputs_tab_->form);
fl_addto_tabfolder(dialog_->tabfolder_prefs,
_("Outputs"),
outputs_tab_->form);
- fl_addto_tabfolder(dialog_->tabfolder_prefs,
- _("Usage"),
- usage_tab_->form);
// now build the nested tabfolders
// Starting with look and feel
_("Misc"),
lnf_misc_->form);
+ // then build converters
+ fl_addto_tabfolder(converters_tab_->tabfolder_outer,
+ _("Formats"),
+ formats_->form);
+ fl_addto_tabfolder(converters_tab_->tabfolder_outer,
+ _("Converters"),
+ converters_->form);
+
// then build inputs
// Paths should probably go in a few outer_tab called Files
fl_addto_tabfolder(inputs_tab_->tabfolder_outer,
// and other stuff which may cost us a lot on slower/high-load machines.
applyColours();
+ applyConverters();
+ applyFormats();
applyInputsMisc();
applyInterface();
applyLanguage();
}
+void FormPreferences::feedback( FL_OBJECT * ob )
+{
+ string str;
+
+ if( ob->form->fdui == colours_ ) {
+ str = feedbackColours( ob );
+ } else if( ob->form->fdui == converters_ ) {
+ str = feedbackConverters( ob );
+ } else if( ob->form->fdui == formats_ ) {
+ str = feedbackFormats( ob );
+ } else if( ob->form->fdui == inputs_misc_ ) {
+ str = feedbackInputsMisc( ob );
+ } else if( ob->form->fdui == interface_ ) {
+ str = feedbackInterface( ob );
+ } else if( ob->form->fdui == language_ ) {
+ str = feedbackLanguage( ob );
+ } else if( ob->form->fdui == lnf_misc_ ) {
+ str = feedbackLnFmisc( ob );
+ } else if( ob->form->fdui == outputs_misc_ ) {
+ str = feedbackOutputsMisc( ob );
+ } else if( ob->form->fdui == paths_ ) {
+ str = feedbackPaths( ob );
+ } else if( ob->form->fdui == printer_ ) {
+ str = feedbackPrinter( ob );
+ } else if( ob->form->fdui == screen_fonts_ ) {
+ str = feedbackScreenFonts( ob );
+ } else if( ob->form->fdui == spellchecker_ ) {
+ str = feedbackSpellChecker( ob );
+ }
+
+ str = formatted( str, dialog_->text_warning->w-10,
+ FL_SMALL_SIZE, FL_NORMAL_STYLE );
+
+ fl_set_object_label(dialog_->text_warning, str.c_str());
+ fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+}
+
+
+bool FormPreferences::input(FL_OBJECT * ob, long)
+{
+ bool activate = true;
+
+ // whatever checks you need to ensure the user hasn't entered
+ // some totally ridiculous value somewhere. Change activate to suit.
+ // comments before each test describe what is _valid_
+
+ if( ob->form->fdui == colours_ ) {
+ if( ! inputColours( ob ) )
+ activate = false;
+ } else if( ob->form->fdui == language_ ) {
+ if( ! inputLanguage( ob ) )
+ activate = false;
+ } else if( ob->form->fdui == paths_ ) {
+ if( ! inputPaths( ob ) )
+ activate = false;
+ } else if( ob->form->fdui == screen_fonts_ ) {
+ if( ! inputScreenFonts() )
+ activate = false;
+ } else if( ob->form->fdui == spellchecker_ ) {
+ if( ! inputSpellChecker( ob ) )
+ activate = false;
+ }
+
+ return activate;
+}
+
+
void FormPreferences::update()
{
if (!dialog_) return;
// read lyxrc entries
updateColours();
+ updateConverters();
+ updateFormats();
updateInputsMisc();
updateInterface();
updateLanguage();
}
-bool FormPreferences::input(FL_OBJECT * ob, long data)
+void FormPreferences::applyColours() const
{
- bool activate = true;
+}
- // Remove any existing messages
- fl_set_object_label(dialog_->text_warning, " ");
- // whatever checks you need to ensure the user hasn't entered
- // some totally ridiculous value somewhere. Change activate to suit.
- // comments before each test describe what is _valid_
+void FormPreferences::buildColours()
+{
+ colours_ = build_colours();
- State cb = static_cast<State>( data );
- switch( cb ) {
- case COLOURS:
- feedbackColours( ob );
- break;
+ FL_OBJECT *obj;
+ obj = colours_->valslider_red;
+ fl_set_slider_bounds(obj, 0, 255);
+ fl_set_slider_precision(obj, 0);
+ fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
+
+ obj = colours_->valslider_green;
+ fl_set_slider_bounds(obj, 0, 255);
+ fl_set_slider_precision(obj, 0);
+ fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
+
+ obj = colours_->valslider_blue;
+ fl_set_slider_bounds(obj, 0, 255);
+ fl_set_slider_precision(obj, 0);
+ fl_set_slider_return(obj, FL_RETURN_END_CHANGED);
- case INPUTSMISC:
- feedbackInputsMisc( ob );
- break;
+ fl_set_object_color(colours_->button_colour,
+ FL_FREE_COL4, FL_FREE_COL4);
+
+ fl_set_input_return(colours_->input_name, FL_RETURN_END_CHANGED);
- case INTERFACE:
- feedbackInterface( ob );
- break;
+ if( ColoursLoadBrowser(colourFile) )
+ fl_set_input(colours_->input_name, colourFile.c_str());
+ else
+ fl_set_input(colours_->input_name, N_("No file found"));
- case LANGUAGE:
- feedbackLanguage( ob );
- if( ! inputLanguage( ob ) )
- activate = false;
- break;
+ // deactivate the browse button because it isn't implemented
+ fl_deactivate_object(colours_->button_browse);
+ fl_set_object_lcol(colours_->button_browse, FL_INACTIVE);
+}
- case LOOKNFEELMISC:
- feedbackLnFmisc( ob );
- break;
- case OUTPUTSMISC:
- feedbackOutputsMisc( ob );
- break;
+string FormPreferences::feedbackColours( FL_OBJECT const * const ) const
+{
+ return string();
+}
- case PATHS:
- feedbackPaths( ob );
- if( ! inputPaths( ob ) )
- activate = false;
- break;
- case PRINTER:
- feedbackPrinter( ob );
- break;
+bool FormPreferences::inputColours( FL_OBJECT const * const ob )
+{
+ bool activate = true;
+
+ if( ob == colours_->browser_x11 ) {
+ int i = fl_get_browser(colours_->browser_x11);
+ if( i > 0) {
+ ColoursUpdateBrowser(i-1);
+ }
- case SCREENFONTS:
- feedbackScreenFonts( ob );
- if( ! inputScreenFonts() )
- activate = false;
- break;
+ } else if( ob == colours_->valslider_red
+ || ob == colours_->valslider_green
+ || ob == colours_->valslider_blue ) {
+ ColoursUpdateRGB();
+
+ } else if( ob == colours_->input_name) {
+ string file = fl_get_input(colours_->input_name);
+ if( ColoursLoadBrowser(file) )
+ fl_set_input(colours_->input_name, file.c_str());
+ else if( ColoursLoadBrowser(colourFile) )
+ fl_set_input(colours_->input_name, colourFile.c_str());
+ else
+ fl_set_input(colours_->input_name, N_("No file found"));
+ }
- case SPELLCHECKER:
- feedbackSpellChecker( ob );
- if( ! inputSpellChecker( ob ) )
- activate = false;
- break;
+ return activate;
+}
- case TABS:
- break;
+
+bool FormPreferences::ColoursLoadBrowser( string const & filename )
+{
+ LyXLex lex(0, 0);
+
+ if (!lex.setFile(filename))
+ return false;
+
+ istream & is = lex.getStream();
+ string line;
+
+ vector<RGB> cols;
+ vector<string> names;
+
+ while( 1 ) {
+ getline( is, line );
+ if( line.empty() )
+ break;
+
+ if( line[0] != '!' ) {
+ RGB col;
+ string name;
+
+ istringstream iss(line);
+ iss >> col.r >> col.g >> col.b;
+ while( iss.good() ) {
+ string next;
+ iss >> next;
+ if( !name.empty() ) name += " ";
+ name += next;
+ }
+
+ // remove redundant entries on the fly
+ bool add = cols.empty();
+ if( !add ) {
+ vector<RGB>::const_iterator it =
+ find( cols.begin(), cols.end(), col );
+ add = (it == cols.end());
+ }
+
+ if ( add ) {
+ name = lowercase( name );
+ if( name == "gray0" ) name = "black";
+ if( name == "gray100" ) name = "white";
+
+ if( name == "black" || name == "white" ) {
+ cols.insert(cols.begin(), col);
+ names.insert(names.begin(), name);
+ } else {
+ cols.push_back(col);
+ names.push_back(name);
+ }
+ }
+ }
+ }
+
+ vector<string>::iterator sit = names.begin();
+ for( vector<RGB>::const_iterator iit = cols.begin();
+ iit != cols.end(); ++iit, ++sit ) {
+ colourDB.push_back( X11Colour(*sit, *iit) );
+ }
+
+ FL_OBJECT * colbr = colours_->browser_x11;
+ fl_freeze_form(colours_->form);
+ fl_clear_browser( colbr );
+
+ for( vector<X11Colour>::const_iterator cit = colourDB.begin();
+ cit != colourDB.end(); ++cit ) {
+ string name = (*cit).first;
+ //RGB col = (*cit).second;
+ //name += " (" + tostr(col.r) + ", " + tostr(col.g) +
+ // ", " + tostr(col.b) + ")";
+ fl_addto_browser(colbr, name.c_str());
}
- return activate;
+ fl_set_browser_topline(colbr, 1);
+ fl_select_browser_line(colbr, 1);
+ ColoursUpdateBrowser(0);
+ fl_unfreeze_form(colours_->form);
+
+ return true;
}
-void FormPreferences::applyColours()
+int FormPreferences::ColoursSearchEntry(RGB const & col ) const
{
+ int mindiff = 0x7fffffff;
+ vector<X11Colour>::const_iterator mincit = colourDB.begin();
+
+ for( vector<X11Colour>::const_iterator cit = colourDB.begin();
+ cit != colourDB.end(); ++cit ) {
+ RGB colDB = (*cit).second;
+ RGB diff;
+ diff.r = col.r - colDB.r;
+ diff.g = col.g - colDB.g;
+ diff.b = col.b - colDB.b;
+
+ int d = (2 * (diff.r * diff.r) +
+ 3 * (diff.g * diff.g) +
+ (diff.b * diff.b));
+
+ if( mindiff > d ) {
+ mindiff = d;
+ mincit = cit;
+ }
+ }
+ return static_cast<int>(mincit - colourDB.begin());
}
-void FormPreferences::buildColours()
+void FormPreferences::ColoursUpdateBrowser( int i )
{
- colours_ = build_colours();
+ fl_freeze_form(colours_->form);
+
+ RGB col = colourDB[i].second;
+
+ fl_mapcolor(FL_FREE_COL4+i, col.r, col.g, col.b);
+ fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
+ fl_set_slider_value(colours_->valslider_red, col.r);
+ fl_set_slider_value(colours_->valslider_green, col.g);
+ fl_set_slider_value(colours_->valslider_blue, col.b);
+ fl_redraw_object(colours_->button_colour);
+
+ fl_unfreeze_form(colours_->form);
}
-void FormPreferences::feedbackColours( FL_OBJECT const * const )
+void FormPreferences::ColoursUpdateRGB()
{
+ fl_freeze_form(colours_->form);
+
+ RGB col;
+ col.r = int(fl_get_slider_value(colours_->valslider_red));
+ col.g = int(fl_get_slider_value(colours_->valslider_green));
+ col.b = int(fl_get_slider_value(colours_->valslider_blue));
+
+ fl_mapcolor(FL_FREE_COL4, col.r, col.g, col.b);
+ fl_redraw_object(colours_->button_colour);
+
+ int i = ColoursSearchEntry( col );
+ // change topline only if necessary
+ // int top = fl_get_browser_topline(colours_->browser_x11);
+ // if(i < top || i > (top+15))
+ fl_set_browser_topline(colours_->browser_x11, i-5);
+ fl_select_browser_line(colours_->browser_x11, i + 1);
+
+ fl_unfreeze_form(colours_->form);
}
}
-void FormPreferences::applyInputsMisc()
+void FormPreferences::applyConverters() const
+{
+}
+
+
+void FormPreferences::buildConverters()
+{
+ converters_ = build_converters();
+
+}
+
+
+string FormPreferences::feedbackConverters( FL_OBJECT const * const ) const
+{
+ return string();
+}
+
+
+void FormPreferences::updateConverters()
+{
+}
+
+
+void FormPreferences::applyFormats() const
+{
+}
+
+
+void FormPreferences::buildFormats()
+{
+ formats_ = build_formats();
+
+ fl_set_input_return(formats_->input_format, FL_RETURN_CHANGED);
+ fl_set_input_return(formats_->input_viewer, FL_RETURN_CHANGED);
+ fl_set_input_return(formats_->input_gui_name, FL_RETURN_CHANGED);
+ fl_set_input_return(formats_->input_extension, FL_RETURN_CHANGED);
+
+ fl_set_input_filter(formats_->input_format, fl_lowercase_filter);
+}
+
+
+string FormPreferences::feedbackFormats( FL_OBJECT const * const ) const
+{
+ string str;
+
+ return str;
+}
+
+
+bool FormPreferences::inputFormats( FL_OBJECT const * const )
+{
+ return true;
+}
+
+
+void FormPreferences::updateFormats()
+{
+}
+
+
+void FormPreferences::applyInputsMisc() const
{
lyxrc.date_insert_format = fl_get_input(inputs_misc_->input_date_format);
}
fl_set_input_return(inputs_misc_->input_date_format,
FL_RETURN_CHANGED);
+
+ // set up the feedback mechanism
+ fl_addto_form(inputs_misc_->form);
+
+ setPostHandler( inputs_misc_->input_date_format );
+
+ fl_end_form();
}
-void FormPreferences::feedbackInputsMisc( FL_OBJECT const * const ob )
+string FormPreferences::feedbackInputsMisc( FL_OBJECT const * const ob ) const
{
string str;
- if( ob == inputs_misc_->input_date_format ) {
- str = N_("This accepts the normal strftime formats; see man strftime for full details.\nE.g.\"%A, %e. %B %Y\".");
- }
+ if( ob == inputs_misc_->input_date_format )
+ str = lyxrc.getDescription( LyXRC::RC_DATE_INSERT_FORMAT );
- fl_set_object_label(dialog_->text_warning, str.c_str());
- fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+ return str;
}
}
-void FormPreferences::applyInterface()
+void FormPreferences::applyInterface() const
{
lyxrc.popup_font_name =
fl_get_input(interface_->input_popup_font);
fl_deactivate_object(interface_->button_ui_file_browse);
fl_set_object_lcol(interface_->button_bind_file_browse, FL_INACTIVE);
fl_set_object_lcol(interface_->button_ui_file_browse, FL_INACTIVE);
+
+ // set up the feedback mechanism
+ fl_addto_form(interface_->form);
+
+ setPostHandler( interface_->input_popup_font );
+ setPostHandler( interface_->input_menu_font );
+ setPostHandler( interface_->input_popup_encoding );
+ setPostHandler( interface_->input_bind_file );
+ setPostHandler( interface_->button_bind_file_browse );
+ setPostHandler( interface_->input_ui_file );
+ setPostHandler( interface_->button_ui_file_browse );
+ setPostHandler( interface_->check_override_x_dead_keys );
+
+ fl_end_form();
}
-void FormPreferences::feedbackInterface( FL_OBJECT const * const ob )
+
+string FormPreferences::feedbackInterface( FL_OBJECT const * const ob ) const
{
string str;
- if( ob == interface_->input_popup_font ) {
- str = N_("The font for popups.");
- } else if ( ob == interface_->input_menu_font ) {
- str = N_("The font for menus (and groups titles in popups).");
- } else if ( ob == interface_->input_popup_encoding ) {
- str = N_("The norm for the menu/popups fonts.");
- } else if ( ob == interface_->input_bind_file ) {
- str = N_("Keybindings file. Can either specify an absolute path,\nor LyX will look in its global and local bind/ directories.");
- } else if ( ob == interface_->input_ui_file ) {
- str = N_("The UI (user interface) file. Can either specify an absolute path,\nor LyX will look in its global and local ui/ directories.");
- } else if ( ob == interface_->check_override_x_dead_keys ) {
- str = N_("Set to true for LyX to take over the handling of the dead keys\n(a.k.a accent keys) that may be defined for your keyboard.");
- }
-
- fl_set_object_label(dialog_->text_warning, str.c_str());
- fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+ if( ob == interface_->input_popup_font )
+ str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_POPUP );
+ else if ( ob == interface_->input_menu_font )
+ str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_MENU );
+ else if ( ob == interface_->input_popup_encoding )
+ str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING_MENU );
+ else if ( ob == interface_->input_bind_file )
+ str = lyxrc.getDescription( LyXRC::RC_BINDFILE );
+ else if ( ob == interface_->input_ui_file )
+ str = lyxrc.getDescription( LyXRC::RC_UIFILE );
+ else if ( ob == interface_->check_override_x_dead_keys )
+ str = lyxrc.getDescription( LyXRC::RC_OVERRIDE_X_DEADKEYS );
+
+ return str;
}
}
-void FormPreferences::applyLanguage()
+void FormPreferences::applyLanguage() const
{
- vector<string>::size_type choice =
- fl_get_choice(language_->choice_default_lang) - 1;
- lyxrc.default_language = languageNames[choice];
+ lyxrc.default_language = combo_default_lang->getline();
int button = fl_get_button(language_->check_use_kbmap);
lyxrc.use_kbmap = static_cast<bool>(button);
if( button ) {
- choice = fl_get_choice(language_->choice_kbmap_1) - 1;
- lyxrc.primary_kbmap = languageNames[choice];
-
- choice = fl_get_choice(language_->choice_kbmap_2) - 1;
- lyxrc.secondary_kbmap = languageNames[choice];
+ lyxrc.primary_kbmap = combo_kbmap_1->getline();
+ lyxrc.secondary_kbmap = combo_kbmap_2->getline();
}
button = fl_get_button(language_->check_rtl_support);
fl_set_input_return(language_->input_command_begin, FL_RETURN_CHANGED);
fl_set_input_return(language_->input_command_end, FL_RETURN_CHANGED);
- // Only do this the first time buildLanguage() is called.
- if( languageNames.empty() ) {
- for( Languages::const_iterator lang = languages.begin();
- lang != languages.end(); lang++ ) {
- languageNames.push_back( (*lang).second.lang() );
- }
- }
-
- string names = " " + languageNames.front();
- for( vector<string>::const_iterator lang = languageNames.begin();
- lang != languageNames.end(); ++lang ) {
- names += " | " + (*lang);
- }
- names += " ";
+ // The default_language is a combo-box and has to be inserted manually
+ fl_freeze_form(language_->form);
+ fl_addto_form(language_->form);
+
+ FL_OBJECT * obj = language_->choice_default_lang;
+ fl_deactivate_object(language_->choice_default_lang);
+ combo_default_lang = new Combox(FL_COMBOX_DROPLIST);
+ combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400);
+ combo_default_lang->shortcut("#L",1);
+ combo_default_lang->setcallback(ComboLanguageCB, this);
+ LanguagesAdd( *combo_default_lang );
+
+ // ditto kbmap_1
+ obj = language_->choice_kbmap_1;
+ fl_deactivate_object(language_->choice_kbmap_1);
+ combo_kbmap_1 = new Combox(FL_COMBOX_DROPLIST);
+ combo_kbmap_1->add(obj->x, obj->y, obj->w, obj->h, 400);
+ combo_kbmap_1->shortcut("#1",1);
+ combo_kbmap_1->setcallback(ComboLanguageCB, this);
+ LanguagesAdd( *combo_kbmap_1 );
- fl_addto_choice(language_->choice_default_lang, names.c_str());
- fl_addto_choice(language_->choice_kbmap_1, names.c_str());
- fl_addto_choice(language_->choice_kbmap_2, names.c_str());
+ // ditto kbmap_2
+ obj = language_->choice_kbmap_2;
+ fl_deactivate_object(language_->choice_kbmap_2);
+ combo_kbmap_2 = new Combox(FL_COMBOX_DROPLIST);
+ combo_kbmap_2->add(obj->x, obj->y, obj->w, obj->h, 400);
+ combo_kbmap_2->shortcut("#2",1);
+ combo_kbmap_2->setcallback(ComboLanguageCB, this);
+ LanguagesAdd( *combo_kbmap_2 );
+
+ fl_end_form();
+ fl_unfreeze_form(language_->form);
+
+ // set up the feedback mechanism
+ fl_addto_form(language_->form);
+
+ setPostHandler( language_->input_package );
+ setPostHandler( language_->check_use_kbmap );
+
+ // This is safe, as nothing is done to the pointer, other than
+ // to use its address in a block-if statement.
+ //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_default_lang) );
+ //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_1) );
+ //setPostHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_2) );
+
+ setPostHandler( language_->check_rtl_support );
+ setPostHandler( language_->check_mark_foreign );
+ setPostHandler( language_->check_auto_begin );
+ setPostHandler( language_->check_auto_end );
+ setPostHandler( language_->input_command_begin );
+ setPostHandler( language_->input_command_end );
+
+ fl_end_form();
}
-void FormPreferences::feedbackLanguage( FL_OBJECT const * const ob )
+string FormPreferences::feedbackLanguage( FL_OBJECT const * const ob ) const
{
string str;
- if( ob == language_->choice_default_lang ) {
- str = N_("New documents will be assigned this language.");
- } else if( ob == language_->check_use_kbmap
- || ob == language_->choice_kbmap_1
- || ob == language_->choice_kbmap_2 ) {
- str = N_("Use this to set the correct mapping file for your keyboard.\nYou'll need this if you for instance want to type German documents\non an American keyboard.");
- } else if( ob == language_->check_rtl_support ) {
- str = N_("Use to enable support of right-to-left languages (e.g. Hebrew, Arabic).");
- } else if( ob == language_->check_auto_begin ) {
- str = N_("Use if a language switching command is needed at the beginning\nof the document.");
- } else if( ob == language_->check_auto_end ) {
- str = N_("Use if a language switching command is needed at the end\nof the document.");
- } else if( ob == language_->check_mark_foreign ) {
- str = N_("Use to control the highlighting of words with a language foreign to\nthat of the document.");
- } else if( ob == language_->input_package ) {
- str = N_("The latex command for loading the language package.\nE.g. \"\\usepackage{babel}\", \"\\usepackage{omega}\".");
- } else if( ob == language_->input_command_begin ) {
- str = N_("The latex command for changing from the language of the document\nto another language.\nE.g. \\selectlanguage{$$lang} where $$lang is substituted by the name\nof the second language.");
- } else if( ob == language_->input_command_end ) {
- str = N_("The latex command for changing back to the language of the document.");
- }
-
- fl_set_object_label(dialog_->text_warning, str.c_str());
- fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+ if( reinterpret_cast<Combox const *>(ob) == combo_default_lang )
+ str = lyxrc.getDescription( LyXRC::RC_DEFAULT_LANGUAGE );
+ else if( ob == language_->check_use_kbmap )
+ str = lyxrc.getDescription( LyXRC::RC_KBMAP );
+ else if( reinterpret_cast<Combox const *>(ob) == combo_kbmap_1)
+ str = lyxrc.getDescription( LyXRC::RC_KBMAP_PRIMARY );
+ else if( reinterpret_cast<Combox const *>(ob) == combo_kbmap_2 )
+ str = lyxrc.getDescription( LyXRC::RC_KBMAP_SECONDARY );
+ else if( ob == language_->check_rtl_support )
+ str = lyxrc.getDescription( LyXRC::RC_RTL_SUPPORT );
+ else if( ob == language_->check_auto_begin )
+ str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_BEGIN );
+ else if( ob == language_->check_auto_end )
+ str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_AUTO_END );
+ else if( ob == language_->check_mark_foreign )
+ str = lyxrc.getDescription( LyXRC::RC_MARK_FOREIGN_LANGUAGE );
+ else if( ob == language_->input_package )
+ str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_PACKAGE );
+ else if( ob == language_->input_command_begin )
+ str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_BEGIN );
+ else if( ob == language_->input_command_end )
+ str = lyxrc.getDescription( LyXRC::RC_LANGUAGE_COMMAND_END );
+
+ return str;
}
bool FormPreferences::inputLanguage( FL_OBJECT const * const ob )
{
bool activate = true;
-
+
if( !ob || ob == language_->check_use_kbmap ) {
if( fl_get_button(language_->check_use_kbmap) ) {
- fl_activate_object(language_->choice_kbmap_1);
- fl_activate_object(language_->choice_kbmap_2);
- fl_set_object_lcol(language_->choice_kbmap_1,
- FL_BLACK);
- fl_set_object_lcol(language_->choice_kbmap_2,
- FL_BLACK);
+ combo_kbmap_1->activate();
+ combo_kbmap_2->activate();
} else {
- fl_deactivate_object(language_->choice_kbmap_1);
- fl_deactivate_object(language_->choice_kbmap_2);
- fl_set_object_lcol(language_->choice_kbmap_1,
- FL_INACTIVE);
- fl_set_object_lcol(language_->choice_kbmap_2,
- FL_INACTIVE);
+ combo_kbmap_1->deactivate();
+ combo_kbmap_2->deactivate();
}
}
fl_set_button(language_->check_use_kbmap,
lyxrc.use_kbmap);
- vector<string>::iterator it =
- find( languageNames.begin(), languageNames.end(),
- lyxrc.default_language );
- int choice = 0;
- if( it != languageNames.end() )
- choice = static_cast<int>( it - languageNames.begin() );
-
- fl_set_choice(language_->choice_default_lang, choice+1);
-
- it = find( languageNames.begin(), languageNames.end(),
- lyxrc.primary_kbmap );
- choice = 0;
- if( it != languageNames.end() )
- choice = static_cast<int>( it - languageNames.begin() );
-
- fl_set_choice(language_->choice_kbmap_1, choice+1);
-
- it = find( languageNames.begin(), languageNames.end(),
- lyxrc.secondary_kbmap );
- choice = 0;
- if( it != languageNames.end() )
- choice = static_cast<int>( it - languageNames.begin() );
+ combo_default_lang->select_text( lyxrc.default_language );
- fl_set_choice(language_->choice_kbmap_2, choice+1);
+ if( lyxrc.use_kbmap ) {
+ combo_kbmap_1->select_text( lyxrc.primary_kbmap );
+ combo_kbmap_2->select_text( lyxrc.secondary_kbmap );
+ } else {
+ combo_kbmap_1->select_text( lyxrc.default_language );
+ combo_kbmap_2->select_text( lyxrc.default_language );
+ }
fl_set_button(language_->check_rtl_support, lyxrc.rtl_support);
fl_set_button(language_->check_auto_begin, lyxrc.language_auto_begin);
}
-void FormPreferences::applyLnFmisc()
+void FormPreferences::LanguagesAdd( Combox & combo ) const
+{
+ for(Languages::const_iterator cit = languages.begin();
+ cit != languages.end(); cit++) {
+ combo.addto((*cit).second.lang());
+ }
+}
+
+
+void FormPreferences::applyLnFmisc() const
{
lyxrc.show_banner = fl_get_button(lnf_misc_->check_banner);
lyxrc.auto_region_delete = fl_get_button(lnf_misc_->
FL_RETURN_CHANGED);
fl_set_counter_return(lnf_misc_->counter_wm_jump,
FL_RETURN_CHANGED);
+
+ // set up the feedback mechanism
+ fl_addto_form(lnf_misc_->form);
+
+ setPostHandler( lnf_misc_->check_banner );
+ setPostHandler( lnf_misc_->check_auto_region_delete );
+ setPostHandler( lnf_misc_->check_exit_confirm );
+ setPostHandler( lnf_misc_->check_display_shortcuts );
+ setPostHandler( lnf_misc_->counter_autosave );
+ setPostHandler( lnf_misc_->check_ask_new_file );
+ setPostHandler( lnf_misc_->check_cursor_follows_scrollbar );
+ setPostHandler( lnf_misc_->counter_wm_jump );
+
+ fl_end_form();
}
-void FormPreferences::feedbackLnFmisc( FL_OBJECT const * const ob )
+string FormPreferences::feedbackLnFmisc( FL_OBJECT const * const ob ) const
{
string str;
- if( ob == lnf_misc_->check_banner ) {
- str = N_("Set to false if you don't want the startup banner.");
- } else if( ob == lnf_misc_->check_auto_region_delete ) {
- str = N_("Set to false if you don't want the current selection to be replaced\nautomatically by what you type.");
- } else if( ob == lnf_misc_->check_exit_confirm ) {
- str = N_("Sets whether LyX asks for a second confirmation to exit when you have\nchanged documents.\n(LyX will still ask to save changed documents.)");
- } else if( ob == lnf_misc_->check_display_shortcuts ) {
- str = N_("LyX continously displays names of last command executed,\nalong with a list of defined short-cuts for it in the minibuffer.\nSet to false if LyX seems slow.");
- } else if( ob == lnf_misc_->check_ask_new_file ) {
- str = N_("This sets the behaviour if you want to be asked for a filename when\ncreating a new document or wait until you save it and be asked then.");
- } else if( ob == lnf_misc_->check_cursor_follows_scrollbar ) {
- str = N_("LyX normally doesn't update the cursor position if you move the scrollbar.\nSet to true if you'd prefer to always have the cursor on screen.");
- } else if( ob == lnf_misc_->counter_autosave ) {
- str = N_("The time interval between auto-saves (in seconds).\n0 means no auto-save");
- } else if( ob == lnf_misc_->counter_wm_jump ) {
- str = N_("The wheel movement factor (for mice with wheels or five button mice)");
- }
-
- fl_set_object_label(dialog_->text_warning, str.c_str());
- fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+ if( ob == lnf_misc_->check_banner )
+ str = lyxrc.getDescription( LyXRC::RC_SHOW_BANNER );
+ else if( ob == lnf_misc_->check_auto_region_delete )
+ str = lyxrc.getDescription( LyXRC::RC_AUTOREGIONDELETE );
+ else if( ob == lnf_misc_->check_exit_confirm )
+ str = lyxrc.getDescription( LyXRC::RC_EXIT_CONFIRMATION );
+ else if( ob == lnf_misc_->check_display_shortcuts )
+ str = lyxrc.getDescription( LyXRC::RC_DISPLAY_SHORTCUTS );
+ else if( ob == lnf_misc_->check_ask_new_file )
+ str = lyxrc.getDescription( LyXRC::RC_NEW_ASK_FILENAME );
+ else if( ob == lnf_misc_->check_cursor_follows_scrollbar )
+ str = lyxrc.getDescription( LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR );
+ else if( ob == lnf_misc_->counter_autosave )
+ str = lyxrc.getDescription( LyXRC::RC_AUTOSAVE );
+ else if( ob == lnf_misc_->counter_wm_jump )
+ str = lyxrc.getDescription( LyXRC::RC_WHEEL_JUMP );
+
+ return str;
}
void FormPreferences::updateLnFmisc()
}
-void FormPreferences::applyOutputsMisc()
+void FormPreferences::applyOutputsMisc() const
{
lyxrc.ascii_linelen = static_cast<unsigned int>
(fl_get_counter_value(outputs_misc_->counter_line_len));
FL_RETURN_CHANGED);
fl_addto_choice(outputs_misc_->choice_default_papersize,
_(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
+
+ // set up the feedback mechanism
+ fl_addto_form(outputs_misc_->form);
+
+ setPostHandler( outputs_misc_->counter_line_len );
+ setPostHandler( outputs_misc_->input_tex_encoding );
+ setPostHandler( outputs_misc_->choice_default_papersize );
+ setPostHandler( outputs_misc_->input_ascii_roff );
+ setPostHandler( outputs_misc_->input_checktex );
+
+ fl_end_form();
}
-void FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob )
+string FormPreferences::feedbackOutputsMisc(FL_OBJECT const * const ob ) const
{
string str;
- if( ob == outputs_misc_->counter_line_len ) {
- str = N_("This is the maximum line length of an exported ASCII file\n(LaTeX, SGML or plain text).");
- } else if( ob == outputs_misc_->input_tex_encoding ) {
- str = N_("The font encoding used for the LaTeX2e fontenc package.\nT1 is highly recommended for non-English languages.");
- } else if( ob == outputs_misc_->input_ascii_roff ) {
- str = N_("Use to define an external program to render tables in the ASCII output.\nE.g. \"groff -t -Tlatin1 $$FName\" where $$FName is the input file.\nIf \"none\" is specified, an internal routine is used.");
- } else if( ob == outputs_misc_->input_checktex ) {
- str = N_("Define how to run chktex.\nE.g. \"chktex -n11 -n1 -n3 -n6 -n9 -22 -n25 -n30 -n38\"\nRefer to the ChkTeX documentation.");
- } else if( ob == outputs_misc_->choice_default_papersize ) {
- str = N_("Specify the default paper size.");
- }
-
- fl_set_object_label(dialog_->text_warning, str.c_str());
- fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+ if( ob == outputs_misc_->counter_line_len )
+ str = lyxrc.getDescription( LyXRC::RC_ASCII_LINELEN );
+ else if( ob == outputs_misc_->input_tex_encoding )
+ str = lyxrc.getDescription( LyXRC::RC_FONT_ENCODING );
+ else if( ob == outputs_misc_->input_ascii_roff )
+ str = lyxrc.getDescription( LyXRC::RC_ASCIIROFF_COMMAND );
+ else if( ob == outputs_misc_->input_checktex )
+ str = lyxrc.getDescription( LyXRC::RC_CHKTEX_COMMAND );
+ else if( ob == outputs_misc_->choice_default_papersize )
+ str = lyxrc.getDescription( LyXRC::RC_DEFAULT_PAPERSIZE );
+
+ return str;
}
fl_set_object_lcol(paths_->button_lastfiles_browse, FL_INACTIVE);
fl_set_object_lcol(paths_->button_backup_path_browse, FL_INACTIVE);
fl_set_object_lcol(paths_->button_serverpipe_browse, FL_INACTIVE);
+
+ // set up the feedback mechanism
+ fl_addto_form(paths_->form);
+
+ setPostHandler( paths_->input_default_path );
+ setPostHandler( paths_->button_document_browse );
+ setPostHandler( paths_->counter_lastfiles );
+ setPostHandler( paths_->input_template_path );
+ setPostHandler( paths_->button_template_browse );
+ setPostHandler( paths_->check_last_files );
+ setPostHandler( paths_->button_temp_dir_browse );
+ setPostHandler( paths_->input_lastfiles );
+ setPostHandler( paths_->button_lastfiles_browse );
+ setPostHandler( paths_->check_make_backups );
+ setPostHandler( paths_->input_backup_path );
+ setPostHandler( paths_->button_backup_path_browse );
+ setPostHandler( paths_->input_serverpipe );
+ setPostHandler( paths_->button_serverpipe_browse );
+ setPostHandler( paths_->input_temp_dir );
+ setPostHandler( paths_->check_use_temp_dir );
+
+ fl_end_form();
}
-void FormPreferences::feedbackPaths( FL_OBJECT const * const ob )
+string FormPreferences::feedbackPaths( FL_OBJECT const * const ob ) const
{
string str;
- if( ob == paths_->input_default_path ) {
- str = N_("The default path for your documents.");
- } else if ( ob == paths_->input_template_path ) {
- str = N_("The path that LyX will set when offering to choose a template.");
- } else if ( ob == paths_->check_use_temp_dir ) {
- str = N_("Specify to use a temporary directory to store temporary TeX output.\nThis directory is deleted when you quit LyX.");
- } else if ( ob == paths_->input_temp_dir ) {
- str = N_("The path that LyX will use to store temporary TeX output.");
- } else if ( ob == paths_->check_last_files ) {
- str = N_("Specify to check whether the lastfiles still exist.");
- } else if ( ob == paths_->input_lastfiles ) {
- str = N_("The file where the last-files information should be stored.");
- } else if ( ob == paths_->counter_lastfiles ) {
- str = N_("Maximal number of lastfiles. Up to 9 can appear in the file menu.");
- } else if ( ob == paths_->check_make_backups ) {
- str = N_("Set to false if you don't want LyX to create backup files.");
- } else if ( ob == paths_->input_backup_path ) {
- str = N_("The path for storing backup files. If it is an empty string,\nLyX will store the backup file in the same directory as the original file.");
- } else if ( ob == paths_->input_serverpipe ) {
- str = N_("This starts the lyxserver. The pipes get an additional extension\n\".in\" and \".out\". Only for advanced users.");
- }
-
- fl_set_object_label(dialog_->text_warning, str.c_str());
- fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+
+ if( ob == paths_->input_default_path )
+ str = lyxrc.getDescription( LyXRC::RC_DOCUMENTPATH );
+ else if ( ob == paths_->input_template_path )
+ str = lyxrc.getDescription( LyXRC::RC_TEMPLATEPATH );
+ else if ( ob == paths_->check_use_temp_dir )
+ str = lyxrc.getDescription( LyXRC::RC_USETEMPDIR );
+ else if ( ob == paths_->input_temp_dir )
+ str = lyxrc.getDescription( LyXRC::RC_TEMPDIRPATH );
+ else if ( ob == paths_->check_last_files )
+ str = lyxrc.getDescription( LyXRC::RC_CHECKLASTFILES );
+ else if ( ob == paths_->input_lastfiles )
+ str = lyxrc.getDescription( LyXRC::RC_LASTFILES );
+ else if ( ob == paths_->counter_lastfiles )
+ str = lyxrc.getDescription( LyXRC::RC_NUMLASTFILES );
+ else if ( ob == paths_->check_make_backups )
+ str = lyxrc.getDescription( LyXRC::RC_MAKE_BACKUP );
+ else if ( ob == paths_->input_backup_path )
+ str = lyxrc.getDescription( LyXRC::RC_BACKUPDIR_PATH );
+ else if ( ob == paths_->input_serverpipe )
+ str = lyxrc.getDescription( LyXRC::RC_SERVERPIPE );
+
+ return str;
}
}
-void FormPreferences::applyPrinter()
+void FormPreferences::applyPrinter() const
{
lyxrc.print_adapt_output = fl_get_button(printer_->check_adapt_output);
lyxrc.print_command = fl_get_input(printer_->input_command);
}
-void FormPreferences::feedbackPrinter( FL_OBJECT const * const ob )
+string FormPreferences::feedbackPrinter( FL_OBJECT const * const ob ) const
{
string str;
- if( ob == printer_->input_command ) {
- str = N_("Your favorite print program, eg \"dvips\", \"dvilj4\"");
- } else if( ob == printer_->check_adapt_output ) {
- str = N_("Set to true for LyX to pass the name of the destination printer to your\nprint command.");
- } else if( ob == printer_->input_to_printer ) {
- str = N_("Option to pass to the print program to print on a specific printer.");
- } else if( ob == printer_->input_to_file ) {
- str = N_("Option to pass to the print program to print to a file.");
- } else if( ob == printer_->input_file_extension ) {
- str = N_("Extension of printer program output file. Usually .ps");
- } else if( ob == printer_->input_extra_options ) {
- str = N_("Extra options to pass to printing program after everything else,\nbut before the filename of the DVI file to be printed.");
- } else if( ob == printer_->input_spool_command ) {
- str = N_("When set, this printer option automatically prints to a file and then calls\na separate print spooling program on that file with the given name\nand arguments.");
- } else if( ob == printer_->input_spool_prefix ) {
- str = N_("If you specify a printer name in the print dialog, the following argument\nis prepended along with the printer name after the spool command.");
- } else if( ob == printer_->input_name ) {
- str = N_("The default printer to print on. If none is specified, LyX will\nuse the environment variable PRINTER.");
- } else if( ob == printer_->input_even_pages
- || ob == printer_->input_odd_pages
- || ob == printer_->input_page_range
- || ob == printer_->input_reverse
- || ob == printer_->input_landscape
- || ob == printer_->input_copies
- || ob == printer_->input_collated
- || ob == printer_->input_paper_type
- || ob == printer_->input_paper_size ) {
- str = N_("Look at the man page for your favorite print program to learn\nwhich options to use.");
- }
-
-
- fl_set_object_label(dialog_->text_warning, str.c_str());
- fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+ if( ob == printer_->input_command )
+ str = lyxrc.getDescription( LyXRC::RC_PRINT_COMMAND );
+ else if( ob == printer_->check_adapt_output )
+ str = lyxrc.getDescription( LyXRC::RC_PRINT_ADAPTOUTPUT );
+ else if( ob == printer_->input_to_printer )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTTOPRINTER );
+ else if( ob == printer_->input_to_file )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTTOFILE );
+ else if( ob == printer_->input_file_extension )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTFILEEXTENSION );
+ else if( ob == printer_->input_extra_options )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTEXSTRAOPTIONS );
+ else if( ob == printer_->input_spool_command )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_COMMAND );
+ else if( ob == printer_->input_spool_prefix )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTSPOOL_PRINTERPREFIX );
+ else if( ob == printer_->input_name )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTER );
+ else if( ob == printer_->input_even_pages )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTEVENPAGEFLAG );
+ else if( ob == printer_->input_odd_pages )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTODDPAGEFLAG );
+ else if( ob == printer_->input_page_range )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTPAGERANGEFLAG );
+ else if( ob == printer_->input_reverse )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTREVERSEFLAG );
+ else if( ob == printer_->input_landscape )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTLANDSCAPEFLAG );
+ else if( ob == printer_->input_copies )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTCOLLCOPIESFLAG );
+ else if( ob == printer_->input_collated )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTCOPIESFLAG );
+ else if( ob == printer_->input_paper_type )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERFLAG );
+ else if( ob == printer_->input_paper_size )
+ str = lyxrc.getDescription( LyXRC::RC_PRINTPAPERDIMENSIONFLAG );
+
+ return str;
}
fl_set_input_return(printer_->input_spool_prefix, FL_RETURN_CHANGED);
fl_set_input_return(printer_->input_paper_size, FL_RETURN_CHANGED);
fl_set_input_return(printer_->input_name, FL_RETURN_CHANGED);
+
+ // set up the feedback mechanism
+ fl_addto_form(printer_->form);
+
+ setPostHandler( printer_->input_command );
+ setPostHandler( printer_->input_page_range );
+ setPostHandler( printer_->input_copies );
+ setPostHandler( printer_->input_reverse );
+ setPostHandler( printer_->input_to_printer );
+ setPostHandler( printer_->input_file_extension );
+ setPostHandler( printer_->input_spool_command );
+ setPostHandler( printer_->input_paper_type );
+ setPostHandler( printer_->input_even_pages );
+ setPostHandler( printer_->input_odd_pages );
+ setPostHandler( printer_->input_collated );
+ setPostHandler( printer_->input_landscape );
+ setPostHandler( printer_->input_to_file );
+ setPostHandler( printer_->input_extra_options );
+ setPostHandler( printer_->input_spool_prefix );
+ setPostHandler( printer_->input_paper_size );
+ setPostHandler( printer_->input_name );
+ setPostHandler( printer_->check_adapt_output );
+
+ fl_end_form();
}
}
-void FormPreferences::applyScreenFonts()
+void FormPreferences::applyScreenFonts() const
{
bool changed = false;
lyxrc.use_scalable_fonts = button;
}
- int ivalue = fl_get_counter_value(screen_fonts_->counter_zoom);
- if( lyxrc.zoom != static_cast<unsigned int>( ivalue ) ) {
+ unsigned int ivalue = static_cast<unsigned int>
+ (fl_get_counter_value(screen_fonts_->counter_zoom));
+ if( lyxrc.zoom != ivalue) {
+ changed = true;
+ lyxrc.zoom = ivalue;
+ }
+
+ ivalue = static_cast<unsigned int>
+ (fl_get_counter_value(screen_fonts_->counter_dpi));
+ if (lyxrc.dpi != ivalue) {
changed = true;
- lyxrc.zoom = static_cast<unsigned int>( ivalue );
+ lyxrc.dpi = ivalue;
}
double dvalue = strToDbl(fl_get_input(screen_fonts_->input_tiny));
fl_set_input_return(screen_fonts_->input_screen_encoding,
FL_RETURN_CHANGED);
fl_set_counter_return(screen_fonts_->counter_zoom, FL_RETURN_CHANGED);
+ fl_set_counter_return(screen_fonts_->counter_dpi, FL_RETURN_CHANGED);
fl_set_input_return(screen_fonts_->input_tiny, FL_RETURN_CHANGED);
fl_set_input_return(screen_fonts_->input_script, FL_RETURN_CHANGED);
fl_set_input_return(screen_fonts_->input_footnote, FL_RETURN_CHANGED);
fl_set_input_return(screen_fonts_->input_largest, FL_RETURN_CHANGED);
fl_set_input_return(screen_fonts_->input_huge, FL_RETURN_CHANGED);
fl_set_input_return(screen_fonts_->input_huger, FL_RETURN_CHANGED);
+
+ fl_set_input_filter(screen_fonts_->input_tiny,
+ fl_unsigned_int_filter);
+ fl_set_input_filter(screen_fonts_->input_script,
+ fl_unsigned_int_filter);
+ fl_set_input_filter(screen_fonts_->input_footnote,
+ fl_unsigned_int_filter);
+ fl_set_input_filter(screen_fonts_->input_small,
+ fl_unsigned_int_filter);
+ fl_set_input_filter(screen_fonts_->input_normal,
+ fl_unsigned_int_filter);
+ fl_set_input_filter(screen_fonts_->input_large,
+ fl_unsigned_int_filter);
+ fl_set_input_filter(screen_fonts_->input_larger,
+ fl_unsigned_int_filter);
+ fl_set_input_filter(screen_fonts_->input_largest,
+ fl_unsigned_int_filter);
+ fl_set_input_filter(screen_fonts_->input_huge,
+ fl_unsigned_int_filter);
+ fl_set_input_filter(screen_fonts_->input_huger,
+ fl_unsigned_int_filter);
+
+ // set up the feedback mechanism
+ fl_addto_form(screen_fonts_->form);
+
+ setPostHandler( screen_fonts_->input_roman );
+ setPostHandler( screen_fonts_->input_sans );
+ setPostHandler( screen_fonts_->input_typewriter );
+ setPostHandler( screen_fonts_->counter_zoom );
+ setPostHandler( screen_fonts_->counter_dpi );
+ setPostHandler( screen_fonts_->check_scalable );
+ setPostHandler( screen_fonts_->input_screen_encoding );
+ setPostHandler( screen_fonts_->input_tiny );
+ setPostHandler( screen_fonts_->input_script );
+ setPostHandler( screen_fonts_->input_footnote );
+ setPostHandler( screen_fonts_->input_small );
+ setPostHandler( screen_fonts_->input_large );
+ setPostHandler( screen_fonts_->input_larger );
+ setPostHandler( screen_fonts_->input_largest );
+ setPostHandler( screen_fonts_->input_normal );
+ setPostHandler( screen_fonts_->input_huge );
+ setPostHandler( screen_fonts_->input_huger );
+
+ fl_end_form();
}
-void FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob )
+string FormPreferences::feedbackScreenFonts(FL_OBJECT const * const ob ) const
{
string str;
- if( ob == screen_fonts_->input_roman
- || ob == screen_fonts_->input_sans
- || ob == screen_fonts_->input_typewriter ) {
- str = N_("The screen fonts used to display the text while editing.");
- } else if( ob == screen_fonts_->check_scalable ) {
- str = N_("Allow the use of scalable screen fonts? If false, LyX will use the\nclosest existing size for a match. Use this if the scalable fonts\nlook bad and you have many fixed size fonts.");
- } else if( ob == screen_fonts_->input_screen_encoding ) {
- str = N_("The norm for the screen fonts.");
- } else if( ob == screen_fonts_->counter_zoom ) {
- str = N_("The zoom percentage for screen fonts.\nA setting of 100% will make the fonts roughly the same size as on paper.");
- } else if( ob == screen_fonts_->input_tiny
- || ob == screen_fonts_->input_script
- || ob == screen_fonts_->input_footnote
- || ob == screen_fonts_->input_small
- || ob == screen_fonts_->input_large
- || ob == screen_fonts_->input_larger
- || ob == screen_fonts_->input_larger
- || ob == screen_fonts_->input_largest
- || ob == screen_fonts_->input_normal
- || ob == screen_fonts_->input_huge
- || ob == screen_fonts_->input_huger ) {
- str = N_("The font sizes used for calculating the scaling of the screen fonts.");
- }
-
- fl_set_object_label(dialog_->text_warning, str.c_str());
- fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+ if( ob == screen_fonts_->input_roman )
+ str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ROMAN );
+ else if( ob == screen_fonts_->input_sans )
+ str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SANS );
+ else if( ob == screen_fonts_->input_typewriter )
+ str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_TYPEWRITER );
+ else if( ob == screen_fonts_->check_scalable )
+ str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SCALABLE );
+ else if( ob == screen_fonts_->input_screen_encoding )
+ str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_ENCODING );
+ else if( ob == screen_fonts_->counter_zoom )
+ str = lyxrc.getDescription( LyXRC::RC_SCREEN_ZOOM );
+ else if( ob == screen_fonts_->counter_dpi )
+ str = lyxrc.getDescription( LyXRC::RC_SCREEN_DPI );
+ else if( ob == screen_fonts_->input_tiny
+ || ob == screen_fonts_->input_script
+ || ob == screen_fonts_->input_footnote
+ || ob == screen_fonts_->input_small
+ || ob == screen_fonts_->input_large
+ || ob == screen_fonts_->input_larger
+ || ob == screen_fonts_->input_larger
+ || ob == screen_fonts_->input_largest
+ || ob == screen_fonts_->input_normal
+ || ob == screen_fonts_->input_huge
+ || ob == screen_fonts_->input_huger )
+ str = lyxrc.getDescription( LyXRC::RC_SCREEN_FONT_SIZES );
+
+ return str;
}
lyxrc.font_norm.c_str());
fl_set_button(screen_fonts_->check_scalable,
lyxrc.use_scalable_fonts);
- fl_set_counter_value(screen_fonts_->counter_zoom,
- lyxrc.zoom);
+ fl_set_counter_value(screen_fonts_->counter_zoom, lyxrc.zoom);
+ fl_set_counter_value(screen_fonts_->counter_dpi, lyxrc.dpi);
fl_set_input(screen_fonts_->input_tiny,
tostr(lyxrc.font_sizes[LyXFont::SIZE_TINY]).c_str());
fl_set_input(screen_fonts_->input_script,
fl_deactivate_object(spellchecker_->button_personal_dict);
fl_set_object_lcol(spellchecker_->button_personal_dict,
FL_INACTIVE);
+
+ // set up the feedback mechanism
+ fl_addto_form(spellchecker_->form);
+
+ setPostHandler( spellchecker_->choice_spell_command );
+ setPostHandler( spellchecker_->check_alt_lang );
+ setPostHandler( spellchecker_->input_alt_lang );
+ setPostHandler( spellchecker_->check_escape_chars );
+ setPostHandler( spellchecker_->input_escape_chars );
+ setPostHandler( spellchecker_->check_personal_dict );
+ setPostHandler( spellchecker_->input_personal_dict );
+ setPostHandler( spellchecker_->button_personal_dict );
+ setPostHandler( spellchecker_->check_compound_words );
+ setPostHandler( spellchecker_->check_input_enc );
+
+ fl_end_form();
}
-void FormPreferences::feedbackSpellChecker( FL_OBJECT const * const ob )
+string FormPreferences::feedbackSpellChecker( FL_OBJECT const * const ob ) const
{
string str;
- if( ob == spellchecker_->choice_spell_command ) {
- str = N_("What command runs the spell checker?");
- } else if( ob == spellchecker_->check_alt_lang ) {
- str = N_("Specify an alternate language.\nThe default is to use the language of the document.");
- } else if( ob == spellchecker_->check_escape_chars ) {
- str = N_("Specify additional chars that can be part of a word.");
- } else if( ob == spellchecker_->check_personal_dict ) {
- str = N_("Specify an alternate personal dictionary file.\nE.g. \".ispell_english\".");
- } else if( ob == spellchecker_->check_compound_words ) {
- str = N_("Consider run-together words, such as \"notthe\" for \"not the\",\nas legal words?");
- } else if( ob == spellchecker_->check_input_enc ) {
- str = N_("Specify whether to pass the -T input encoding option to ispell.\nEnable this if you can't spellcheck words with international letters\nin them.\nThis may not work with all dictionaries.");
- }
- fl_set_object_label(dialog_->text_warning, str.c_str());
- fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
+ if( ob == spellchecker_->choice_spell_command )
+ str = lyxrc.getDescription( LyXRC::RC_SPELL_COMMAND );
+ else if( ob == spellchecker_->check_alt_lang )
+ str = lyxrc.getDescription( LyXRC::RC_USE_ALT_LANG );
+ else if( ob == spellchecker_->input_alt_lang )
+ str = lyxrc.getDescription( LyXRC::RC_ALT_LANG );
+ else if( ob == spellchecker_->check_escape_chars )
+ str = lyxrc.getDescription( LyXRC::RC_USE_ESC_CHARS );
+ else if( ob == spellchecker_->input_escape_chars )
+ str = lyxrc.getDescription( LyXRC::RC_ESC_CHARS );
+ else if( ob == spellchecker_->check_personal_dict )
+ str = lyxrc.getDescription( LyXRC::RC_USE_PERS_DICT );
+ else if( ob == spellchecker_->input_personal_dict )
+ str = lyxrc.getDescription( LyXRC::RC_PERS_DICT );
+ else if( ob == spellchecker_->check_compound_words )
+ str = lyxrc.getDescription( LyXRC::RC_ACCEPT_COMPOUND );
+ else if( ob == spellchecker_->check_input_enc )
+ str = lyxrc.getDescription( LyXRC::RC_USE_INP_ENC );
+
+ return str;
}
}
}
- return true; // all input is valid!
+ return true; // All input is valid!
}
return success;
}
+
+
+void FormPreferences::ComboLanguageCB(int, void * v, Combox * combox)
+{
+ FormPreferences * pre = static_cast<FormPreferences*>(v);
+ // This is safe, as nothing is done to the pointer, other than
+ // to use its address in a block-if statement.
+ pre->bc_.valid( pre->input( reinterpret_cast<FL_OBJECT *>(combox), 0 ));
+}
+
+
+// C functions for the timer callback used to give the user feedback
+C_GENERICCB(FormPreferences, FeedbackCB)
+
+void FormPreferences::FeedbackCB(FL_OBJECT * ob, long)
+{
+ FormPreferences * pre =
+ static_cast<FormPreferences*>(ob->form->u_vdata);
+ pre->feedback( pre->feedbackObj );
+}
+
+extern "C" int C_FormPreferencesFeedbackPost(FL_OBJECT * ob, int event,
+ FL_Coord, FL_Coord, int, void *)
+{
+ // can occur when form is being deleted. This seems an easier fix than
+ // a call "fl_set_object_posthandler(ob, 0)" for each and every object
+ // in the destructor.
+ if( !ob->form ) return 0;
+
+ FormPreferences * pre =
+ static_cast<FormPreferences*>(ob->form->u_vdata);
+ pre->feedbackPost(ob, event);
+ return 0;
+}
+
+
+// post_handler for feedback messages
+void FormPreferences::feedbackPost(FL_OBJECT *ob, int event)
+{
+ // We do not test for empty help here, since this can never happen
+ if(event == FL_ENTER){
+ // Used as a placeholder for ob, so that we don't have to
+ // a horrible reinterpret_cast to long and pass it as an
+ // argument in fl_set_object_callback.
+ feedbackObj = ob;
+ fl_set_object_callback(dialog_->timer_feedback,
+ C_FormPreferencesFeedbackCB,
+ 0);
+ fl_set_timer(dialog_->timer_feedback, 0.5);
+ }
+ else if(event != FL_MOTION){
+ fl_set_timer(dialog_->timer_feedback, 0);
+ feedbackObj = 0;
+ fl_set_object_label(dialog_->text_warning, "");
+ }
+}
+
+
+void FormPreferences::setPostHandler( FL_OBJECT * ob ) const
+{
+ fl_set_object_posthandler(ob, C_FormPreferencesFeedbackPost);
+}