]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormPreferences.C
some mods I had in my local tree, mostly small stuff, perhaps minus the the Makefile...
[lyx.git] / src / frontends / xforms / FormPreferences.C
index 55d351ffafffc63f873953b0280cd039f5650ff0..d43c4ef22d9314a1dccc8ca95c50d305ae4f02e5 100644 (file)
@@ -1,11 +1,10 @@
-// -*- C++ -*-
 /* This file is part of
  * ======================================================
  * 
  *           LyX, The Document Processor
  *      
  *         Copyright 1995 Matthias Ettrich
- *          Copyright 1995-2000 The LyX Team.
+ *          Copyright 1995-2001 The LyX Team.
  *
  *======================================================*/
 /* FormPreferences.C
 #include "combox.h"
 #include "debug.h"
 #include "support/filetools.h"
+#include "support/LAssert.h"
 #include "lyx_gui_misc.h" // idex, scex
 #include "lyxlex.h"
 #include "input_validators.h"
-#include "xform_helpers.h"
+#include "xforms_helpers.h"
+#include "helper_funcs.h"
 #include "converter.h"
 #include "support/lyxfunctional.h"
 #include "support/lyxmanip.h"
 
 using std::endl;
-using std::find;
-using std::find_if;
 using std::pair;
 using std::make_pair;
 using std::max;
 using std::min;
-using std::sort;
 using std::vector;
+using SigC::slot;
 
 extern string system_lyxdir;
 extern string user_lyxdir;
 extern Languages languages;
 
+namespace {
+
 // These should probably go inside the class definition...
-static Formats    local_formats;
-static Converters local_converters;
+Formats    local_formats;
+Converters local_converters;
+
+} // namespace anon
+
 
 FormPreferences::FormPreferences(LyXView * lv, Dialogs * d)
-       : FormBaseBI(lv, d, _("Preferences"), new PreferencesPolicy),
-         dialog_(0),
-         converters_tab_(0), inputs_tab_(0), look_n_feel_tab_(0),
-         outputs_tab_(0),  lang_opts_tab_(0),
+       : FormBaseBI(lv, d, _("Preferences"), false),
          warningPosted(false),
          colors_(*this), converters_(*this), inputs_misc_(*this),
          formats_(*this), interface_(*this), language_(*this), 
          lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
-         printer_(*this), screen_fonts_(*this), spellchecker_(*this)
+         printer_(*this), screen_fonts_(*this), spelloptions_(*this)
 {
        // let the dialog be shown
        // This is a permanent connection so we won't bother
        // storing a copy because we won't be disconnecting.
        d->showPreferences.connect(slot(this, &FormPreferences::show));
-}
-
-
-FormPreferences::~FormPreferences()
-{
-       delete converters_tab_;
-       delete inputs_tab_;
-       delete look_n_feel_tab_;
-       delete outputs_tab_;
-       delete lang_opts_tab_;
-
-       delete dialog_;
-}
-
-
-void FormPreferences::connect()
-{
-       fl_set_form_maxsize( dialog_->form, minw_, minh_ );
-
-       FormBaseBI::connect();
-}
-
-
-void FormPreferences::disconnect()
-{
-       // colors_->disconnect();
-       // converters_->disconnect(); //local_converters.Clear();
-       // formats_->disconnect();    //local_formats.Clear();
-
-       FormBaseBI::disconnect();
+       d->showSpellcheckerPreferences.connect(slot(this, &FormPreferences::showSpellPref));
 }
 
 
@@ -146,22 +118,30 @@ void FormPreferences::redraw()
 
 FL_FORM * FormPreferences::form() const
 {
-       if (dialog_) return dialog_->form;
+       if (dialog_.get()) return dialog_->form;
        return 0;
 }
 
 
+void FormPreferences::showSpellPref()
+{
+       show();
+       fl_set_folder(dialog_->tabfolder_prefs, lang_opts_tab_->form);
+       fl_set_folder(lang_opts_tab_->tabfolder_outer, spelloptions_.dialog()->form);
+}
+
+
 void FormPreferences::ok()
 {
-       FormBase::ok();
+       FormBaseDeprecated::ok();
 
-       if (colors_.modifiedXformPrefs) {
+       if (colors_.modifiedXformsPrefs) {
                string const filename =
                        AddName(user_lyxdir, "preferences.xform");
-               colors_.modifiedXformPrefs = !XformColor::write(filename);
+               colors_.modifiedXformsPrefs = !XformsColor::write(filename);
        }
        
-       lv_->getLyXFunc()->Dispatch(LFUN_SAVEPREFERENCES);
+       lv_->getLyXFunc()->dispatch(LFUN_SAVEPREFERENCES);
 }
 
 
@@ -174,31 +154,26 @@ void FormPreferences::hide()
            && outer_form->visible) {
                fl_hide_form(outer_form);
        }
-       FormBase::hide();
+       FormBaseDeprecated::hide();
 }
 
 
 void FormPreferences::build()
 {
-       dialog_ = build_preferences();
+       dialog_.reset(build_preferences());
 
        // Manage the restore, save, apply and cancel/close buttons
-       bc_.setOK(dialog_->button_ok);
-       bc_.setApply(dialog_->button_apply);
-       bc_.setCancel(dialog_->button_cancel);
-       bc_.setUndoAll(dialog_->button_restore);
-       bc_.refresh();
-
-       // Workaround dumb xforms sizing bug
-       minw_ = form()->w;
-       minh_ = form()->h;
+       bc().setOK(dialog_->button_ok);
+       bc().setApply(dialog_->button_apply);
+       bc().setCancel(dialog_->button_cancel);
+       bc().setRestore(dialog_->button_restore);
 
        // build the tab folders
-       converters_tab_ = build_outer_tab();
-       look_n_feel_tab_ = build_outer_tab();
-       inputs_tab_ = build_outer_tab();
-       outputs_tab_ = build_outer_tab();
-       lang_opts_tab_ = build_outer_tab();
+       converters_tab_.reset(build_outer_tab());
+       look_n_feel_tab_.reset(build_outer_tab());
+       inputs_tab_.reset(build_outer_tab());
+       outputs_tab_.reset(build_outer_tab());
+       lang_opts_tab_.reset(build_outer_tab());
 
        // build actual tabfolder contents
        // these will become nested tabfolders
@@ -213,7 +188,7 @@ void FormPreferences::build()
        paths_.build();
        printer_.build();
        screen_fonts_.build();
-       spellchecker_.build();
+       spelloptions_.build();
 
        // Now add them to the tabfolder
        fl_addto_tabfolder(dialog_->tabfolder_prefs,
@@ -275,7 +250,7 @@ void FormPreferences::build()
        // then building usage
        fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
                           _("Spell checker"),
-                          spellchecker_.dialog()->form);
+                          spelloptions_.dialog()->form);
        fl_addto_tabfolder(lang_opts_tab_->tabfolder_outer,
                           _("Language"),
                           language_.dialog()->form);
@@ -306,13 +281,13 @@ void FormPreferences::apply()
        paths_.apply();
        printer_.apply();
        screen_fonts_.apply();
-       spellchecker_.apply();
+       spelloptions_.apply();
 }
 
 
 void FormPreferences::feedback(FL_OBJECT * ob)
 {
-       Assert(ob);
+       lyx::Assert(ob);
 
        string str;
 
@@ -338,12 +313,11 @@ void FormPreferences::feedback(FL_OBJECT * ob)
                str = printer_.feedback(ob);
        } else if (ob->form->fdui == screen_fonts_.dialog()) {
                str = screen_fonts_.feedback(ob);
-       } else if (ob->form->fdui == spellchecker_.dialog()) {
-               str = spellchecker_.feedback(ob);
+       } else if (ob->form->fdui == spelloptions_.dialog()) {
+               str = spelloptions_.feedback(ob);
        }
 
-       str = formatted(_(str), dialog_->text_warning->w-10,
-                       FL_SMALL_SIZE, FL_NORMAL_STYLE);
+       str = formatted(_(str), dialog_->text_warning->w-10, FL_SMALL_SIZE);
 
        fl_set_object_label(dialog_->text_warning, str.c_str());
        fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
@@ -352,7 +326,7 @@ void FormPreferences::feedback(FL_OBJECT * ob)
 
 bool FormPreferences::input(FL_OBJECT * ob, long)
 {
-       Assert(ob);
+       lyx::Assert(ob);
        
        // whatever checks you need to ensure the user hasn't entered
        // some totally ridiculous value somewhere.  Change activate to suit.
@@ -373,8 +347,8 @@ bool FormPreferences::input(FL_OBJECT * ob, long)
                return paths_.input(ob);
        else if (ob->form->fdui == screen_fonts_.dialog())
                return screen_fonts_.input();
-       else if (ob->form->fdui == spellchecker_.dialog())
-               return spellchecker_.input(ob);
+       else if (ob->form->fdui == spelloptions_.dialog())
+               return spelloptions_.input(ob);
 
        return true;
 }
@@ -382,7 +356,7 @@ bool FormPreferences::input(FL_OBJECT * ob, long)
 
 void FormPreferences::update()
 {
-       if (!dialog_) return;
+       if (!dialog_.get()) return;
     
        // read lyxrc entries
        colors_.update();
@@ -396,13 +370,18 @@ void FormPreferences::update()
        paths_.update();
        printer_.update();
        screen_fonts_.update();
-       spellchecker_.update();
+       spelloptions_.update();
 }
 
 
-FormPreferences::Colors::~Colors()
+FormPreferences::Colors::Colors(FormPreferences & p)
+       : modifiedXformsPrefs(false), parent_(p)
+{}
+
+
+FD_form_colors const * FormPreferences::Colors::dialog()
 {
-       delete dialog_;
+       return dialog_.get();
 }
 
 
@@ -411,31 +390,30 @@ void FormPreferences::Colors::apply()
        bool modifiedText = false;
        bool modifiedBackground = false;
 
-       for (vector<XformColor>::const_iterator cit = xformColorDB.begin();
-            cit != xformColorDB.end(); ++cit) {
+       for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
+            cit != xformsColorDB.end(); ++cit) {
                RGBColor col;
-               fl_getmcolor((*cit).colorID, &col.r, &col.g, &col.b);
-               if (col != (*cit).color()) {
-                       modifiedXformPrefs = true;
-                       if ((*cit).colorID == FL_BLACK)
+               fl_getmcolor(cit->colorID, &col.r, &col.g, &col.b);
+               if (col != cit->color()) {
+                       modifiedXformsPrefs = true;
+                       if (cit->colorID == FL_BLACK)
                                modifiedText = true;
-                       if ((*cit).colorID == FL_COL1)
+                       if (cit->colorID == FL_COL1)
                                modifiedBackground = true;
                }
        }
 
-       if (modifiedXformPrefs) {
-               for (vector<XformColor>::const_iterator cit =
-                            xformColorDB.begin(); 
-                    cit != xformColorDB.end(); ++cit) {
-                       fl_mapcolor((*cit).colorID,
-                                   (*cit).r, (*cit).g, (*cit).b);
+       if (modifiedXformsPrefs) {
+               for (vector<XformsColor>::const_iterator cit =
+                            xformsColorDB.begin(); 
+                    cit != xformsColorDB.end(); ++cit) {
+                       fl_mapcolor(cit->colorID, cit->r, cit->g, cit->b);
 
-                       if (modifiedText && (*cit).colorID == FL_BLACK) {
+                       if (modifiedText && cit->colorID == FL_BLACK) {
                                AdjustVal(FL_INACTIVE, FL_BLACK, 0.5);
                        }
 
-                       if (modifiedBackground && (*cit).colorID == FL_COL1) {
+                       if (modifiedBackground && cit->colorID == FL_COL1) {
                                AdjustVal(FL_MCOL,      FL_COL1, 0.1);
                                AdjustVal(FL_TOP_BCOL,  FL_COL1, 0.1);
                                AdjustVal(FL_LEFT_BCOL, FL_COL1, 0.1);
@@ -444,9 +422,9 @@ void FormPreferences::Colors::apply()
                                AdjustVal(FL_BOTTOM_BCOL, FL_COL1, -0.5);
                        }
 
-                       if ((*cit).colorID == GUI_COLOR_CURSOR) {
+                       if (cit->colorID == GUI_COLOR_CURSOR) {
                                fl_mapcolor(GUI_COLOR_CURSOR,
-                                           (*cit).r, (*cit).g, (*cit).b);
+                                           cit->r, cit->g, cit->b);
                                fl_set_cursor_color(FL_DEFAULT_CURSOR,
                                                    GUI_COLOR_CURSOR, FL_WHITE);
                        }
@@ -457,11 +435,11 @@ void FormPreferences::Colors::apply()
        // Now do the same for the LyX LColors...
        for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
             cit != lyxColorDB.end(); ++cit) {
-               LColor::color lc = lcolor.getFromGUIName((*cit).getname());
+               LColor::color lc = lcolor.getFromGUIName(cit->getname());
                if (lc == LColor::inherit) continue;
 
                // Create a valid X11 name of the form "#rrggbb"
-               string const hexname = X11hexname((*cit).color());
+               string const hexname = X11hexname(cit->color());
                
                if (lcolor.getX11Name(lc) != hexname) {
                        lyxerr[Debug::GUI]
@@ -473,7 +451,7 @@ void FormPreferences::Colors::apply()
 
                        string const s = lcolor.getLyXName(lc) + string(" ") +
                                hexname;
-                       parent_.lv_->getLyXFunc()->Dispatch(LFUN_SET_COLOR, s);
+                       parent_.lv_->getLyXFunc()->dispatch(LFUN_SET_COLOR, s);
                }
        }
 }
@@ -481,7 +459,7 @@ void FormPreferences::Colors::apply()
 
 void FormPreferences::Colors::build()
 {
-       dialog_ = parent_.build_colors();
+       dialog_.reset(parent_.build_colors());
 
        fl_set_object_color(dialog_->button_color,
                            GUI_COLOR_CHOICE, GUI_COLOR_CHOICE);
@@ -599,14 +577,14 @@ void FormPreferences::Colors::InputBrowserLyX() const
        // Is the choice an Xforms color...
        RGBColor col;
 
-       if( selLyX-1 < xformColorDB.size() ) {
-               vector<XformColor>::size_type const i = selLyX - 1;
-               col = xformColorDB[i].color();
+       if( selLyX-1 < xformsColorDB.size() ) {
+               vector<XformsColor>::size_type const i = selLyX - 1;
+               col = xformsColorDB[i].color();
        }
        // or a LyX Logical color?
        else {
                vector<NamedColor>::size_type const i = selLyX - 1 -
-                       xformColorDB.size();
+                       xformsColorDB.size();
                col = lyxColorDB[i].color();
        }
 
@@ -619,8 +597,7 @@ void FormPreferences::Colors::InputBrowserLyX() const
        SwitchColorSpace();
        
        // Deactivate the modify button to begin with...
-       fl_deactivate_object(dialog_->button_modify);
-       fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
+       setEnabled(dialog_->button_modify, false);
        
        fl_unfreeze_form(dialog_->form);
 }
@@ -663,24 +640,18 @@ void FormPreferences::Colors::InputHSV()
        bool modify = false;
        
        // Is the choice an Xforms color...
-       if( selLyX-1 < xformColorDB.size() ) {
-               vector<XformColor>::size_type const i = selLyX - 1;
-               modify = (xformColorDB[i].color() != col);
+       if( selLyX-1 < xformsColorDB.size() ) {
+               vector<XformsColor>::size_type const i = selLyX - 1;
+               modify = (xformsColorDB[i].color() != col);
        }
        // or a LyX Logical color?
        else {
                vector<NamedColor>::size_type const i = selLyX - 1 -
-                       xformColorDB.size();
+                       xformsColorDB.size();
                modify = (lyxColorDB[i].color() != col);
        }
 
-       if (modify) {
-               fl_activate_object(dialog_->button_modify);
-               fl_set_object_lcol(dialog_->button_modify, FL_BLACK);
-       } else {
-               fl_deactivate_object(dialog_->button_modify);
-               fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
-       }
+       setEnabled(dialog_->button_modify, modify);
 }
 
 
@@ -710,24 +681,18 @@ void FormPreferences::Colors::InputRGB()
        bool modify = false;
        
        // Is the choice an Xforms color...
-       if( selLyX-1 < xformColorDB.size() ) {
-               vector<XformColor>::size_type const i = selLyX - 1;
-               modify = (xformColorDB[i].color() != col);
+       if( selLyX-1 < xformsColorDB.size() ) {
+               vector<XformsColor>::size_type const i = selLyX - 1;
+               modify = (xformsColorDB[i].color() != col);
        }
        // or a LyX Logical color?
        else {
                vector<NamedColor>::size_type const i = selLyX - 1 -
-                       xformColorDB.size();
+                       xformsColorDB.size();
                modify = (lyxColorDB[i].color() != col);
        }
 
-       if (modify) {
-               fl_activate_object(dialog_->button_modify);
-               fl_set_object_lcol(dialog_->button_modify, FL_BLACK);
-       } else {
-               fl_deactivate_object(dialog_->button_modify);
-               fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
-       }
+       setEnabled(dialog_->button_modify, modify);
 }
 
 
@@ -735,15 +700,15 @@ void FormPreferences::Colors::LoadBrowserLyX()
 {
        if (!dialog_->browser_lyx_objs->visible) return;
 
-       // First, define the modifiable xform colors
-       xformColorDB.clear();
-       XformColor xcol;
+       // First, define the modifiable xforms colors
+       xformsColorDB.clear();
+       XformsColor xcol;
 
        xcol.name = _("GUI background");
        xcol.colorID = FL_COL1;
        fl_getmcolor(FL_COL1, &xcol.r, &xcol.g, &xcol.b);
 
-       xformColorDB.push_back(xcol);
+       xformsColorDB.push_back(xcol);
 
        xcol.name = _("GUI text");
        xcol.colorID = FL_BLACK;
@@ -752,19 +717,19 @@ void FormPreferences::Colors::LoadBrowserLyX()
        fl_mapcolor(GUI_COLOR_CURSOR, xcol.r, xcol.g, xcol.b);
        fl_set_cursor_color(FL_DEFAULT_CURSOR, GUI_COLOR_CURSOR, FL_WHITE);
 
-       xformColorDB.push_back(xcol);
+       xformsColorDB.push_back(xcol);
 
        xcol.name = _("GUI selection");
        xcol.colorID = FL_YELLOW;
        fl_getmcolor(FL_YELLOW, &xcol.r, &xcol.g, &xcol.b);
 
-       xformColorDB.push_back(xcol);
+       xformsColorDB.push_back(xcol);
 
        xcol.name = _("GUI pointer");
        xcol.colorID = GUI_COLOR_CURSOR;
        fl_getmcolor(GUI_COLOR_CURSOR, &xcol.r, &xcol.g, &xcol.b);
 
-       xformColorDB.push_back(xcol);
+       xformsColorDB.push_back(xcol);
 
        // Now create the the LyX LColors database
        lyxColorDB.clear();
@@ -796,7 +761,7 @@ void FormPreferences::Colors::LoadBrowserLyX()
 
                        string const arg = lcolor.getLyXName(lc) + " black";
                        parent_.lv_->getLyXFunc()->
-                               Dispatch(LFUN_SET_COLOR, arg);
+                               dispatch(LFUN_SET_COLOR, arg);
                        continue;
                }
 
@@ -831,13 +796,13 @@ void FormPreferences::Colors::LoadBrowserLyX()
        FL_OBJECT * colbr = dialog_->browser_lyx_objs;
        fl_freeze_form(dialog_->form);
        fl_clear_browser(colbr);
-       for (vector<XformColor>::const_iterator cit = xformColorDB.begin();
-            cit != xformColorDB.end(); ++cit) {
-               fl_addto_browser(colbr, (*cit).getname().c_str());
+       for (vector<XformsColor>::const_iterator cit = xformsColorDB.begin();
+            cit != xformsColorDB.end(); ++cit) {
+               fl_addto_browser(colbr, cit->getname().c_str());
        }
        for (vector<NamedColor>::const_iterator cit = lyxColorDB.begin();
             cit != lyxColorDB.end(); ++cit) {
-               fl_addto_browser(colbr, (*cit).getname().c_str());
+               fl_addto_browser(colbr, cit->getname().c_str());
        }
 
        // just to be safe...
@@ -859,26 +824,23 @@ void FormPreferences::Colors::Modify()
        fl_getmcolor(GUI_COLOR_CHOICE, &col.r, &col.g, &col.b);
 
        // Is the choice an Xforms color...
-       if( selLyX-1 < xformColorDB.size() ) {
-               vector<XformColor>::size_type const i = selLyX - 1;
-               xformColorDB[i].r  = col.r;
-               xformColorDB[i].g  = col.g;
-               xformColorDB[i].b  = col.b;
+       if( selLyX-1 < xformsColorDB.size() ) {
+               vector<XformsColor>::size_type const i = selLyX - 1;
+               xformsColorDB[i].r  = col.r;
+               xformsColorDB[i].g  = col.g;
+               xformsColorDB[i].b  = col.b;
        }
        // or a LyX Logical color?
        else {
                vector<NamedColor>::size_type const i = selLyX - 1 -
-                       xformColorDB.size();
+                       xformsColorDB.size();
                lyxColorDB[i].r  = col.r;
                lyxColorDB[i].g  = col.g;
                lyxColorDB[i].b  = col.b;
        }
 
        fl_freeze_form(dialog_->form);
-
-       fl_deactivate_object(dialog_->button_modify);
-       fl_set_object_lcol(dialog_->button_modify, FL_INACTIVE);
-       
+       setEnabled(dialog_->button_modify, false);      
        fl_unfreeze_form(dialog_->form);
 }
 
@@ -963,23 +925,28 @@ string const FormPreferences::Colors::X11hexname(RGBColor const & col) const
 }
 
 
-FormPreferences::Converters::~Converters()
+FormPreferences::Converters::Converters(FormPreferences & p)
+       : parent_(p)
+{}
+
+
+FD_form_converters const * FormPreferences::Converters::dialog()
 {
-       delete dialog_;
+       return dialog_.get();
 }
 
 
 void FormPreferences::Converters::apply() const
 {
        converters = local_converters;
-       converters.Update(formats);
-       converters.BuildGraph();
+       converters.update(formats);
+       converters.buildGraph();
 }
 
 
 void FormPreferences::Converters::build()
 {
-       dialog_ = parent_.build_converters();
+       dialog_.reset(parent_.build_converters());
 
        fl_set_input_return(dialog_->input_converter, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_flags, FL_RETURN_CHANGED);
@@ -1038,7 +1005,7 @@ bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
                return Add();
 
        } else if (ob == dialog_->button_delete) {
-               return Delete();
+               return erase();
        }
 
        return true;
@@ -1048,21 +1015,21 @@ bool FormPreferences::Converters::input(FL_OBJECT const * const ob)
 void FormPreferences::Converters::update()
 {
        local_converters = converters;
-       local_converters.Update(local_formats);
+       local_converters.update(local_formats);
        UpdateBrowser();
 }
 
 
 void FormPreferences::Converters::UpdateBrowser()
 {
-       local_converters.Sort();
+       local_converters.sort();
 
        fl_freeze_form(dialog_->form);
        fl_clear_browser(dialog_->browser_all);
        for (::Converters::const_iterator cit = local_converters.begin();
             cit != local_converters.end(); ++cit) {
-               string const name = (*cit).From->prettyname() + " -> "
-                       + (*cit).To->prettyname();
+               string const name = cit->From->prettyname() + " -> "
+                       + cit->To->prettyname();
                fl_addto_browser(dialog_->browser_all, name.c_str());
        }
        Input();
@@ -1077,14 +1044,13 @@ bool FormPreferences::Converters::Add()
        string const command = fl_get_input(dialog_->input_converter);
        string const flags = fl_get_input(dialog_->input_flags);
 
-       Converter const * old = local_converters.GetConverter(from, to);
-       local_converters.Add(from, to, command, flags);
+       Converter const * old = local_converters.getConverter(from, to);
+       local_converters.add(from, to, command, flags);
        if (!old) {
-               local_converters.UpdateLast(local_formats);
+               local_converters.updateLast(local_formats);
                UpdateBrowser();
        }
-       fl_deactivate_object(dialog_->button_add);
-       fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
+       setEnabled(dialog_->button_add, false);
 
        return true;
 }
@@ -1097,39 +1063,35 @@ bool FormPreferences::Converters::Browser()
 
        fl_freeze_form(dialog_->form);
 
-       Converter const & c = local_converters.Get(i-1);
-       int j = local_formats.GetNumber(c.from);
+       Converter const & c = local_converters.get(i - 1);
+       int j = local_formats.getNumber(c.from);
        if (j >= 0)
-               fl_set_choice(dialog_->choice_from, j+1);
+               fl_set_choice(dialog_->choice_from, j + 1);
 
-       j = local_formats.GetNumber(c.to);
+       j = local_formats.getNumber(c.to);
        if (j >= 0)
-               fl_set_choice(dialog_->choice_to, j+1);
+               fl_set_choice(dialog_->choice_to, j + 1);
 
        fl_set_input(dialog_->input_converter, c.command.c_str());
        fl_set_input(dialog_->input_flags, c.flags.c_str());
 
        fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
-       fl_set_button_shortcut(dialog_->button_add,
-                               scex(_("Modify|#M")), 1);
-
-       fl_deactivate_object(dialog_->button_add);
-       fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
+       fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
 
-       fl_activate_object(dialog_->button_delete);
-       fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
+       setEnabled(dialog_->button_add,    false);
+       setEnabled(dialog_->button_delete, true);
                                
        fl_unfreeze_form(dialog_->form);
        return false;
 }
 
 
-bool FormPreferences::Converters::Delete()
+bool FormPreferences::Converters::erase()
 {
        string const from = GetFrom();
        string const to = GetTo();
 
-       local_converters.Delete(from, to);
+       local_converters.erase(from, to);
        UpdateBrowser();
        return true;
 }
@@ -1139,43 +1101,32 @@ bool FormPreferences::Converters::Input()
 {
        string const from = GetFrom();
        string const to = GetTo();
-       int const sel = local_converters.GetNumber(from, to);
+       int const sel = local_converters.getNumber(from, to);
        
        fl_freeze_form(dialog_->form);
 
        if (sel < 0) {
-               fl_set_object_label(dialog_->button_add,
-                                    idex(_("Add|#A")));
-               fl_set_button_shortcut(dialog_->button_add,
-                                       scex(_("Add|#A")), 1);
+               fl_set_object_label(dialog_->button_add, idex(_("Add|#A")));
+               fl_set_button_shortcut(dialog_->button_add, 
+                                      scex(_("Add|#A")), 1);
 
                fl_deselect_browser(dialog_->browser_all);
-
-               fl_deactivate_object(dialog_->button_delete);
-               fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
+               setEnabled(dialog_->button_delete, false);
 
        } else {
-               fl_set_object_label(dialog_->button_add,
-                                    idex(_("Modify|#M")));
+               fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
                fl_set_button_shortcut(dialog_->button_add,
                                        scex(_("Modify|#M")), 1);
                
                int top = max(sel-5, 0);
                fl_set_browser_topline(dialog_->browser_all, top);
                fl_select_browser_line(dialog_->browser_all, sel+1);
-               
-               fl_activate_object(dialog_->button_delete);
-               fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
+               setEnabled(dialog_->button_delete, true);
        }
 
-       string const command = fl_get_input(dialog_->input_converter);
-       if (command.empty() || from == to) {
-               fl_deactivate_object(dialog_->button_add);
-               fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
-       } else {
-               fl_activate_object(dialog_->button_add);
-               fl_set_object_lcol(dialog_->button_add, FL_BLACK);
-       }
+       string const command = strip(fl_get_input(dialog_->input_converter));
+       bool const enable = !(command.empty() || from == to);
+       setEnabled(dialog_->button_add, enable);
 
        fl_unfreeze_form(dialog_->form);
        return false;
@@ -1188,7 +1139,7 @@ string const FormPreferences::Converters::GetFrom() const
                fl_get_choice(dialog_->choice_from);
 
        if (i > 0 && i <= local_formats.size())
-               return local_formats.Get(i-1).name();
+               return local_formats.get(i - 1).name();
        else {
                lyxerr << "FormPreferences::Converters::GetFrom: No choice!"
                       << endl;
@@ -1200,10 +1151,10 @@ string const FormPreferences::Converters::GetFrom() const
 string const FormPreferences::Converters::GetTo() const
 {
        ::Formats::FormatList::size_type const i =
-               fl_get_choice(dialog_->choice_from);
+               fl_get_choice(dialog_->choice_to);
 
        if (i > 0 && i <= local_formats.size())
-               return local_formats.Get(i-1).name();
+               return local_formats.get(i - 1).name();
        else {
                lyxerr << "FormPreferences::Converters::GetTo: No choice!"
                       << endl;
@@ -1221,7 +1172,7 @@ void FormPreferences::Converters::UpdateChoices() const
                        choice += " | ";
                else
                        choice += " ";
-               choice += (*cit).prettyname();
+               choice += cit->prettyname();
        }
        choice += " ";
 
@@ -1233,9 +1184,14 @@ void FormPreferences::Converters::UpdateChoices() const
 }
 
 
-FormPreferences::Formats::~Formats()
+FormPreferences::Formats::Formats( FormPreferences &  p )
+       : parent_(p)
+{}
+
+
+FD_form_formats const * FormPreferences::Formats::dialog()
 {
-       delete dialog_;
+       return dialog_.get();
 }
 
 
@@ -1247,7 +1203,7 @@ void FormPreferences::Formats::apply() const
 
 void FormPreferences::Formats::build()
 {
-       dialog_ = parent_.build_formats();
+       dialog_.reset(parent_.build_formats());
 
        fl_set_input_return(dialog_->input_format, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_viewer, FL_RETURN_CHANGED);
@@ -1315,7 +1271,7 @@ bool FormPreferences::Formats::input(FL_OBJECT const * const ob)
                return Add();
 
        } else if (ob == dialog_->button_delete) {
-               return Delete();
+               return erase();
        }
 
        return false;
@@ -1331,7 +1287,7 @@ void FormPreferences::Formats::update()
 
 void FormPreferences::Formats::UpdateBrowser()
 {
-       local_formats.Sort();
+       local_formats.sort();
 
        fl_freeze_form(dialog_->form);
        fl_deselect_browser(dialog_->browser_all);
@@ -1339,14 +1295,14 @@ void FormPreferences::Formats::UpdateBrowser()
        for (::Formats::const_iterator cit = local_formats.begin();
             cit != local_formats.end(); ++cit)
                fl_addto_browser(dialog_->browser_all,
-                                (*cit).prettyname().c_str());
+                                cit->prettyname().c_str());
 
        Input();
        fl_unfreeze_form(dialog_->form);
 
        // Mustn't forget to update the Formats available to the converters_
        parent_.converters_.UpdateChoices();
-       local_converters.Update(local_formats);
+       local_converters.update(local_formats);
 }
 
 
@@ -1358,17 +1314,16 @@ bool FormPreferences::Formats::Add()
        string const shortcut =  fl_get_input(dialog_->input_shrtcut);
        string const viewer =  fl_get_input(dialog_->input_viewer);
 
-       Format const * old = local_formats.GetFormat(name);
+       Format const * old = local_formats.getFormat(name);
        string const old_prettyname = old ? old->prettyname() : string();
-       local_formats.Add(name, extension, prettyname, shortcut);
-       local_formats.SetViewer(name, viewer);
+       local_formats.add(name, extension, prettyname, shortcut);
+       local_formats.setViewer(name, viewer);
        if (!old || prettyname != old_prettyname) {
                UpdateBrowser();
                if (old)
                        parent_.converters_.UpdateBrowser();
        }
-       fl_deactivate_object(dialog_->button_add);
-       fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
+       setEnabled(dialog_->button_add, false);
 
        return true;
 }
@@ -1381,7 +1336,7 @@ bool FormPreferences::Formats::Browser()
 
        fl_freeze_form(dialog_->form);
 
-       Format const & f = local_formats.Get(i-1);
+       Format const & f = local_formats.get(i - 1);
 
        fl_set_input(dialog_->input_format, f.name().c_str());
        fl_set_input(dialog_->input_gui_name, f.prettyname().c_str());
@@ -1392,29 +1347,25 @@ bool FormPreferences::Formats::Browser()
        fl_set_object_label(dialog_->button_add, idex(_("Modify|#M")));
        fl_set_button_shortcut(dialog_->button_add, scex(_("Modify|#M")), 1);
 
-       fl_deactivate_object(dialog_->button_add);
-       fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
-
-       fl_activate_object(dialog_->button_delete);
-       fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
+       setEnabled(dialog_->button_add,    false);
+       setEnabled(dialog_->button_delete, true);
                                
        fl_unfreeze_form(dialog_->form);
        return false;
 }
 
 
-bool FormPreferences::Formats::Delete()
+bool FormPreferences::Formats::erase()
 {
        string const name = fl_get_input(dialog_->input_format);
 
-       if (local_converters.FormatIsUsed(name)) {
+       if (local_converters.formatIsUsed(name)) {
                parent_.printWarning(_("Cannot remove a Format used by a Converter. Remove the converter first."));
-               fl_deactivate_object(dialog_->button_delete);
-               fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
+               setEnabled(dialog_->button_delete, false);
                return false;
        }
 
-       local_formats.Delete(name);
+       local_formats.erase(name);
        UpdateBrowser();
        return true;
 }
@@ -1423,7 +1374,7 @@ bool FormPreferences::Formats::Delete()
 bool FormPreferences::Formats::Input()
 {
        string const name = fl_get_input(dialog_->input_format);
-       int const sel = local_formats.GetNumber(name);
+       int const sel = local_formats.getNumber(name);
        fl_freeze_form(dialog_->form);
 
        if (sel < 0) {
@@ -1433,9 +1384,7 @@ bool FormPreferences::Formats::Input()
                                        scex(_("Add|#A")), 1);
 
                fl_deselect_browser(dialog_->browser_all);
-
-               fl_deactivate_object(dialog_->button_delete);
-               fl_set_object_lcol(dialog_->button_delete, FL_INACTIVE);
+               setEnabled(dialog_->button_delete, false);
 
        } else {
                fl_set_object_label(dialog_->button_add,
@@ -1446,31 +1395,28 @@ bool FormPreferences::Formats::Input()
                int const top = max(sel-5, 0);
                fl_set_browser_topline(dialog_->browser_all, top);
                fl_select_browser_line(dialog_->browser_all, sel+1);
-               
-               fl_activate_object(dialog_->button_add);
-               fl_set_object_lcol(dialog_->button_add, FL_BLACK);
 
-               fl_activate_object(dialog_->button_delete);
-               fl_set_object_lcol(dialog_->button_delete, FL_BLACK);
+               setEnabled(dialog_->button_add, true);
+               setEnabled(dialog_->button_delete, true);
        }
 
        string const prettyname = fl_get_input(dialog_->input_gui_name);
-       if (name.empty() || prettyname.empty()) {
-               fl_deactivate_object(dialog_->button_add);
-               fl_set_object_lcol(dialog_->button_add, FL_INACTIVE);
-       } else {
-               fl_activate_object(dialog_->button_add);
-               fl_set_object_lcol(dialog_->button_add, FL_BLACK);
-       }
+       bool const enable = !(name.empty() || prettyname.empty());
+       setEnabled(dialog_->button_add, enable);
 
        fl_unfreeze_form(dialog_->form);
        return false;
 }
 
 
-FormPreferences::InputsMisc::~InputsMisc()
+FormPreferences::InputsMisc::InputsMisc( FormPreferences &  p )
+       : parent_(p)
+{}
+
+
+FD_form_inputs_misc const * FormPreferences::InputsMisc::dialog()
 {
-       delete dialog_;
+       return dialog_.get();
 }
 
 
@@ -1483,7 +1429,7 @@ void FormPreferences::InputsMisc::apply() const
 
 void FormPreferences::InputsMisc::build()
 {
-       dialog_ = parent_.build_inputs_misc();
+       dialog_.reset(parent_.build_inputs_misc());
 
        fl_set_input_return(dialog_->input_date_format, FL_RETURN_CHANGED);
 
@@ -1511,9 +1457,14 @@ void FormPreferences::InputsMisc::update()
 }
 
 
-FormPreferences::Interface::~Interface()
+FormPreferences::Interface::Interface( FormPreferences &  p )
+       : parent_(p)
+{}
+
+
+FD_form_interface const * FormPreferences::Interface::dialog()
 {
-       delete dialog_;
+       return dialog_.get();
 }
 
 
@@ -1533,7 +1484,7 @@ void FormPreferences::Interface::apply() const
 
 void FormPreferences::Interface::build()
 {
-       dialog_ = parent_.build_interface();
+       dialog_.reset(parent_.build_interface());
 
        fl_set_input_return(dialog_->input_popup_font, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_menu_font, FL_RETURN_CHANGED);
@@ -1623,10 +1574,14 @@ void FormPreferences::Interface::update()
 }
 
 
-FormPreferences::Language::~Language()
+FormPreferences::Language::Language( FormPreferences &  p )
+       : parent_(p)
+{}
+
+
+FD_form_language const * FormPreferences::Language::dialog()
 {
-       delete combo_default_lang;
-       delete dialog_;
+       return dialog_.get();
 }
 
 
@@ -1675,7 +1630,7 @@ void FormPreferences::Language::apply()
 
 void FormPreferences::Language::build()
 {
-       dialog_ = parent_.build_language();
+       dialog_.reset(parent_.build_language());
 
        fl_set_input_return(dialog_->input_package, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_command_begin, FL_RETURN_CHANGED);
@@ -1687,7 +1642,7 @@ void FormPreferences::Language::build()
 
        FL_OBJECT * obj = dialog_->choice_default_lang;
        fl_deactivate_object(dialog_->choice_default_lang);
-       combo_default_lang = new Combox(FL_COMBOX_DROPLIST);
+       combo_default_lang.reset(new Combox(FL_COMBOX_DROPLIST));
        combo_default_lang->add(obj->x, obj->y, obj->w, obj->h, 400,
                                parent_.lang_opts_tab_->tabfolder_outer,
                                parent_.dialog_->tabfolder_prefs);
@@ -1696,7 +1651,7 @@ void FormPreferences::Language::build()
 
        for (Languages::const_iterator cit = languages.begin();
            cit != languages.end(); ++cit) {
-               combo_default_lang->addto((*cit).second.lang());
+               combo_default_lang->addto(cit->second.lang());
        }
 
        fl_end_form();
@@ -1735,7 +1690,7 @@ FormPreferences::Language::feedback(FL_OBJECT const * const ob) const
 {
        string str;
 
-       if (reinterpret_cast<Combox const *>(ob) == combo_default_lang)
+       if (reinterpret_cast<Combox const *>(ob) == combo_default_lang.get())
                str = lyxrc.getDescription(LyXRC::RC_DEFAULT_LANGUAGE);
        else if (ob == dialog_->check_use_kbmap)
                str = lyxrc.getDescription(LyXRC::RC_KBMAP);
@@ -1774,35 +1729,11 @@ bool FormPreferences::Language::input(FL_OBJECT const * const ob)
        // objects,
        // otherwise the function is called by an xforms CB via input().
        if (!ob || ob == dialog_->check_use_kbmap) {
-               if (fl_get_button(dialog_->check_use_kbmap)) {
-                       fl_activate_object(dialog_->button_kbmap1_browse);
-                       fl_set_object_lcol(dialog_->button_kbmap1_browse,
-                                          FL_BLACK);
-
-                       fl_activate_object(dialog_->button_kbmap2_browse);
-                       fl_set_object_lcol(dialog_->button_kbmap2_browse,
-                                          FL_BLACK);
-
-                       fl_activate_object(dialog_->input_kbmap1);
-                       fl_set_object_lcol(dialog_->input_kbmap1, FL_BLACK);
-                       fl_activate_object(dialog_->input_kbmap2);
-                       fl_set_object_lcol(dialog_->input_kbmap2, FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->button_kbmap1_browse);
-                       fl_set_object_lcol(dialog_->button_kbmap1_browse,
-                                          FL_INACTIVE);
-
-                       fl_deactivate_object(dialog_->button_kbmap2_browse);
-                       fl_set_object_lcol(dialog_->button_kbmap2_browse,
-                                          FL_INACTIVE);
-
-                       fl_deactivate_object(dialog_->input_kbmap1);
-                       fl_set_object_lcol(dialog_->input_kbmap1,
-                                          FL_INACTIVE);
-                       fl_deactivate_object(dialog_->input_kbmap2);
-                       fl_set_object_lcol(dialog_->input_kbmap2,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_use_kbmap);
+               setEnabled(dialog_->button_kbmap1_browse, enable);
+               setEnabled(dialog_->button_kbmap2_browse, enable);
+               setEnabled(dialog_->input_kbmap1, enable);
+               setEnabled(dialog_->input_kbmap2, enable);
        }
 
        if (ob == dialog_->button_kbmap1_browse) {
@@ -1832,7 +1763,7 @@ void FormPreferences::Language::update()
        fl_set_button(dialog_->check_use_kbmap,
                      lyxrc.use_kbmap);
 
-       combo_default_lang->select_text(lyxrc.default_language);
+       combo_default_lang->select(lyxrc.default_language);
 
        if (lyxrc.use_kbmap) {
                fl_set_input(dialog_->input_kbmap1,
@@ -1871,13 +1802,18 @@ void FormPreferences::Language::ComboCB(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));
+    pre->bc().valid(pre->input(reinterpret_cast<FL_OBJECT *>(combox), 0));
 }
 
 
-FormPreferences::LnFmisc::~LnFmisc()
+FormPreferences::LnFmisc::LnFmisc( FormPreferences &  p )
+       : parent_(p)
+{}
+
+
+FD_form_lnf_misc const * FormPreferences::LnFmisc::dialog()
 {
-       delete dialog_;
+       return dialog_.get();
 }
 
 
@@ -1892,6 +1828,8 @@ void FormPreferences::LnFmisc::apply() const
        lyxrc.new_ask_filename = fl_get_button(dialog_->check_ask_new_file);
        lyxrc.cursor_follows_scrollbar =
                fl_get_button(dialog_->check_cursor_follows_scrollbar);
+       lyxrc.dialogs_iconify_with_main =
+               fl_get_button(dialog_->check_dialogs_iconify_with_main);
        lyxrc.autosave = static_cast<unsigned int>
                (fl_get_counter_value(dialog_->counter_autosave));
        lyxrc.wheel_jump = static_cast<unsigned int>
@@ -1901,7 +1839,7 @@ void FormPreferences::LnFmisc::apply() const
 
 void FormPreferences::LnFmisc::build()
 {
-       dialog_ = parent_.build_lnf_misc();
+       dialog_.reset(parent_.build_lnf_misc());
 
        fl_set_counter_step(dialog_->counter_autosave, 1, 10);
        fl_set_counter_step(dialog_->counter_wm_jump, 1, 10);
@@ -1917,6 +1855,7 @@ void FormPreferences::LnFmisc::build()
        setPreHandler(dialog_->counter_autosave);
        setPreHandler(dialog_->check_ask_new_file);
        setPreHandler(dialog_->check_cursor_follows_scrollbar);
+       setPreHandler(dialog_->check_dialogs_iconify_with_main);
        setPreHandler(dialog_->counter_wm_jump);
 }
 
@@ -1938,6 +1877,8 @@ FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
                str = lyxrc.getDescription(LyXRC::RC_NEW_ASK_FILENAME);
        else if (ob == dialog_->check_cursor_follows_scrollbar)
                str = lyxrc.getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
+       else if (ob == dialog_->check_dialogs_iconify_with_main)
+               str = lyxrc.getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
        else if (ob == dialog_->counter_autosave)
                str = lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
        else if (ob == dialog_->counter_wm_jump)
@@ -1957,14 +1898,21 @@ void FormPreferences::LnFmisc::update()
        fl_set_button(dialog_->check_ask_new_file, lyxrc.new_ask_filename);
        fl_set_button(dialog_->check_cursor_follows_scrollbar,
                      lyxrc.cursor_follows_scrollbar);
+       fl_set_button(dialog_->check_dialogs_iconify_with_main,
+                     lyxrc.dialogs_iconify_with_main);
        fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
        fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
 }
 
 
-FormPreferences::OutputsMisc::~OutputsMisc()
+FormPreferences::OutputsMisc::OutputsMisc( FormPreferences &  p )
+       : parent_(p)
+{}
+
+
+FD_form_outputs_misc const * FormPreferences::OutputsMisc::dialog()
 {
-       delete dialog_;
+       return dialog_.get();
 }
 
 
@@ -1980,12 +1928,13 @@ void FormPreferences::OutputsMisc::apply() const
 
        lyxrc.ascii_roff_command = fl_get_input(dialog_->input_ascii_roff);
        lyxrc.chktex_command = fl_get_input(dialog_->input_checktex);
+       lyxrc.view_dvi_paper_option = fl_get_input(dialog_->input_paperoption);
 }
 
 
 void FormPreferences::OutputsMisc::build()
 {
-       dialog_ = parent_.build_outputs_misc();
+       dialog_.reset(parent_.build_outputs_misc());
 
        fl_set_counter_step(dialog_->counter_line_len, 1, 10);
 
@@ -1993,6 +1942,7 @@ void FormPreferences::OutputsMisc::build()
        fl_set_input_return(dialog_->input_tex_encoding, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_ascii_roff,   FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_checktex,     FL_RETURN_CHANGED);
+       fl_set_input_return(dialog_->input_paperoption,  FL_RETURN_CHANGED);
 
        fl_addto_choice(dialog_->choice_default_papersize,
                        _(" default | US letter | legal | executive | A3 | A4 | A5 | B5 "));
@@ -2003,6 +1953,7 @@ void FormPreferences::OutputsMisc::build()
        setPreHandler(dialog_->choice_default_papersize);
        setPreHandler(dialog_->input_ascii_roff);
        setPreHandler(dialog_->input_checktex);
+       setPreHandler(dialog_->input_paperoption);
 }
 
 
@@ -2021,6 +1972,8 @@ FormPreferences::OutputsMisc::feedback(FL_OBJECT const * const ob) const
                str = lyxrc.getDescription(LyXRC::RC_CHKTEX_COMMAND);
        else if (ob == dialog_->choice_default_papersize)
                str = lyxrc.getDescription(LyXRC::RC_DEFAULT_PAPERSIZE);
+       else if (ob == dialog_->input_paperoption)
+               str = lyxrc.getDescription(LyXRC::RC_VIEWDVI_PAPEROPTION);
 
        return str;
 }
@@ -2038,12 +1991,19 @@ void FormPreferences::OutputsMisc::update()
                     lyxrc.ascii_roff_command.c_str());
        fl_set_input(dialog_->input_checktex,
                     lyxrc.chktex_command.c_str());
+       fl_set_input(dialog_->input_paperoption,
+                     lyxrc.view_dvi_paper_option.c_str());
 }
 
 
-FormPreferences::Paths::~Paths()
+FormPreferences::Paths::Paths( FormPreferences &  p )
+       : parent_(p)
+{}
+
+
+FD_form_paths const * FormPreferences::Paths::dialog()
 {
-       delete dialog_;
+       return dialog_.get();
 }
 
 
@@ -2084,7 +2044,7 @@ void FormPreferences::Paths::apply()
 
 void FormPreferences::Paths::build()
 {
-       dialog_ = parent_.build_paths();
+       dialog_.reset(parent_.build_paths());
 
        fl_set_input_return(dialog_->input_default_path, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_template_path, FL_RETURN_CHANGED);
@@ -2133,7 +2093,6 @@ FormPreferences::Paths::feedback(FL_OBJECT const * const ob) const
                str = lyxrc.getDescription(LyXRC::RC_BACKUPDIR_PATH);
        else if (ob == dialog_->input_serverpipe) {
                str = lyxrc.getDescription(LyXRC::RC_SERVERPIPE);
-               str += " Enter either the input pipe, xxx.in, or the output pipe, xxx.out.";
        }
 
        return str;
@@ -2148,39 +2107,18 @@ bool FormPreferences::Paths::input(FL_OBJECT const * const ob)
        // objects,
        // otherwise the function is called by an xforms CB via input().
        if (!ob || ob == dialog_->check_use_temp_dir) {
-               if (fl_get_button(dialog_->check_use_temp_dir)) {
-                       fl_activate_object(dialog_->input_temp_dir);
-                       fl_set_object_lcol(dialog_->input_temp_dir,
-                                          FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->input_temp_dir);
-                       fl_set_object_lcol(dialog_->input_temp_dir,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_use_temp_dir);
+               setEnabled(dialog_->input_temp_dir, enable);
        }
 
        if (!ob || ob == dialog_->check_last_files) {
-               if (fl_get_button(dialog_->check_last_files)) {
-                       fl_activate_object(dialog_->input_lastfiles);
-                       fl_set_object_lcol(dialog_->input_lastfiles,
-                                          FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->input_lastfiles);
-                       fl_set_object_lcol(dialog_->input_lastfiles,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_last_files);
+               setEnabled(dialog_->input_lastfiles, enable);
        }
 
        if (!ob || ob == dialog_->check_make_backups) {
-               if (fl_get_button(dialog_->check_make_backups)) {
-                       fl_activate_object(dialog_->input_backup_path);
-                       fl_set_object_lcol(dialog_->input_backup_path,
-                                          FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->input_backup_path);
-                       fl_set_object_lcol(dialog_->input_backup_path,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_make_backups);
+               setEnabled(dialog_->input_backup_path, enable);
        }
 
        if (!ob || ob == dialog_->input_default_path) {
@@ -2320,9 +2258,14 @@ void FormPreferences::Paths::update()
 }
 
 
-FormPreferences::Printer::~Printer()
+FormPreferences::Printer::Printer(FormPreferences &  p)
+       : parent_(p)
+{}
+
+
+FD_form_printer const * FormPreferences::Printer::dialog()
 {
-       delete dialog_;
+       return dialog_.get();
 }
 
 
@@ -2402,7 +2345,7 @@ FormPreferences::Printer::feedback(FL_OBJECT const * const ob) const
 
 void FormPreferences::Printer::build()
 {
-       dialog_ = parent_.build_printer();
+       dialog_.reset(parent_.build_printer());
 
        fl_set_input_return(dialog_->input_command, FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_page_range, FL_RETURN_CHANGED);
@@ -2485,9 +2428,14 @@ void FormPreferences::Printer::update()
 }
 
 
-FormPreferences::ScreenFonts::~ScreenFonts()
+FormPreferences::ScreenFonts::ScreenFonts( FormPreferences &  p )
+       : parent_(p)
+{}
+
+
+FD_form_screen_fonts const * FormPreferences::ScreenFonts::dialog()
 {
-       delete dialog_;
+       return dialog_.get();
 }
 
 
@@ -2602,14 +2550,14 @@ void FormPreferences::ScreenFonts::apply() const
        if (changed) {
                // Now update the buffers
                // Can anything below here affect the redraw process?
-               parent_.lv_->getLyXFunc()->Dispatch(LFUN_SCREEN_FONT_UPDATE);
+               parent_.lv_->getLyXFunc()->dispatch(LFUN_SCREEN_FONT_UPDATE);
        }
 }
 
 
 void FormPreferences::ScreenFonts::build()
 {
-       dialog_ = parent_.build_screen_fonts();
+       dialog_.reset(parent_.build_screen_fonts());
 
        fl_set_counter_step(dialog_->counter_zoom, 1, 10);
        fl_set_counter_step(dialog_->counter_dpi,  1, 10);
@@ -2787,13 +2735,19 @@ void FormPreferences::ScreenFonts::update()
 }
 
 
-FormPreferences::SpellChecker::~SpellChecker()
+
+FormPreferences::SpellOptions::SpellOptions( FormPreferences &  p )
+       : parent_(p)
+{}
+
+
+FD_form_spelloptions const * FormPreferences::SpellOptions::dialog()
 {
-       delete dialog_;
+       return dialog_.get();
 }
 
 
-void FormPreferences::SpellChecker::apply()
+void FormPreferences::SpellOptions::apply()
 {
 
        string choice = fl_get_choice_text(dialog_->choice_spell_command);
@@ -2801,6 +2755,7 @@ void FormPreferences::SpellChecker::apply()
        
        lyxrc.isp_command = choice;
 
+#if 0
        // If spell checker == "none", all other input set to off.
        if (fl_get_choice(dialog_->choice_spell_command) == 1) {
                lyxrc.isp_use_alt_lang = false;
@@ -2815,6 +2770,7 @@ void FormPreferences::SpellChecker::apply()
                lyxrc.isp_accept_compound = false;
                lyxrc.isp_use_input_encoding = false;
        } else {
+#else
                int button = fl_get_button(dialog_->check_alt_lang);
                choice = fl_get_input(dialog_->input_alt_lang);
                if (button && choice.empty()) button = 0;
@@ -2844,19 +2800,26 @@ void FormPreferences::SpellChecker::apply()
 
                button = fl_get_button(dialog_->check_input_enc);
                lyxrc.isp_use_input_encoding = static_cast<bool>(button);
+#endif
+#if 0
        }
+#endif
 
        // Reset view
        update();
 }
 
 
-void FormPreferences::SpellChecker::build()
+void FormPreferences::SpellOptions::build()
 {
-       dialog_ = parent_.build_spellchecker();
+       dialog_.reset(parent_.build_spelloptions());
 
        fl_addto_choice(dialog_->choice_spell_command,
+#if 0
                        _(" none | ispell | aspell "));
+#else
+                       _(" ispell | aspell "));
+#endif
        fl_set_input_return(dialog_->input_alt_lang,      FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_escape_chars,  FL_RETURN_CHANGED);
        fl_set_input_return(dialog_->input_personal_dict, FL_RETURN_CHANGED);
@@ -2876,7 +2839,7 @@ void FormPreferences::SpellChecker::build()
 
 
 string const
-FormPreferences::SpellChecker::feedback(FL_OBJECT const * const ob) const
+FormPreferences::SpellOptions::feedback(FL_OBJECT const * const ob) const
 {
        string str;
 
@@ -2903,12 +2866,13 @@ FormPreferences::SpellChecker::feedback(FL_OBJECT const * const ob) const
 }
 
 
-bool FormPreferences::SpellChecker::input(FL_OBJECT const * const ob)
+bool FormPreferences::SpellOptions::input(FL_OBJECT const * const ob)
 {
-       // !ob if function is called from updateSpellChecker() to de/activate
+       // !ob if function is called from updateSpellOptions() to de/activate
        // objects,
        // otherwise the function is called by an xforms CB via input().
 
+#if 0
        // If spell checker == "none", disable all input.
        if (!ob || ob == dialog_->choice_spell_command) {
                if (fl_get_choice(dialog_->choice_spell_command) == 1) {
@@ -2929,41 +2893,21 @@ bool FormPreferences::SpellChecker::input(FL_OBJECT const * const ob)
                        fl_activate_object(dialog_->check_input_enc);
                }
        }
+#endif
 
        if (!ob || ob == dialog_->check_alt_lang) {
-               if (fl_get_button(dialog_->check_alt_lang)) {
-                       fl_activate_object(dialog_->input_alt_lang);
-                       fl_set_object_lcol(dialog_->input_alt_lang,
-                                          FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->input_alt_lang);
-                       fl_set_object_lcol(dialog_->input_alt_lang,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_alt_lang);
+               setEnabled(dialog_->input_alt_lang, enable);
        }
 
        if (!ob || ob == dialog_->check_escape_chars) {
-               if (fl_get_button(dialog_->check_escape_chars)) {
-                       fl_activate_object(dialog_->input_escape_chars);
-                       fl_set_object_lcol(dialog_->input_escape_chars,
-                                          FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->input_escape_chars);
-                       fl_set_object_lcol(dialog_->input_escape_chars,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_escape_chars);
+               setEnabled(dialog_->input_escape_chars, enable);
        }
 
        if (!ob || ob == dialog_->check_personal_dict) {
-               if (fl_get_button(dialog_->check_personal_dict)) {
-                       fl_activate_object(dialog_->input_personal_dict);
-                       fl_set_object_lcol(dialog_->input_personal_dict,
-                                          FL_BLACK);
-               } else {
-                       fl_deactivate_object(dialog_->input_personal_dict);
-                       fl_set_object_lcol(dialog_->input_personal_dict,
-                                          FL_INACTIVE);
-               }
+               bool const enable = fl_get_button(dialog_->check_personal_dict);
+               setEnabled(dialog_->input_personal_dict, enable);
        }
 
        if (ob == dialog_->button_personal_dict) {
@@ -2977,15 +2921,22 @@ bool FormPreferences::SpellChecker::input(FL_OBJECT const * const ob)
 }
 
 
-void FormPreferences::SpellChecker::update()
+void FormPreferences::SpellOptions::update()
 {
        int choice = 1;
+#if 0
        if (lyxrc.isp_command == "none")
                choice = 1;
        else if (lyxrc.isp_command == "ispell")
                choice = 2;
        else if (lyxrc.isp_command == "aspell")
                choice = 3;
+#else
+       if (lyxrc.isp_command == "ispell")
+               choice = 1;
+       else if (lyxrc.isp_command == "aspell")
+               choice = 2;
+#endif
        fl_set_choice(dialog_->choice_spell_command, choice);
        
        string str;
@@ -3025,8 +2976,7 @@ void FormPreferences::printWarning(string const & warning)
        warningPosted = true;
 
        string str = _("WARNING!") + string(" ") + warning;
-       str = formatted(str, dialog_->text_warning->w-10,
-                        FL_SMALL_SIZE, FL_NORMAL_STYLE);
+       str = formatted(str, dialog_->text_warning->w-10, FL_SMALL_SIZE);
 
        fl_set_object_label(dialog_->text_warning, str.c_str());
        fl_set_object_lsize(dialog_->text_warning, FL_SMALL_SIZE);
@@ -3044,7 +2994,7 @@ void FormPreferences::browse(FL_OBJECT * inpt,
 
        // Show the file browser dialog
        string const new_filename =
-               browseFile(filename, title, pattern, dir1, dir2);
+               browseFile(lv_, filename, title, pattern, dir1, dir2);
 
        // Save the filename to the dialog
        if (new_filename != filename && !new_filename.empty()) {
@@ -3055,20 +3005,27 @@ void FormPreferences::browse(FL_OBJECT * inpt,
 
 
 // C function wrapper, required by xforms.
-extern "C" int C_FormPreferencesFeedbackCB(FL_OBJECT * ob, int event,
-                                          FL_Coord mx, FL_Coord my,
-                                          int key, void * xev)
-{
-       return FormPreferences::FeedbackCB(ob, event, mx, my, key, xev);
+extern "C" {
+       
+       static
+       int C_FormPreferencesFeedbackCB(FL_OBJECT * ob, int event,
+                                       FL_Coord mx, FL_Coord my,
+                                       int key, void * xev)
+       {
+               return FormPreferences::FeedbackCB(ob, event,
+                                                  mx, my, key, xev);
+       }
+       
 }
 
+
 int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event,
                                FL_Coord, FL_Coord, int, void *)
 {
        // Note that the return value is important in the pre-emptive handler.
        // Don't return anything other than 0.
 
-       Assert(ob);
+       lyx::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);
@@ -3084,7 +3041,7 @@ int FormPreferences::FeedbackCB(FL_OBJECT * ob, int event,
 // preemptive handler for feedback messages
 void FormPreferences::Feedback(FL_OBJECT * ob, int event)
 {
-       Assert(ob);
+       lyx::Assert(ob);
 
        switch (event) {
        case FL_ENTER:
@@ -3105,6 +3062,6 @@ void FormPreferences::Feedback(FL_OBJECT * ob, int event)
 
 void FormPreferences::setPreHandler(FL_OBJECT * ob)
 {
-       Assert(ob);
+       lyx::Assert(ob);
        fl_set_object_prehandler(ob, C_FormPreferencesFeedbackCB);
 }