]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormPreferences.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / FormPreferences.C
index 562ba46ac7309933849c705febe2f331aaace4eb..b40d8ebbb95bac253f8b2de9f2e26d0ff1031446 100644 (file)
@@ -1,9 +1,11 @@
 /**
  * \file FormPreferences.C
- * Copyright 2000-2001 The LyX Team.
- * See the file COPYING.
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Angus Leeming, a.leeming@ic.ac.uk
+ * \author Angus Leeming 
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
 
 #include "FormPreferences.h"
 #include "forms/form_preferences.h"
-#include "Dialogs.h"
+
+#include "combox.h"
+#include "Color.h"
+#include "input_validators.h"
+#include "forms_gettext.h"
+#include "xforms_helpers.h"
+#include "helper_funcs.h"
 
 #include "buffer.h"
 #include "converter.h"
 #include "debug.h"
-#include "frontends/LyXView.h"
 #include "language.h"
 #include "frnt_lang.h"
-#include "lyxfunc.h"
 #include "lyxlex.h"
 #include "lyxrc.h"
 #include "LColor.h"
 #include "Lsstream.h"
 #include "funcrequest.h"
 
-#include "combox.h"
-#include "Color.h"
-#include "input_validators.h"
-#include "forms_gettext.h"
-#include "xforms_helpers.h"
-#include "helper_funcs.h"
+#include "frontends/LyXView.h"
+#include "frontends/Dialogs.h"
 
 #include "support/lyxfunctional.h"
 #include "support/lyxmanip.h"
@@ -42,6 +44,7 @@
 #include "support/LAssert.h"
 
 #include "graphics/GraphicsCache.h"
+#include "graphics/GraphicsTypes.h"
 
 #include <boost/bind.hpp>
 
@@ -72,7 +75,7 @@ Converters local_converters;
 
 
 FormPreferences::FormPreferences(LyXView & lv, Dialogs & d)
-       : FormBaseBI(&lv, &d, _("Preferences"), false),
+       : FormBaseBI(lv, d, _("Preferences"), false),
          colors_(*this), converters_(*this), inputs_misc_(*this),
          formats_(*this), interface_(*this), language_(*this),
          lnf_misc_(*this), outputs_misc_(*this), paths_(*this),
@@ -132,7 +135,7 @@ void FormPreferences::ok()
                colors_.modifiedXformsPrefs = !XformsColor::write(filename);
        }
 
-       lv_->getLyXFunc().dispatch(LFUN_SAVEPREFERENCES);
+       lv_.dispatch(FuncRequest(LFUN_SAVEPREFERENCES));
 }
 
 
@@ -415,7 +418,7 @@ void FormPreferences::Colors::apply()
                                setCursorColor(GUI_COLOR_CURSOR);
                        }
                }
-               parent_.lv_->getDialogs().redrawGUI();
+               parent_.lv_.getDialogs().redrawGUI();
        }
 
        // Now do the same for the LyX LColors...
@@ -437,7 +440,7 @@ void FormPreferences::Colors::apply()
 
                        string const s = lcolor.getLyXName(lc) + string(" ") +
                                hexname;
-                       parent_.lv_->getLyXFunc().dispatch(FuncRequest(LFUN_SET_COLOR, s));
+                       parent_.lv_.dispatch(FuncRequest(LFUN_SET_COLOR, s));
                }
        }
 }
@@ -744,8 +747,7 @@ void FormPreferences::Colors::LoadBrowserLyX()
                               << "\". Set to \"black\"!" << endl;
 
                        string const arg = lcolor.getLyXName(lc) + " black";
-                       parent_.lv_->getLyXFunc().
-                               dispatch(FuncRequest(LFUN_SET_COLOR, arg));
+                       parent_.lv_.dispatch(FuncRequest(LFUN_SET_COLOR, arg));
                        continue;
                }
 
@@ -1825,15 +1827,14 @@ void FormPreferences::LnFmisc::apply() const
        lyxrc.wheel_jump = static_cast<unsigned int>
                (fl_get_counter_value(dialog_->counter_wm_jump));
 
-       string const old_value = lyxrc.display_graphics;
-       if (fl_get_button(dialog_->radio_display_monochrome)) {
-               lyxrc.display_graphics = "mono";
-       } else if (fl_get_button(dialog_->radio_display_grayscale)) {
-               lyxrc.display_graphics = "gray";
-       } else if (fl_get_button(dialog_->radio_display_color)) {
-               lyxrc.display_graphics = "color";
-       } else {
-               lyxrc.display_graphics = "no";
+       // See FIXME below
+       // grfx::DisplayType old_value = lyxrc.display_graphics;
+       switch (fl_get_choice(dialog_->choice_display)) {
+               case 4: lyxrc.display_graphics = grfx::NoDisplay; break;
+               case 3: lyxrc.display_graphics = grfx::ColorDisplay; break;
+               case 2: lyxrc.display_graphics = grfx::GrayscaleDisplay; break;
+               case 1: lyxrc.display_graphics = grfx::MonochromeDisplay; break;
+               default: lyxrc.display_graphics = grfx::ColorDisplay; break;
        }
 
 #ifdef WITH_WARNINGS
@@ -1865,10 +1866,8 @@ void FormPreferences::LnFmisc::build()
        setPrehandler(dialog_->check_dialogs_iconify_with_main);
        setPrehandler(dialog_->check_preview_latex);
        setPrehandler(dialog_->counter_wm_jump);
-       setPrehandler(dialog_->radio_display_monochrome);
-       setPrehandler(dialog_->radio_display_grayscale);
-       setPrehandler(dialog_->radio_display_color);
-       setPrehandler(dialog_->radio_no_display);
+       
+       fl_addto_choice(dialog_->choice_display, _("Monochrome|Grayscale|Color|Do not display"));
 }
 
 
@@ -1887,10 +1886,7 @@ FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
                return lyxrc.getDescription(LyXRC::RC_AUTOSAVE);
        if (ob == dialog_->counter_wm_jump)
                return lyxrc.getDescription(LyXRC::RC_WHEEL_JUMP);
-       if (ob == dialog_->radio_display_monochrome ||
-                ob == dialog_->radio_display_grayscale ||
-                ob == dialog_->radio_display_color ||
-                ob == dialog_->radio_no_display)
+       if (ob == dialog_->choice_display)
                return lyxrc.getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
        return string();
 }
@@ -1909,14 +1905,12 @@ void FormPreferences::LnFmisc::update()
        fl_set_counter_value(dialog_->counter_autosave, lyxrc.autosave);
        fl_set_counter_value(dialog_->counter_wm_jump, lyxrc.wheel_jump);
 
-       if (lyxrc.display_graphics == "mono") {
-               fl_set_button(dialog_->radio_display_monochrome, 1);
-       } else if (lyxrc.display_graphics == "gray") {
-               fl_set_button(dialog_->radio_display_grayscale, 1);
-       } else if (lyxrc.display_graphics == "color") {
-               fl_set_button(dialog_->radio_display_color, 1);
-       } else {
-               fl_set_button(dialog_->radio_no_display, 1);
+       switch (lyxrc.display_graphics) {
+               case grfx::NoDisplay:           fl_set_choice(dialog_->choice_display, 4); break;
+               case grfx::ColorDisplay:        fl_set_choice(dialog_->choice_display, 3); break;
+               case grfx::GrayscaleDisplay:    fl_set_choice(dialog_->choice_display, 2); break;
+               case grfx::MonochromeDisplay:   fl_set_choice(dialog_->choice_display, 1); break;
+               default:                        fl_set_choice(dialog_->choice_display, 3); break;
        }
 }
 
@@ -2557,7 +2551,7 @@ 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_.dispatch(FuncRequest(LFUN_SCREEN_FONT_UPDATE));
        }
 }
 
@@ -2980,7 +2974,7 @@ void FormPreferences::browse(FL_OBJECT * inpt,
 
        // Show the file browser dialog
        string const new_filename =
-               browseFile(lv_, 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()) {