]> git.lyx.org Git - features.git/commitdiff
Enable the user to preview xfig figures (f.ex.) without previewing mathed.
authorAngus Leeming <leeming@lyx.org>
Mon, 19 Apr 2004 13:31:17 +0000 (13:31 +0000)
committerAngus Leeming <leeming@lyx.org>
Mon, 19 Apr 2004 13:31:17 +0000 (13:31 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8670 a592a061-630c-0410-9148-cb99ea01b6c8

18 files changed:
src/BufferView_pimpl.C
src/ChangeLog
src/frontends/qt2/QPrefs.C
src/frontends/qt2/QPrefsDialog.C
src/frontends/qt2/ui/QPrefDisplayModule.ui
src/frontends/xforms/FormPreferences.C
src/frontends/xforms/forms/form_preferences.fd
src/graphics/Previews.C
src/graphics/Previews.h
src/insets/ChangeLog
src/insets/insetexternal.C
src/insets/insetinclude.C
src/insets/render_preview.C
src/insets/render_preview.h
src/lyxrc.C
src/lyxrc.h
src/mathed/ChangeLog
src/mathed/math_hullinset.C

index 72e072490a7b617c194211cc43255426f93a5ec7..d264edeb592a4926473bfdd5cc467cbe0754a5c1 100644 (file)
@@ -353,7 +353,7 @@ void BufferView::Pimpl::setBuffer(Buffer * b)
        owner_->updateLayoutChoice();
        owner_->updateWindowTitle();
 
-       if (lyx::graphics::Previews::activated() && buffer_)
+       if (buffer_ && lyx::graphics::Previews::status() != LyXRC::PREVIEW_OFF)
                lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
 }
 
index d5da907c6d4caa015de60814f5056e2d2dc2a158..577e362defde55fa4f3554caa61cd9a1f35556c2 100644 (file)
@@ -1,3 +1,10 @@
+2004-04-19  Angus Leeming  <leeming@lyx.org>
+
+       * BufferView_pimpl.C (setBuffer): changed preview interface.
+
+       * lyxrc.[Ch] (preview): no longer a bool. Now an enum with three
+       possible values.
+
 2004-04-19  John Levon  <levon@movementarian.org>
 
        * BufferView_pimpl.C:
index 349f204e4b8436afdb058299e1be4bbdb5585e97..bce074e77f9eb81e0447544caffcb40546398d66 100644 (file)
@@ -181,15 +181,25 @@ void QPrefs::apply()
 
        QPrefDisplayModule * displaymod(dialog_->displayModule);
 
-       rc.preview = displaymod->previewCB->isChecked();
-
+       switch (displaymod->instantPreviewCO->currentItem()) {
+       case 0:
+               rc.preview = LyXRC::PREVIEW_OFF;
+               break;
+       case 1:
+               rc.preview = LyXRC::PREVIEW_NO_MATH;
+               break;
+       case 2:
+               rc.preview = LyXRC::PREVIEW_ON;
+               break;
+       }
+       
        lyx::graphics::DisplayType dtype(lyx::graphics::ColorDisplay);
 
        switch (displaymod->displayGraphicsCO->currentItem()) {
-               case 3: dtype = lyx::graphics::NoDisplay; break;
-               case 2: dtype = lyx::graphics::ColorDisplay; break;
-               case 1: dtype = lyx::graphics::GrayscaleDisplay;        break;
-               case 0: dtype = lyx::graphics::MonochromeDisplay; break;
+       case 3: dtype = lyx::graphics::NoDisplay; break;
+       case 2: dtype = lyx::graphics::ColorDisplay; break;
+       case 1: dtype = lyx::graphics::GrayscaleDisplay;        break;
+       case 0: dtype = lyx::graphics::MonochromeDisplay; break;
        }
        rc.display_graphics = dtype;
 
@@ -490,8 +500,18 @@ void QPrefs::update_contents()
 
        QPrefDisplayModule * displaymod(dialog_->displayModule);
 
