2000-06-12 11:55:12 +00:00
/* FormPreferences.C
* FormPreferences Interface Class Implementation
*/
2000-11-03 09:47:02 +00:00
# include <utility>
2000-06-12 11:55:12 +00:00
# include <config.h>
2000-07-27 10:26:38 +00:00
2000-06-12 11:55:12 +00:00
# include FORMS_H_LOCATION
2000-07-27 10:26:38 +00:00
# ifdef __GNUG_
# pragma implementation
# endif
2000-11-03 09:47:02 +00:00
# include "Lsstream.h"
2000-06-12 11:55:12 +00:00
# include "FormPreferences.h"
2000-07-19 15:54:35 +00:00
# include "form_preferences.h"
2000-06-12 11:55:12 +00:00
# include "input_validators.h"
# include "LyXView.h"
2000-10-30 11:33:05 +00:00
# include "language.h"
2000-06-12 11:55:12 +00:00
# include "lyxfunc.h"
# include "Dialogs.h"
# include "lyxrc.h"
2000-10-30 21:53:29 +00:00
# include "combox.h"
2000-06-12 11:55:12 +00:00
# include "debug.h"
2000-07-28 04:59:45 +00:00
# include "support/FileInfo.h"
# include "support/filetools.h"
2000-07-27 10:26:38 +00:00
# include "lyx_gui_misc.h"
2000-11-03 09:47:02 +00:00
# include "lyxlex.h"
# include "input_validators.h"
2000-11-02 14:47:47 +00:00
# include "xform_helpers.h" // formatted()
2000-10-30 21:53:29 +00:00
# include "xform_macros.h"
2000-11-06 11:20:22 +00:00
# include "converter.h"
# include "support/lyxfunctional.h"
2000-06-12 11:55:12 +00:00
# ifdef SIGC_CXX_NAMESPACES
using SigC : : slot ;
# endif
2000-10-30 11:33:05 +00:00
using std : : find ;
2000-11-08 09:39:46 +00:00
using std : : find_if ;
2000-11-03 09:47:02 +00:00
using std : : pair ;
2000-11-08 09:39:46 +00:00
using std : : sort ;
2000-10-30 11:33:05 +00:00
using std : : vector ;
2000-11-03 09:47:02 +00:00
extern string fmt ( char const * fmtstr . . . ) ;
2000-11-08 09:39:46 +00:00
extern string system_lyxdir ;
2000-10-30 11:33:05 +00:00
extern Languages languages ;
2000-06-12 11:55:12 +00:00
2000-11-10 17:29:47 +00:00
static string const colorFile ( " /usr/lib/X11/rgb.txt " ) ;
vector < X11Color > FormPreferences : : colorDB ;
vector < XFormColor > FormPreferences : : xformColorDB ;
2000-11-08 09:39:46 +00:00
pair < vector < string > , vector < string > > FormPreferences : : dirlist ;
2000-11-09 15:28:42 +00:00
// Two functions used to help sort a vector<Command> and a vector<Format>.
// Only used in this file, so no need to declare them globally.
bool CommandsCompare ( Command const & a , Command const & b )
{
if ( a . from - > prettyname = = b . from - > prettyname )
return ( a . to - > prettyname < b . to - > prettyname ) ;
else
return ( a . from - > prettyname < b . from - > prettyname ) ;
}
bool FormatsCompare ( Format const & a , Format const & b )
{
return ( a . name < b . name ) ;
}
2000-06-12 11:55:12 +00:00
FormPreferences : : FormPreferences ( LyXView * lv , Dialogs * d )
2000-10-13 05:57:05 +00:00
: FormBaseBI ( lv , d , _ ( " Preferences " ) , new PreferencesPolicy ) ,
2000-11-03 17:05:42 +00:00
dialog_ ( 0 ) ,
converters_tab_ ( 0 ) , inputs_tab_ ( 0 ) , look_n_feel_tab_ ( 0 ) ,
outputs_tab_ ( 0 ) , usage_tab_ ( 0 ) ,
2000-11-10 17:29:47 +00:00
colors_ ( 0 ) , converters_ ( 0 ) , formats_ ( 0 ) , inputs_misc_ ( 0 ) ,
2000-11-03 09:47:02 +00:00
interface_ ( 0 ) , language_ ( 0 ) , lnf_misc_ ( 0 ) , outputs_misc_ ( 0 ) ,
paths_ ( 0 ) , printer_ ( 0 ) , screen_fonts_ ( 0 ) , spellchecker_ ( 0 ) ,
2000-11-02 14:47:47 +00:00
combo_default_lang ( 0 ) , combo_kbmap_1 ( 0 ) , combo_kbmap_2 ( 0 ) ,
2000-11-09 15:28:42 +00:00
warningPosted ( false )
2000-06-12 11:55:12 +00:00
{
// let the dialog be shown
// This is a permanent connection so we won't bother
// storing a copy because we won't be disconnecting.
2000-08-14 05:24:35 +00:00
d - > showPreferences . connect ( slot ( this , & FormPreferences : : show ) ) ;
2000-06-12 11:55:12 +00:00
}
FormPreferences : : ~ FormPreferences ( )
{
2000-10-30 21:53:29 +00:00
delete combo_default_lang ;
delete combo_kbmap_1 ;
delete combo_kbmap_2 ;
2000-11-10 17:29:47 +00:00
delete colors_ ;
2000-11-03 17:05:42 +00:00
delete converters_ ;
2000-11-03 09:47:02 +00:00
delete formats_ ;
2000-10-30 11:33:05 +00:00
delete inputs_misc_ ;
2000-10-11 07:59:25 +00:00
delete interface_ ;
2000-10-27 10:04:51 +00:00
delete language_ ;
delete lnf_misc_ ;
delete outputs_misc_ ;
2000-10-02 00:10:25 +00:00
delete paths_ ;
2000-10-27 10:04:51 +00:00
delete printer_ ;
delete screen_fonts_ ;
delete spellchecker_ ;
2000-10-30 21:53:29 +00:00
2000-11-09 15:28:42 +00:00
delete converters_tab_ ;
delete inputs_tab_ ;
delete look_n_feel_tab_ ;
delete outputs_tab_ ;
delete usage_tab_ ;
2000-10-30 21:53:29 +00:00
delete dialog_ ;
2000-10-27 10:04:51 +00:00
}
2000-11-10 17:29:47 +00:00
void FormPreferences : : redraw ( )
{
if ( form ( ) & & form ( ) - > visible )
fl_redraw_form ( form ( ) ) ;
else
return ;
FL_FORM * outer_form = fl_get_active_folder ( dialog_ - > tabfolder_prefs ) ;
if ( outer_form & & outer_form - > visible )
fl_redraw_form ( outer_form ) ;
else
return ;
if ( outer_form = = converters_tab_ - > form )
outer_form =
fl_get_active_folder ( converters_tab_ - > tabfolder_outer ) ;
else if ( outer_form = = look_n_feel_tab_ - > form )
outer_form =
fl_get_active_folder ( look_n_feel_tab_ - > tabfolder_outer ) ;
else if ( outer_form = = inputs_tab_ - > form )
outer_form = fl_get_active_folder ( inputs_tab_ - > tabfolder_outer ) ;
else if ( outer_form = = outputs_tab_ - > form )
outer_form =
fl_get_active_folder ( outputs_tab_ - > tabfolder_outer ) ;
else if ( outer_form = = usage_tab_ - > form )
outer_form = fl_get_active_folder ( usage_tab_ - > tabfolder_outer ) ;
if ( outer_form & & outer_form - > visible )
fl_redraw_form ( outer_form ) ;
}
2000-10-27 10:04:51 +00:00
FL_FORM * FormPreferences : : form ( ) const
{
if ( dialog_ ) return dialog_ - > form ;
return 0 ;
}
void FormPreferences : : ok ( )
{
FormBase : : ok ( ) ;
lv_ - > getLyXFunc ( ) - > Dispatch ( LFUN_SAVEPREFERENCES ) ;
}
2000-10-10 04:12:56 +00:00
void FormPreferences : : hide ( )
{
2000-10-11 07:59:25 +00:00
// We need to hide the active tabfolder otherwise we get a
// BadDrawable error from X windows and LyX crashes without saving.
2000-10-10 04:12:56 +00:00
FL_FORM * outer_form = fl_get_active_folder ( dialog_ - > tabfolder_prefs ) ;
if ( outer_form
& & outer_form - > visible ) {
fl_hide_form ( outer_form ) ;
}
FormBase : : hide ( ) ;
}
2000-06-12 11:55:12 +00:00
void FormPreferences : : build ( )
{
dialog_ = build_preferences ( ) ;
2000-08-14 05:24:35 +00:00
// manage the restore, save, apply and cancel/close buttons
2000-10-02 00:10:25 +00:00
bc_ . setOK ( dialog_ - > button_ok ) ;
bc_ . setApply ( dialog_ - > button_apply ) ;
bc_ . setCancel ( dialog_ - > button_cancel ) ;
bc_ . setUndoAll ( dialog_ - > button_restore ) ;
bc_ . refresh ( ) ;
2000-08-14 05:24:35 +00:00
// Workaround dumb xforms sizing bug
2000-10-20 09:50:09 +00:00
minw_ = form ( ) - > w ;
minh_ = form ( ) - > h ;
2000-08-14 05:24:35 +00:00
2000-10-03 05:53:25 +00:00
// build the tab folders
2000-11-03 17:05:42 +00:00
converters_tab_ = build_outer_tab ( ) ;
2000-10-03 05:53:25 +00:00
look_n_feel_tab_ = build_outer_tab ( ) ;
2000-10-27 10:04:51 +00:00
inputs_tab_ = build_outer_tab ( ) ;
2000-11-03 17:05:42 +00:00
outputs_tab_ = build_outer_tab ( ) ;
2000-10-27 10:04:51 +00:00
usage_tab_ = build_outer_tab ( ) ;
2000-10-03 05:53:25 +00:00
// build actual tabfolder contents
// these will become nested tabfolders
2000-11-10 17:29:47 +00:00
buildColors ( ) ;
2000-11-03 17:05:42 +00:00
buildConverters ( ) ;
2000-11-03 09:47:02 +00:00
buildFormats ( ) ;
2000-10-30 11:33:05 +00:00
buildInputsMisc ( ) ;
2000-10-27 10:04:51 +00:00
buildInterface ( ) ;
buildLanguage ( ) ;
buildLnFmisc ( ) ;
buildOutputsMisc ( ) ;
buildPaths ( ) ;
buildPrinter ( ) ;
buildScreenFonts ( ) ;
buildSpellchecker ( ) ;
2000-07-28 04:59:45 +00:00
// Now add them to the tabfolder
2000-06-12 11:55:12 +00:00
fl_addto_tabfolder ( dialog_ - > tabfolder_prefs ,
2000-10-03 05:53:25 +00:00
_ ( " Look and Feel " ) ,
look_n_feel_tab_ - > form ) ;
2000-11-03 17:05:42 +00:00
fl_addto_tabfolder ( dialog_ - > tabfolder_prefs ,
_ ( " Usage " ) ,
usage_tab_ - > form ) ;
fl_addto_tabfolder ( dialog_ - > tabfolder_prefs ,
_ ( " Converters " ) ,
converters_tab_ - > form ) ;
2000-10-03 05:53:25 +00:00
fl_addto_tabfolder ( dialog_ - > tabfolder_prefs ,
_ ( " Inputs " ) ,
inputs_tab_ - > form ) ;
2000-06-12 11:55:12 +00:00
fl_addto_tabfolder ( dialog_ - > tabfolder_prefs ,
2000-10-03 05:53:25 +00:00
_ ( " Outputs " ) ,
outputs_tab_ - > form ) ;
// now build the nested tabfolders
// Starting with look and feel
fl_addto_tabfolder ( look_n_feel_tab_ - > tabfolder_outer ,
2000-06-12 11:55:12 +00:00
_ ( " Screen Fonts " ) ,
2000-08-14 05:24:35 +00:00
screen_fonts_ - > form ) ;
2000-10-03 05:53:25 +00:00
fl_addto_tabfolder ( look_n_feel_tab_ - > tabfolder_outer ,
2000-10-11 07:59:25 +00:00
_ ( " Interface " ) ,
interface_ - > form ) ;
2000-10-03 05:53:25 +00:00
fl_addto_tabfolder ( look_n_feel_tab_ - > tabfolder_outer ,
2000-11-10 17:29:47 +00:00
_ ( " Colors " ) ,
colors_ - > form ) ;
2000-10-27 10:04:51 +00:00
fl_addto_tabfolder ( look_n_feel_tab_ - > tabfolder_outer ,
_ ( " Misc " ) ,
lnf_misc_ - > form ) ;
2000-10-03 05:53:25 +00:00
2000-11-03 17:05:42 +00:00
// then build converters
fl_addto_tabfolder ( converters_tab_ - > tabfolder_outer ,
_ ( " Formats " ) ,
formats_ - > form ) ;
fl_addto_tabfolder ( converters_tab_ - > tabfolder_outer ,
_ ( " Converters " ) ,
converters_ - > form ) ;
2000-10-03 05:53:25 +00:00
// then build inputs
// Paths should probably go in a few outer_tab called Files
fl_addto_tabfolder ( inputs_tab_ - > tabfolder_outer ,
2000-06-12 11:55:12 +00:00
_ ( " Paths " ) ,
2000-08-14 05:24:35 +00:00
paths_ - > form ) ;
2000-10-30 11:33:05 +00:00
fl_addto_tabfolder ( inputs_tab_ - > tabfolder_outer ,
_ ( " Misc " ) ,
inputs_misc_ - > form ) ;
2000-06-12 11:55:12 +00:00
2000-10-03 05:53:25 +00:00
// then building outputs
fl_addto_tabfolder ( outputs_tab_ - > tabfolder_outer ,
_ ( " Printer " ) ,
printer_ - > form ) ;
2000-10-11 07:59:25 +00:00
fl_addto_tabfolder ( outputs_tab_ - > tabfolder_outer ,
2000-10-27 10:04:51 +00:00
_ ( " Misc " ) ,
outputs_misc_ - > form ) ;
2000-06-12 11:55:12 +00:00
2000-10-27 10:04:51 +00:00
// then building usage
fl_addto_tabfolder ( usage_tab_ - > tabfolder_outer ,
_ ( " Spell checker " ) ,
spellchecker_ - > form ) ;
fl_addto_tabfolder ( usage_tab_ - > tabfolder_outer ,
_ ( " Language " ) ,
language_ - > form ) ;
2000-06-12 11:55:12 +00:00
}
void FormPreferences : : apply ( )
{
// set the new lyxrc entries
// many of these need to trigger other functions when the assignment
// is made. For example, screen zoom and font types. These could be
// handled either by signals/slots in lyxrc or just directly call the
// associated functions here.
2000-08-14 05:24:35 +00:00
// There are other problems with this scheme. We really should check
// what we copy to make sure that it really is necessary to do things
// like update the screen fonts because that flushes the textcache
// and other stuff which may cost us a lot on slower/high-load machines.
2000-10-27 10:04:51 +00:00
2000-11-10 17:29:47 +00:00
applyColors ( ) ;
2000-11-03 17:05:42 +00:00
applyConverters ( ) ;
2000-11-03 09:47:02 +00:00
applyFormats ( ) ;
2000-10-30 11:33:05 +00:00
applyInputsMisc ( ) ;
2000-10-27 10:04:51 +00:00
applyInterface ( ) ;
2000-10-30 11:33:05 +00:00
applyLanguage ( ) ;
2000-10-27 10:04:51 +00:00
applyLnFmisc ( ) ;
applyOutputsMisc ( ) ;
applyPaths ( ) ;
applyPrinter ( ) ;
applyScreenFonts ( ) ;
applySpellChecker ( ) ;
}
2000-10-30 21:53:29 +00:00
void FormPreferences : : feedback ( FL_OBJECT * ob )
2000-10-27 10:04:51 +00:00
{
2000-11-09 15:28:42 +00:00
Assert ( ob ) ;
2000-11-07 06:41:13 +00:00
2000-11-02 14:47:47 +00:00
string str ;
2000-11-10 17:29:47 +00:00
if ( ob - > form - > fdui = = colors_ ) {
str = feedbackColors ( ob ) ;
2000-11-04 10:00:12 +00:00
} else if ( ob - > form - > fdui = = converters_ ) {
2000-11-03 17:05:42 +00:00
str = feedbackConverters ( ob ) ;
2000-11-04 10:00:12 +00:00
} else if ( ob - > form - > fdui = = formats_ ) {
2000-11-03 09:47:02 +00:00
str = feedbackFormats ( ob ) ;
2000-11-04 10:00:12 +00:00
} else if ( ob - > form - > fdui = = inputs_misc_ ) {
2000-11-02 14:47:47 +00:00
str = feedbackInputsMisc ( ob ) ;
2000-11-04 10:00:12 +00:00
} else if ( ob - > form - > fdui = = interface_ ) {
2000-11-02 14:47:47 +00:00
str = feedbackInterface ( ob ) ;
2000-11-04 10:00:12 +00:00
} else if ( ob - > form - > fdui = = language_ ) {
2000-11-02 14:47:47 +00:00
str = feedbackLanguage ( ob ) ;
2000-11-04 10:00:12 +00:00
} else if ( ob - > form - > fdui = = lnf_misc_ ) {
2000-11-02 14:47:47 +00:00
str = feedbackLnFmisc ( ob ) ;
2000-11-04 10:00:12 +00:00
} else if ( ob - > form - > fdui = = outputs_misc_ ) {
2000-11-02 14:47:47 +00:00
str = feedbackOutputsMisc ( ob ) ;
2000-11-04 10:00:12 +00:00
} else if ( ob - > form - > fdui = = paths_ ) {
2000-11-02 14:47:47 +00:00
str = feedbackPaths ( ob ) ;
2000-11-04 10:00:12 +00:00
} else if ( ob - > form - > fdui = = printer_ ) {
2000-11-02 14:47:47 +00:00
str = feedbackPrinter ( ob ) ;
2000-11-04 10:00:12 +00:00
} else if ( ob - > form - > fdui = = screen_fonts_ ) {
2000-11-02 14:47:47 +00:00
str = feedbackScreenFonts ( ob ) ;
2000-11-04 10:00:12 +00:00
} else if ( ob - > form - > fdui = = spellchecker_ ) {
2000-11-02 14:47:47 +00:00
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 )
2000-10-27 10:04:51 +00:00
{
2000-11-08 09:39:46 +00:00
Assert ( ob ) ;
2000-10-27 10:04:51 +00:00
// 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_
2000-11-10 17:29:47 +00:00
if ( ob - > form - > fdui = = colors_ )
return inputColors ( ob ) ;
2000-11-09 15:28:42 +00:00
else if ( ob - > form - > fdui = = converters_ )
return inputConverters ( ob ) ;
2000-11-06 11:20:22 +00:00
else if ( ob - > form - > fdui = = language_ )
return inputLanguage ( ob ) ;
else if ( ob - > form - > fdui = = paths_ )
return inputPaths ( ob ) ;
else if ( ob - > form - > fdui = = screen_fonts_ )
return inputScreenFonts ( ) ;
else if ( ob - > form - > fdui = = spellchecker_ )
return inputSpellChecker ( ob ) ;
else if ( ob - > form - > fdui = = formats_ )
return inputFormats ( ob ) ;
2000-10-27 10:04:51 +00:00
2000-11-10 17:29:47 +00:00
return true ;
2000-10-27 10:04:51 +00:00
}
2000-10-30 21:53:29 +00:00
void FormPreferences : : update ( )
{
if ( ! dialog_ ) return ;
// read lyxrc entries
2000-11-10 17:29:47 +00:00
updateColors ( ) ;
2000-11-03 17:05:42 +00:00
updateConverters ( ) ;
2000-11-03 09:47:02 +00:00
updateFormats ( ) ;
2000-10-30 21:53:29 +00:00
updateInputsMisc ( ) ;
updateInterface ( ) ;
updateLanguage ( ) ;
updateLnFmisc ( ) ;
updateOutputsMisc ( ) ;
updatePaths ( ) ;
updatePrinter ( ) ;
updateScreenFonts ( ) ;
updateSpellChecker ( ) ;
}
2000-11-10 17:29:47 +00:00
void FormPreferences : : applyColors ( ) const
2000-10-30 11:33:05 +00:00
{
2000-11-10 17:29:47 +00:00
bool modifiedXForms = false ;
bool modifiedText = false ;
bool modifiedBackground = false ;
for ( vector < XFormColor > : : const_iterator cit = xformColorDB . begin ( ) ;
cit ! = xformColorDB . end ( ) ; + + cit ) {
RGB col ;
fl_getmcolor ( ( * cit ) . colorID , & col . r , & col . g , & col . b ) ;
if ( col ! = ( * cit ) . col ) {
modifiedXForms = true ;
if ( ( * cit ) . colorID = = FL_BLACK )
modifiedText = true ;
if ( ( * cit ) . colorID = = FL_COL1 )
modifiedBackground = true ;
}
}
if ( modifiedXForms ) {
vector < XFormColor > : : const_iterator cit ;
for ( cit = xformColorDB . begin ( ) ;
cit ! = xformColorDB . end ( ) ; + + cit ) {
fl_mapcolor ( ( * cit ) . colorID ,
( * cit ) . col . r , ( * cit ) . col . g , ( * cit ) . col . b ) ;
if ( modifiedText & & ( * cit ) . colorID = = FL_BLACK ) {
ColorsAdjustVal ( FL_INACTIVE , FL_BLACK , 0.5 ) ;
}
if ( modifiedBackground & & ( * cit ) . colorID = = FL_COL1 ) {
ColorsAdjustVal ( FL_MCOL , FL_COL1 , 0.1 ) ;
ColorsAdjustVal ( FL_TOP_BCOL , FL_COL1 , 0.1 ) ;
ColorsAdjustVal ( FL_LEFT_BCOL , FL_COL1 , 0.1 ) ;
ColorsAdjustVal ( FL_RIGHT_BCOL , FL_COL1 , - 0.5 ) ;
ColorsAdjustVal ( FL_BOTTOM_BCOL , FL_COL1 , - 0.5 ) ;
}
}
Dialogs : : redrawGUI ( ) ;
}
2000-10-30 11:33:05 +00:00
}
2000-11-10 17:29:47 +00:00
void FormPreferences : : buildColors ( )
2000-10-27 10:04:51 +00:00
{
2000-11-10 17:29:47 +00:00
colors_ = build_colors ( ) ;
2000-11-03 09:47:02 +00:00
2000-11-10 17:29:47 +00:00
FL_OBJECT * obj = colors_ - > valslider_red ;
2000-11-03 09:47:02 +00:00
fl_set_slider_bounds ( obj , 0 , 255 ) ;
fl_set_slider_precision ( obj , 0 ) ;
fl_set_slider_return ( obj , FL_RETURN_END_CHANGED ) ;
2000-11-10 17:29:47 +00:00
obj = colors_ - > valslider_green ;
2000-11-03 09:47:02 +00:00
fl_set_slider_bounds ( obj , 0 , 255 ) ;
fl_set_slider_precision ( obj , 0 ) ;
fl_set_slider_return ( obj , FL_RETURN_END_CHANGED ) ;
2000-11-10 17:29:47 +00:00
obj = colors_ - > valslider_blue ;
2000-11-03 09:47:02 +00:00
fl_set_slider_bounds ( obj , 0 , 255 ) ;
fl_set_slider_precision ( obj , 0 ) ;
fl_set_slider_return ( obj , FL_RETURN_END_CHANGED ) ;
2000-11-10 17:29:47 +00:00
fl_set_object_color ( colors_ - > button_color ,
2000-11-03 09:47:02 +00:00
FL_FREE_COL4 , FL_FREE_COL4 ) ;
2000-11-10 17:29:47 +00:00
fl_set_input_return ( colors_ - > input_name , FL_RETURN_END_CHANGED ) ;
2000-11-03 09:47:02 +00:00
2000-11-10 17:29:47 +00:00
if ( ColorsLoadBrowserX11 ( colorFile ) )
fl_set_input ( colors_ - > input_name , colorFile . c_str ( ) ) ;
2000-11-03 09:47:02 +00:00
else
2000-11-10 17:29:47 +00:00
fl_set_input ( colors_ - > input_name , N_ ( " No file found " ) ) ;
ColorsLoadBrowserLyX ( ) ;
2000-11-03 09:47:02 +00:00
// deactivate the browse button because it isn't implemented
2000-11-10 17:29:47 +00:00
fl_deactivate_object ( colors_ - > button_browse ) ;
fl_set_object_lcol ( colors_ - > button_browse , FL_INACTIVE ) ;
2000-11-09 15:28:42 +00:00
// set up the feedback mechanism
2000-11-10 17:29:47 +00:00
setPreHandler ( colors_ - > browser_x11 ) ;
setPreHandler ( colors_ - > input_name ) ;
setPreHandler ( colors_ - > button_browse ) ;
setPreHandler ( colors_ - > button_color ) ;
setPreHandler ( colors_ - > valslider_red ) ;
setPreHandler ( colors_ - > valslider_green ) ;
setPreHandler ( colors_ - > valslider_blue ) ;
setPreHandler ( colors_ - > browser_lyx_objs ) ;
setPreHandler ( colors_ - > button_modify ) ;
2000-11-03 09:47:02 +00:00
}
2000-11-08 09:39:46 +00:00
string const
2000-11-10 17:29:47 +00:00
FormPreferences : : feedbackColors ( FL_OBJECT const * const ob ) const
2000-11-03 17:05:42 +00:00
{
2000-11-10 17:29:47 +00:00
string str ;
if ( ob = = colors_ - > browser_x11 ) {
str = N_ ( " The colors listed in the X11 database. " ) ;
} else if ( ob = = colors_ - > browser_lyx_objs ) {
str = N_ ( " LyX objects that can be assigned a color. " ) ;
} else if ( ob = = colors_ - > input_name ) {
str = N_ ( " The file containing the X11 color database. " ) ;
} else if ( ob = = colors_ - > button_color ) {
str = N_ ( " You will only be able to modify the LyX object if the sliders and X11 browser agree. Force this by clicking on the highlighted browser name. " ) ;
} else if ( ob = = colors_ - > valslider_red
| | ob = = colors_ - > valslider_green
| | ob = = colors_ - > valslider_blue ) {
str = N_ ( " Find a new color. The name highlighted in the X11 database is the closest match to this. " ) ;
} else if ( ob = = colors_ - > button_modify ) {
str = N_ ( " Modify the color of the LyX object. " ) ;
}
return str ;
2000-11-03 17:05:42 +00:00
}
2000-11-10 17:29:47 +00:00
bool FormPreferences : : inputColors ( FL_OBJECT const * const ob )
2000-11-03 17:05:42 +00:00
{
2000-11-10 17:29:47 +00:00
if ( ob = = colors_ - > browser_x11 ) {
return ColorsBrowserX11 ( ) ;
} else if ( ob = = colors_ - > valslider_red
| | ob = = colors_ - > valslider_green
| | ob = = colors_ - > valslider_blue ) {
return ColorsRGB ( ) ;
} else if ( ob = = colors_ - > input_name ) {
return ColorsDatabase ( ) ;
} else if ( ob = = colors_ - > browser_lyx_objs ) {
return ColorsBrowserLyX ( ) ;
} else if ( ob = = colors_ - > button_modify ) {
return ColorsModify ( ) ;
}
2000-11-03 17:05:42 +00:00
2000-11-10 17:29:47 +00:00
return true ;
}
2000-11-03 17:05:42 +00:00
2000-11-10 17:29:47 +00:00
void FormPreferences : : ColorsAdjustVal ( int colAdjust , int colParent ,
double addVal ) const
{
RGB rgb ;
fl_getmcolor ( colParent , & rgb . r , & rgb . g , & rgb . b ) ;
HSV hsv = HSV ( rgb ) ;
hsv . v + = addVal ;
if ( hsv . v > 1.0 )
hsv . v = 1.0 ;
else if ( hsv . v < 0.0 )
hsv . v = 0.0 ;
rgb = RGB ( hsv ) ;
fl_mapcolor ( colAdjust , rgb . r , rgb . g , rgb . b ) ;
}
bool FormPreferences : : ColorsBrowserLyX ( ) const
{
int i = fl_get_browser ( colors_ - > browser_lyx_objs ) ;
if ( i < 1 )
return true ;
string name = fl_get_browser_line ( colors_ - > browser_lyx_objs , i ) ;
vector < XFormColor > : : const_iterator cit =
find_if ( xformColorDB . begin ( ) , xformColorDB . end ( ) ,
compare_memfun ( & XFormColor : : getname , name ) ) ;
if ( cit ! = xformColorDB . end ( ) ) {
fl_freeze_form ( colors_ - > form ) ;
fl_set_slider_value ( colors_ - > valslider_red , ( * cit ) . col . r ) ;
fl_set_slider_value ( colors_ - > valslider_green , ( * cit ) . col . g ) ;
fl_set_slider_value ( colors_ - > valslider_blue , ( * cit ) . col . b ) ;
ColorsRGB ( ) ;
fl_unfreeze_form ( colors_ - > form ) ;
2000-11-03 17:05:42 +00:00
}
2000-11-10 17:29:47 +00:00
fl_deactivate_object ( colors_ - > button_modify ) ;
fl_set_object_lcol ( colors_ - > button_modify , FL_INACTIVE ) ;
return true ;
}
bool FormPreferences : : ColorsBrowserX11 ( ) const
{
int i = fl_get_browser ( colors_ - > browser_x11 ) ;
if ( i < 1 )
return true ;
fl_freeze_form ( colors_ - > form ) ;
RGB col = colorDB [ i - 1 ] . 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 ( colors_ - > valslider_red , col . r ) ;
fl_set_slider_value ( colors_ - > valslider_green , col . g ) ;
fl_set_slider_value ( colors_ - > valslider_blue , col . b ) ;
fl_redraw_object ( colors_ - > button_color ) ;
// Is it valid to activate the "Modify" button?
int line = fl_get_browser ( colors_ - > browser_lyx_objs ) ;
bool isSelected = ( line > 0 ) ;
if ( isSelected )
if ( line > fl_get_browser_maxline ( colors_ - > browser_lyx_objs ) )
isSelected = false ;
if ( isSelected & & colorDB [ i - 1 ] . second = = col ) {
fl_activate_object ( colors_ - > button_modify ) ;
fl_set_object_lcol ( colors_ - > button_modify , FL_BLACK ) ;
}
fl_unfreeze_form ( colors_ - > form ) ;
return true ;
}
bool FormPreferences : : ColorsDatabase ( ) const
{
string file = fl_get_input ( colors_ - > input_name ) ;
if ( ColorsLoadBrowserX11 ( file ) )
fl_set_input ( colors_ - > input_name , file . c_str ( ) ) ;
else if ( ColorsLoadBrowserX11 ( colorFile ) )
fl_set_input ( colors_ - > input_name , colorFile . c_str ( ) ) ;
else
fl_set_input ( colors_ - > input_name , N_ ( " No file found " ) ) ;
return true ;
2000-11-03 17:05:42 +00:00
}
2000-11-10 17:29:47 +00:00
void FormPreferences : : ColorsLoadBrowserLyX ( )
{
XFormColor xcol ;
xcol . name = " GUI background " ;
xcol . colorID = FL_COL1 ;
fl_getmcolor ( FL_COL1 , & xcol . col . r , & xcol . col . g , & xcol . col . b ) ;
xformColorDB . push_back ( xcol ) ;
xcol . name = " GUI text " ;
xcol . colorID = FL_BLACK ;
fl_getmcolor ( FL_BLACK , & xcol . col . r , & xcol . col . g , & xcol . col . b ) ;
xformColorDB . push_back ( xcol ) ;
xcol . name = " GUI active tab " ;
xcol . colorID = FL_LIGHTER_COL1 ;
fl_getmcolor ( FL_LIGHTER_COL1 , & xcol . col . r , & xcol . col . g , & xcol . col . b ) ;
xformColorDB . push_back ( xcol ) ;
xcol . name = " GUI push button " ;
xcol . colorID = FL_YELLOW ;
fl_getmcolor ( FL_YELLOW , & xcol . col . r , & xcol . col . g , & xcol . col . b ) ;
xformColorDB . push_back ( xcol ) ;
FL_OBJECT * colbr = colors_ - > browser_lyx_objs ;
fl_clear_browser ( colbr ) ;
for ( vector < XFormColor > : : const_iterator cit = xformColorDB . begin ( ) ;
cit ! = xformColorDB . end ( ) ; + + cit ) {
fl_addto_browser ( colbr , ( * cit ) . name . c_str ( ) ) ;
}
fl_deselect_browser ( colors_ - > browser_lyx_objs ) ;
fl_deactivate_object ( colors_ - > button_modify ) ;
fl_set_object_lcol ( colors_ - > button_modify , FL_INACTIVE ) ;
}
bool FormPreferences : : ColorsLoadBrowserX11 ( string const & filename ) const
2000-11-03 09:47:02 +00:00
{
LyXLex lex ( 0 , 0 ) ;
2000-11-08 15:19:55 +00:00
lex . setCommentChar ( ' ! ' ) ;
2000-11-03 09:47:02 +00:00
if ( ! lex . setFile ( filename ) )
2000-11-10 17:29:47 +00:00
return true ;
2000-11-03 09:47:02 +00:00
2000-11-03 17:05:42 +00:00
vector < RGB > cols ;
vector < string > names ;
2000-11-08 15:19:55 +00:00
while ( lex . next ( ) ) {
RGB col ;
col . r = lex . GetInteger ( ) ;
lex . next ( ) ;
col . g = lex . GetInteger ( ) ;
lex . next ( ) ;
col . b = lex . GetInteger ( ) ;
lex . EatLine ( ) ;
string name = frontStrip ( lex . GetString ( ) , " \t " ) ;
// remove redundant entries on the fly
bool add = cols . empty ( ) ;
if ( ! add ) {
2000-11-09 15:28:42 +00:00
vector < RGB > : : const_iterator cit =
2000-11-08 15:19:55 +00:00
find ( cols . begin ( ) , cols . end ( ) , col ) ;
2000-11-09 15:28:42 +00:00
add = ( cit = = cols . end ( ) ) ;
2000-11-08 15:19:55 +00:00
}
if ( add ) {
2000-11-09 15:28:42 +00:00
if ( col = = RGB ( 0 , 0 , 0 ) )
name = " black " ;
else if ( col = = RGB ( 255 , 255 , 255 ) )
name = " white " ;
else
name = lowercase ( name ) ;
2000-11-10 17:29:47 +00:00
if ( col = = RGB ( 0 , 0 , 0 ) | | col = = RGB ( 255 , 255 , 255 ) ) {
2000-11-08 15:19:55 +00:00
cols . insert ( cols . begin ( ) , col ) ;
names . insert ( names . begin ( ) , name ) ;
} else {
cols . push_back ( col ) ;
names . push_back ( name ) ;
2000-11-03 17:05:42 +00:00
}
2000-11-08 15:19:55 +00:00
}
}
2000-11-10 17:29:47 +00:00
FL_OBJECT * colbr = colors_ - > browser_x11 ;
fl_freeze_form ( colors_ - > form ) ;
fl_clear_browser ( colbr ) ;
2000-11-09 15:28:42 +00:00
vector < string > : : const_iterator sit = names . begin ( ) ;
2000-11-04 10:00:12 +00:00
for ( vector < RGB > : : const_iterator iit = cols . begin ( ) ;
iit ! = cols . end ( ) ; + + iit , + + sit ) {
2000-11-10 17:29:47 +00:00
colorDB . push_back ( X11Color ( * sit , * iit ) ) ;
fl_addto_browser ( colbr , ( * sit ) . c_str ( ) ) ;
2000-11-03 17:05:42 +00:00
}
2000-11-03 09:47:02 +00:00
fl_set_browser_topline ( colbr , 1 ) ;
fl_select_browser_line ( colbr , 1 ) ;
2000-11-10 17:29:47 +00:00
ColorsBrowserX11 ( ) ;
fl_unfreeze_form ( colors_ - > form ) ;
2000-11-03 09:47:02 +00:00
return true ;
2000-10-27 10:04:51 +00:00
}
2000-11-10 17:29:47 +00:00
bool FormPreferences : : ColorsModify ( ) const
2000-10-30 11:33:05 +00:00
{
2000-11-10 17:29:47 +00:00
int i = fl_get_browser ( colors_ - > browser_lyx_objs ) ;
if ( i < 1 )
return true ;
2000-10-30 11:33:05 +00:00
2000-11-10 17:29:47 +00:00
string name = fl_get_browser_line ( colors_ - > browser_lyx_objs , i ) ;
2000-11-03 09:47:02 +00:00
2000-11-10 17:29:47 +00:00
vector < XFormColor > : : iterator it = // non-const; it's modified below
find_if ( xformColorDB . begin ( ) , xformColorDB . end ( ) ,
compare_memfun ( & XFormColor : : getname , name ) ) ;
2000-11-03 09:47:02 +00:00
2000-11-10 17:29:47 +00:00
if ( it = = xformColorDB . end ( ) )
return true ;
2000-11-03 09:47:02 +00:00
2000-11-10 17:29:47 +00:00
int j = fl_get_browser ( colors_ - > browser_x11 ) ;
if ( j < 1 )
return true ;
2000-11-03 09:47:02 +00:00
2000-11-10 17:29:47 +00:00
( * it ) . col . r = colorDB [ j - 1 ] . second . r ;
( * it ) . col . g = colorDB [ j - 1 ] . second . g ;
( * it ) . col . b = colorDB [ j - 1 ] . second . b ;
2000-11-03 09:47:02 +00:00
2000-11-10 17:29:47 +00:00
fl_deselect_browser ( colors_ - > browser_x11 ) ;
fl_deselect_browser ( colors_ - > browser_lyx_objs ) ;
fl_deactivate_object ( colors_ - > button_modify ) ;
fl_set_object_lcol ( colors_ - > button_modify , FL_INACTIVE ) ;
2000-11-03 09:47:02 +00:00
2000-11-10 17:29:47 +00:00
return true ;
2000-11-03 09:47:02 +00:00
}
2000-11-10 17:29:47 +00:00
bool FormPreferences : : ColorsRGB ( ) const
2000-11-03 09:47:02 +00:00
{
2000-11-10 17:29:47 +00:00
fl_freeze_form ( colors_ - > form ) ;
2000-11-03 09:47:02 +00:00
2000-11-03 17:05:42 +00:00
RGB col ;
2000-11-10 17:29:47 +00:00
col . r = int ( fl_get_slider_value ( colors_ - > valslider_red ) ) ;
col . g = int ( fl_get_slider_value ( colors_ - > valslider_green ) ) ;
col . b = int ( fl_get_slider_value ( colors_ - > valslider_blue ) ) ;
2000-11-03 09:47:02 +00:00
2000-11-03 17:05:42 +00:00
fl_mapcolor ( FL_FREE_COL4 , col . r , col . g , col . b ) ;
2000-11-10 17:29:47 +00:00
fl_redraw_object ( colors_ - > button_color ) ;
2000-11-03 09:47:02 +00:00
2000-11-10 17:29:47 +00:00
int const i = ColorsSearchEntry ( col ) ;
2000-11-03 09:47:02 +00:00
// change topline only if necessary
2000-11-10 17:29:47 +00:00
// int top = fl_get_browser_topline(colors_->browser_x11);
2000-11-04 10:00:12 +00:00
// if (i < top || i > (top+15))
2000-11-10 17:29:47 +00:00
fl_set_browser_topline ( colors_ - > browser_x11 , i - 5 ) ;
fl_select_browser_line ( colors_ - > browser_x11 , i + 1 ) ;
// Only activate the "Modify" button if the browser and slider colors
// are the same AND if a LyX object is selected.
int line = fl_get_browser ( colors_ - > browser_lyx_objs ) ;
bool isSelected = ( line > 0 ) ;
if ( isSelected )
if ( line > fl_get_browser_maxline ( colors_ - > browser_lyx_objs ) )
isSelected = false ;
if ( isSelected & & colorDB [ i ] . second = = col ) {
fl_activate_object ( colors_ - > button_modify ) ;
fl_set_object_lcol ( colors_ - > button_modify , FL_BLACK ) ;
} else {
fl_deactivate_object ( colors_ - > button_modify ) ;
fl_set_object_lcol ( colors_ - > button_modify , FL_INACTIVE ) ;
}
fl_unfreeze_form ( colors_ - > form ) ;
return true ;
}
int FormPreferences : : ColorsSearchEntry ( RGB const & col ) const
{
int mindiff = 0x7fffffff ;
vector < X11Color > : : const_iterator mincit = colorDB . begin ( ) ;
2000-11-03 09:47:02 +00:00
2000-11-10 17:29:47 +00:00
for ( vector < X11Color > : : const_iterator cit = colorDB . begin ( ) ;
cit ! = colorDB . 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 - colorDB . begin ( ) ) ;
2000-11-03 09:47:02 +00:00
}
2000-11-10 17:29:47 +00:00
void FormPreferences : : updateColors ( )
2000-11-04 10:00:12 +00:00
{ }
2000-11-03 09:47:02 +00:00
2000-11-03 17:05:42 +00:00
void FormPreferences : : applyConverters ( ) const
2000-11-09 15:28:42 +00:00
{
/* Uncomment once Converter is a "real" class.
vector < Command > old = Converter : : GetAllCommands ( ) ;
for ( vector < Command > : : const_iterator cit = old . begin ( ) ;
cit ! = old . end ( ) ; + + cit ) {
pair < string , string > FromTo =
pair < string , string > ( ( * cit ) . from - > prettyname ,
( * cit ) . to - > prettyname ) ;
vector < Command > : : const_iterator cit2 =
find_if ( commands_vec . begin ( ) , commands_vec . end ( ) ,
compare_memfun ( & Command : : getFromToPrettyname ,
FromTo ) ) ;
// Ie, converter exists in old, but is removed now.
// Can't actually Delete it, because old will contain
// system defauts.
if ( cit2 = = commands_vec . end ( ) )
commands . Add ( ( * cit ) . from , ( * cit ) . to , string ( ) ) ;
}
// Add new converters.
for ( vector < Command > : : const_iterator cit = commands_vec . begin ( ) ;
cit ! = commands_vec . end ( ) ; + + cit ) {
commands . Add ( ( * cit ) . from , ( * cit ) . to , ( * cit ) . command ) ;
}
*/
}
2000-11-03 17:05:42 +00:00
void FormPreferences : : buildConverters ( )
{
converters_ = build_converters ( ) ;
2000-11-09 15:28:42 +00:00
2000-11-08 09:39:46 +00:00
fl_set_input_return ( converters_ - > input_converter , FL_RETURN_CHANGED ) ;
fl_set_input_return ( converters_ - > input_flags , FL_RETURN_CHANGED ) ;
2000-11-09 15:28:42 +00:00
// set up the feedback mechanism
setPreHandler ( converters_ - > browser_all ) ;
setPreHandler ( converters_ - > button_delete ) ;
setPreHandler ( converters_ - > button_add ) ;
setPreHandler ( converters_ - > input_converter ) ;
setPreHandler ( converters_ - > choice_from ) ;
setPreHandler ( converters_ - > choice_to ) ;
setPreHandler ( converters_ - > input_flags ) ;
2000-11-03 09:47:02 +00:00
}
2000-11-04 10:00:12 +00:00
string const
2000-11-09 15:28:42 +00:00
FormPreferences : : feedbackConverters ( FL_OBJECT const * const ob ) const
2000-11-03 17:05:42 +00:00
{
2000-11-09 15:28:42 +00:00
string str ;
if ( ob = = converters_ - > browser_all ) {
str = N_ ( " All the currently defined converters known to LyX. " ) ;
} else if ( ob = = converters_ - > choice_from ) {
str = N_ ( " Convert \" from \" this format " ) ;
} else if ( ob = = converters_ - > choice_to ) {
str = N_ ( " Convert \" to \" this format " ) ;
} else if ( ob = = converters_ - > input_converter ) {
str = N_ ( " The conversion command. \" $$FName \" is the input file name, \" $$BaseName \" is the file name without its extension and $$OutName is the name of the output file. " ) ;
} else if ( ob = = converters_ - > input_flags ) {
str = N_ ( " I have no idea what this field is to be used for! " ) ;
} else if ( ob = = converters_ - > button_delete ) {
str = N_ ( " Remove the current converter from the list of available converters. " ) ;
} else if ( ob = = converters_ - > button_add ) {
str = N_ ( " Add the current converter to the list of available converters. " ) ;
}
return str ;
}
bool FormPreferences : : inputConverters ( FL_OBJECT const * const ob )
{
if ( ob = = converters_ - > browser_all ) {
return ConvertersBrowser ( ) ;
} else if ( ob = = converters_ - > choice_from
| | ob = = converters_ - > choice_to
| | ob = = converters_ - > input_converter
| | ob = = converters_ - > input_flags ) {
return ConvertersInput ( ) ;
} else if ( ob = = converters_ - > button_add ) {
return ConvertersAdd ( ) ;
} else if ( ob = = converters_ - > button_delete ) {
return ConvertersDelete ( ) ;
}
2000-11-10 17:29:47 +00:00
return true ;
2000-11-03 17:05:42 +00:00
}
void FormPreferences : : updateConverters ( )
2000-11-08 09:39:46 +00:00
{
2000-11-09 15:28:42 +00:00
commands_vec = Converter : : GetAllCommands ( ) ;
sort ( commands_vec . begin ( ) , commands_vec . end ( ) , & CommandsCompare ) ;
ConvertersClear ( ) ;
}
bool FormPreferences : : ConvertersAdd ( )
{
Command command ( 0 , 0 , " " ) ;
if ( ! ConvertersSetCommand ( command ) )
return false ;
string from = command . from - > prettyname ;
string to = command . to - > prettyname ;
pair < string , string > FromTo = pair < string , string > ( from , to ) ;
2000-11-08 09:39:46 +00:00
2000-11-10 17:29:47 +00:00
vector < Command > : : iterator it = // non-const; it's modified below
2000-11-09 15:28:42 +00:00
find_if ( commands_vec . begin ( ) , commands_vec . end ( ) ,
compare_memfun ( & Command : : getFromToPrettyname , FromTo ) ) ;
fl_freeze_form ( converters_ - > form ) ;
if ( it = = commands_vec . end ( ) ) {
// Unable to find command. Add to list.
commands_vec . push_back ( command ) ;
sort ( commands_vec . begin ( ) , commands_vec . end ( ) ,
& CommandsCompare ) ;
} else {
// Command found. Modify it.
( * it ) . from = command . from ;
( * it ) . to = command . to ;
( * it ) . command = command . command ;
2000-11-08 09:39:46 +00:00
}
2000-11-09 15:28:42 +00:00
// Clear input
ConvertersClear ( ) ;
fl_unfreeze_form ( converters_ - > form ) ;
return true ;
}
bool FormPreferences : : ConvertersBrowser ( )
{
int i = fl_get_browser ( converters_ - > browser_all ) ;
if ( i < = 0 ) return false ;
fl_freeze_form ( converters_ - > form ) ;
Command const & c = commands_vec [ i - 1 ] ;
int sel = 0 ;
for ( i = 1 ;
i < = fl_get_choice_maxitems ( converters_ - > choice_from ) ; + + i ) {
string str =
fl_get_choice_item_text ( converters_ - > choice_from , i ) ;
str = strip ( frontStrip ( str ) ) ;
if ( str = = c . from - > prettyname ) {
sel = i ;
break ;
}
}
if ( sel ! = 0 )
fl_set_choice ( converters_ - > choice_from , sel ) ;
sel = 0 ;
for ( int i = 1 ;
i < = fl_get_choice_maxitems ( converters_ - > choice_to ) ; + + i ) {
string str =
fl_get_choice_item_text ( converters_ - > choice_to , i ) ;
str = strip ( frontStrip ( str ) ) ;
if ( str = = c . to - > prettyname ) {
sel = i ;
break ;
}
}
if ( sel ! = 0 )
fl_set_choice ( converters_ - > choice_to , sel ) ;
fl_set_input ( converters_ - > input_converter , c . command . c_str ( ) ) ;
fl_set_object_label ( converters_ - > button_add , idex ( _ ( " Modify|#M " ) ) ) ;
fl_set_button_shortcut ( converters_ - > button_add ,
scex ( _ ( " Modify|#M " ) ) , 1 ) ;
fl_deactivate_object ( converters_ - > button_add ) ;
fl_set_object_lcol ( converters_ - > button_add , FL_INACTIVE ) ;
fl_activate_object ( converters_ - > button_delete ) ;
fl_set_object_lcol ( converters_ - > button_delete , FL_BLACK ) ;
fl_unfreeze_form ( converters_ - > form ) ;
return false ;
}
void FormPreferences : : ConvertersClear ( ) const
{
// Re-create browser
fl_clear_browser ( converters_ - > browser_all ) ;
for ( vector < Command > : : const_iterator cit = commands_vec . begin ( ) ;
cit ! = commands_vec . end ( ) ; + + cit ) {
string from = ( * cit ) . from - > prettyname ;
string to = ( * cit ) . to - > prettyname ;
string name = from + " -> " + to ;
fl_addto_browser ( converters_ - > browser_all , name . c_str ( ) ) ;
}
fl_set_input ( converters_ - > input_converter , " " ) ;
fl_set_input ( converters_ - > input_flags , " " ) ;
fl_deselect_browser ( formats_ - > browser_all ) ;
fl_set_object_label ( converters_ - > button_add , idex ( _ ( " Add|#A " ) ) ) ;
fl_set_button_shortcut ( converters_ - > button_add , scex ( _ ( " Add|#A " ) ) , 1 ) ;
2000-11-08 09:39:46 +00:00
fl_deactivate_object ( converters_ - > button_add ) ;
fl_set_object_lcol ( converters_ - > button_add , FL_INACTIVE ) ;
2000-11-09 15:28:42 +00:00
2000-11-08 09:39:46 +00:00
fl_deactivate_object ( converters_ - > button_delete ) ;
fl_set_object_lcol ( converters_ - > button_delete , FL_INACTIVE ) ;
}
2000-10-30 11:33:05 +00:00
2000-11-09 15:28:42 +00:00
bool FormPreferences : : ConvertersContainFormat ( Format const & format ) const
{
for ( vector < Command > : : const_iterator cit = commands_vec . begin ( ) ;
cit ! = commands_vec . end ( ) ; + + cit ) {
if ( format . name = = ( * cit ) . from - > name ) return true ;
if ( format . name = = ( * cit ) . to - > name ) return true ;
}
return false ;
}
bool FormPreferences : : ConvertersDelete ( )
{
Command command ( 0 , 0 , " " ) ;
if ( ! ConvertersSetCommand ( command ) )
return false ;
string from = command . from - > prettyname ;
string to = command . to - > prettyname ;
pair < string , string > FromTo = pair < string , string > ( from , to ) ;
2000-11-10 17:29:47 +00:00
vector < Command > : : iterator it = // non-const; it's modified below
2000-11-09 15:28:42 +00:00
find_if ( commands_vec . begin ( ) , commands_vec . end ( ) ,
compare_memfun ( & Command : : getFromToPrettyname , FromTo ) ) ;
fl_freeze_form ( converters_ - > form ) ;
if ( it = = commands_vec . end ( ) ) {
fl_deactivate_object ( converters_ - > button_delete ) ;
fl_set_object_lcol ( converters_ - > button_delete , FL_INACTIVE ) ;
fl_unfreeze_form ( converters_ - > form ) ;
return false ;
}
commands_vec . erase ( it ) ;
ConvertersClear ( ) ;
fl_unfreeze_form ( converters_ - > form ) ;
return true ;
}
bool FormPreferences : : ConvertersInput ( )
{
string from = fl_get_choice_text ( converters_ - > choice_from ) ;
from = strip ( frontStrip ( from ) ) ;
string to = fl_get_choice_text ( converters_ - > choice_to ) ;
to = strip ( frontStrip ( to ) ) ;
string name ;
if ( ! from . empty ( ) & & ! to . empty ( ) )
name = from + " -> " + to ;
int sel = 0 ;
if ( ! name . empty ( ) ) {
for ( int i = 0 ;
i < fl_get_browser_maxline ( converters_ - > browser_all ) ;
+ + i ) {
string str =
fl_get_browser_line ( converters_ - > browser_all ,
i + 1 ) ;
if ( str = = name ) {
sel = i + 1 ;
break ;
}
}
}
fl_freeze_form ( converters_ - > form ) ;
if ( sel = = 0 ) {
fl_set_object_label ( converters_ - > button_add ,
idex ( _ ( " Add|#A " ) ) ) ;
fl_set_button_shortcut ( converters_ - > button_add ,
scex ( _ ( " Add|#A " ) ) , 1 ) ;
if ( name . empty ( ) ) {
fl_deactivate_object ( converters_ - > button_add ) ;
fl_set_object_lcol ( converters_ - > button_add , FL_INACTIVE ) ;
} else {
fl_activate_object ( converters_ - > button_add ) ;
fl_set_object_lcol ( converters_ - > button_add , FL_BLACK ) ;
}
fl_deselect_browser ( converters_ - > browser_all ) ;
fl_deactivate_object ( converters_ - > button_delete ) ;
fl_set_object_lcol ( converters_ - > button_delete , FL_INACTIVE ) ;
} else {
fl_set_object_label ( converters_ - > button_add ,
idex ( _ ( " Modify|#M " ) ) ) ;
fl_set_button_shortcut ( converters_ - > button_add ,
scex ( _ ( " Modify|#M " ) ) , 1 ) ;
int top = sel - 6 ;
if ( top < 1 ) top = 0 ;
fl_set_browser_topline ( converters_ - > browser_all , top ) ;
fl_select_browser_line ( converters_ - > browser_all , sel ) ;
fl_activate_object ( converters_ - > button_add ) ;
fl_set_object_lcol ( converters_ - > button_add , FL_BLACK ) ;
fl_activate_object ( converters_ - > button_delete ) ;
fl_set_object_lcol ( converters_ - > button_delete , FL_BLACK ) ;
}
fl_unfreeze_form ( converters_ - > form ) ;
return true ;
}
bool FormPreferences : : ConvertersSetCommand ( Command & command ) const
{
string from = fl_get_choice_text ( converters_ - > choice_from ) ;
from = strip ( frontStrip ( from ) ) ;
if ( from . empty ( ) )
return false ;
vector < Format > : : const_iterator fit =
find_if ( formats_vec . begin ( ) , formats_vec . end ( ) ,
compare_memfun ( & Format : : getprettyname , from ) ) ;
if ( fit = = formats_vec . end ( ) )
return false ;
string to = fl_get_choice_text ( converters_ - > choice_to ) ;
to = strip ( frontStrip ( to ) ) ;
if ( to . empty ( ) )
return false ;
vector < Format > : : const_iterator tit =
find_if ( formats_vec . begin ( ) , formats_vec . end ( ) ,
compare_memfun ( & Format : : getprettyname , to ) ) ;
if ( tit = = formats_vec . end ( ) )
return false ;
string converter = fl_get_input ( converters_ - > input_converter ) ;
string flags = fl_get_input ( converters_ - > input_flags ) ;
command . from = fit ;
command . to = tit ;
command . command = converter ;
return true ;
}
void FormPreferences : : ConvertersUpdateChoices ( )
{
string choice ;
for ( vector < Format > : : iterator cit = formats_vec . begin ( ) ;
cit ! = formats_vec . end ( ) ; + + cit ) {
if ( ! choice . empty ( ) )
choice + = " | " ;
else
choice + = " " ;
choice + = ( * cit ) . prettyname ;
}
choice + = " " ;
fl_clear_choice ( converters_ - > choice_from ) ;
fl_addto_choice ( converters_ - > choice_from , choice . c_str ( ) ) ;
fl_clear_choice ( converters_ - > choice_to ) ;
fl_addto_choice ( converters_ - > choice_to , choice . c_str ( ) ) ;
}
2000-11-03 09:47:02 +00:00
void FormPreferences : : applyFormats ( ) const
2000-11-06 11:20:22 +00:00
{
vector < Format > old = formats . GetAllFormats ( ) ;
2000-11-09 15:28:42 +00:00
for ( vector < Format > : : const_iterator cit = old . begin ( ) ;
cit ! = old . end ( ) ; + + cit ) {
vector < Format > : : const_iterator cit2 =
find_if ( formats_vec . begin ( ) , formats_vec . end ( ) ,
compare_memfun ( & Format : : getname , ( * cit ) . name ) ) ;
2000-11-06 11:20:22 +00:00
2000-11-09 15:28:42 +00:00
// Ie, format exists in old, but is removed now.
// Can't actually Delete it, because old will contain
// system defauts.
if ( cit2 = = formats_vec . end ( ) )
formats . Add ( ( * cit ) . name , string ( ) , string ( ) , string ( ) ) ;
}
// Add new formats.
for ( vector < Format > : : const_iterator cit = formats_vec . begin ( ) ;
cit ! = formats_vec . end ( ) ; + + cit ) {
formats . Add ( ( * cit ) . name , ( * cit ) . extension , ( * cit ) . prettyname ,
( * cit ) . shortcut ) ;
formats . SetViewer ( ( * cit ) . name , ( * cit ) . viewer ) ;
2000-11-06 11:20:22 +00:00
}
}
2000-11-03 09:47:02 +00:00
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 ) ;
2000-11-08 09:39:46 +00:00
fl_set_input_return ( formats_ - > input_shrtcut , FL_RETURN_CHANGED ) ;
2000-11-03 09:47:02 +00:00
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 ) ;
2000-11-06 11:20:22 +00:00
2000-11-09 15:28:42 +00:00
// set up the feedback mechanism
setPreHandler ( formats_ - > browser_all ) ;
setPreHandler ( formats_ - > input_format ) ;
setPreHandler ( formats_ - > input_gui_name ) ;
setPreHandler ( formats_ - > button_delete ) ;
setPreHandler ( formats_ - > button_add ) ;
setPreHandler ( formats_ - > input_extension ) ;
setPreHandler ( formats_ - > input_viewer ) ;
setPreHandler ( formats_ - > input_shrtcut ) ;
2000-11-03 09:47:02 +00:00
}
2000-11-08 09:39:46 +00:00
string const
2000-11-09 15:28:42 +00:00
FormPreferences : : feedbackFormats ( FL_OBJECT const * const ob ) const
2000-11-03 09:47:02 +00:00
{
string str ;
2000-11-09 15:28:42 +00:00
if ( ob = = formats_ - > browser_all ) {
str = N_ ( " All the currently defined formats known to LyX. " ) ;
} else if ( ob = = formats_ - > input_format ) {
str = N_ ( " The format identifier. " ) ;
} else if ( ob = = formats_ - > input_gui_name ) {
str = N_ ( " The format name as it will appear in the menus. " ) ;
} else if ( ob = = formats_ - > input_shrtcut ) {
str = N_ ( " The keyboard accelerator. Use a letter in the GUI name. Case sensitive. " ) ;
} else if ( ob = = formats_ - > input_extension ) {
str = N_ ( " Used to recognize the file. E.g., ps, pdf, tex. " ) ;
} else if ( ob = = formats_ - > input_viewer ) {
str = N_ ( " The command used to launch the viwer application \n E.g. \" netscape $$FName \" where $$FName is the name of the file. " ) ;
} else if ( ob = = formats_ - > button_delete ) {
str = N_ ( " Remove the current format from the list of available formats. " ) ;
} else if ( ob = = formats_ - > button_add ) {
str = N_ ( " Add the current format to the list of available formats. " ) ;
}
2000-11-03 09:47:02 +00:00
return str ;
}
2000-11-06 11:20:22 +00:00
bool FormPreferences : : inputFormats ( FL_OBJECT const * const ob )
2000-11-03 09:47:02 +00:00
{
2000-11-09 15:28:42 +00:00
if ( ob = = formats_ - > browser_all ) {
return FormatsBrowser ( ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
} else if ( ob = = formats_ - > input_format
| | ob = = formats_ - > input_gui_name
| | ob = = formats_ - > input_shrtcut
| | ob = = formats_ - > input_extension
| | ob = = formats_ - > input_viewer ) {
return FormatsInput ( ) ;
2000-11-08 09:39:46 +00:00
2000-11-06 11:20:22 +00:00
} else if ( ob = = formats_ - > button_add ) {
2000-11-09 15:28:42 +00:00
return FormatsAdd ( ) ;
2000-11-08 09:39:46 +00:00
} else if ( ob = = formats_ - > button_delete ) {
2000-11-09 15:28:42 +00:00
return FormatsDelete ( ) ;
2000-11-06 11:20:22 +00:00
}
2000-11-09 15:28:42 +00:00
return false ;
2000-11-03 09:47:02 +00:00
}
void FormPreferences : : updateFormats ( )
2000-11-08 09:39:46 +00:00
{
formats_vec = formats . GetAllFormats ( ) ;
2000-11-09 15:28:42 +00:00
sort ( formats_vec . begin ( ) , formats_vec . end ( ) , & FormatsCompare ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
// Mustn't forget to update the Formats available to the converters
ConvertersUpdateChoices ( ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
FormatsClear ( ) ;
2000-11-08 09:39:46 +00:00
}
2000-11-09 15:28:42 +00:00
bool FormPreferences : : FormatsAdd ( )
2000-11-08 09:39:46 +00:00
{
string name = fl_get_input ( formats_ - > input_format ) ;
string prettyname = fl_get_input ( formats_ - > input_gui_name ) ;
string extension = fl_get_input ( formats_ - > input_extension ) ;
string shortcut = fl_get_input ( formats_ - > input_shrtcut ) ;
2000-11-09 15:28:42 +00:00
string viewer = fl_get_input ( formats_ - > input_viewer ) ;
2000-11-08 09:39:46 +00:00
if ( prettyname . empty ( ) )
return false ;
Format format ( name , extension , prettyname , shortcut , viewer ) ;
2000-11-10 17:29:47 +00:00
vector < Format > : : iterator it = // non-const; it's modified below
2000-11-08 09:39:46 +00:00
find_if ( formats_vec . begin ( ) , formats_vec . end ( ) ,
compare_memfun ( & Format : : getname , name ) ) ;
2000-11-09 15:28:42 +00:00
fl_freeze_form ( formats_ - > form ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
if ( it = = formats_vec . end ( ) ) {
// Unable to find format. Add to list.
2000-11-08 09:39:46 +00:00
formats_vec . push_back ( format ) ;
2000-11-09 15:28:42 +00:00
sort ( formats_vec . begin ( ) , formats_vec . end ( ) , & FormatsCompare ) ;
// Mustn't forget to update the Formats available to the
// converters
ConvertersUpdateChoices ( ) ;
// Re-create browser
fl_clear_browser ( formats_ - > browser_all ) ;
for ( vector < Format > : : const_iterator cit = formats_vec . begin ( ) ;
cit ! = formats_vec . end ( ) ; + + cit )
fl_addto_browser ( formats_ - > browser_all ,
( * cit ) . name . c_str ( ) ) ;
} else {
// Format found. Modify it.
( * it ) . name = name ;
( * it ) . prettyname = prettyname ;
( * it ) . extension = extension ;
( * it ) . shortcut = shortcut ;
( * it ) . viewer = viewer ;
}
// Clear input
FormatsClear ( ) ;
fl_unfreeze_form ( formats_ - > form ) ;
return true ;
}
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
bool FormPreferences : : FormatsBrowser ( )
{
int i = fl_get_browser ( formats_ - > browser_all ) ;
if ( i < = 0 ) return false ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
fl_freeze_form ( formats_ - > form ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
Format const & f = formats_vec [ i - 1 ] ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
fl_set_input ( formats_ - > input_format , f . name . c_str ( ) ) ;
fl_set_input ( formats_ - > input_gui_name , f . prettyname . c_str ( ) ) ;
fl_set_input ( formats_ - > input_shrtcut , f . shortcut . c_str ( ) ) ;
fl_set_input ( formats_ - > input_extension , f . extension . c_str ( ) ) ;
fl_set_input ( formats_ - > input_viewer , f . viewer . c_str ( ) ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
fl_set_object_label ( formats_ - > button_add , idex ( _ ( " Modify|#M " ) ) ) ;
fl_set_button_shortcut ( formats_ - > button_add , scex ( _ ( " Modify|#M " ) ) , 1 ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
fl_deactivate_object ( formats_ - > button_add ) ;
fl_set_object_lcol ( formats_ - > button_add , FL_INACTIVE ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
fl_activate_object ( formats_ - > button_delete ) ;
fl_set_object_lcol ( formats_ - > button_delete , FL_BLACK ) ;
fl_unfreeze_form ( formats_ - > form ) ;
return false ;
2000-11-08 09:39:46 +00:00
}
2000-11-09 15:28:42 +00:00
void FormPreferences : : FormatsClear ( ) const
2000-11-08 09:39:46 +00:00
{
2000-11-09 15:28:42 +00:00
// Re-create browser
fl_clear_browser ( formats_ - > browser_all ) ;
for ( vector < Format > : : const_iterator cit = formats_vec . begin ( ) ;
cit ! = formats_vec . end ( ) ; + + cit )
fl_addto_browser ( formats_ - > browser_all , ( * cit ) . name . c_str ( ) ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
fl_deselect_browser ( formats_ - > browser_all ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
fl_set_input ( formats_ - > input_format , " " ) ;
fl_set_input ( formats_ - > input_gui_name , " " ) ;
fl_set_input ( formats_ - > input_shrtcut , " " ) ;
fl_set_input ( formats_ - > input_extension , " " ) ;
fl_set_input ( formats_ - > input_viewer , " " ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
fl_set_object_label ( formats_ - > button_add , idex ( _ ( " Add|#A " ) ) ) ;
fl_set_button_shortcut ( formats_ - > button_add , scex ( _ ( " Add|#A " ) ) , 1 ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
fl_deactivate_object ( formats_ - > button_add ) ;
fl_set_object_lcol ( formats_ - > button_add , FL_INACTIVE ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
fl_deactivate_object ( formats_ - > button_delete ) ;
fl_set_object_lcol ( formats_ - > button_delete , FL_INACTIVE ) ;
2000-11-08 09:39:46 +00:00
}
2000-11-09 15:28:42 +00:00
bool FormPreferences : : FormatsDelete ( )
2000-11-08 09:39:46 +00:00
{
2000-11-09 15:28:42 +00:00
string name = fl_get_input ( formats_ - > input_format ) ;
2000-11-10 17:29:47 +00:00
vector < Format > : : iterator it = // non-const; it's modified below
2000-11-08 09:39:46 +00:00
find_if ( formats_vec . begin ( ) , formats_vec . end ( ) ,
compare_memfun ( & Format : : getname , name ) ) ;
2000-11-09 15:28:42 +00:00
fl_freeze_form ( formats_ - > form ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
bool warning = ConvertersContainFormat ( * it ) ;
if ( warning ) {
string str = N_ ( " WARNING! Cannot remove a Format used by a Converter. Remove the converter first. " ) ;
printWarning ( str ) ;
}
if ( it = = formats_vec . end ( ) | | warning ) {
fl_deactivate_object ( formats_ - > button_delete ) ;
fl_set_object_lcol ( formats_ - > button_delete , FL_INACTIVE ) ;
2000-11-08 09:39:46 +00:00
fl_unfreeze_form ( formats_ - > form ) ;
2000-11-09 15:28:42 +00:00
return false ;
2000-11-08 09:39:46 +00:00
}
2000-11-09 15:28:42 +00:00
formats_vec . erase ( it ) ;
FormatsClear ( ) ;
// Mustn't forget to update the Formats available to the converters
ConvertersUpdateChoices ( ) ;
fl_unfreeze_form ( formats_ - > form ) ;
2000-11-08 09:39:46 +00:00
return true ;
}
2000-11-09 15:28:42 +00:00
bool FormPreferences : : FormatsInput ( )
2000-11-08 09:39:46 +00:00
{
2000-11-09 15:28:42 +00:00
string name = fl_get_input ( formats_ - > input_format ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
int sel = 0 ;
if ( ! name . empty ( ) ) {
for ( int i = 0 ;
i < fl_get_browser_maxline ( formats_ - > browser_all ) ; + + i ) {
string str =
fl_get_browser_line ( formats_ - > browser_all ,
i + 1 ) ;
if ( str = = name ) {
sel = i + 1 ;
break ;
}
}
}
2000-11-08 09:39:46 +00:00
fl_freeze_form ( formats_ - > form ) ;
2000-11-09 15:28:42 +00:00
if ( sel = = 0 ) {
2000-11-08 09:39:46 +00:00
fl_set_object_label ( formats_ - > button_add ,
idex ( _ ( " Add|#A " ) ) ) ;
fl_set_button_shortcut ( formats_ - > button_add ,
scex ( _ ( " Add|#A " ) ) , 1 ) ;
if ( name . empty ( ) ) {
fl_deactivate_object ( formats_ - > button_add ) ;
fl_set_object_lcol ( formats_ - > button_add , FL_INACTIVE ) ;
} else {
fl_activate_object ( formats_ - > button_add ) ;
fl_set_object_lcol ( formats_ - > button_add , FL_BLACK ) ;
}
2000-11-09 15:28:42 +00:00
fl_deselect_browser ( formats_ - > browser_all ) ;
2000-11-08 09:39:46 +00:00
fl_deactivate_object ( formats_ - > button_delete ) ;
fl_set_object_lcol ( formats_ - > button_delete , FL_INACTIVE ) ;
} else {
fl_set_object_label ( formats_ - > button_add ,
idex ( _ ( " Modify|#M " ) ) ) ;
fl_set_button_shortcut ( formats_ - > button_add ,
scex ( _ ( " Modify|#M " ) ) , 1 ) ;
2000-11-09 15:28:42 +00:00
int top = sel - 6 ;
2000-11-08 09:39:46 +00:00
if ( top < 1 ) top = 0 ;
2000-11-09 15:28:42 +00:00
fl_set_browser_topline ( formats_ - > browser_all , top ) ;
fl_select_browser_line ( formats_ - > browser_all , sel ) ;
2000-11-08 09:39:46 +00:00
fl_activate_object ( formats_ - > button_add ) ;
fl_set_object_lcol ( formats_ - > button_add , FL_BLACK ) ;
fl_activate_object ( formats_ - > button_delete ) ;
fl_set_object_lcol ( formats_ - > button_delete , FL_BLACK ) ;
}
fl_unfreeze_form ( formats_ - > form ) ;
return true ;
}
2000-11-03 09:47:02 +00:00
2000-11-02 14:47:47 +00:00
void FormPreferences : : applyInputsMisc ( ) const
2000-10-30 11:33:05 +00:00
{
2000-11-04 10:00:12 +00:00
lyxrc . date_insert_format =
fl_get_input ( inputs_misc_ - > input_date_format ) ;
2000-10-30 11:33:05 +00:00
}
void FormPreferences : : buildInputsMisc ( )
{
inputs_misc_ = build_inputs_misc ( ) ;
fl_set_input_return ( inputs_misc_ - > input_date_format ,
FL_RETURN_CHANGED ) ;
2000-10-30 21:53:29 +00:00
// set up the feedback mechanism
2000-11-09 15:28:42 +00:00
setPreHandler ( inputs_misc_ - > input_date_format ) ;
2000-10-30 11:33:05 +00:00
}
2000-11-04 10:00:12 +00:00
string const
FormPreferences : : feedbackInputsMisc ( FL_OBJECT const * const ob ) const
2000-10-30 11:33:05 +00:00
{
string str ;
2000-11-04 10:00:12 +00:00
if ( ob = = inputs_misc_ - > input_date_format )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_DATE_INSERT_FORMAT ) ;
2000-10-30 11:33:05 +00:00
2000-11-02 14:47:47 +00:00
return str ;
2000-10-30 11:33:05 +00:00
}
void FormPreferences : : updateInputsMisc ( )
{
fl_set_input ( inputs_misc_ - > input_date_format ,
lyxrc . date_insert_format . c_str ( ) ) ;
}
2000-11-02 14:47:47 +00:00
void FormPreferences : : applyInterface ( ) const
2000-10-27 10:04:51 +00:00
{
2000-06-12 11:55:12 +00:00
lyxrc . popup_font_name =
2000-10-11 07:59:25 +00:00
fl_get_input ( interface_ - > input_popup_font ) ;
lyxrc . menu_font_name = fl_get_input ( interface_ - > input_menu_font ) ;
2000-08-14 05:24:35 +00:00
lyxrc . font_norm_menu =
2000-10-11 07:59:25 +00:00
fl_get_input ( interface_ - > input_popup_encoding ) ;
lyxrc . bind_file = fl_get_input ( interface_ - > input_bind_file ) ;
lyxrc . ui_file = fl_get_input ( interface_ - > input_ui_file ) ;
2000-10-13 05:57:05 +00:00
lyxrc . override_x_deadkeys =
fl_get_button ( interface_ - > check_override_x_dead_keys ) ;
2000-10-27 10:04:51 +00:00
}
void FormPreferences : : buildInterface ( )
{
interface_ = build_interface ( ) ;
fl_set_input_return ( interface_ - > input_popup_font , FL_RETURN_CHANGED ) ;
fl_set_input_return ( interface_ - > input_menu_font , FL_RETURN_CHANGED ) ;
fl_set_input_return ( interface_ - > input_popup_encoding ,
FL_RETURN_CHANGED ) ;
fl_set_input_return ( interface_ - > input_bind_file , FL_RETURN_CHANGED ) ;
fl_set_input_return ( interface_ - > input_ui_file , FL_RETURN_CHANGED ) ;
// deactivate the browse buttons because they aren't implemented
fl_deactivate_object ( interface_ - > button_bind_file_browse ) ;
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 ) ;
2000-10-30 21:53:29 +00:00
// set up the feedback mechanism
2000-11-09 15:28:42 +00:00
setPreHandler ( interface_ - > input_popup_font ) ;
setPreHandler ( interface_ - > input_menu_font ) ;
setPreHandler ( interface_ - > input_popup_encoding ) ;
setPreHandler ( interface_ - > input_bind_file ) ;
setPreHandler ( interface_ - > button_bind_file_browse ) ;
setPreHandler ( interface_ - > input_ui_file ) ;
setPreHandler ( interface_ - > button_ui_file_browse ) ;
setPreHandler ( interface_ - > check_override_x_dead_keys ) ;
2000-10-27 10:04:51 +00:00
}
2000-11-04 10:00:12 +00:00
string const
FormPreferences : : feedbackInterface ( FL_OBJECT const * const ob ) const
2000-10-27 10:04:51 +00:00
{
string str ;
2000-11-04 10:00:12 +00:00
if ( ob = = interface_ - > input_popup_font )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SCREEN_FONT_POPUP ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = interface_ - > input_menu_font )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SCREEN_FONT_MENU ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = interface_ - > input_popup_encoding )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SCREEN_FONT_ENCODING_MENU ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = interface_ - > input_bind_file )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_BINDFILE ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = interface_ - > input_ui_file )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_UIFILE ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = interface_ - > check_override_x_dead_keys )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_OVERRIDE_X_DEADKEYS ) ;
2000-10-25 10:19:25 +00:00
2000-11-02 14:47:47 +00:00
return str ;
2000-10-27 10:04:51 +00:00
}
2000-10-25 10:19:25 +00:00
2000-10-27 10:04:51 +00:00
void FormPreferences : : updateInterface ( )
{
fl_set_input ( interface_ - > input_popup_font ,
lyxrc . popup_font_name . c_str ( ) ) ;
fl_set_input ( interface_ - > input_menu_font ,
lyxrc . menu_font_name . c_str ( ) ) ;
fl_set_input ( interface_ - > input_popup_encoding ,
lyxrc . font_norm_menu . c_str ( ) ) ;
fl_set_input ( interface_ - > input_bind_file ,
lyxrc . bind_file . c_str ( ) ) ;
fl_set_input ( interface_ - > input_ui_file ,
lyxrc . ui_file . c_str ( ) ) ;
fl_set_button ( interface_ - > check_override_x_dead_keys ,
lyxrc . override_x_deadkeys ) ;
}
2000-11-08 09:39:46 +00:00
void FormPreferences : : applyLanguage ( )
2000-10-30 11:33:05 +00:00
{
2000-10-30 21:53:29 +00:00
lyxrc . default_language = combo_default_lang - > getline ( ) ;
2000-10-30 11:33:05 +00:00
int button = fl_get_button ( language_ - > check_use_kbmap ) ;
2000-11-08 09:39:46 +00:00
string name_1 = combo_kbmap_1 - > getline ( ) ;
string name_2 = combo_kbmap_2 - > getline ( ) ;
if ( button )
button = ( ! name_1 . empty ( ) & & ! name_2 . empty ( ) ) ;
2000-10-30 11:33:05 +00:00
lyxrc . use_kbmap = static_cast < bool > ( button ) ;
2000-11-04 10:00:12 +00:00
if ( button ) {
2000-11-09 15:28:42 +00:00
vector < string > : : const_iterator cit =
2000-11-08 09:39:46 +00:00
find ( dirlist . second . begin ( ) , dirlist . second . end ( ) ,
name_1 ) ;
2000-11-09 15:28:42 +00:00
vector < string > : : size_type sel = cit - dirlist . second . begin ( ) ;
2000-11-08 09:39:46 +00:00
lyxrc . primary_kbmap = dirlist . first [ sel ] ;
2000-11-09 15:28:42 +00:00
cit = find ( dirlist . second . begin ( ) , dirlist . second . end ( ) ,
2000-11-08 09:39:46 +00:00
name_2 ) ;
2000-11-09 15:28:42 +00:00
sel = cit - dirlist . second . begin ( ) ;
2000-11-08 09:39:46 +00:00
lyxrc . secondary_kbmap = dirlist . first [ sel ] ;
2000-10-30 11:33:05 +00:00
}
button = fl_get_button ( language_ - > check_rtl_support ) ;
lyxrc . rtl_support = static_cast < bool > ( button ) ;
button = fl_get_button ( language_ - > check_auto_begin ) ;
lyxrc . language_auto_begin = static_cast < bool > ( button ) ;
button = fl_get_button ( language_ - > check_auto_end ) ;
lyxrc . language_auto_end = static_cast < bool > ( button ) ;
button = fl_get_button ( language_ - > check_mark_foreign ) ;
lyxrc . mark_foreign_language = static_cast < bool > ( button ) ;
lyxrc . language_package = fl_get_input ( language_ - > input_package ) ;
lyxrc . language_command_begin = fl_get_input ( language_ - > input_command_begin ) ;
lyxrc . language_command_end = fl_get_input ( language_ - > input_command_end ) ;
2000-11-08 09:39:46 +00:00
// Ensure that all is self-consistent.
updateLanguage ( ) ;
2000-10-30 11:33:05 +00:00
}
2000-10-27 10:04:51 +00:00
void FormPreferences : : buildLanguage ( )
{
language_ = build_language ( ) ;
2000-10-30 11:33:05 +00:00
fl_set_input_return ( language_ - > input_package , FL_RETURN_CHANGED ) ;
fl_set_input_return ( language_ - > input_command_begin , FL_RETURN_CHANGED ) ;
fl_set_input_return ( language_ - > input_command_end , FL_RETURN_CHANGED ) ;
2000-10-30 21:53:29 +00:00
// The default_language is a combo-box and has to be inserted manually
2000-11-03 09:47:02 +00:00
fl_freeze_form ( language_ - > form ) ;
2000-10-30 21:53:29 +00:00
fl_addto_form ( language_ - > form ) ;
2000-10-30 11:33:05 +00:00
2000-10-30 21:53:29 +00:00
FL_OBJECT * obj = language_ - > choice_default_lang ;
2000-11-03 09:47:02 +00:00
fl_deactivate_object ( language_ - > choice_default_lang ) ;
2000-10-30 21:53:29 +00:00
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 ) ;
2000-11-08 09:39:46 +00:00
for ( Languages : : const_iterator cit = languages . begin ( ) ;
2000-11-09 15:28:42 +00:00
cit ! = languages . end ( ) ; + + cit ) {
2000-11-08 09:39:46 +00:00
combo_default_lang - > addto ( ( * cit ) . second . lang ( ) ) ;
}
2000-10-30 21:53:29 +00:00
// ditto kbmap_1
2000-11-08 09:39:46 +00:00
string dir = AddPath ( system_lyxdir , " kbd " ) ;
2000-11-09 15:28:42 +00:00
dirlist . first = DirList ( dir , " kmap " ) ;
for ( vector < string > : : const_iterator cit = dirlist . first . begin ( ) ;
cit ! = dirlist . first . end ( ) ; + + cit ) {
string name = ChangeExtension ( OnlyFilename ( * cit ) , " " ) ;
dirlist . second . push_back ( name ) ;
}
2000-11-08 09:39:46 +00:00
2000-10-30 21:53:29 +00:00
obj = language_ - > choice_kbmap_1 ;
2000-11-03 09:47:02 +00:00
fl_deactivate_object ( language_ - > choice_kbmap_1 ) ;
2000-10-30 21:53:29 +00:00
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 ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
for ( vector < string > : : const_iterator cit = dirlist . second . begin ( ) ;
cit ! = dirlist . second . end ( ) ; + + cit ) {
2000-11-08 09:39:46 +00:00
combo_kbmap_1 - > addto ( * cit ) ;
}
2000-10-30 21:53:29 +00:00
// ditto kbmap_2
obj = language_ - > choice_kbmap_2 ;
2000-11-03 09:47:02 +00:00
fl_deactivate_object ( language_ - > choice_kbmap_2 ) ;
2000-10-30 21:53:29 +00:00
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 ) ;
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
for ( vector < string > : : const_iterator cit = dirlist . second . begin ( ) ;
cit ! = dirlist . second . end ( ) ; + + cit ) {
2000-11-08 09:39:46 +00:00
combo_kbmap_2 - > addto ( * cit ) ;
}
2000-10-30 21:53:29 +00:00
fl_end_form ( ) ;
2000-11-03 09:47:02 +00:00
fl_unfreeze_form ( language_ - > form ) ;
2000-10-30 21:53:29 +00:00
// set up the feedback mechanism
2000-11-09 15:28:42 +00:00
setPreHandler ( language_ - > input_package ) ;
setPreHandler ( language_ - > check_use_kbmap ) ;
2000-10-30 21:53:29 +00:00
2000-11-02 14:47:47 +00:00
// This is safe, as nothing is done to the pointer, other than
// to use its address in a block-if statement.
2000-11-09 15:28:42 +00:00
//setPreHandler( reinterpret_cast<FL_OBJECT *>(combo_default_lang) );
//setPreHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_1) );
//setPreHandler( reinterpret_cast<FL_OBJECT *>(combo_kbmap_2) );
2000-10-30 21:53:29 +00:00
2000-11-09 15:28:42 +00:00
setPreHandler ( language_ - > check_rtl_support ) ;
setPreHandler ( language_ - > check_mark_foreign ) ;
setPreHandler ( language_ - > check_auto_begin ) ;
setPreHandler ( language_ - > check_auto_end ) ;
setPreHandler ( language_ - > input_command_begin ) ;
setPreHandler ( language_ - > input_command_end ) ;
2000-11-08 09:39:46 +00:00
// Activate/Deactivate the input fields dependent on the state of the
// buttons.
inputLanguage ( 0 ) ;
2000-10-30 21:53:29 +00:00
}
2000-11-04 10:00:12 +00:00
string const
FormPreferences : : feedbackLanguage ( FL_OBJECT const * const ob ) const
2000-10-30 11:33:05 +00:00
{
string str ;
2000-11-04 10:00:12 +00:00
if ( reinterpret_cast < Combox const * > ( ob ) = = combo_default_lang )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_DEFAULT_LANGUAGE ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = language_ - > check_use_kbmap )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_KBMAP ) ;
2000-11-04 10:00:12 +00:00
else if ( reinterpret_cast < Combox const * > ( ob ) = = combo_kbmap_1 )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_KBMAP_PRIMARY ) ;
2000-11-04 10:00:12 +00:00
else if ( reinterpret_cast < Combox const * > ( ob ) = = combo_kbmap_2 )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_KBMAP_SECONDARY ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = language_ - > check_rtl_support )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_RTL_SUPPORT ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = language_ - > check_auto_begin )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_LANGUAGE_AUTO_BEGIN ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = language_ - > check_auto_end )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_LANGUAGE_AUTO_END ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = language_ - > check_mark_foreign )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_MARK_FOREIGN_LANGUAGE ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = language_ - > input_package )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_LANGUAGE_PACKAGE ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = language_ - > input_command_begin )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_LANGUAGE_COMMAND_BEGIN ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = language_ - > input_command_end )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_LANGUAGE_COMMAND_END ) ;
2000-10-30 11:33:05 +00:00
2000-11-02 14:47:47 +00:00
return str ;
2000-10-30 11:33:05 +00:00
}
bool FormPreferences : : inputLanguage ( FL_OBJECT const * const ob )
{
bool activate = true ;
2000-10-30 21:53:29 +00:00
2000-11-09 15:28:42 +00:00
// !ob if function is called from buildLanguage() to de/activate
// objects,
// otherwise the function is called by an xforms CB via input().
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = language_ - > check_use_kbmap ) {
if ( fl_get_button ( language_ - > check_use_kbmap ) ) {
2000-10-30 21:53:29 +00:00
combo_kbmap_1 - > activate ( ) ;
combo_kbmap_2 - > activate ( ) ;
2000-10-30 11:33:05 +00:00
} else {
2000-10-30 21:53:29 +00:00
combo_kbmap_1 - > deactivate ( ) ;
combo_kbmap_2 - > deactivate ( ) ;
2000-10-30 11:33:05 +00:00
}
}
return activate ;
}
void FormPreferences : : updateLanguage ( )
{
fl_set_button ( language_ - > check_use_kbmap ,
lyxrc . use_kbmap ) ;
2000-10-30 21:53:29 +00:00
combo_default_lang - > select_text ( lyxrc . default_language ) ;
2000-10-30 11:33:05 +00:00
2000-11-04 10:00:12 +00:00
if ( lyxrc . use_kbmap ) {
2000-11-08 09:39:46 +00:00
string fullpath = lyxrc . primary_kbmap ;
2000-11-09 15:28:42 +00:00
vector < string > : : const_iterator cit =
2000-11-08 09:39:46 +00:00
find ( dirlist . first . begin ( ) , dirlist . first . end ( ) ,
fullpath ) ;
2000-11-09 15:28:42 +00:00
if ( cit ! = dirlist . first . end ( ) ) {
2000-11-10 17:29:47 +00:00
vector < string > : : size_type sel =
cit - dirlist . first . begin ( ) ;
combo_kbmap_1 - > select_text ( dirlist . second [ sel ] ) ;
2000-11-09 15:28:42 +00:00
} else
combo_kbmap_1 - > select_text ( " " ) ;
2000-11-08 09:39:46 +00:00
fullpath = lyxrc . secondary_kbmap ;
2000-11-09 15:28:42 +00:00
cit = find ( dirlist . first . begin ( ) , dirlist . first . end ( ) ,
2000-11-08 09:39:46 +00:00
fullpath ) ;
2000-11-09 15:28:42 +00:00
if ( cit ! = dirlist . first . end ( ) ) {
2000-11-10 17:29:47 +00:00
vector < string > : : size_type sel =
cit - dirlist . first . begin ( ) ;
combo_kbmap_2 - > select_text ( dirlist . second [ sel ] ) ;
2000-11-09 15:28:42 +00:00
} else
2000-11-10 17:29:47 +00:00
combo_kbmap_2 - > select_text ( " " ) ;
2000-10-30 21:53:29 +00:00
} else {
2000-11-08 09:39:46 +00:00
combo_kbmap_1 - > select_text ( " " ) ;
combo_kbmap_2 - > select_text ( " " ) ;
2000-10-30 21:53:29 +00:00
}
2000-10-30 11:33:05 +00:00
fl_set_button ( language_ - > check_rtl_support , lyxrc . rtl_support ) ;
fl_set_button ( language_ - > check_auto_begin , lyxrc . language_auto_begin ) ;
fl_set_button ( language_ - > check_auto_end , lyxrc . language_auto_end ) ;
fl_set_button ( language_ - > check_mark_foreign ,
lyxrc . mark_foreign_language ) ;
fl_set_input ( language_ - > input_package ,
lyxrc . language_package . c_str ( ) ) ;
fl_set_input ( language_ - > input_command_begin ,
lyxrc . language_command_begin . c_str ( ) ) ;
fl_set_input ( language_ - > input_command_end ,
lyxrc . language_command_end . c_str ( ) ) ;
// Activate/Deactivate the input fields dependent on the state of the
// buttons.
inputLanguage ( 0 ) ;
2000-10-27 10:04:51 +00:00
}
2000-11-02 14:47:47 +00:00
void FormPreferences : : applyLnFmisc ( ) const
2000-10-27 10:04:51 +00:00
{
lyxrc . show_banner = fl_get_button ( lnf_misc_ - > check_banner ) ;
lyxrc . auto_region_delete = fl_get_button ( lnf_misc_ - >
check_auto_region_delete ) ;
lyxrc . exit_confirmation = fl_get_button ( lnf_misc_ - > check_exit_confirm ) ;
lyxrc . display_shortcuts =
2000-11-08 09:39:46 +00:00
fl_get_button ( lnf_misc_ - > check_display_shrtcuts ) ;
2000-10-27 10:04:51 +00:00
lyxrc . new_ask_filename = fl_get_button ( lnf_misc_ - > check_ask_new_file ) ;
lyxrc . cursor_follows_scrollbar =
fl_get_button ( lnf_misc_ - > check_cursor_follows_scrollbar ) ;
lyxrc . autosave = static_cast < unsigned int >
( fl_get_counter_value ( lnf_misc_ - > counter_autosave ) ) ;
lyxrc . wheel_jump = static_cast < unsigned int >
( fl_get_counter_value ( lnf_misc_ - > counter_wm_jump ) ) ;
}
void FormPreferences : : buildLnFmisc ( )
{
lnf_misc_ = build_lnf_misc ( ) ;
fl_set_counter_return ( lnf_misc_ - > counter_autosave ,
FL_RETURN_CHANGED ) ;
fl_set_counter_return ( lnf_misc_ - > counter_wm_jump ,
FL_RETURN_CHANGED ) ;
2000-10-30 21:53:29 +00:00
// set up the feedback mechanism
2000-11-09 15:28:42 +00:00
setPreHandler ( lnf_misc_ - > check_banner ) ;
setPreHandler ( lnf_misc_ - > check_auto_region_delete ) ;
setPreHandler ( lnf_misc_ - > check_exit_confirm ) ;
setPreHandler ( lnf_misc_ - > check_display_shrtcuts ) ;
setPreHandler ( lnf_misc_ - > counter_autosave ) ;
setPreHandler ( lnf_misc_ - > check_ask_new_file ) ;
setPreHandler ( lnf_misc_ - > check_cursor_follows_scrollbar ) ;
setPreHandler ( lnf_misc_ - > counter_wm_jump ) ;
2000-10-27 10:04:51 +00:00
}
2000-11-04 10:00:12 +00:00
string const FormPreferences : : feedbackLnFmisc ( FL_OBJECT const * const ob ) const
2000-10-27 10:04:51 +00:00
{
string str ;
2000-11-04 10:00:12 +00:00
if ( ob = = lnf_misc_ - > check_banner )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SHOW_BANNER ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = lnf_misc_ - > check_auto_region_delete )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_AUTOREGIONDELETE ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = lnf_misc_ - > check_exit_confirm )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_EXIT_CONFIRMATION ) ;
2000-11-08 09:39:46 +00:00
else if ( ob = = lnf_misc_ - > check_display_shrtcuts )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_DISPLAY_SHORTCUTS ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = lnf_misc_ - > check_ask_new_file )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_NEW_ASK_FILENAME ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = lnf_misc_ - > check_cursor_follows_scrollbar )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_CURSOR_FOLLOWS_SCROLLBAR ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = lnf_misc_ - > counter_autosave )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_AUTOSAVE ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = lnf_misc_ - > counter_wm_jump )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_WHEEL_JUMP ) ;
2000-10-30 21:53:29 +00:00
2000-11-02 14:47:47 +00:00
return str ;
2000-10-27 10:04:51 +00:00
}
2000-11-04 10:00:12 +00:00
2000-10-27 10:04:51 +00:00
void FormPreferences : : updateLnFmisc ( )
{
fl_set_button ( lnf_misc_ - > check_banner ,
lyxrc . show_banner ) ;
fl_set_button ( lnf_misc_ - > check_auto_region_delete ,
lyxrc . auto_region_delete ) ;
fl_set_button ( lnf_misc_ - > check_exit_confirm ,
lyxrc . exit_confirmation ) ;
2000-11-08 09:39:46 +00:00
fl_set_button ( lnf_misc_ - > check_display_shrtcuts ,
2000-10-27 10:04:51 +00:00
lyxrc . display_shortcuts ) ;
fl_set_button ( lnf_misc_ - > check_ask_new_file ,
lyxrc . new_ask_filename ) ;
fl_set_button ( lnf_misc_ - > check_cursor_follows_scrollbar ,
lyxrc . cursor_follows_scrollbar ) ;
fl_set_counter_value ( lnf_misc_ - > counter_autosave ,
lyxrc . autosave ) ;
fl_set_counter_value ( lnf_misc_ - > counter_wm_jump ,
lyxrc . wheel_jump ) ;
}
2000-11-02 14:47:47 +00:00
void FormPreferences : : applyOutputsMisc ( ) const
2000-10-27 10:04:51 +00:00
{
lyxrc . ascii_linelen = static_cast < unsigned int >
( fl_get_counter_value ( outputs_misc_ - > counter_line_len ) ) ;
lyxrc . fontenc = fl_get_input ( outputs_misc_ - > input_tex_encoding ) ;
int choice =
fl_get_choice ( outputs_misc_ - > choice_default_papersize ) - 1 ;
lyxrc . default_papersize = static_cast < BufferParams : : PAPER_SIZE > ( choice ) ;
2000-10-30 11:33:05 +00:00
lyxrc . ascii_roff_command = fl_get_input ( outputs_misc_ - > input_ascii_roff ) ;
lyxrc . chktex_command = fl_get_input ( outputs_misc_ - > input_checktex ) ;
2000-10-27 10:04:51 +00:00
}
void FormPreferences : : buildOutputsMisc ( )
{
outputs_misc_ = build_outputs_misc ( ) ;
fl_set_counter_return ( outputs_misc_ - > counter_line_len ,
FL_RETURN_CHANGED ) ;
fl_set_input_return ( outputs_misc_ - > input_tex_encoding ,
FL_RETURN_CHANGED ) ;
2000-10-30 11:33:05 +00:00
fl_set_input_return ( outputs_misc_ - > input_ascii_roff ,
FL_RETURN_CHANGED ) ;
fl_set_input_return ( outputs_misc_ - > input_checktex ,
FL_RETURN_CHANGED ) ;
2000-10-27 10:04:51 +00:00
fl_addto_choice ( outputs_misc_ - > choice_default_papersize ,
_ ( " default | US letter | legal | executive | A3 | A4 | A5 | B5 " ) ) ;
2000-10-30 21:53:29 +00:00
// set up the feedback mechanism
2000-11-09 15:28:42 +00:00
setPreHandler ( outputs_misc_ - > counter_line_len ) ;
setPreHandler ( outputs_misc_ - > input_tex_encoding ) ;
setPreHandler ( outputs_misc_ - > choice_default_papersize ) ;
setPreHandler ( outputs_misc_ - > input_ascii_roff ) ;
setPreHandler ( outputs_misc_ - > input_checktex ) ;
2000-10-27 10:04:51 +00:00
}
2000-11-04 10:00:12 +00:00
string const
FormPreferences : : feedbackOutputsMisc ( FL_OBJECT const * const ob ) const
2000-10-27 10:04:51 +00:00
{
string str ;
2000-11-04 10:00:12 +00:00
if ( ob = = outputs_misc_ - > counter_line_len )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_ASCII_LINELEN ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = outputs_misc_ - > input_tex_encoding )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_FONT_ENCODING ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = outputs_misc_ - > input_ascii_roff )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_ASCIIROFF_COMMAND ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = outputs_misc_ - > input_checktex )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_CHKTEX_COMMAND ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = outputs_misc_ - > choice_default_papersize )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_DEFAULT_PAPERSIZE ) ;
2000-10-30 21:53:29 +00:00
2000-11-02 14:47:47 +00:00
return str ;
2000-10-27 10:04:51 +00:00
}
void FormPreferences : : updateOutputsMisc ( )
{
fl_set_counter_value ( outputs_misc_ - > counter_line_len ,
lyxrc . ascii_linelen ) ;
fl_set_input ( outputs_misc_ - > input_tex_encoding ,
lyxrc . fontenc . c_str ( ) ) ;
fl_set_choice ( outputs_misc_ - > choice_default_papersize ,
lyxrc . default_papersize + 1 ) ;
2000-10-30 11:33:05 +00:00
fl_set_input ( outputs_misc_ - > input_ascii_roff ,
lyxrc . ascii_roff_command . c_str ( ) ) ;
fl_set_input ( outputs_misc_ - > input_checktex ,
lyxrc . chktex_command . c_str ( ) ) ;
2000-10-27 10:04:51 +00:00
}
void FormPreferences : : applyPaths ( )
{
lyxrc . document_path = fl_get_input ( paths_ - > input_default_path ) ;
lyxrc . template_path = fl_get_input ( paths_ - > input_template_path ) ;
int button = fl_get_button ( paths_ - > check_use_temp_dir ) ;
string str = fl_get_input ( paths_ - > input_temp_dir ) ;
2000-11-04 10:00:12 +00:00
if ( ! button ) str . erase ( ) ;
2000-10-27 10:04:51 +00:00
lyxrc . use_tempdir = button ;
lyxrc . tempdir_path = str ;
button = fl_get_button ( paths_ - > check_last_files ) ;
str = fl_get_input ( paths_ - > input_lastfiles ) ;
2000-11-04 10:00:12 +00:00
if ( ! button ) str . erase ( ) ;
2000-10-27 10:04:51 +00:00
lyxrc . check_lastfiles = button ;
lyxrc . lastfiles = str ;
lyxrc . num_lastfiles = static_cast < unsigned int >
( fl_get_counter_value ( paths_ - > counter_lastfiles ) ) ;
button = fl_get_button ( paths_ - > check_make_backups ) ;
str = fl_get_input ( paths_ - > input_backup_path ) ;
2000-11-04 10:00:12 +00:00
if ( ! button ) str . erase ( ) ;
2000-10-27 10:04:51 +00:00
lyxrc . make_backup = button ;
lyxrc . backupdir_path = str ;
lyxrc . lyxpipes = fl_get_input ( paths_ - > input_serverpipe ) ;
// update view
updatePaths ( ) ;
}
void FormPreferences : : buildPaths ( )
{
paths_ = build_paths ( ) ;
fl_set_input_return ( paths_ - > input_default_path , FL_RETURN_CHANGED ) ;
fl_set_input_return ( paths_ - > input_template_path , FL_RETURN_CHANGED ) ;
fl_set_input_return ( paths_ - > input_temp_dir , FL_RETURN_CHANGED ) ;
fl_set_input_return ( paths_ - > input_lastfiles , FL_RETURN_CHANGED ) ;
fl_set_input_return ( paths_ - > input_backup_path , FL_RETURN_CHANGED ) ;
fl_set_counter_return ( paths_ - > counter_lastfiles , FL_RETURN_CHANGED ) ;
fl_set_input_return ( paths_ - > input_serverpipe , FL_RETURN_CHANGED ) ;
// deactivate the browse buttons because they aren't implemented
fl_deactivate_object ( paths_ - > button_document_browse ) ;
fl_deactivate_object ( paths_ - > button_template_browse ) ;
fl_deactivate_object ( paths_ - > button_temp_dir_browse ) ;
fl_deactivate_object ( paths_ - > button_lastfiles_browse ) ;
fl_deactivate_object ( paths_ - > button_backup_path_browse ) ;
fl_deactivate_object ( paths_ - > button_serverpipe_browse ) ;
fl_set_object_lcol ( paths_ - > button_document_browse , FL_INACTIVE ) ;
fl_set_object_lcol ( paths_ - > button_template_browse , FL_INACTIVE ) ;
fl_set_object_lcol ( paths_ - > button_temp_dir_browse , FL_INACTIVE ) ;
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 ) ;
2000-10-30 21:53:29 +00:00
// set up the feedback mechanism
2000-11-09 15:28:42 +00:00
setPreHandler ( paths_ - > input_default_path ) ;
setPreHandler ( paths_ - > button_document_browse ) ;
setPreHandler ( paths_ - > counter_lastfiles ) ;
setPreHandler ( paths_ - > input_template_path ) ;
setPreHandler ( paths_ - > button_template_browse ) ;
setPreHandler ( paths_ - > check_last_files ) ;
setPreHandler ( paths_ - > button_temp_dir_browse ) ;
setPreHandler ( paths_ - > input_lastfiles ) ;
setPreHandler ( paths_ - > button_lastfiles_browse ) ;
setPreHandler ( paths_ - > check_make_backups ) ;
setPreHandler ( paths_ - > input_backup_path ) ;
setPreHandler ( paths_ - > button_backup_path_browse ) ;
setPreHandler ( paths_ - > input_serverpipe ) ;
setPreHandler ( paths_ - > button_serverpipe_browse ) ;
setPreHandler ( paths_ - > input_temp_dir ) ;
setPreHandler ( paths_ - > check_use_temp_dir ) ;
2000-10-27 10:04:51 +00:00
}
2000-11-04 10:00:12 +00:00
string const FormPreferences : : feedbackPaths ( FL_OBJECT const * const ob ) const
2000-10-27 10:04:51 +00:00
{
string str ;
2000-11-02 14:47:47 +00:00
2000-11-04 10:00:12 +00:00
if ( ob = = paths_ - > input_default_path )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_DOCUMENTPATH ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = paths_ - > input_template_path )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_TEMPLATEPATH ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = paths_ - > check_use_temp_dir )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_USETEMPDIR ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = paths_ - > input_temp_dir )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_TEMPDIRPATH ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = paths_ - > check_last_files )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_CHECKLASTFILES ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = paths_ - > input_lastfiles )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_LASTFILES ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = paths_ - > counter_lastfiles )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_NUMLASTFILES ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = paths_ - > check_make_backups )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_MAKE_BACKUP ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = paths_ - > input_backup_path )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_BACKUPDIR_PATH ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = paths_ - > input_serverpipe )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SERVERPIPE ) ;
return str ;
2000-10-27 10:04:51 +00:00
}
bool FormPreferences : : inputPaths ( FL_OBJECT const * const ob )
{
bool activate = true ;
2000-11-09 15:28:42 +00:00
// !ob if function is called from updatePaths() to de/activate objects,
// otherwise the function is called by an xforms CB via input().
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = paths_ - > check_use_temp_dir ) {
if ( fl_get_button ( paths_ - > check_use_temp_dir ) ) {
2000-10-27 10:04:51 +00:00
fl_activate_object ( paths_ - > input_temp_dir ) ;
fl_set_object_lcol ( paths_ - > input_temp_dir ,
FL_BLACK ) ;
} else {
fl_deactivate_object ( paths_ - > input_temp_dir ) ;
fl_set_object_lcol ( paths_ - > input_temp_dir ,
FL_INACTIVE ) ;
}
}
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = paths_ - > check_last_files ) {
if ( fl_get_button ( paths_ - > check_last_files ) ) {
2000-10-27 10:04:51 +00:00
fl_activate_object ( paths_ - > input_lastfiles ) ;
fl_set_object_lcol ( paths_ - > input_lastfiles ,
FL_BLACK ) ;
} else {
fl_deactivate_object ( paths_ - > input_lastfiles ) ;
fl_set_object_lcol ( paths_ - > input_lastfiles ,
FL_INACTIVE ) ;
}
}
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = paths_ - > check_make_backups ) {
if ( fl_get_button ( paths_ - > check_make_backups ) ) {
2000-10-27 10:04:51 +00:00
fl_activate_object ( paths_ - > input_backup_path ) ;
fl_set_object_lcol ( paths_ - > input_backup_path ,
FL_BLACK ) ;
} else {
fl_deactivate_object ( paths_ - > input_backup_path ) ;
fl_set_object_lcol ( paths_ - > input_backup_path ,
FL_INACTIVE ) ;
}
}
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = paths_ - > input_default_path ) {
2000-10-27 10:04:51 +00:00
string name = fl_get_input ( paths_ - > input_default_path ) ;
2000-11-04 10:00:12 +00:00
if ( ! WriteableDir ( name ) )
2000-10-27 10:04:51 +00:00
return false ;
}
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = paths_ - > input_template_path ) {
2000-10-27 10:04:51 +00:00
string name = fl_get_input ( paths_ - > input_template_path ) ;
2000-11-04 10:00:12 +00:00
if ( ! ReadableDir ( name ) )
2000-10-27 10:04:51 +00:00
return false ;
}
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = paths_ - > input_temp_dir ) {
2000-10-27 10:04:51 +00:00
string name = fl_get_input ( paths_ - > input_temp_dir ) ;
2000-11-04 10:00:12 +00:00
if ( fl_get_button ( paths_ - > check_make_backups )
2000-10-27 10:04:51 +00:00
& & ! name . empty ( )
& & ! WriteableDir ( name ) )
return false ;
}
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = paths_ - > input_backup_path ) {
2000-10-27 10:04:51 +00:00
string name = fl_get_input ( paths_ - > input_backup_path ) ;
2000-11-04 10:00:12 +00:00
if ( fl_get_button ( paths_ - > check_make_backups )
2000-10-27 10:04:51 +00:00
& & ! name . empty ( )
& & ! WriteableDir ( name ) )
return false ;
}
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = paths_ - > input_lastfiles ) {
2000-10-27 10:04:51 +00:00
string name = fl_get_input ( paths_ - > input_lastfiles ) ;
2000-11-04 10:00:12 +00:00
if ( fl_get_button ( paths_ - > check_last_files )
2000-10-27 10:04:51 +00:00
& & ! name . empty ( )
& & ! WriteableFile ( name ) )
return false ;
}
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = paths_ - > input_serverpipe ) {
2000-10-27 10:04:51 +00:00
string name = fl_get_input ( paths_ - > input_serverpipe ) ;
2000-11-04 10:00:12 +00:00
if ( ! name . empty ( ) ) {
if ( ! WriteableFile ( name , " .in " ) )
2000-10-27 10:04:51 +00:00
return false ;
2000-11-04 10:00:12 +00:00
if ( ! WriteableFile ( name , " .out " ) )
2000-10-27 10:04:51 +00:00
return false ;
}
}
return activate ;
}
void FormPreferences : : updatePaths ( )
{
fl_set_input ( paths_ - > input_default_path ,
lyxrc . document_path . c_str ( ) ) ;
fl_set_input ( paths_ - > input_template_path ,
lyxrc . template_path . c_str ( ) ) ;
2000-11-04 10:00:12 +00:00
string str ;
if ( lyxrc . make_backup ) str = lyxrc . backupdir_path ;
2000-10-27 10:04:51 +00:00
fl_set_button ( paths_ - > check_make_backups ,
lyxrc . make_backup ) ;
fl_set_input ( paths_ - > input_backup_path , str . c_str ( ) ) ;
str . erase ( ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . use_tempdir ) str = lyxrc . tempdir_path ;
2000-10-27 10:04:51 +00:00
fl_set_button ( paths_ - > check_use_temp_dir ,
lyxrc . use_tempdir ) ;
fl_set_input ( paths_ - > input_temp_dir , str . c_str ( ) ) ;
str . erase ( ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . check_lastfiles ) str = lyxrc . lastfiles ;
2000-10-27 10:04:51 +00:00
fl_set_button ( paths_ - > check_last_files ,
lyxrc . check_lastfiles ) ;
fl_set_input ( paths_ - > input_lastfiles , str . c_str ( ) ) ;
fl_set_counter_value ( paths_ - > counter_lastfiles ,
lyxrc . num_lastfiles ) ;
fl_set_input ( paths_ - > input_serverpipe , lyxrc . lyxpipes . c_str ( ) ) ;
// Activate/Deactivate the input fields dependent on the state of the
// buttons.
inputPaths ( 0 ) ;
}
2000-11-02 14:47:47 +00:00
void FormPreferences : : applyPrinter ( ) const
2000-10-27 10:04:51 +00:00
{
lyxrc . print_adapt_output = fl_get_button ( printer_ - > check_adapt_output ) ;
lyxrc . print_command = fl_get_input ( printer_ - > input_command ) ;
lyxrc . print_pagerange_flag = fl_get_input ( printer_ - > input_page_range ) ;
lyxrc . print_copies_flag = fl_get_input ( printer_ - > input_copies ) ;
lyxrc . print_reverse_flag = fl_get_input ( printer_ - > input_reverse ) ;
lyxrc . print_to_printer = fl_get_input ( printer_ - > input_to_printer ) ;
lyxrc . print_file_extension =
fl_get_input ( printer_ - > input_file_extension ) ;
lyxrc . print_spool_command =
fl_get_input ( printer_ - > input_spool_command ) ;
lyxrc . print_paper_flag = fl_get_input ( printer_ - > input_paper_type ) ;
lyxrc . print_evenpage_flag = fl_get_input ( printer_ - > input_even_pages ) ;
lyxrc . print_oddpage_flag = fl_get_input ( printer_ - > input_odd_pages ) ;
lyxrc . print_collcopies_flag = fl_get_input ( printer_ - > input_collated ) ;
lyxrc . print_landscape_flag = fl_get_input ( printer_ - > input_landscape ) ;
lyxrc . print_to_file = fl_get_input ( printer_ - > input_to_file ) ;
lyxrc . print_extra_options =
fl_get_input ( printer_ - > input_extra_options ) ;
lyxrc . print_spool_printerprefix =
fl_get_input ( printer_ - > input_spool_prefix ) ;
lyxrc . print_paper_dimension_flag =
fl_get_input ( printer_ - > input_paper_size ) ;
lyxrc . printer = fl_get_input ( printer_ - > input_name ) ;
}
2000-11-08 09:39:46 +00:00
string const
FormPreferences : : feedbackPrinter ( FL_OBJECT const * const ob ) const
2000-10-27 10:04:51 +00:00
{
string str ;
2000-11-04 10:00:12 +00:00
if ( ob = = printer_ - > input_command )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINT_COMMAND ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > check_adapt_output )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINT_ADAPTOUTPUT ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_to_printer )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTTOPRINTER ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_to_file )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTTOFILE ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_file_extension )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTFILEEXTENSION ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_extra_options )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTEXSTRAOPTIONS ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_spool_command )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTSPOOL_COMMAND ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_spool_prefix )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTSPOOL_PRINTERPREFIX ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_name )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTER ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_even_pages )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTEVENPAGEFLAG ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_odd_pages )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTODDPAGEFLAG ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_page_range )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTPAGERANGEFLAG ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_reverse )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTREVERSEFLAG ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_landscape )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTLANDSCAPEFLAG ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_copies )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTCOLLCOPIESFLAG ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_collated )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTCOPIESFLAG ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_paper_type )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTPAPERFLAG ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = printer_ - > input_paper_size )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PRINTPAPERDIMENSIONFLAG ) ;
return str ;
2000-10-27 10:04:51 +00:00
}
void FormPreferences : : buildPrinter ( )
{
printer_ = build_printer ( ) ;
fl_set_input_return ( printer_ - > input_command , FL_RETURN_CHANGED ) ;
fl_set_input_return ( printer_ - > input_page_range , FL_RETURN_CHANGED ) ;
fl_set_input_return ( printer_ - > input_copies , FL_RETURN_CHANGED ) ;
fl_set_input_return ( printer_ - > input_reverse , FL_RETURN_CHANGED ) ;
fl_set_input_return ( printer_ - > input_to_printer , FL_RETURN_CHANGED ) ;
fl_set_input_return ( printer_ - > input_file_extension , FL_RETURN_CHANGED ) ;
fl_set_input_return ( printer_ - > input_spool_command , FL_RETURN_CHANGED ) ;
fl_set_input_return ( printer_ - > input_paper_type , FL_RETURN_CHANGED ) ;
fl_set_input_return ( printer_ - > input_even_pages , FL_RETURN_CHANGED ) ;
fl_set_input_return ( printer_ - > input_odd_pages , FL_RETURN_CHANGED ) ;
fl_set_input_return ( printer_ - > input_collated , FL_RETURN_CHANGED ) ;
fl_set_input_return ( printer_ - > input_landscape , FL_RETURN_CHANGED ) ;
fl_set_input_return ( printer_ - > input_to_file , FL_RETURN_CHANGED ) ;
fl_set_input_return ( printer_ - > input_extra_options , FL_RETURN_CHANGED ) ;
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 ) ;
2000-10-30 21:53:29 +00:00
// set up the feedback mechanism
2000-11-09 15:28:42 +00:00
setPreHandler ( printer_ - > input_command ) ;
setPreHandler ( printer_ - > input_page_range ) ;
setPreHandler ( printer_ - > input_copies ) ;
setPreHandler ( printer_ - > input_reverse ) ;
setPreHandler ( printer_ - > input_to_printer ) ;
setPreHandler ( printer_ - > input_file_extension ) ;
setPreHandler ( printer_ - > input_spool_command ) ;
setPreHandler ( printer_ - > input_paper_type ) ;
setPreHandler ( printer_ - > input_even_pages ) ;
setPreHandler ( printer_ - > input_odd_pages ) ;
setPreHandler ( printer_ - > input_collated ) ;
setPreHandler ( printer_ - > input_landscape ) ;
setPreHandler ( printer_ - > input_to_file ) ;
setPreHandler ( printer_ - > input_extra_options ) ;
setPreHandler ( printer_ - > input_spool_prefix ) ;
setPreHandler ( printer_ - > input_paper_size ) ;
setPreHandler ( printer_ - > input_name ) ;
setPreHandler ( printer_ - > check_adapt_output ) ;
2000-10-27 10:04:51 +00:00
}
void FormPreferences : : updatePrinter ( )
{
fl_set_button ( printer_ - > check_adapt_output ,
lyxrc . print_adapt_output ) ;
fl_set_input ( printer_ - > input_command ,
lyxrc . print_command . c_str ( ) ) ;
fl_set_input ( printer_ - > input_page_range ,
lyxrc . print_pagerange_flag . c_str ( ) ) ;
fl_set_input ( printer_ - > input_copies ,
lyxrc . print_copies_flag . c_str ( ) ) ;
fl_set_input ( printer_ - > input_reverse ,
lyxrc . print_reverse_flag . c_str ( ) ) ;
fl_set_input ( printer_ - > input_to_printer ,
lyxrc . print_to_printer . c_str ( ) ) ;
fl_set_input ( printer_ - > input_file_extension ,
lyxrc . print_file_extension . c_str ( ) ) ;
fl_set_input ( printer_ - > input_spool_command ,
lyxrc . print_spool_command . c_str ( ) ) ;
fl_set_input ( printer_ - > input_paper_type ,
lyxrc . print_paper_flag . c_str ( ) ) ;
fl_set_input ( printer_ - > input_even_pages ,
lyxrc . print_evenpage_flag . c_str ( ) ) ;
fl_set_input ( printer_ - > input_odd_pages ,
lyxrc . print_oddpage_flag . c_str ( ) ) ;
fl_set_input ( printer_ - > input_collated ,
lyxrc . print_collcopies_flag . c_str ( ) ) ;
fl_set_input ( printer_ - > input_landscape ,
lyxrc . print_landscape_flag . c_str ( ) ) ;
fl_set_input ( printer_ - > input_to_file ,
lyxrc . print_to_file . c_str ( ) ) ;
fl_set_input ( printer_ - > input_extra_options ,
lyxrc . print_extra_options . c_str ( ) ) ;
fl_set_input ( printer_ - > input_spool_prefix ,
lyxrc . print_spool_printerprefix . c_str ( ) ) ;
fl_set_input ( printer_ - > input_paper_size ,
lyxrc . print_paper_dimension_flag . c_str ( ) ) ;
fl_set_input ( printer_ - > input_name ,
lyxrc . printer . c_str ( ) ) ;
}
2000-11-02 14:47:47 +00:00
void FormPreferences : : applyScreenFonts ( ) const
2000-10-27 10:04:51 +00:00
{
bool changed = false ;
string str = fl_get_input ( screen_fonts_ - > input_roman ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . roman_font_name ! = str ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . roman_font_name = str ;
}
str = fl_get_input ( screen_fonts_ - > input_sans ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . sans_font_name ! = str ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . sans_font_name = str ;
}
str = fl_get_input ( screen_fonts_ - > input_typewriter ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . typewriter_font_name ! = str ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . typewriter_font_name = str ;
}
str = fl_get_input ( screen_fonts_ - > input_screen_encoding ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . font_norm ! = str ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . font_norm = str ;
}
bool button = fl_get_button ( screen_fonts_ - > check_scalable ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . use_scalable_fonts ! = button ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . use_scalable_fonts = button ;
}
2000-10-30 21:53:29 +00:00
unsigned int ivalue = static_cast < unsigned int >
( fl_get_counter_value ( screen_fonts_ - > counter_zoom ) ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . zoom ! = ivalue ) {
2000-10-30 21:53:29 +00:00
changed = true ;
lyxrc . zoom = ivalue ;
}
ivalue = static_cast < unsigned int >
( fl_get_counter_value ( screen_fonts_ - > counter_dpi ) ) ;
if ( lyxrc . dpi ! = ivalue ) {
2000-10-27 10:04:51 +00:00
changed = true ;
2000-10-30 21:53:29 +00:00
lyxrc . dpi = ivalue ;
2000-10-27 10:04:51 +00:00
}
double dvalue = strToDbl ( fl_get_input ( screen_fonts_ - > input_tiny ) ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . font_sizes [ LyXFont : : SIZE_TINY ] ! = dvalue ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . font_sizes [ LyXFont : : SIZE_TINY ] = dvalue ;
}
dvalue = strToDbl ( fl_get_input ( screen_fonts_ - > input_script ) ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . font_sizes [ LyXFont : : SIZE_SCRIPT ] ! = dvalue ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . font_sizes [ LyXFont : : SIZE_SCRIPT ] = dvalue ;
}
dvalue = strToDbl ( fl_get_input ( screen_fonts_ - > input_footnote ) ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . font_sizes [ LyXFont : : SIZE_FOOTNOTE ] ! = dvalue ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . font_sizes [ LyXFont : : SIZE_FOOTNOTE ] = dvalue ;
}
dvalue = strToDbl ( fl_get_input ( screen_fonts_ - > input_small ) ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . font_sizes [ LyXFont : : SIZE_SMALL ] ! = dvalue ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . font_sizes [ LyXFont : : SIZE_SMALL ] = dvalue ;
}
dvalue = strToDbl ( fl_get_input ( screen_fonts_ - > input_normal ) ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . font_sizes [ LyXFont : : SIZE_NORMAL ] ! = dvalue ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . font_sizes [ LyXFont : : SIZE_NORMAL ] = dvalue ;
}
dvalue = strToDbl ( fl_get_input ( screen_fonts_ - > input_large ) ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . font_sizes [ LyXFont : : SIZE_LARGE ] ! = dvalue ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . font_sizes [ LyXFont : : SIZE_LARGE ] = dvalue ;
}
dvalue = strToDbl ( fl_get_input ( screen_fonts_ - > input_larger ) ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . font_sizes [ LyXFont : : SIZE_LARGER ] ! = dvalue ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . font_sizes [ LyXFont : : SIZE_LARGER ] = dvalue ;
}
dvalue = strToDbl ( fl_get_input ( screen_fonts_ - > input_largest ) ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . font_sizes [ LyXFont : : SIZE_LARGEST ] ! = dvalue ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . font_sizes [ LyXFont : : SIZE_LARGEST ] = dvalue ;
}
dvalue = strToDbl ( fl_get_input ( screen_fonts_ - > input_huge ) ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . font_sizes [ LyXFont : : SIZE_HUGE ] ! = dvalue ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . font_sizes [ LyXFont : : SIZE_HUGE ] = dvalue ;
}
dvalue = strToDbl ( fl_get_input ( screen_fonts_ - > input_huger ) ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . font_sizes [ LyXFont : : SIZE_HUGER ] ! = dvalue ) {
2000-10-27 10:04:51 +00:00
changed = true ;
lyxrc . font_sizes [ LyXFont : : SIZE_HUGER ] = dvalue ;
}
2000-11-04 10:00:12 +00:00
if ( changed ) {
2000-10-27 10:04:51 +00:00
// Now update the buffers
// Can anything below here affect the redraw process?
lv_ - > getLyXFunc ( ) - > Dispatch ( LFUN_SCREEN_FONT_UPDATE ) ;
}
}
void FormPreferences : : buildScreenFonts ( )
{
screen_fonts_ = build_screen_fonts ( ) ;
fl_set_input_return ( screen_fonts_ - > input_roman , FL_RETURN_CHANGED ) ;
fl_set_input_return ( screen_fonts_ - > input_sans , FL_RETURN_CHANGED ) ;
fl_set_input_return ( screen_fonts_ - > input_typewriter ,
FL_RETURN_CHANGED ) ;
fl_set_input_return ( screen_fonts_ - > input_screen_encoding ,
FL_RETURN_CHANGED ) ;
fl_set_counter_return ( screen_fonts_ - > counter_zoom , FL_RETURN_CHANGED ) ;
2000-10-30 21:53:29 +00:00
fl_set_counter_return ( screen_fonts_ - > counter_dpi , FL_RETURN_CHANGED ) ;
2000-10-27 10:04:51 +00:00
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_small , FL_RETURN_CHANGED ) ;
fl_set_input_return ( screen_fonts_ - > input_normal , FL_RETURN_CHANGED ) ;
fl_set_input_return ( screen_fonts_ - > input_large , FL_RETURN_CHANGED ) ;
fl_set_input_return ( screen_fonts_ - > input_larger , 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 ) ;
2000-10-30 21:53:29 +00:00
2000-11-03 09:47:02 +00:00
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 ) ;
2000-10-30 21:53:29 +00:00
// set up the feedback mechanism
2000-11-09 15:28:42 +00:00
setPreHandler ( screen_fonts_ - > input_roman ) ;
setPreHandler ( screen_fonts_ - > input_sans ) ;
setPreHandler ( screen_fonts_ - > input_typewriter ) ;
setPreHandler ( screen_fonts_ - > counter_zoom ) ;
setPreHandler ( screen_fonts_ - > counter_dpi ) ;
setPreHandler ( screen_fonts_ - > check_scalable ) ;
setPreHandler ( screen_fonts_ - > input_screen_encoding ) ;
setPreHandler ( screen_fonts_ - > input_tiny ) ;
setPreHandler ( screen_fonts_ - > input_script ) ;
setPreHandler ( screen_fonts_ - > input_footnote ) ;
setPreHandler ( screen_fonts_ - > input_small ) ;
setPreHandler ( screen_fonts_ - > input_large ) ;
setPreHandler ( screen_fonts_ - > input_larger ) ;
setPreHandler ( screen_fonts_ - > input_largest ) ;
setPreHandler ( screen_fonts_ - > input_normal ) ;
setPreHandler ( screen_fonts_ - > input_huge ) ;
setPreHandler ( screen_fonts_ - > input_huger ) ;
2000-10-27 10:04:51 +00:00
}
2000-11-04 10:00:12 +00:00
string const
FormPreferences : : feedbackScreenFonts ( FL_OBJECT const * const ob ) const
2000-10-27 10:04:51 +00:00
{
string str ;
2000-11-04 10:00:12 +00:00
if ( ob = = screen_fonts_ - > input_roman )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SCREEN_FONT_ROMAN ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = screen_fonts_ - > input_sans )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SCREEN_FONT_SANS ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = screen_fonts_ - > input_typewriter )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SCREEN_FONT_TYPEWRITER ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = screen_fonts_ - > check_scalable )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SCREEN_FONT_SCALABLE ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = screen_fonts_ - > input_screen_encoding )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SCREEN_FONT_ENCODING ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = screen_fonts_ - > counter_zoom )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SCREEN_ZOOM ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = screen_fonts_ - > counter_dpi )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SCREEN_DPI ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = screen_fonts_ - > input_tiny
2000-10-30 21:53:29 +00:00
| | 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 )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SCREEN_FONT_SIZES ) ;
2000-10-30 21:53:29 +00:00
2000-11-02 14:47:47 +00:00
return str ;
2000-10-27 10:04:51 +00:00
}
bool FormPreferences : : inputScreenFonts ( )
{
bool activate = true ;
string str ;
// Make sure that all fonts all have positive entries
// Also note that an empty entry is returned as 0.0 by strToDbl
if ( 0.0 > = strToDbl ( fl_get_input ( screen_fonts_ - > input_tiny ) )
| | 0.0 > = strToDbl ( fl_get_input ( screen_fonts_ - > input_script ) )
| | 0.0 > = strToDbl ( fl_get_input ( screen_fonts_ - > input_footnote ) )
| | 0.0 > = strToDbl ( fl_get_input ( screen_fonts_ - > input_small ) )
| | 0.0 > = strToDbl ( fl_get_input ( screen_fonts_ - > input_normal ) )
| | 0.0 > = strToDbl ( fl_get_input ( screen_fonts_ - > input_large ) )
| | 0.0 > = strToDbl ( fl_get_input ( screen_fonts_ - > input_larger ) )
| | 0.0 > = strToDbl ( fl_get_input ( screen_fonts_ - > input_largest ) )
| | 0.0 > = strToDbl ( fl_get_input ( screen_fonts_ - > input_huge ) )
| | 0.0 > = strToDbl ( fl_get_input ( screen_fonts_ - > input_huger ) ) ) {
activate = false ;
str = N_ ( " WARNING! Fonts must be positive! " ) ;
// Fontsizes -- tiny < script < footnote etc.
} else if ( strToDbl ( fl_get_input ( screen_fonts_ - > input_tiny ) ) >
strToDbl ( fl_get_input ( screen_fonts_ - > input_script ) ) | |
strToDbl ( fl_get_input ( screen_fonts_ - > input_script ) ) >
strToDbl ( fl_get_input ( screen_fonts_ - > input_footnote ) ) | |
strToDbl ( fl_get_input ( screen_fonts_ - > input_footnote ) ) >
strToDbl ( fl_get_input ( screen_fonts_ - > input_small ) ) | |
strToDbl ( fl_get_input ( screen_fonts_ - > input_small ) ) >
strToDbl ( fl_get_input ( screen_fonts_ - > input_normal ) ) | |
strToDbl ( fl_get_input ( screen_fonts_ - > input_normal ) ) >
strToDbl ( fl_get_input ( screen_fonts_ - > input_large ) ) | |
strToDbl ( fl_get_input ( screen_fonts_ - > input_large ) ) >
strToDbl ( fl_get_input ( screen_fonts_ - > input_larger ) ) | |
strToDbl ( fl_get_input ( screen_fonts_ - > input_larger ) ) >
strToDbl ( fl_get_input ( screen_fonts_ - > input_largest ) ) | |
strToDbl ( fl_get_input ( screen_fonts_ - > input_largest ) ) >
strToDbl ( fl_get_input ( screen_fonts_ - > input_huge ) ) | |
strToDbl ( fl_get_input ( screen_fonts_ - > input_huge ) ) >
strToDbl ( fl_get_input ( screen_fonts_ - > input_huger ) ) ) {
activate = false ;
str = N_ ( " WARNING! Fonts must be input in the order tiny > script> \n footnote > small > normal > large > larger > largest > huge > huger. " ) ;
}
2000-11-09 15:28:42 +00:00
if ( ! activate )
printWarning ( str ) ;
2000-10-27 10:04:51 +00:00
return activate ;
}
void FormPreferences : : updateScreenFonts ( )
{
fl_set_input ( screen_fonts_ - > input_roman ,
lyxrc . roman_font_name . c_str ( ) ) ;
fl_set_input ( screen_fonts_ - > input_sans ,
lyxrc . sans_font_name . c_str ( ) ) ;
fl_set_input ( screen_fonts_ - > input_typewriter ,
lyxrc . typewriter_font_name . c_str ( ) ) ;
fl_set_input ( screen_fonts_ - > input_screen_encoding ,
lyxrc . font_norm . c_str ( ) ) ;
fl_set_button ( screen_fonts_ - > check_scalable ,
lyxrc . use_scalable_fonts ) ;
2000-10-30 21:53:29 +00:00
fl_set_counter_value ( screen_fonts_ - > counter_zoom , lyxrc . zoom ) ;
fl_set_counter_value ( screen_fonts_ - > counter_dpi , lyxrc . dpi ) ;
2000-10-27 10:04:51 +00:00
fl_set_input ( screen_fonts_ - > input_tiny ,
tostr ( lyxrc . font_sizes [ LyXFont : : SIZE_TINY ] ) . c_str ( ) ) ;
fl_set_input ( screen_fonts_ - > input_script ,
tostr ( lyxrc . font_sizes [ LyXFont : : SIZE_SCRIPT ] ) . c_str ( ) ) ;
fl_set_input ( screen_fonts_ - > input_footnote ,
tostr ( lyxrc . font_sizes [ LyXFont : : SIZE_FOOTNOTE ] ) . c_str ( ) ) ;
fl_set_input ( screen_fonts_ - > input_small ,
tostr ( lyxrc . font_sizes [ LyXFont : : SIZE_SMALL ] ) . c_str ( ) ) ;
fl_set_input ( screen_fonts_ - > input_normal ,
tostr ( lyxrc . font_sizes [ LyXFont : : SIZE_NORMAL ] ) . c_str ( ) ) ;
fl_set_input ( screen_fonts_ - > input_large ,
tostr ( lyxrc . font_sizes [ LyXFont : : SIZE_LARGE ] ) . c_str ( ) ) ;
fl_set_input ( screen_fonts_ - > input_larger ,
tostr ( lyxrc . font_sizes [ LyXFont : : SIZE_LARGER ] ) . c_str ( ) ) ;
fl_set_input ( screen_fonts_ - > input_largest ,
tostr ( lyxrc . font_sizes [ LyXFont : : SIZE_LARGEST ] ) . c_str ( ) ) ;
fl_set_input ( screen_fonts_ - > input_huge ,
tostr ( lyxrc . font_sizes [ LyXFont : : SIZE_HUGE ] ) . c_str ( ) ) ;
fl_set_input ( screen_fonts_ - > input_huger ,
tostr ( lyxrc . font_sizes [ LyXFont : : SIZE_HUGER ] ) . c_str ( ) ) ;
2000-10-25 10:19:25 +00:00
}
void FormPreferences : : applySpellChecker ( )
{
2000-11-09 15:28:42 +00:00
string choice = fl_get_choice_text ( spellchecker_ - > choice_spell_command ) ;
choice = strip ( frontStrip ( choice ) ) ;
2000-10-25 10:19:25 +00:00
lyxrc . isp_command = choice ;
// If spell checker == "none", all other input set to off.
2000-11-04 10:00:12 +00:00
if ( fl_get_choice ( spellchecker_ - > choice_spell_command ) = = 1 ) {
2000-10-25 10:19:25 +00:00
lyxrc . isp_use_alt_lang = false ;
lyxrc . isp_alt_lang . erase ( ) ;
lyxrc . isp_use_esc_chars = false ;
lyxrc . isp_esc_chars . erase ( ) ;
lyxrc . isp_use_pers_dict = false ;
lyxrc . isp_pers_dict . erase ( ) ;
lyxrc . isp_accept_compound = false ;
lyxrc . isp_use_input_encoding = false ;
} else {
2000-10-27 10:04:51 +00:00
int button = fl_get_button ( spellchecker_ - > check_alt_lang ) ;
choice = fl_get_input ( spellchecker_ - > input_alt_lang ) ;
2000-11-04 10:00:12 +00:00
if ( button & & choice . empty ( ) ) button = 0 ;
if ( ! button ) choice . erase ( ) ;
2000-10-25 10:19:25 +00:00
lyxrc . isp_use_alt_lang = static_cast < bool > ( button ) ;
lyxrc . isp_alt_lang = choice ;
2000-10-27 10:04:51 +00:00
button = fl_get_button ( spellchecker_ - > check_escape_chars ) ;
choice = fl_get_input ( spellchecker_ - > input_escape_chars ) ;
2000-11-04 10:00:12 +00:00
if ( button & & choice . empty ( ) ) button = 0 ;
if ( ! button ) choice . erase ( ) ;
2000-10-25 10:19:25 +00:00
lyxrc . isp_use_esc_chars = static_cast < bool > ( button ) ;
lyxrc . isp_esc_chars = choice ;
2000-10-27 10:04:51 +00:00
button = fl_get_button ( spellchecker_ - > check_personal_dict ) ;
choice = fl_get_input ( spellchecker_ - > input_personal_dict ) ;
2000-11-04 10:00:12 +00:00
if ( button & & choice . empty ( ) ) button = 0 ;
if ( ! button ) choice . erase ( ) ;
2000-10-25 10:19:25 +00:00
lyxrc . isp_use_pers_dict = static_cast < bool > ( button ) ;
lyxrc . isp_pers_dict = choice ;
2000-10-27 10:04:51 +00:00
button = fl_get_button ( spellchecker_ - > check_compound_words ) ;
2000-10-25 10:19:25 +00:00
lyxrc . isp_accept_compound = static_cast < bool > ( button ) ;
2000-10-27 10:04:51 +00:00
button = fl_get_button ( spellchecker_ - > check_input_enc ) ;
2000-10-25 10:19:25 +00:00
lyxrc . isp_use_input_encoding = static_cast < bool > ( button ) ;
}
2000-10-27 10:04:51 +00:00
// Reset view
2000-10-25 10:19:25 +00:00
updateSpellChecker ( ) ;
2000-06-12 11:55:12 +00:00
}
2000-10-27 10:04:51 +00:00
void FormPreferences : : buildSpellchecker ( )
2000-06-12 11:55:12 +00:00
{
2000-10-27 10:04:51 +00:00
spellchecker_ = build_spellchecker ( ) ;
2000-10-25 10:19:25 +00:00
2000-10-27 10:04:51 +00:00
fl_addto_choice ( spellchecker_ - > choice_spell_command ,
_ ( " none | ispell | aspell " ) ) ;
fl_set_input_return ( spellchecker_ - > input_alt_lang ,
FL_RETURN_CHANGED ) ;
fl_set_input_return ( spellchecker_ - > input_escape_chars ,
FL_RETURN_CHANGED ) ;
fl_set_input_return ( spellchecker_ - > input_personal_dict ,
FL_RETURN_CHANGED ) ;
// deactivate the browse button because it isn't implemented
fl_deactivate_object ( spellchecker_ - > button_personal_dict ) ;
fl_set_object_lcol ( spellchecker_ - > button_personal_dict ,
FL_INACTIVE ) ;
2000-10-30 21:53:29 +00:00
// set up the feedback mechanism
2000-11-09 15:28:42 +00:00
setPreHandler ( spellchecker_ - > choice_spell_command ) ;
setPreHandler ( spellchecker_ - > check_alt_lang ) ;
setPreHandler ( spellchecker_ - > input_alt_lang ) ;
setPreHandler ( spellchecker_ - > check_escape_chars ) ;
setPreHandler ( spellchecker_ - > input_escape_chars ) ;
setPreHandler ( spellchecker_ - > check_personal_dict ) ;
setPreHandler ( spellchecker_ - > input_personal_dict ) ;
setPreHandler ( spellchecker_ - > button_personal_dict ) ;
setPreHandler ( spellchecker_ - > check_compound_words ) ;
setPreHandler ( spellchecker_ - > check_input_enc ) ;
2000-10-27 10:04:51 +00:00
}
2000-11-04 10:00:12 +00:00
string const
FormPreferences : : feedbackSpellChecker ( FL_OBJECT const * const ob ) const
2000-10-27 10:04:51 +00:00
{
string str ;
2000-11-02 14:47:47 +00:00
2000-11-04 10:00:12 +00:00
if ( ob = = spellchecker_ - > choice_spell_command )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_SPELL_COMMAND ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = spellchecker_ - > check_alt_lang )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_USE_ALT_LANG ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = spellchecker_ - > input_alt_lang )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_ALT_LANG ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = spellchecker_ - > check_escape_chars )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_USE_ESC_CHARS ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = spellchecker_ - > input_escape_chars )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_ESC_CHARS ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = spellchecker_ - > check_personal_dict )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_USE_PERS_DICT ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = spellchecker_ - > input_personal_dict )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_PERS_DICT ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = spellchecker_ - > check_compound_words )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_ACCEPT_COMPOUND ) ;
2000-11-04 10:00:12 +00:00
else if ( ob = = spellchecker_ - > check_input_enc )
2000-11-02 14:47:47 +00:00
str = lyxrc . getDescription ( LyXRC : : RC_USE_INP_ENC ) ;
2000-10-27 10:04:51 +00:00
2000-11-02 14:47:47 +00:00
return str ;
2000-10-27 10:04:51 +00:00
}
bool FormPreferences : : inputSpellChecker ( FL_OBJECT const * const ob )
{
2000-11-09 15:28:42 +00:00
// !ob if function is called from updateSpellChecker() to de/activate
// objects,
// otherwise the function is called by an xforms CB via input().
2000-10-27 10:04:51 +00:00
// If spell checker == "none", disable all input.
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = spellchecker_ - > choice_spell_command ) {
if ( fl_get_choice ( spellchecker_ - > choice_spell_command ) = = 1 ) {
2000-10-27 10:04:51 +00:00
fl_deactivate_object ( spellchecker_ - > check_alt_lang ) ;
fl_deactivate_object ( spellchecker_ - > input_alt_lang ) ;
fl_deactivate_object ( spellchecker_ - > check_escape_chars ) ;
fl_deactivate_object ( spellchecker_ - > input_escape_chars ) ;
fl_deactivate_object ( spellchecker_ - > check_personal_dict ) ;
fl_deactivate_object ( spellchecker_ - > input_personal_dict ) ;
fl_deactivate_object ( spellchecker_ - > check_compound_words ) ;
fl_deactivate_object ( spellchecker_ - > check_input_enc ) ;
return true ;
} else {
fl_activate_object ( spellchecker_ - > check_alt_lang ) ;
fl_activate_object ( spellchecker_ - > check_escape_chars ) ;
fl_activate_object ( spellchecker_ - > check_personal_dict ) ;
fl_activate_object ( spellchecker_ - > check_compound_words ) ;
fl_activate_object ( spellchecker_ - > check_input_enc ) ;
}
}
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = spellchecker_ - > check_alt_lang ) {
if ( fl_get_button ( spellchecker_ - > check_alt_lang ) ) {
2000-10-27 10:04:51 +00:00
fl_activate_object ( spellchecker_ - > input_alt_lang ) ;
fl_set_object_lcol ( spellchecker_ - > input_alt_lang ,
FL_BLACK ) ;
} else {
fl_deactivate_object ( spellchecker_ - > input_alt_lang ) ;
fl_set_object_lcol ( spellchecker_ - > input_alt_lang ,
FL_INACTIVE ) ;
}
}
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = spellchecker_ - > check_escape_chars ) {
if ( fl_get_button ( spellchecker_ - > check_escape_chars ) ) {
2000-10-27 10:04:51 +00:00
fl_activate_object ( spellchecker_ - > input_escape_chars ) ;
fl_set_object_lcol ( spellchecker_ - > input_escape_chars ,
FL_BLACK ) ;
} else {
fl_deactivate_object ( spellchecker_ - > input_escape_chars ) ;
fl_set_object_lcol ( spellchecker_ - > input_escape_chars ,
FL_INACTIVE ) ;
}
}
2000-11-04 10:00:12 +00:00
if ( ! ob | | ob = = spellchecker_ - > check_personal_dict ) {
if ( fl_get_button ( spellchecker_ - > check_personal_dict ) ) {
2000-10-27 10:04:51 +00:00
fl_activate_object ( spellchecker_ - > input_personal_dict ) ;
fl_set_object_lcol ( spellchecker_ - > input_personal_dict ,
FL_BLACK ) ;
} else {
fl_deactivate_object ( spellchecker_ - > input_personal_dict ) ;
fl_set_object_lcol ( spellchecker_ - > input_personal_dict ,
FL_INACTIVE ) ;
}
}
2000-11-03 09:47:02 +00:00
return true ; // All input is valid!
2000-10-25 10:19:25 +00:00
}
2000-10-11 07:59:25 +00:00
2000-10-25 10:19:25 +00:00
void FormPreferences : : updateSpellChecker ( )
{
int choice = 1 ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . isp_command = = " none " )
2000-10-25 10:19:25 +00:00
choice = 1 ;
2000-11-04 10:00:12 +00:00
else if ( lyxrc . isp_command = = " ispell " )
2000-10-25 10:19:25 +00:00
choice = 2 ;
2000-11-04 10:00:12 +00:00
else if ( lyxrc . isp_command = = " aspell " )
2000-10-25 10:19:25 +00:00
choice = 3 ;
2000-10-27 10:04:51 +00:00
fl_set_choice ( spellchecker_ - > choice_spell_command , choice ) ;
2000-10-25 10:19:25 +00:00
2000-11-08 09:39:46 +00:00
string str ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . isp_use_alt_lang ) str = lyxrc . isp_alt_lang ;
2000-10-25 10:19:25 +00:00
2000-10-27 10:04:51 +00:00
fl_set_button ( spellchecker_ - > check_alt_lang ,
2000-10-25 10:19:25 +00:00
lyxrc . isp_use_alt_lang ) ;
2000-10-27 10:04:51 +00:00
fl_set_input ( spellchecker_ - > input_alt_lang , str . c_str ( ) ) ;
2000-10-25 10:19:25 +00:00
2000-10-27 10:04:51 +00:00
str . erase ( ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . isp_use_esc_chars ) str = lyxrc . isp_esc_chars ;
2000-10-25 10:19:25 +00:00
2000-10-27 10:04:51 +00:00
fl_set_button ( spellchecker_ - > check_escape_chars ,
2000-10-25 10:19:25 +00:00
lyxrc . isp_use_esc_chars ) ;
2000-10-27 10:04:51 +00:00
fl_set_input ( spellchecker_ - > input_escape_chars , str . c_str ( ) ) ;
2000-10-25 10:19:25 +00:00
2000-10-27 10:04:51 +00:00
str . erase ( ) ;
2000-11-04 10:00:12 +00:00
if ( lyxrc . isp_use_pers_dict ) str = lyxrc . isp_pers_dict ;
2000-10-25 10:19:25 +00:00
2000-10-27 10:04:51 +00:00
fl_set_button ( spellchecker_ - > check_personal_dict ,
2000-10-25 10:19:25 +00:00
lyxrc . isp_use_pers_dict ) ;
2000-10-27 10:04:51 +00:00
fl_set_input ( spellchecker_ - > input_personal_dict , str . c_str ( ) ) ;
2000-10-25 10:19:25 +00:00
2000-10-27 10:04:51 +00:00
fl_set_button ( spellchecker_ - > check_compound_words ,
2000-10-25 10:19:25 +00:00
lyxrc . isp_accept_compound ) ;
2000-10-27 10:04:51 +00:00
fl_set_button ( spellchecker_ - > check_input_enc ,
2000-10-25 10:19:25 +00:00
lyxrc . isp_use_input_encoding ) ;
// Activate/Deactivate the input fields dependent on the state of the
// buttons.
2000-10-27 10:04:51 +00:00
inputSpellChecker ( 0 ) ;
2000-06-12 11:55:12 +00:00
}
2000-11-09 15:28:42 +00:00
bool FormPreferences : : WriteableDir ( string const & name )
2000-06-12 11:55:12 +00:00
{
2000-10-27 10:04:51 +00:00
bool success = true ;
string str ;
2000-10-13 05:57:05 +00:00
2000-11-04 10:00:12 +00:00
if ( ! AbsolutePath ( name ) ) {
2000-10-27 10:04:51 +00:00
success = false ;
str = N_ ( " WARNING! The absolute path is required. " ) ;
2000-10-13 05:57:05 +00:00
}
2000-11-04 10:00:12 +00:00
FileInfo const tp ( name ) ;
if ( success & & ! tp . isDir ( ) ) {
2000-10-27 10:04:51 +00:00
success = false ;
str = N_ ( " WARNING! Directory does not exist. " ) ;
2000-10-13 05:57:05 +00:00
}
2000-11-04 10:00:12 +00:00
if ( success & & ! tp . writable ( ) ) {
2000-10-27 10:04:51 +00:00
success = false ;
str = N_ ( " WARNING! Cannot write to this directory. " ) ;
2000-10-13 05:57:05 +00:00
}
2000-11-09 15:28:42 +00:00
if ( ! success )
printWarning ( str ) ;
2000-10-27 10:04:51 +00:00
return success ;
}
2000-10-13 05:57:05 +00:00
2000-10-27 10:04:51 +00:00
2000-11-09 15:28:42 +00:00
bool FormPreferences : : ReadableDir ( string const & name )
2000-10-27 10:04:51 +00:00
{
bool success = true ;
string str ;
2000-11-04 10:00:12 +00:00
if ( ! AbsolutePath ( name ) ) {
2000-10-27 10:04:51 +00:00
success = false ;
str = N_ ( " WARNING! The absolute path is required. " ) ;
2000-07-28 04:59:45 +00:00
}
2000-11-04 10:00:12 +00:00
FileInfo const tp ( name ) ;
if ( success & & ! tp . isDir ( ) ) {
2000-10-27 10:04:51 +00:00
success = false ;
str = N_ ( " WARNING! Directory does not exist. " ) ;
2000-07-28 04:59:45 +00:00
}
2000-11-04 10:00:12 +00:00
if ( success & & ! tp . readable ( ) ) {
2000-10-27 10:04:51 +00:00
success = false ;
str = N_ ( " WARNING! Cannot read this directory. " ) ;
}
2000-10-25 10:19:25 +00:00
2000-11-09 15:28:42 +00:00
if ( ! success )
printWarning ( str ) ;
2000-10-27 10:04:51 +00:00
return success ;
2000-06-12 11:55:12 +00:00
}
2000-11-04 10:00:12 +00:00
bool FormPreferences : : WriteableFile ( string const & name ,
2000-11-09 15:28:42 +00:00
string const & suffix )
2000-10-25 10:19:25 +00:00
{
2000-10-27 10:04:51 +00:00
// A writeable file is either:
// * An existing file to which we have write access, or
// * A file that doesn't yet exist but that would exist in a writeable
// directory.
2000-10-25 10:19:25 +00:00
2000-10-27 10:04:51 +00:00
bool success = true ;
string str ;
2000-10-25 10:19:25 +00:00
2000-11-04 10:00:12 +00:00
if ( name . empty ( ) ) {
2000-10-27 10:04:51 +00:00
success = false ;
str = N_ ( " WARNING! No file input. " ) ;
2000-10-25 10:19:25 +00:00
}
2000-11-04 10:00:12 +00:00
string const dir = OnlyPath ( name ) ;
if ( success & & ! AbsolutePath ( dir ) ) {
2000-10-27 10:04:51 +00:00
success = false ;
str = N_ ( " WARNING! The absolute path is required. " ) ;
2000-10-25 10:19:25 +00:00
}
2000-11-04 10:00:12 +00:00
#if 0
2000-11-08 09:39:46 +00:00
// This is not a nice way to use FileInfo (Lgb)
2000-10-27 10:04:51 +00:00
FileInfo d ;
2000-11-04 10:00:12 +00:00
2000-10-27 10:04:51 +00:00
{
FileInfo d1 ( dir ) ;
FileInfo d2 ( name ) ;
2000-11-04 10:00:12 +00:00
if ( d2 . isDir ( ) )
2000-10-27 10:04:51 +00:00
d = d2 ;
else
d = d1 ;
}
2000-11-04 10:00:12 +00:00
# else
// This should be equivalent (Lgb)
FileInfo d ( name ) ;
if ( ! d . isDir ( ) ) {
d . newFile ( dir ) ;
}
# endif
if ( success & & ! d . isDir ( ) ) {
2000-10-27 10:04:51 +00:00
success = false ;
str = N_ ( " WARNING! Directory does not exist. " ) ;
}
2000-11-04 10:00:12 +00:00
if ( success & & ! d . writable ( ) ) {
2000-10-27 10:04:51 +00:00
success = false ;
str = N_ ( " WARNING! Cannot write to this directory. " ) ;
}
2000-10-25 10:19:25 +00:00
2000-10-27 10:04:51 +00:00
FileInfo f ( name + suffix ) ;
2000-11-04 10:00:12 +00:00
if ( success & & ( dir = = name | | f . isDir ( ) ) ) {
2000-10-27 10:04:51 +00:00
success = false ;
str = N_ ( " WARNING! A file is required, not a directory. " ) ;
}
2000-10-02 04:21:44 +00:00
2000-11-04 10:00:12 +00:00
if ( success & & ( f . exist ( ) & & ! f . writable ( ) ) ) {
2000-10-27 10:04:51 +00:00
success = false ;
str = N_ ( " WARNING! Cannot write to this file. " ) ;
}
2000-11-09 15:28:42 +00:00
if ( ! success )
printWarning ( str ) ;
2000-10-02 04:21:44 +00:00
2000-10-27 10:04:51 +00:00
return success ;
2000-10-02 04:21:44 +00:00
}
2000-10-30 21:53:29 +00:00
2000-11-09 15:28:42 +00:00
void FormPreferences : : printWarning ( string const & warning )
2000-10-30 21:53:29 +00:00
{
2000-11-09 15:28:42 +00:00
warningPosted = true ;
2000-10-30 21:53:29 +00:00
2000-11-09 15:28:42 +00:00
string str = formatted ( warning , dialog_ - > text_warning - > w - 10 ,
FL_SMALL_SIZE , FL_NORMAL_STYLE ) ;
2000-10-30 21:53:29 +00:00
2000-11-09 15:28:42 +00:00
fl_set_object_label ( dialog_ - > text_warning , str . c_str ( ) ) ;
fl_set_object_lsize ( dialog_ - > text_warning , FL_SMALL_SIZE ) ;
}
2000-11-02 14:47:47 +00:00
2000-11-08 09:39:46 +00:00
2000-11-09 15:28:42 +00:00
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 ) ) ;
2000-10-30 21:53:29 +00:00
}
2000-11-04 10:00:12 +00:00
2000-11-09 15:28:42 +00:00
// C function wrapper, required by xforms.
C_PREPOSTHANDLER ( FormPreferences , FeedbackCB )
int FormPreferences : : FeedbackCB ( FL_OBJECT * ob , int event ,
FL_Coord , FL_Coord , int , void * )
2000-10-30 21:53:29 +00:00
{
2000-11-09 15:28:42 +00:00
// Note that the return value is important in the pre-emptive handler.
// Don't return anything other than 0.
Assert ( ob ) ;
// Don't Assert this one, as it can happen quite reasonably when things
// are being deleted in the d-tor.
//Assert(ob->form);
if ( ! ob - > form ) return 0 ;
2000-11-03 09:47:02 +00:00
2000-10-30 21:53:29 +00:00
FormPreferences * pre =
static_cast < FormPreferences * > ( ob - > form - > u_vdata ) ;
2000-11-09 15:28:42 +00:00
pre - > Feedback ( ob , event ) ;
2000-11-02 14:47:47 +00:00
return 0 ;
2000-10-30 21:53:29 +00:00
}
2000-11-02 14:47:47 +00:00
2000-11-09 15:28:42 +00:00
// preemptive handler for feedback messages
void FormPreferences : : Feedback ( FL_OBJECT * ob , int event )
2000-10-30 21:53:29 +00:00
{
2000-11-08 09:39:46 +00:00
Assert ( ob ) ;
2000-11-09 15:28:42 +00:00
switch ( event ) {
case FL_ENTER :
warningPosted = false ;
feedback ( ob ) ;
break ;
case FL_LEAVE :
if ( ! warningPosted )
fl_set_object_label ( dialog_ - > text_warning , " " ) ;
break ;
default :
break ;
2000-10-30 21:53:29 +00:00
}
}
2000-11-09 15:28:42 +00:00
void FormPreferences : : setPreHandler ( FL_OBJECT * ob ) const
2000-10-30 21:53:29 +00:00
{
2000-11-08 09:39:46 +00:00
Assert ( ob ) ;
2000-11-09 15:28:42 +00:00
fl_set_object_prehandler ( ob , C_FormPreferencesFeedbackCB ) ;
2000-10-30 21:53:29 +00:00
}