-       displaymod->previewCB->setChecked(rc.preview);
-
+       switch (rc.preview) {
+       case LyXRC::PREVIEW_OFF:
+               displaymod->instantPreviewCO->setCurrentItem(0);
+               break;
+       case LyXRC::PREVIEW_NO_MATH :
+               displaymod->instantPreviewCO->setCurrentItem(1);
+               break;
+       case LyXRC::PREVIEW_ON :
+               displaymod->instantPreviewCO->setCurrentItem(2);
+               break;
+       }
+       
        int item = 2;
 
        switch (rc.display_graphics) {
index cb6fb8361cca20dbe0d9dfc75c72c71d16b3f714..ab0aca780307ebbcacfd7b2efcb019a3d2824412 100644 (file)
@@ -206,7 +206,7 @@ QPrefsDialog::QPrefsDialog(QPrefs * form)
        connect(latexModule->latexAutoresetCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
        connect(latexModule->latexDviPaperED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
        connect(latexModule->latexPaperSizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
-       connect(displayModule->previewCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
+       connect(displayModule->instantPreviewCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
        connect(displayModule->displayGraphicsCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
        connect(pathsModule->workingDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
        connect(pathsModule->templateDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
index 3d8e4cfe07f0c52941982a168c77d409e009a2d2..aa25e1933b19a4423865e075f20b8909a40a976b 100644 (file)
         <rect>
             <x>0</x>
             <y>0</y>
-            <width>240</width>
-            <height>102</height>
+            <width>264</width>
+            <height>133</height>
         </rect>
     </property>
     <property stdset="1">
         <name>caption</name>
         <string>Display insets</string>
     </property>
-    <vbox>
+    <grid>
         <property stdset="1">
             <name>margin</name>
             <number>11</number>
             <name>spacing</name>
             <number>6</number>
         </property>
-        <widget>
+        <widget row="0"  column="0" >
             <class>QLayoutWidget</class>
             <property stdset="1">
                 <name>name</name>
-                <cstring>Layout1</cstring>
+                <cstring>Layout3</cstring>
             </property>
             <grid>
                 <property stdset="1">
                     <name>spacing</name>
                     <number>6</number>
                 </property>
+                <widget row="0"  column="0" >
+                    <class>QLabel</class>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>displayGraphicsLA</cstring>
+                    </property>
+                    <property stdset="1">
+                        <name>text</name>
+                        <string>Display &amp;Graphics:</string>
+                    </property>
+                    <property>
+                        <name>buddy</name>
+                        <cstring>displayGraphicsCO</cstring>
+                    </property>
+                </widget>
+                <widget row="1"  column="1" >
+                    <class>QComboBox</class>
+                    <item>
+                        <property>
+                            <name>text</name>
+                            <string>Off</string>
+                        </property>
+                    </item>
+                    <item>
+                        <property>
+                            <name>text</name>
+                            <string>No math</string>
+                        </property>
+                    </item>
+                    <item>
+                        <property>
+                            <name>text</name>
+                            <string>On</string>
+                        </property>
+                    </item>
+                    <property stdset="1">
+                        <name>name</name>
+                        <cstring>instantPreviewCO</cstring>
+                    </property>
+                </widget>
                 <widget row="0"  column="1" >
                     <class>QComboBox</class>
                     <item>
                         <cstring>displayGraphicsCO</cstring>
                     </property>
                 </widget>
-                <widget row="0"  column="0" >
+                <widget row="1"  column="0" >
                     <class>QLabel</class>
                     <property stdset="1">
                         <name>name</name>
-                        <cstring>displayGraphicsLA</cstring>
+                        <cstring>instantPreviewLA</cstring>
                     </property>
                     <property stdset="1">
                         <name>text</name>
-                        <string>Display &amp;Graphics:</string>
+                        <string>Instant &amp;Preview:</string>
                     </property>
                     <property>
                         <name>buddy</name>
-                        <cstring>displayGraphicsCO</cstring>
+                        <cstring>instantPreviewCO</cstring>
                     </property>
                 </widget>
             </grid>
         </widget>
-        <widget>
-            <class>QCheckBox</class>
-            <property stdset="1">
-                <name>name</name>
-                <cstring>previewCB</cstring>
-            </property>
-            <property stdset="1">
-                <name>text</name>
-                <string>Instant &amp;preview</string>
-            </property>
-        </widget>
-        <spacer>
+        <spacer row="1"  column="0" >
             <property>
                 <name>name</name>
                 <cstring>Spacer1</cstring>
                 </size>
             </property>
         </spacer>
-    </vbox>
+    </grid>
 </widget>
 </UI>
index f0ee6e3179fa175ce54d7844cb182b30f6e90a31..2d4f5e93594bb457fb0a5c123e41c7de8680fd2f 100644 (file)
@@ -1607,7 +1607,19 @@ void FormPreferences::LnFmisc::apply(LyXRC & rc) const
                fl_get_button(dialog_->check_cursor_follows_scrollbar);
        rc.dialogs_iconify_with_main =
                fl_get_button(dialog_->check_dialogs_iconify_with_main);
-       rc.preview = fl_get_button(dialog_->check_preview_latex);
+
+       switch (fl_get_choice(dialog_->choice_instant_preview)) {
+       case 1:
+               rc.preview = LyXRC::PREVIEW_OFF;
+               break;
+       case 2:
+               rc.preview = LyXRC::PREVIEW_NO_MATH;
+               break;
+       case 3:
+               rc.preview = LyXRC::PREVIEW_ON;
+               break;
+       }
+       
        rc.autosave = static_cast<unsigned int>
                (fl_get_counter_value(dialog_->counter_autosave));
        rc.wheel_jump = static_cast<unsigned int>
@@ -1615,7 +1627,7 @@ void FormPreferences::LnFmisc::apply(LyXRC & rc) const
 
        // See FIXME below
        // lyx::graphics::DisplayType old_value = rc.display_graphics;
-       switch (fl_get_choice(dialog_->choice_display)) {
+       switch (fl_get_choice(dialog_->choice_graphics_display)) {
        case 4:
                rc.display_graphics = lyx::graphics::NoDisplay;
                break;
@@ -1660,11 +1672,14 @@ void FormPreferences::LnFmisc::build()
        setPrehandler(dialog_->counter_autosave);
        setPrehandler(dialog_->check_cursor_follows_scrollbar);
        setPrehandler(dialog_->check_dialogs_iconify_with_main);
-       setPrehandler(dialog_->check_preview_latex);
+       setPrehandler(dialog_->choice_instant_preview);
        setPrehandler(dialog_->counter_wm_jump);
 
-       fl_addto_choice(dialog_->choice_display,
+       fl_addto_choice(dialog_->choice_graphics_display,
                        _("Monochrome|Grayscale|Color|Do not display").c_str());
+
+       fl_addto_choice(dialog_->choice_instant_preview,
+                       _("Off|No math|On").c_str());
 }
 
 
@@ -1677,13 +1692,13 @@ FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
                return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
        if (ob == dialog_->check_dialogs_iconify_with_main)
                return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
-       if (ob == dialog_->check_preview_latex)
+       if (ob == dialog_->choice_instant_preview)
                return LyXRC::getDescription(LyXRC::RC_PREVIEW);
        if (ob == dialog_->counter_autosave)
                return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
        if (ob == dialog_->counter_wm_jump)
                return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
-       if (ob == dialog_->choice_display)
+       if (ob == dialog_->choice_graphics_display)
                return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
        return string();
 }
@@ -1697,26 +1712,37 @@ void FormPreferences::LnFmisc::update(LyXRC const & rc)
                      rc.cursor_follows_scrollbar);
        fl_set_button(dialog_->check_dialogs_iconify_with_main,
                      rc.dialogs_iconify_with_main);
-       fl_set_button(dialog_->check_preview_latex,
-                     rc.preview);
+
+       switch (rc.preview) {
+       case LyXRC::PREVIEW_OFF:
+               fl_set_choice(dialog_->choice_instant_preview, 1);
+               break;
+       case LyXRC::PREVIEW_NO_MATH:
+               fl_set_choice(dialog_->choice_instant_preview, 2);
+               break;
+       case LyXRC::PREVIEW_ON:
+               fl_set_choice(dialog_->choice_instant_preview, 3);
+               break;
+       }
+
        fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
        fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
 
        switch (rc.display_graphics) {
        case lyx::graphics::NoDisplay:
-               fl_set_choice(dialog_->choice_display, 4);
+               fl_set_choice(dialog_->choice_graphics_display, 4);
                break;
        case lyx::graphics::ColorDisplay:
-               fl_set_choice(dialog_->choice_display, 3);
+               fl_set_choice(dialog_->choice_graphics_display, 3);
                break;
        case lyx::graphics::GrayscaleDisplay:
-               fl_set_choice(dialog_->choice_display, 2);
+               fl_set_choice(dialog_->choice_graphics_display, 2);
                break;
        case lyx::graphics::MonochromeDisplay:
-               fl_set_choice(dialog_->choice_display, 1);
+               fl_set_choice(dialog_->choice_graphics_display, 1);
                break;
        default:
-               fl_set_choice(dialog_->choice_display, 3);
+               fl_set_choice(dialog_->choice_graphics_display, 3);
                break;
        }
 }
index 1c34f14d28a985a5422ad7deb2a30db943a7b035..fcb2f2f7d2c1c75158990a16012c618505a235c7 100644 (file)
@@ -883,10 +883,10 @@ argument:
 --------------------
 class: FL_CHECKBUTTON
 type: PUSH_BUTTON
-box: 15 25 30 30
+box: 300 20 30 30
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_CENTER
+alignment: FL_ALIGN_LEFT
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
@@ -902,10 +902,10 @@ argument: 0
 --------------------
 class: FL_CHECKBUTTON
 type: PUSH_BUTTON
-box: 15 75 30 30
+box: 300 60 30 30
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_CENTER
+alignment: FL_ALIGN_LEFT
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
@@ -921,10 +921,10 @@ argument: 0
 --------------------
 class: FL_CHECKBUTTON
 type: PUSH_BUTTON
-box: 15 130 30 30
+box: 300 100 30 30
 boxtype: FL_NO_BOX
 colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_CENTER
+alignment: FL_ALIGN_LEFT
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
@@ -940,7 +940,7 @@ argument: 0
 --------------------
 class: FL_COUNTER
 type: NORMAL_COUNTER
-box: 310 190 115 30
+box: 300 260 115 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_BLUE
 alignment: FL_ALIGN_TOP
@@ -962,7 +962,7 @@ argument: 0
 --------------------
 class: FL_COUNTER
 type: NORMAL_COUNTER
-box: 310 115 115 30
+box: 80 260 115 30
 boxtype: FL_UP_BOX
 colors: FL_COL1 FL_BLUE
 alignment: FL_ALIGN_TOP
@@ -982,39 +982,38 @@ argument: 0
   sstep: 1
 
 --------------------
-class: FL_CHECKBUTTON
-type: PUSH_BUTTON
-box: 15 185 30 30
-boxtype: FL_NO_BOX
-colors: FL_COL1 FL_YELLOW
-alignment: FL_ALIGN_CENTER
+class: FL_CHOICE
+type: NORMAL_CHOICE
+box: 300 150 130 30
+boxtype: FL_FRAME_BOX
+colors: FL_COL1 FL_BLACK
+alignment: FL_ALIGN_LEFT
 style: FL_NORMAL_STYLE
 size: FL_NORMAL_SIZE
 lcol: FL_BLACK
-label: Instant Preview|#P
+label: Graphics display:|#G
 shortcut: 
-resize: FL_RESIZE_ALL
+resize: FL_RESIZE_NONE
 gravity: FL_NoGravity FL_NoGravity
-name: check_preview_latex
+name: choice_graphics_display
 callback: C_FormDialogView_InputCB
 argument: 0
-       value: 1
 
 --------------------
 class: FL_CHOICE
 type: NORMAL_CHOICE
-box: 305 40 130 30
+box: 300 200 130 30
 boxtype: FL_FRAME_BOX
 colors: FL_COL1 FL_BLACK
-alignment: FL_ALIGN_TOP
+alignment: FL_ALIGN_LEFT
 style: FL_NORMAL_STYLE
-size: FL_DEFAULT_SIZE
+size: FL_NORMAL_SIZE
 lcol: FL_BLACK
-label: Graphics display:|#G
+label: Instant Preview:|#p
 shortcut: 
 resize: FL_RESIZE_NONE
 gravity: FL_NoGravity FL_NoGravity
-name: choice_display
+name: choice_instant_preview
 callback: C_FormDialogView_InputCB
 argument: 0
 
index 29a0424e25f34aaa237ab4bae13a9671dc43a2c1..f07e9bc952c26e10278d4b10ee3b9b83a78a3c55 100644 (file)
@@ -24,7 +24,7 @@
 namespace lyx {
 namespace graphics {
 
-bool Previews::activated()
+LyXRC_PreviewStatus Previews::status()
 {
        return lyxrc.preview;
 }
index 2ede9c4bb9453f809d0e5747a0ce87975cc4b741..db666d11bef8322f35304bea04e98b6892d396c8 100644 (file)
@@ -19,6 +19,7 @@
 #include <boost/scoped_ptr.hpp>
 
 class Buffer;
+class LyXRC_PreviewStatus;
 
 namespace lyx {
 namespace graphics {
@@ -28,7 +29,7 @@ class PreviewLoader;
 class Previews : boost::noncopyable {
 public:
        /// a wrapper for lyxrc.preview
-       static bool activated();
+       static LyXRC_PreviewStatus status();
 
        /// This is a singleton class. Get the instance.
        static Previews & get();
index 633663e8e1d6e8ddda80525457e677eb812411c1..4c535b042a84811c1518eded815a5901867b43b0 100644 (file)
@@ -1,3 +1,9 @@
+2004-04-19  Angus Leeming  <leeming@lyx.org>
+
+       * insetexternal.C:
+       * insetinclude.C:
+       * render_preview.[Ch]: changes due to changes to LyXRC::preview.
+
 2004-04-19  Angus Leeming  <leeming@lyx.org>
 
        * insetexternal.C (priv_dispatch): remove unnecessary invocation of
index 51c79fea42a859061608ae0d0ed7f0fe62c2dd8b..bd0219db1eac9a8c9eb34526e74ef746359c3207 100644 (file)
@@ -503,7 +503,7 @@ RenderType getRenderType(InsetExternalParams const & p)
                return RENDERBUTTON;
 
        if (p.display == external::PreviewDisplay) {
-               if (RenderPreview::activated())
+               if (RenderPreview::status() != LyXRC::PREVIEW_OFF)
                        return RENDERPREVIEW;
                return RENDERBUTTON;
        }
@@ -779,7 +779,7 @@ void add_preview_and_start_loading(RenderMonitoredPreview & renderer,
 {
        InsetExternalParams const & params = inset.params();
 
-       if (RenderPreview::activated() &&
+       if (RenderPreview::status() != LyXRC::PREVIEW_OFF &&
            preview_wanted(params)) {
                renderer.setAbsFile(params.filename.absFilename());
                string const snippet = latex_string(inset, buffer);
index 0930842971f300a4237b9fd2850d32cd9c4c79af..2f3a0648960099a7de612cd212bffa631eadf870 100644 (file)
@@ -24,6 +24,7 @@
 #include "gettext.h"
 #include "LaTeXFeatures.h"
 #include "lyx_main.h"
+#include "lyxrc.h"
 #include "lyxlex.h"
 #include "metricsinfo.h"
 #include "outputparams.h"
@@ -572,7 +573,7 @@ void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
        BOOST_ASSERT(mi.base.bv && mi.base.bv->buffer());
 
        bool use_preview = false;
-       if (RenderPreview::activated()) {
+       if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
                lyx::graphics::PreviewImage const * pimage =
                        preview_->getPreviewImage(*mi.base.bv->buffer());
                use_preview = pimage && pimage->image();
@@ -605,7 +606,7 @@ void InsetInclude::draw(PainterInfo & pi, int x, int y) const
        BOOST_ASSERT(pi.base.bv && pi.base.bv->buffer());
 
        bool use_preview = false;
-       if (RenderPreview::activated()) {
+       if (RenderPreview::status() == LyXRC::PREVIEW_OFF) {
                lyx::graphics::PreviewImage const * pimage =
                        preview_->getPreviewImage(*pi.base.bv->buffer());
                use_preview = pimage && pimage->image();
@@ -661,7 +662,8 @@ void add_preview(RenderMonitoredPreview & renderer, InsetInclude const & inset,
                 Buffer const & buffer)
 {
        InsetCommandParams const & params = inset.params();
-       if (RenderPreview::activated() && preview_wanted(params, buffer)) {
+       if (RenderPreview::status() == LyXRC::PREVIEW_OFF &&
+           preview_wanted(params, buffer)) {
                renderer.setAbsFile(includedFilename(buffer, params));
                string const snippet = latex_string(inset, buffer);
                renderer.addPreview(snippet, buffer);
index 4bc8f4f477c7b0570e1ce5d6a507cbd1a74c2522..3e4c643f567407fd6d29ce80c2baaf49276047e4 100644 (file)
@@ -19,6 +19,7 @@
 #include "gettext.h"
 #include "LColor.h"
 #include "lyx_main.h"
+#include "lyxrc.h"
 #include "metricsinfo.h"
 
 #include "frontends/font_metrics.h"
@@ -39,9 +40,9 @@ namespace graphics = lyx::graphics;
 namespace support  = lyx::support;
 
 
-bool RenderPreview::activated()
+LyXRC_PreviewStatus RenderPreview::status()
 {
-       return graphics::Previews::activated();
+       return graphics::Previews::status();
 }
 
 
@@ -162,7 +163,7 @@ void RenderPreview::draw(PainterInfo & pi, int x, int y) const
 
 void RenderPreview::startLoading(Buffer const & buffer) const
 {
-       if (!activated() && !snippet_.empty())
+       if (status() == LyXRC::PREVIEW_OFF || snippet_.empty())
                return;
 
        graphics::Previews & previews = graphics::Previews::get();
@@ -175,7 +176,7 @@ void RenderPreview::startLoading(Buffer const & buffer) const
 void RenderPreview::addPreview(string const & latex_snippet,
                               Buffer const & buffer)
 {
-       if (!activated())
+       if (status() == LyXRC::PREVIEW_OFF)
                return;
 
        graphics::Previews & previews = graphics::Previews::get();
@@ -187,7 +188,7 @@ void RenderPreview::addPreview(string const & latex_snippet,
 void RenderPreview::addPreview(string const & latex_snippet,
                               graphics::PreviewLoader & ploader)
 {
-       if (!activated())
+       if (status() == LyXRC::PREVIEW_OFF)
                return;
 
        snippet_ = support::trim(latex_snippet);
index 036a5ae2f3e3b7cd00439a7871f8e63c0e5de882..0774c44a4e19c968efb144c23689cc6d0c88570b 100644 (file)
@@ -26,6 +26,7 @@
 
 class Buffer;
 class BufferView;
+class LyXRC_PreviewStatus;
 class MetricsInfo;
 class PainterInfo;
 
@@ -41,8 +42,8 @@ class PreviewLoader;
 
 class RenderPreview : public RenderBase, public boost::signals::trackable {
 public:
-       /// a wrapper for Previews::activated()
-       static bool activated();
+       /// a wrapper for Previews::status()
+       static LyXRC_PreviewStatus status();
 
        RenderPreview(InsetBase const *);
        RenderPreview(RenderPreview const &, InsetBase const *);
index 5faa48ad2070fc23fd3d149fd586539355b6da11..f79b9e679c9d80731f3f570c2835ba62932cfad2 100644 (file)
@@ -265,7 +265,7 @@ void LyXRC::setDefaults() {
        cursor_follows_scrollbar = false;
        dialogs_iconify_with_main = false;
        label_init_length = 3;
-       preview = false;
+       preview = PREVIEW_OFF;
        preview_hashed_labels  = false;
        preview_scale_factor = 0.9;
 
@@ -1064,7 +1064,18 @@ int LyXRC::read(LyXLex & lexrc)
 
                case RC_PREVIEW:
                        if (lexrc.next()) {
-                               preview = lexrc.getBool();
+                               string const tmp = lexrc.getString();
+                               if (tmp == "true" || tmp == "on")
+                                       preview = PREVIEW_ON;
+                               else if (tmp == "no_math")
+                                       preview = PREVIEW_NO_MATH;
+                               else {
+                                       preview = PREVIEW_OFF;
+                                       if (tmp != "false" && tmp != "off")
+                                               lyxerr << "Unrecognized "
+                                                       "preview status \""
+                                                      << tmp << '\n' << endl;
+                               }
                        }
                        break;
 
@@ -1286,7 +1297,19 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
        case RC_PREVIEW:
                if (ignore_system_lyxrc ||
                    preview != system_lyxrc.preview) {
-                       os << "\\preview " << tostr(preview) << '\n';
+                       string status;
+                       switch (preview) {
+                       case PREVIEW_ON:
+                               status = "on";
+                               break;
+                       case PREVIEW_NO_MATH:
+                               status = "no_math";
+                               break;
+                       case PREVIEW_OFF:
+                               status = "off";
+                               break;
+                       }
+                       os << "\\preview " << status << '\n';
                }
 
        case RC_PREVIEW_HASHED_LABELS:
index 6f17e49565b221da27c47e673f811570e39ab85e..e948e6489fcf8ec6ae1b56988da30fe1b677f23b 100644 (file)
@@ -355,7 +355,13 @@ public:
        ///
        bool show_banner;
        ///
-       bool preview;
+       enum PreviewStatus {
+               PREVIEW_OFF,
+               PREVIEW_NO_MATH,
+               PREVIEW_ON
+       };
+       ///
+       PreviewStatus preview;
        ///
        bool preview_hashed_labels;
        ///
@@ -366,6 +372,19 @@ public:
        std::string user_email;
 };
 
+
+/** \c LyXRC_PreviewStatus is a wrapper for LyXRC::PreviewStatus.
+ *  It can be forward-declared and passed as a function argument without
+ *  having to expose lyxrc.h.
+ */
+class LyXRC_PreviewStatus {
+        LyXRC::PreviewStatus val_;
+public:
+       LyXRC_PreviewStatus(LyXRC::PreviewStatus val) : val_(val) {}
+        operator LyXRC::PreviewStatus() const{ return val_; }
+};
+
+
 ///
 extern LyXRC lyxrc;
 ///
index 53739de8d0857931e759ab9777240c6bbb62ad39..8d28c978ec0ed75e03fc5698ccfe4b56fd044466 100644 (file)
@@ -1,3 +1,7 @@
+2004-04-19  Angus Leeming  <leeming@lyx.org>
+
+       * math_hullinset.C: changes due to changes to LyXRC::preview.
+
 2004-04-19  Angus Leeming  <leeming@lyx.org>
 
        * math_hullinset.C (metrics, draw): changes due to the changed
index 8490ff9c0eb7ab4bc2f9d18ffa4baec2971917b9..45ac4537fef8ac41df6bc5a1a753d5f1f39e22bf 100644 (file)
@@ -232,7 +232,8 @@ void MathHullInset::metrics(MetricsInfo & mi, Dimension & dim) const
        BOOST_ASSERT(mi.base.bv && mi.base.bv->buffer());
 
        bool use_preview = false;
-       if (!editing(mi.base.bv) && RenderPreview::activated()) {
+       if (!editing(mi.base.bv) &&
+           RenderPreview::status() == LyXRC::PREVIEW_ON) {
                lyx::graphics::PreviewImage const * pimage =
                        preview_->getPreviewImage(*mi.base.bv->buffer());
                use_preview = pimage && pimage->image();
@@ -285,7 +286,8 @@ void MathHullInset::draw(PainterInfo & pi, int x, int y) const
        BOOST_ASSERT(pi.base.bv && pi.base.bv->buffer());
 
        bool use_preview = false;
-       if (!editing(pi.base.bv) && RenderPreview::activated()) {
+       if (!editing(pi.base.bv) &&
+           RenderPreview::status() == LyXRC::PREVIEW_ON) {
                lyx::graphics::PreviewImage const * pimage =
                        preview_->getPreviewImage(*pi.base.bv->buffer());
                use_preview = pimage && pimage->image();
@@ -364,7 +366,7 @@ void MathHullInset::addPreview(lyx::graphics::PreviewLoader & ploader) const
 
 void MathHullInset::notifyCursorLeaves(LCursor & cur)
 {
-       if (!RenderPreview::activated())
+       if (RenderPreview::status() != LyXRC::PREVIEW_ON)
                return;
 
        Buffer const & buffer = cur.buffer();