]> git.lyx.org Git - features.git/commitdiff
- Simplify prefs, graphics and external display options which are now true or false.
authorAbdelrazak Younes <younes@lyx.org>
Fri, 13 Jun 2008 07:34:55 +0000 (07:34 +0000)
committerAbdelrazak Younes <younes@lyx.org>
Fri, 13 Jun 2008 07:34:55 +0000 (07:34 +0000)
- the display combo in the prefs, external and graphics dialogs are gone
- the lyxrc display_graphics option now overrides any local inset display option
- The external template format has a new tag: Preview
- format incremented to 337

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25245 a592a061-630c-0410-9148-cb99ea01b6c8

26 files changed:
development/FORMAT
lib/external_templates
lib/lyx2lyx/lyx_1_6.py
src/Buffer.cpp
src/LyXRC.cpp
src/LyXRC.h
src/frontends/qt4/GuiExternal.cpp
src/frontends/qt4/GuiGraphics.cpp
src/frontends/qt4/GuiImage.cpp
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/ui/ExternalUi.ui
src/frontends/qt4/ui/GraphicsUi.ui
src/frontends/qt4/ui/PrefDisplayUi.ui
src/graphics/GraphicsLoader.cpp
src/graphics/GraphicsLoader.h
src/graphics/GraphicsParams.cpp
src/graphics/GraphicsParams.h
src/graphics/GraphicsTypes.cpp
src/graphics/GraphicsTypes.h
src/insets/ExternalTemplate.cpp
src/insets/ExternalTemplate.h
src/insets/InsetExternal.cpp
src/insets/InsetExternal.h
src/insets/InsetGraphicsParams.cpp
src/insets/InsetGraphicsParams.h
src/insets/RenderGraphic.cpp

index b56bdc510cc0fef02ba8565a47ca491f425a3789..140e8a660e863252fdf202b210febfa22eaf4b53 100644 (file)
@@ -1,6 +1,9 @@
 LyX file-format changes
 -----------------------
 
+2008-06-13 Abdelrazak Younes <younes@lyx.org>
+       * Format incremented to 337: convert/revert graphics display param.
+
 2008-06-04 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
        * Format incremented to 336: new param \font_cjk.
 
index edcac389aac501b687a844e55f46777e06bec3f1..6aafd6857fc11652a74ada73254dd89598692b9a 100644 (file)
@@ -58,6 +58,13 @@ Template RasterImage
        Transform Resize
        Transform Clip
        Transform Extra
+       # LyX preview options:
+       # Off: LyX will not attempt to show this material on screen.
+       # Graphics: LyX will attempt to show this material as-is or via a
+       #           conversion to a showable format.
+       # InstantPreview: LyX will attempt to use the 'instant preview'
+       #                 mechanism in order to show this material.
+       Preview Graphics
        Format LaTeX
                TransformOption Rotate RotationLatexOption
                TransformOption Resize ResizeLatexOption
@@ -109,6 +116,7 @@ Template XFig
        AutomaticProduction true
        Transform Rotate
        Transform Resize
+       Preview InstantPreview
        Format LaTeX
                TransformCommand Rotate RotationLatexCommand
                TransformCommand Resize ResizeLatexCommand
@@ -175,6 +183,7 @@ Template ChessDiagram
        InputFormat fen
        FileFilter "*.fen"
        AutomaticProduction true
+       Preview InstantPreview
        Format LaTeX
                Product "\\loadgame{$$AbsOrRelPathMaster$$Basename}\\showboard"
                Requirement "chess"
@@ -211,6 +220,7 @@ Template LilyPond
        Transform Resize
        Transform Clip
        Transform Extra
+       Preview InstantPreview
        Format LaTeX
                TransformOption Rotate RotationLatexOption
                TransformOption Resize ResizeLatexOption
@@ -293,6 +303,7 @@ Template Date
        InputFormat date
        FileFilter "*"
        AutomaticProduction true
+       Preview Off
        Format LaTeX
                Product "$$Contents(\"$$Tempname\")"
                UpdateFormat dateout
index 75e0ffe68ad18fafcc629f71f1fab55346ac2176..e352014f17a34db6bac741a049198ab53bf0b6e7 100644 (file)
@@ -2500,6 +2500,40 @@ def revert_InsetSpace(document):
         document.body[i] = document.body[i].replace('\\begin_inset space', '\\begin_inset Space')
 
 
+def convert_display_enum(document):
+    " Convert 'display foo' to 'display false/true'"
+    i = 0
+    while True:
+        i = find_token(document.body, "display", i)
+        if i == -1:
+            return
+        if check_token(i, "none"):
+            document.body[i] = document.body[i].replace('none', 'false')
+        if check_token(i, "default"):
+            document.body[i] = document.body[i].replace('default', 'true')
+        if check_token(i, "monochrome"):
+            document.body[i] = document.body[i].replace('monochrome', 'true')
+        if check_token(i, "grayscale"):
+            document.body[i] = document.body[i].replace('grayscale', 'true')
+        if check_token(i, "color"):
+            document.body[i] = document.body[i].replace('color', 'true')
+        if check_token(i, "preview"):
+            document.body[i] = document.body[i].replace('preview', 'true')
+
+
+def revert_display_enum(document):
+    " Revert 'display false/true' to 'display none/color'"
+    i = 0
+    while True:
+        i = find_token(document.body, "display", i)
+        if i == -1:
+            return
+        if check_token(i, "false"):
+            document.body[i] = document.body[i].replace('false', 'none')
+        if check_token(i, "true"):
+            document.body[i] = document.body[i].replace('true', 'default')
+
+
 def remove_fontsCJK(document):
     ' Remove font_cjk param '
     i = find_token(document.header, "\\font_cjk", 0)
@@ -2610,9 +2644,11 @@ convert = [[277, [fix_wrong_tables]],
            [334, [convert_paper_sizes]],
            [335, [convert_InsetSpace]],
            [336, []],
+           [337, [convert_display_enum]],
           ]
 
-revert =  [[335, [remove_fontsCJK]],
+revert =  [[336, [revert_display_enum]],
+           [335, [remove_fontsCJK]],
            [334, [revert_InsetSpace]],
            [333, [revert_paper_sizes]],
            [332, []],
index 8abcb462abe0285daf3b61319154137fea57a449..e52b6dbacfbddffbce017caeeaa0faf78033dd6d 100644 (file)
@@ -115,7 +115,7 @@ namespace os = support::os;
 
 namespace {
 
-int const LYX_FORMAT = 336;
+int const LYX_FORMAT = 337;
 
 typedef map<string, bool> DepClean;
 typedef map<docstring, pair<InsetLabel const *, Buffer::References> > RefCache;
index fa916ba24288c70052be154b52a91f6a0d8f34d8..cc60cdeb116bb028b13c64a8657f90d4d502396f 100644 (file)
@@ -254,7 +254,7 @@ void LyXRC::setDefaults()
        load_session = false;
        make_backup = true;
        backupdir_path.erase();
-       display_graphics = graphics::ColorDisplay;
+       display_graphics = true;
        // Spellchecker settings:
        use_spell_lib = true;
        isp_command = "ispell";
@@ -420,7 +420,7 @@ int LyXRC::read(Lexer & lexrc)
 
                case RC_DISPLAY_GRAPHICS:
                        if (lexrc.next())
-                               display_graphics = graphics::displayTranslator().find(lexrc.getString());
+                               display_graphics = lexrc.getString() == "true";
                        break;
 
                case RC_TEX_EXPECTS_WINDOWS_PATHS:
@@ -1224,10 +1224,9 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                if (ignore_system_lyxrc ||
                    display_graphics != system_lyxrc.display_graphics) {
                        os << "# Display graphics within LyX\n"
-                          << "# monochrome|grayscale|color|none\n"
+                          << "# true|false\n"
                           << "\\display_graphics "
-                          << graphics::displayTranslator().find(
-                                graphics::DisplayType(display_graphics))
+                          << (display_graphics ? "true" : "false")
                           << '\n';
                }
                if (tag != RC_LAST)
index b7855f7ecde8aef751870337f8641495ced36e39..e34492f2004a4778aa80c549fa191a34a0c28cad 100644 (file)
@@ -376,8 +376,7 @@ public:
        ///
        int label_init_length;
        ///
-       ///graphics::DisplayType
-       int display_graphics;
+       bool display_graphics;
        ///
        bool show_banner;
        ///
index 82bed17a3ff1b09fc4922939d87bd0b72078f5a7..df0ce70f4f3ad4e112ad8cc4b6889cb0567df932 100644 (file)
@@ -98,12 +98,10 @@ GuiExternal::GuiExternal(GuiView & lv)
        connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
        connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
 
-       connect(displayGB, SIGNAL(toggled(bool)),
-               showCO, SLOT(setEnabled(bool)));
+       /*
        connect(displayGB, SIGNAL(toggled(bool)),
                displayscaleED, SLOT(setEnabled(bool)));
-       connect(showCO, SIGNAL(activated(QString)),
-               this, SLOT(change_adaptor()));
+               */
        connect(originCO, SIGNAL(activated(int)),
                this, SLOT(change_adaptor()));
        connect(aspectratioCB, SIGNAL(stateChanged(int)),
@@ -168,7 +166,6 @@ GuiExternal::GuiExternal(GuiView & lv)
        bc().addReadOnly(externalCO);
        bc().addReadOnly(draftCB);
        bc().addReadOnly(displayscaleED);
-       bc().addReadOnly(showCO);
        bc().addReadOnly(displayGB);
        bc().addReadOnly(angleED);
        bc().addReadOnly(originCO);
@@ -365,62 +362,6 @@ static Length::UNIT defaultUnit()
 }
 
 
-static void setDisplay(
-       QGroupBox & displayGB, QComboBox & showCO, QLineEdit & scaleED,
-       external::DisplayType display, unsigned int scale, bool read_only)
-{
-       int item = 0;
-       switch (display) {
-       case external::DefaultDisplay:
-               item = 0;
-               break;
-       case external::MonochromeDisplay:
-               item = 1;
-               break;
-       case external::GrayscaleDisplay:
-               item = 2;
-               break;
-       case external::ColorDisplay:
-               item = 3;
-               break;
-       case external::PreviewDisplay:
-               item = 4;
-               break;
-       case external::NoDisplay:
-               item = 0;
-               break;
-       }
-
-       showCO.setCurrentIndex(item);
-       bool const no_display = display == external::NoDisplay;
-       showCO.setEnabled(!no_display && !read_only);
-       displayGB.setChecked(!no_display);
-       scaleED.setEnabled(!no_display && !read_only);
-       scaleED.setText(QString::number(scale));
-}
-
-
-static external::DisplayType display(QGroupBox const & displayGB,
-       QComboBox const & showCO)
-{
-       if (!displayGB.isChecked())
-               return external::NoDisplay;
-       switch (showCO.currentIndex()) {
-       default:
-       case 0:
-               return external::DefaultDisplay;
-       case 1:
-               return external::MonochromeDisplay;
-       case 2:
-               return external::GrayscaleDisplay;
-       case 3:
-               return external::ColorDisplay;
-       case 4:
-               return external::PreviewDisplay;
-       }
-}
-
-
 static void setRotation(QLineEdit & angleED, QComboBox & originCO,
        external::RotationData const & data)
 {
@@ -569,8 +510,10 @@ void GuiExternal::updateContents()
 
        draftCB->setChecked(params_.draft);
 
-       setDisplay(*displayGB, *showCO, *displayscaleED,
-                  params_.display, params_.lyxscale, isBufferReadonly());
+       displayGB->setChecked(params_.display);
+       displayscaleED->setEnabled(params_.display && !isBufferReadonly());
+       displayscaleED->setText(QString::number(params_.lyxscale));
+       displayGB->setEnabled(lyxrc.display_graphics);
 
        setRotation(*angleED, *originCO, params_.rotationdata);
 
@@ -654,7 +597,7 @@ void GuiExternal::applyView()
 
        params_.draft = draftCB->isChecked();
        params_.lyxscale = displayscaleED->text().toInt();
-       params_.display = display(*displayGB, *showCO);
+       params_.display = displayGB->isChecked();
 
        if (rotationGB->isEnabled())
                getRotation(params_.rotationdata, *angleED, *originCO);
index 1ceb9af9a557decb14e712820b5c3f15294e4f45..cea974402d503cdeaae6be29aa39966c1968534b 100644 (file)
@@ -239,10 +239,7 @@ GuiGraphics::GuiGraphics(GuiView & lv)
        // setChecked(). Note, too, that clicked() would get called whenever it
        // is clicked, even right clicked (I think), not just whenever it is
        // toggled.
-       connect(displayGB, SIGNAL(toggled(bool)),
-               this, SLOT(change_adaptor()));
-       connect(showCB, SIGNAL(currentIndexChanged(int)),
-               this, SLOT(change_adaptor()));
+       connect(displayGB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
        connect(displayscale, SIGNAL(textChanged(const QString&)),
                this, SLOT(change_adaptor()));
        connect(groupId, SIGNAL(textChanged(const QString&)),
@@ -518,18 +515,8 @@ void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp)
        draftCB->setChecked(igp.draft);
        clip->setChecked(igp.clip);
        unzipCB->setChecked(igp.noUnzip);
-
-       int item = 0;
-       switch (igp.display) {
-               case graphics::DefaultDisplay: item = 0; break;
-               case graphics::MonochromeDisplay: item = 1; break;
-               case graphics::GrayscaleDisplay: item = 2; break;
-               case graphics::ColorDisplay: item = 3; break;
-               case graphics::NoDisplay: item = 0; break;
-       }
-       showCB->setCurrentIndex(item);
+       displayGB->setChecked(igp.display);
        displayscale->setText(toqstr(convert<string>(igp.lyxscale)));
-       displayGB->setChecked(igp.display != graphics::NoDisplay);
 
        // the output section (width/height)
 
@@ -540,6 +527,7 @@ void GuiGraphics::paramsToDialog(InsetGraphicsParams const & igp)
        scaleCB->setChecked(scaleChecked);
        scaleCB->blockSignals(false);
        Scale->setEnabled(scaleChecked);
+       displayGB->setEnabled(lyxrc.display_graphics);
 
        groupId->setText(toqstr(igp.groupId));
 
@@ -636,17 +624,7 @@ void GuiGraphics::applyView()
 
        igp.draft = draftCB->isChecked();
        igp.clip = clip->isChecked();
-
-       switch (showCB->currentIndex()) {
-               case 0: igp.display = graphics::DefaultDisplay; break;
-               case 1: igp.display = graphics::MonochromeDisplay; break;
-               case 2: igp.display = graphics::GrayscaleDisplay; break;
-               case 3: igp.display = graphics::ColorDisplay; break;
-               default:;
-       }
-
-       if (!displayGB->isChecked())
-               igp.display = graphics::NoDisplay;
+       igp.display = displayGB->isChecked();
 
        //the graphics section
        if (scaleCB->isChecked() && !Scale->text().isEmpty()) {
index b72e6157a5c629dd75f6c4a7f8b2de1add7ecd16..3af803831f2500f8d1bfaf77842922e3e2991662 100644 (file)
@@ -78,58 +78,15 @@ bool GuiImage::load(FileName const & filename)
 }
 
 
-// This code is taken from KImageEffect::toGray
-static QPixmap toGray(QPixmap const & pix)
-{
-       if (pix.width() == 0 || pix.height() == 0)
-               return pix;
-
-       QImage img = pix.toImage();
-       int const pixels = img.depth() > 8 ?
-               img.width() * img.height() : img.numColors();
-
-       unsigned int *data = img.depth() > 8 ?
-               reinterpret_cast<unsigned int *>(img.bits()) :
-               reinterpret_cast<unsigned int *>(&img.colorTable()[0]);
-
-       for(int i = 0; i < pixels; ++i){
-               int const val = qGray(data[i]);
-               data[i] = qRgba(val, val, val, qAlpha(data[i]));
-       }
-       return QPixmap::fromImage(img);
-}
-
-
 bool GuiImage::setPixmap(Params const & params)
 {
-       if (original_.isNull() || params.display == NoDisplay)
+       if (original_.isNull() || !params.display)
                return false;
 
        is_transformed_ = clip(params);
        is_transformed_ |= rotate(params);
        is_transformed_ |= scale(params);
 
-       switch (params.display) {
-       case GrayscaleDisplay: {
-               transformed_ = is_transformed_
-                       ? toGray(transformed_) :  toGray(original_);
-               is_transformed_ = true;
-               break;
-       }
-
-       case MonochromeDisplay: {
-               QImage img = is_transformed_
-                       ? transformed_.toImage() : original_.toImage();
-               img.convertToFormat(img.format(), Qt::MonoOnly);
-               transformed_ = QPixmap::fromImage(img);
-               is_transformed_ = true;
-               break;
-       }
-
-       default:
-               break;
-       }
-
        if (!is_transformed_)
                // Clear it out to save some memory.
                transformed_ = QPixmap();
index 40b855a27d25619d44b844b4608083d6fd3c1822..18bbad5bfc7f50f57a9cec924cab42324fbf1cb3 100644 (file)
@@ -864,10 +864,8 @@ PrefDisplay::PrefDisplay(GuiPreferences * form)
        : PrefModule(qt_(catLookAndFeel), qt_("Graphics"), form)
 {
        setupUi(this);
-       connect(instantPreviewCO, SIGNAL(activated(int)),
-               this, SIGNAL(changed()));
-       connect(displayGraphicsCO, SIGNAL(activated(int)),
-               this, SIGNAL(changed()));
+       connect(displayGraphicsCB, SIGNAL(toggled(int)), this, SIGNAL(changed()));
+       connect(instantPreviewCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
 }
 
 
@@ -879,15 +877,7 @@ void PrefDisplay::apply(LyXRC & rc) const
                case 2: rc.preview = LyXRC::PREVIEW_ON; break;
        }
 
-       graphics::DisplayType dtype;
-       switch (displayGraphicsCO->currentIndex()) {
-               case 3: dtype = graphics::NoDisplay; break;
-               case 2: dtype = graphics::ColorDisplay; break;
-               case 1: dtype = graphics::GrayscaleDisplay;     break;
-               case 0: dtype = graphics::MonochromeDisplay; break;
-               default: dtype = graphics::GrayscaleDisplay;
-       }
-       rc.display_graphics = dtype;
+       rc.display_graphics = displayGraphicsCB->isChecked();
 
        // FIXME!! The graphics cache no longer has a changeDisplay method.
 #if 0
@@ -913,15 +903,8 @@ void PrefDisplay::update(LyXRC const & rc)
                break;
        }
 
-       int item = 2;
-       switch (rc.display_graphics) {
-               case graphics::NoDisplay:               item = 3; break;
-               case graphics::ColorDisplay:    item = 2; break;
-               case graphics::GrayscaleDisplay:        item = 1; break;
-               case graphics::MonochromeDisplay:       item = 0; break;
-               default: break;
-       }
-       displayGraphicsCO->setCurrentIndex(item);
+       displayGraphicsCB->setChecked(rc.display_graphics);
+       instantPreviewCO->setEnabled(rc.display_graphics);
 }
 
 
index 1bedc8dcdeee7b5c9580c302d4a8a816f674ca4b..82fd52dcbfe3e7691f737b1db017c8211fc4b235 100644 (file)
    </property>
    <item row="0" column="0" >
     <widget class="QTabWidget" name="tab" >
+     <property name="toolTip" >
+      <string/>
+     </property>
      <property name="currentIndex" >
-      <number>0</number>
+      <number>2</number>
      </property>
      <widget class="QWidget" name="filetab" >
+      <property name="geometry" >
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>362</width>
+        <height>375</height>
+       </rect>
+      </property>
       <attribute name="title" >
        <string>F&amp;ile</string>
       </attribute>
             <property name="sizeType" >
              <enum>QSizePolicy::Preferred</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>20</width>
               <height>20</height>
           <item row="0" column="0" >
            <widget class="QComboBox" name="externalCO" >
             <property name="sizePolicy" >
-             <sizepolicy>
-              <hsizetype>3</hsizetype>
-              <vsizetype>0</vsizetype>
+             <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
               <horstretch>0</horstretch>
               <verstretch>0</verstretch>
              </sizepolicy>
       </layout>
      </widget>
      <widget class="QWidget" name="lyxviewtab" >
+      <property name="geometry" >
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>362</width>
+        <height>375</height>
+       </rect>
+      </property>
       <attribute name="title" >
        <string>LaTe&amp;X and LyX options</string>
       </attribute>
-      <layout class="QGridLayout" >
-       <property name="margin" >
-        <number>9</number>
-       </property>
-       <property name="spacing" >
-        <number>6</number>
-       </property>
-       <item row="0" column="0" >
+      <layout class="QVBoxLayout" name="verticalLayout" >
+       <item>
         <widget class="QGroupBox" name="optionsGB" >
          <property name="title" >
           <string>LaTeX Options</string>
          </layout>
         </widget>
        </item>
-       <item row="1" column="0" >
+       <item>
         <widget class="QGroupBox" name="displayGB" >
          <property name="toolTip" >
-          <string>Display image in LyX</string>
+          <string>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+&lt;html>&lt;head>&lt;meta name="qrichtext" content="1" />&lt;style type="text/css">
+p, li { white-space: pre-wrap; }
+&lt;/style>&lt;/head>&lt;body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
+&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">&lt;span style=" font-size:8pt;">Enable LyX to preview this material; only if graphics previewing is not disabled at application level (see Preference dialog).&lt;/span>&lt;/p>
+&lt;p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;">&lt;/p>&lt;/body>&lt;/html></string>
          </property>
          <property name="title" >
           <string>&amp;Show in LyX</string>
          <property name="checkable" >
           <bool>true</bool>
          </property>
-         <layout class="QGridLayout" >
-          <property name="margin" >
-           <number>9</number>
-          </property>
-          <property name="spacing" >
-           <number>6</number>
-          </property>
-          <item row="1" column="2" >
-           <spacer>
-            <property name="orientation" >
-             <enum>Qt::Horizontal</enum>
-            </property>
-            <property name="sizeHint" >
-             <size>
-              <width>87</width>
-              <height>20</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
-          <item row="1" column="0" >
-           <widget class="QComboBox" name="showCO" >
-            <property name="toolTip" >
-             <string>Screen display</string>
-            </property>
-            <item>
-             <property name="text" >
-              <string>Default</string>
-             </property>
-            </item>
-            <item>
-             <property name="text" >
-              <string>Monochrome</string>
-             </property>
-            </item>
-            <item>
-             <property name="text" >
-              <string>Grayscale</string>
-             </property>
-            </item>
-            <item>
-             <property name="text" >
-              <string>Color</string>
-             </property>
-            </item>
-            <item>
-             <property name="text" >
-              <string>Preview</string>
-             </property>
-            </item>
-           </widget>
-          </item>
-          <item row="1" column="1" >
-           <layout class="QHBoxLayout" >
-            <property name="margin" >
-             <number>0</number>
-            </property>
-            <property name="spacing" >
-             <number>6</number>
-            </property>
-            <item>
-             <widget class="QLineEdit" name="displayscaleED" >
-              <property name="enabled" >
-               <bool>true</bool>
-              </property>
-              <property name="sizePolicy" >
-               <sizepolicy>
-                <hsizetype>5</hsizetype>
-                <vsizetype>0</vsizetype>
-                <horstretch>0</horstretch>
-                <verstretch>0</verstretch>
-               </sizepolicy>
-              </property>
-              <property name="toolTip" >
-               <string>Percentage to scale by in LyX</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QLabel" name="displayscaleLA" >
-              <property name="enabled" >
-               <bool>true</bool>
-              </property>
-              <property name="focusPolicy" >
-               <enum>Qt::NoFocus</enum>
-              </property>
-              <property name="text" >
-               <string>%</string>
-              </property>
-             </widget>
-            </item>
-           </layout>
-          </item>
+         <layout class="QGridLayout" name="gridLayout" >
           <item row="0" column="0" >
-           <widget class="QLabel" name="showLA" >
+           <widget class="QLabel" name="scaleLA" >
             <property name="toolTip" >
-             <string>Screen display</string>
+             <string>Percentage to scale by in LyX</string>
             </property>
             <property name="text" >
-             <string>&amp;Display:</string>
+             <string>Sca&amp;le on Screen (%):</string>
             </property>
             <property name="buddy" >
-             <cstring>showCO</cstring>
+             <cstring>displayscaleED</cstring>
             </property>
            </widget>
           </item>
           <item row="0" column="1" >
-           <widget class="QLabel" name="scaleLA" >
+           <widget class="QLineEdit" name="displayscaleED" >
+            <property name="enabled" >
+             <bool>true</bool>
+            </property>
+            <property name="sizePolicy" >
+             <sizepolicy vsizetype="Fixed" hsizetype="Preferred" >
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
             <property name="toolTip" >
              <string>Percentage to scale by in LyX</string>
             </property>
-            <property name="text" >
-             <string>Sca&amp;le:</string>
+           </widget>
+          </item>
+          <item row="0" column="2" >
+           <spacer name="horizontalSpacer" >
+            <property name="orientation" >
+             <enum>Qt::Horizontal</enum>
             </property>
-            <property name="buddy" >
-             <cstring>displayscaleED</cstring>
+            <property name="sizeHint" stdset="0" >
+             <size>
+              <width>40</width>
+              <height>20</height>
+             </size>
             </property>
-           </widget>
+           </spacer>
           </item>
          </layout>
         </widget>
        </item>
-       <item row="2" column="0" >
+       <item>
         <spacer>
          <property name="orientation" >
           <enum>Qt::Vertical</enum>
          </property>
-         <property name="sizeHint" >
+         <property name="sizeHint" stdset="0" >
           <size>
            <width>81</width>
            <height>196</height>
       </layout>
      </widget>
      <widget class="QWidget" name="sizetab" >
+      <property name="geometry" >
+       <rect>
+        <x>0</x>
+        <y>0</y>
+        <width>362</width>
+        <height>375</height>
+       </rect>
+      </property>
       <attribute name="title" >
        <string>Si&amp;ze and Rotation</string>
       </attribute>
             <property name="sizeType" >
              <enum>QSizePolicy::Expanding</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>20</width>
               <height>20</height>
             <item row="0" column="1" >
              <widget class="QLineEdit" name="angleED" >
               <property name="sizePolicy" >
-               <sizepolicy>
-                <hsizetype>3</hsizetype>
-                <vsizetype>0</vsizetype>
+               <sizepolicy vsizetype="Fixed" hsizetype="MinimumExpanding" >
                 <horstretch>0</horstretch>
                 <verstretch>0</verstretch>
                </sizepolicy>
            <number>6</number>
           </property>
           <item row="1" column="2" >
-           <widget class="LengthCombo" native="1" name="heightUnitCO" />
+           <widget class="LengthCombo" name="heightUnitCO" />
           </item>
           <item row="0" column="2" >
            <widget class="QComboBox" name="widthUnitCO" />
             <property name="orientation" >
              <enum>Qt::Horizontal</enum>
             </property>
-            <property name="sizeHint" >
+            <property name="sizeHint" stdset="0" >
              <size>
               <width>43</width>
               <height>18</height>
    </item>
    <item row="1" column="0" >
     <layout class="QHBoxLayout" >
-     <property name="margin" >
-      <number>0</number>
-     </property>
      <property name="spacing" >
       <number>6</number>
      </property>
+     <property name="margin" >
+      <number>0</number>
+     </property>
      <item>
       <spacer>
        <property name="orientation" >
        <property name="sizeType" >
         <enum>QSizePolicy::Expanding</enum>
        </property>
-       <property name="sizeHint" >
+       <property name="sizeHint" stdset="0" >
         <size>
          <width>20</width>
          <height>20</height>
     </layout>
    </item>
   </layout>
+  <zorder>tab</zorder>
+  <zorder>displayscaleLA</zorder>
  </widget>
  <customwidgets>
   <customwidget>
    <class>LengthCombo</class>
-   <extends>QWidget</extends>
+   <extends>QComboBox</extends>
    <header>LengthCombo.h</header>
   </customwidget>
  </customwidgets>
   <tabstop>externalCO</tabstop>
   <tabstop>externalTB</tabstop>
   <tabstop>draftCB</tabstop>
-  <tabstop>showCO</tabstop>
-  <tabstop>displayscaleED</tabstop>
   <tabstop>angleED</tabstop>
   <tabstop>originCO</tabstop>
   <tabstop>okPB</tabstop>
index 18ba74ca0489fcc61525e73af1b7dcfe37eafdc9..5988a26aac1edda47e5492237b20c328f277dc33 100644 (file)
       <string/>
      </property>
      <property name="currentIndex" >
-      <number>0</number>
+      <number>2</number>
      </property>
      <widget class="QWidget" name="Graphics" >
       <property name="geometry" >
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>562</width>
-        <height>293</height>
+        <width>593</width>
+        <height>295</height>
        </rect>
       </property>
       <attribute name="title" >
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>100</width>
-        <height>30</height>
+        <width>593</width>
+        <height>295</height>
        </rect>
       </property>
       <attribute name="title" >
        <rect>
         <x>0</x>
         <y>0</y>
-        <width>595</width>
-        <height>293</height>
+        <width>593</width>
+        <height>295</height>
        </rect>
       </property>
       <attribute name="title" >
          <property name="focusPolicy" >
           <enum>Qt::StrongFocus</enum>
          </property>
+         <property name="toolTip" >
+          <string>Enable LyX to preview this graphics, only if graphics previewing is not disabled at application level (see Preference dialog).</string>
+         </property>
          <property name="title" >
           <string>Sho&amp;w in LyX</string>
          </property>
             </property>
            </spacer>
           </item>
-          <item row="0" column="3" >
-           <widget class="QLineEdit" name="displayscale" >
-            <property name="enabled" >
-             <bool>true</bool>
-            </property>
-            <property name="sizePolicy" >
-             <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
-            <property name="toolTip" >
-             <string>Percentage to scale by in LyX</string>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="2" >
-           <widget class="QLabel" name="scaleLA" >
-            <property name="toolTip" >
-             <string>Percentage to scale by in LyX</string>
-            </property>
-            <property name="text" >
-             <string>Sca&amp;le on Screen (%):</string>
-            </property>
-            <property name="buddy" >
-             <cstring>displayscale</cstring>
-            </property>
-           </widget>
-          </item>
-          <item row="0" column="1" >
-           <widget class="QComboBox" name="showCB" >
-            <property name="toolTip" >
-             <string>Screen display</string>
-            </property>
-            <item>
-             <property name="text" >
-              <string>Default</string>
-             </property>
-            </item>
-            <item>
-             <property name="text" >
-              <string>Monochrome</string>
-             </property>
-            </item>
-            <item>
-             <property name="text" >
-              <string>Grayscale</string>
-             </property>
-            </item>
-            <item>
-             <property name="text" >
-              <string>Color</string>
-             </property>
-            </item>
-           </widget>
-          </item>
-          <item row="0" column="0" >
-           <widget class="QLabel" name="showL" >
-            <property name="toolTip" >
-             <string>Screen display</string>
-            </property>
-            <property name="text" >
-             <string>Scr&amp;een Display:</string>
-            </property>
-            <property name="buddy" >
-             <cstring>showCB</cstring>
-            </property>
-           </widget>
-          </item>
           <item row="1" column="0" >
            <widget class="QLabel" name="label" >
             <property name="sizePolicy" >
             </property>
            </widget>
           </item>
+          <item row="0" column="1" >
+           <widget class="QLineEdit" name="displayscale" >
+            <property name="enabled" >
+             <bool>true</bool>
+            </property>
+            <property name="sizePolicy" >
+             <sizepolicy vsizetype="Fixed" hsizetype="Minimum" >
+              <horstretch>0</horstretch>
+              <verstretch>0</verstretch>
+             </sizepolicy>
+            </property>
+            <property name="toolTip" >
+             <string>Percentage to scale by in LyX</string>
+            </property>
+           </widget>
+          </item>
+          <item row="0" column="0" >
+           <widget class="QLabel" name="scaleLA" >
+            <property name="toolTip" >
+             <string>Percentage to scale by in LyX</string>
+            </property>
+            <property name="text" >
+             <string>Sca&amp;le on Screen (%):</string>
+            </property>
+            <property name="buddy" >
+             <cstring>displayscale</cstring>
+            </property>
+           </widget>
+          </item>
          </layout>
         </widget>
        </item>
   <tabstop>draftCB</tabstop>
   <tabstop>unzipCB</tabstop>
   <tabstop>displayGB</tabstop>
-  <tabstop>showCB</tabstop>
-  <tabstop>displayscale</tabstop>
  </tabstops>
  <includes>
   <include location="local" >qt_i18n.h</include>
index 49c7b1079a22074f56016a25840fe115f13167ae..a8f16a5042845a1737d16305cc4ec57409101b3b 100644 (file)
   <property name="windowTitle" >
    <string/>
   </property>
-  <layout class="QGridLayout" >
-   <property name="margin" >
-    <number>9</number>
-   </property>
-   <property name="spacing" >
-    <number>6</number>
-   </property>
+  <layout class="QGridLayout" name="gridLayout" >
+   <item row="0" column="0" colspan="2" >
+    <widget class="QCheckBox" name="displayGraphicsCB" >
+     <property name="text" >
+      <string>Display &amp;Graphics</string>
+     </property>
+    </widget>
+   </item>
    <item rowspan="2" row="0" column="2" >
     <spacer>
      <property name="orientation" >
       <enum>Qt::Horizontal</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0" >
       <size>
        <width>40</width>
        <height>20</height>
      </property>
     </spacer>
    </item>
+   <item row="1" column="0" >
+    <widget class="QLabel" name="instantPreviewLA" >
+     <property name="text" >
+      <string>Instant &amp;Preview:</string>
+     </property>
+     <property name="buddy" >
+      <cstring>instantPreviewCO</cstring>
+     </property>
+    </widget>
+   </item>
    <item row="1" column="1" >
     <widget class="QComboBox" name="instantPreviewCO" >
      <item>
      </item>
     </widget>
    </item>
-   <item row="0" column="1" >
-    <widget class="QComboBox" name="displayGraphicsCO" >
-     <item>
-      <property name="text" >
-       <string>Monochrome</string>
-      </property>
-     </item>
-     <item>
-      <property name="text" >
-       <string>Grayscale</string>
-      </property>
-     </item>
-     <item>
-      <property name="text" >
-       <string>Color</string>
-      </property>
-     </item>
-     <item>
-      <property name="text" >
-       <string>Do not display</string>
-      </property>
-     </item>
-    </widget>
-   </item>
-   <item row="0" column="0" >
-    <widget class="QLabel" name="displayGraphicsLA" >
-     <property name="text" >
-      <string>Display &amp;Graphics:</string>
-     </property>
-     <property name="buddy" >
-      <cstring>displayGraphicsCO</cstring>
-     </property>
-    </widget>
-   </item>
-   <item row="1" column="0" >
-    <widget class="QLabel" name="instantPreviewLA" >
-     <property name="text" >
-      <string>Instant &amp;Preview:</string>
-     </property>
-     <property name="buddy" >
-      <cstring>instantPreviewCO</cstring>
-     </property>
-    </widget>
-   </item>
    <item row="2" column="0" colspan="2" >
     <spacer>
      <property name="orientation" >
      <property name="sizeType" >
       <enum>QSizePolicy::Expanding</enum>
      </property>
-     <property name="sizeHint" >
+     <property name="sizeHint" stdset="0" >
       <size>
        <width>20</width>
        <height>20</height>
   </layout>
  </widget>
  <tabstops>
-  <tabstop>displayGraphicsCO</tabstop>
   <tabstop>instantPreviewCO</tabstop>
  </tabstops>
  <includes>
index d2b712b60cb959ad5e9786048ddc845a5dae31a6..63b1ac4f188521c62ea0e9f020d4b15eb93f8832 100644 (file)
@@ -207,10 +207,10 @@ Loader::Loader()
 {}
 
 
-Loader::Loader(FileName const & file, DisplayType type)
+Loader::Loader(FileName const & file, bool display)
        : pimpl_(new Impl)
 {
-       reset(file, type);
+       reset(file, display);
 }
 
 
@@ -245,10 +245,10 @@ Loader & Loader::operator=(Loader const & other)
 }
 
 
-void Loader::reset(FileName const & file, DisplayType type) const
+void Loader::reset(FileName const & file, bool display) const
 {
        Params params;
-       params.display = type;
+       params.display = display;
        pimpl_->resetParams(params);
 
        pimpl_->resetFile(file);
@@ -407,8 +407,7 @@ void Loader::Impl::statusChanged()
 
 void Loader::Impl::createPixmap()
 {
-       if (!cached_item_.get() ||
-           params_.display == NoDisplay || status_ != Loaded)
+       if (!cached_item_.get() || !params_.display || status_ != Loaded)
                return;
 
        image_.reset(cached_item_->image()->clone());
index c4ed587f66ca57ac7494835e81723050d441a462..43fd85e69590f48493f23c9664317df9f1333f8e 100644 (file)
@@ -42,7 +42,7 @@ public:
        /// Must use the reset methods to make this instance usable.
        Loader();
        /// The image is not transformed, just displayed as-is.
-       Loader(support::FileName const & file_with_path, DisplayType = ColorDisplay);
+       Loader(support::FileName const & file_with_path, bool display = true);
        /// The image is transformed before display.
        Loader(support::FileName const & file_with_path, Params const &);
        ///
@@ -53,8 +53,7 @@ public:
        Loader & operator=(Loader const &);
 
        /// The file can be changed, or the display params, or both.
-       void reset(support::FileName const & file_with_path,
-                  DisplayType = ColorDisplay) const;
+       void reset(support::FileName const & file_with_path, bool display = true) const;
        ///
        void reset(support::FileName const & file_with_path, Params const &) const;
        ///
index 659cbe84c07c062bd2c26fb7946d2bdd84b1afd8..a53d2c57b1ffb4f038c998cde7ceeea046f9b34c 100644 (file)
@@ -23,7 +23,7 @@ namespace lyx {
 namespace graphics {
 
 Params::Params()
-       : display(ColorDisplay),
+       : display(true),
          scale(100),
          angle(0)
 {}
index a7b7c8ffa424cac72e383b2b8a2edc20f54f4786..7213aaa3a150ba06864cf922c6478eda0bbdd2c5 100644 (file)
@@ -55,7 +55,7 @@ class Params
 public:
        Params();
 
-       DisplayType display;
+       bool display;
        unsigned int scale;
 
        /// The image filename.
index 126bf55f6c0739e010aaba743d28925191913c44..af25934cc04e4b4a8adcfcb49b31e258ec8ea21e 100644 (file)
@@ -19,30 +19,5 @@ using namespace std;
 namespace lyx {
 namespace graphics {
 
-namespace {
-
-/// The translator between the Display enum and corresponding lyx string.
-Translator<DisplayType, string> const initTranslator()
-{
-       Translator<DisplayType, string> translator(DefaultDisplay, "default");
-
-       // Fill the display translator
-       translator.addPair(MonochromeDisplay, "monochrome");
-       translator.addPair(GrayscaleDisplay, "grayscale");
-       translator.addPair(ColorDisplay, "color");
-       translator.addPair(NoDisplay, "none");
-
-       return translator;
-}
-
-} // namespace anon
-
-Translator<DisplayType, string> const & displayTranslator()
-{
-       static Translator<DisplayType, string> const translator =
-               initTranslator();
-       return translator;
-}
-
 } // namespace graphics
 } // namespace lyx
index 50533eb64a222d1b87d4f7d2f83edd53daec9f97..45181d3a8bf803e3dc7780818703e2e81d2606e3 100644 (file)
@@ -50,24 +50,6 @@ enum ImageStatus {
        ErrorUnknown
 };
 
-/// How is the image to be displayed on the LyX screen?
-enum DisplayType {
-       ///
-       DefaultDisplay,
-       ///
-       MonochromeDisplay,
-       ///
-       GrayscaleDisplay,
-       ///
-       ColorDisplay,
-       ///
-       NoDisplay
-};
-
-
-/// The translator between the Display enum and corresponding lyx string.
-Translator<DisplayType, std::string> const & displayTranslator();
-
 } // namespace graphics
 } // namespace lyx
 
index 7861e8a59fa0fd869143385a689a5ded1289272b..600969dc456441d4913f0d62e9f5c0e37de02970 100644 (file)
@@ -102,8 +102,19 @@ public:
                    << "\tHelpTextEnd\n"
                    << "\tInputFormat " << et.inputFormat << '\n'
                    << "\tFileFilter " << et.fileRegExp << '\n'
-                   << "\tAutomaticProduction " << et.automaticProduction << '\n';
-
+                   << "\tAutomaticProduction " << et.automaticProduction << '\n'
+                   << "\tPreview ";
+               switch (et.preview_mode) {
+                       case PREVIEW_OFF:
+                               os_ << "Off\n";
+                               break;
+                       case PREVIEW_GRAPHICS:
+                               os_ << "Graphics\n";
+                               break;
+                       case PREVIEW_INSTANT:
+                               os_ << "InstantPreview\n";
+                               break;
+               }
                typedef vector<TransformID> IDs;
                IDs::const_iterator it  = et.transformIds.begin();
                IDs::const_iterator end = et.transformIds.end();
@@ -299,6 +310,7 @@ void Template::readTemplate(Lexer & lex)
                TO_INPUTFORMAT,
                TO_FILTER,
                TO_AUTOMATIC,
+               TO_PREVIEW,
                TO_TRANSFORM,
                TO_FORMAT,
                TO_END
@@ -306,6 +318,7 @@ void Template::readTemplate(Lexer & lex)
 
        LexerKeyword templateoptiontags[] = {
                { "automaticproduction", TO_AUTOMATIC },
+               { "preview", TO_PREVIEW },
                { "filefilter", TO_FILTER },
                { "format", TO_FORMAT },
                { "guiname", TO_GUINAME },
@@ -345,6 +358,16 @@ void Template::readTemplate(Lexer & lex)
                        automaticProduction = lex.getBool();
                        break;
 
+               case TO_PREVIEW:
+                       lex >> token;
+                       if (token == "InstantPreview")
+                               preview_mode = PREVIEW_INSTANT;
+                       else if (token == "Graphics")
+                               preview_mode = PREVIEW_GRAPHICS;
+                       else
+                               preview_mode = PREVIEW_OFF;
+                       break;
+
                case TO_TRANSFORM: {
                        lex >> token;
                        TransformID id = transformIDTranslator().find(token);
index 7afc65715ba7ad5cd75e15ffac56053f42d23382..23f1f78802ffb9d98d7977ac36a10fce38e41ad1 100644 (file)
@@ -23,6 +23,12 @@ namespace support { class FileName; }
 
 class Lexer;
 
+enum PreviewMode {
+       PREVIEW_OFF = 0,
+       PREVIEW_GRAPHICS,
+       PREVIEW_INSTANT
+};
+
 namespace external {
 
 class Template {
@@ -56,6 +62,8 @@ public:
        std::string fileRegExp;
        /// Should we do automatic production of the output?
        bool automaticProduction;
+       /// How should we preview the data in LyX?
+       PreviewMode preview_mode;
        /// A collection of transforms that we can use to transform the data.
        std::vector<TransformID> transformIds;
 
index 42efa6d289d32958fe981fdb9f7decaffd3942bb..a2b820c49071ee48bf00651eb2cafba4b1c70034 100644 (file)
@@ -12,7 +12,6 @@
 
 #include "InsetExternal.h"
 #include "insets/ExternalSupport.h"
-#include "insets/ExternalTemplate.h"
 #include "insets/RenderButton.h"
 #include "insets/RenderGraphic.h"
 #include "insets/RenderPreview.h"
@@ -54,8 +53,6 @@ using namespace lyx::support;
 
 namespace {
 
-lyx::external::DisplayType const defaultDisplayType = lyx::external::NoDisplay;
-
 unsigned int const defaultLyxScale = 100;
 
 string defaultTemplateName;
@@ -98,39 +95,11 @@ TempName & TempName::operator=(TempName const & other)
        return *this;
 }
 
-
-namespace {
-
-/// The translator between the Display enum and corresponding lyx string.
-Translator<DisplayType, string> const initTranslator()
-{
-       Translator<DisplayType, string> translator(DefaultDisplay, "default");
-
-       // Fill the display translator
-       translator.addPair(MonochromeDisplay, "monochrome");
-       translator.addPair(GrayscaleDisplay, "grayscale");
-       translator.addPair(ColorDisplay, "color");
-       translator.addPair(PreviewDisplay, "preview");
-       translator.addPair(NoDisplay, "none");
-
-       return translator;
-}
-
-} // namespace anon
-
-
-Translator<DisplayType, string> const & displayTranslator()
-{
-       static Translator<DisplayType, string> const translator =
-               initTranslator();
-       return translator;
-}
-
 } // namespace external
 
 
 InsetExternalParams::InsetExternalParams()
-       : display(defaultDisplayType),
+       : display(true),
          lyxscale(defaultLyxScale),
          draft(false)
 {
@@ -180,6 +149,9 @@ void InsetExternalParams::settemplate(string const & name)
        clearIfNotFound(extradata,    external::Extra,  ids);
        clearIfNotFound(resizedata,   external::Resize, ids);
        clearIfNotFound(rotationdata, external::Rotate, ids);
+
+       // 
+       preview_mode = et->preview_mode;
 }
 
 
@@ -191,10 +163,8 @@ void InsetExternalParams::write(Buffer const & buf, ostream & os) const
        if (!filename.empty())
                os << "\tfilename " << filename.outputFilename(buf.filePath()) << '\n';
 
-       if (display != defaultDisplayType)
-               os << "\tdisplay "
-                  << external::displayTranslator().find(display)
-                  << '\n';
+       if (!display)
+               os << "\tdisplay false\n";
 
        if (lyxscale != defaultLyxScale)
                os << "\tlyxscale " << convert<string>(lyxscale) << '\n';
@@ -301,8 +271,7 @@ bool InsetExternalParams::read(Buffer const & buffer, Lexer & lex)
                
                case EX_DISPLAY: {
                        lex.next();
-                       string const name = lex.getString();
-                       display = external::displayTranslator().find(name);
+                       display = lex.getString() != "false";
                        break;
                }
 
@@ -499,33 +468,6 @@ void InsetExternal::draw(PainterInfo & pi, int x, int y) const
 
 namespace {
 
-enum RenderType {
-       RENDERBUTTON,
-       RENDERGRAPHIC,
-       RENDERPREVIEW
-};
-
-
-RenderType getRenderType(InsetExternalParams const & p)
-{
-       if (!external::getTemplatePtr(p) ||
-           p.filename.empty() ||
-           p.display == external::NoDisplay)
-               return RENDERBUTTON;
-
-       if (p.display == external::PreviewDisplay) {
-               if (RenderPreview::status() != LyXRC::PREVIEW_OFF)
-                       return RENDERPREVIEW;
-               return RENDERBUTTON;
-       }
-
-       if (p.display == external::DefaultDisplay &&
-           lyxrc.display_graphics == graphics::NoDisplay)
-               return RENDERBUTTON;
-       return RENDERGRAPHIC;
-}
-
-
 graphics::Params get_grfx_params(InsetExternalParams const & eparams)
 {
        graphics::Params gparams;
@@ -535,31 +477,7 @@ graphics::Params get_grfx_params(InsetExternalParams const & eparams)
        if (eparams.clipdata.clip)
                gparams.bb = eparams.clipdata.bbox;
        gparams.angle = convert<double>(eparams.rotationdata.adjAngle());
-
-       switch (eparams.display) {
-       case external::DefaultDisplay:
-               gparams.display = graphics::DefaultDisplay;
-               break;
-       case external::MonochromeDisplay:
-               gparams.display = graphics::MonochromeDisplay;
-               break;
-       case external::GrayscaleDisplay:
-               gparams.display = graphics::GrayscaleDisplay;
-               break;
-       case external::ColorDisplay:
-               gparams.display = graphics::ColorDisplay;
-               break;
-       case external::NoDisplay:
-               gparams.display = graphics::NoDisplay;
-               break;
-       default:
-               LASSERT(false, /**/);
-       }
-       if (gparams.display == graphics::DefaultDisplay)
-               gparams.display = graphics::DisplayType(lyxrc.display_graphics);
-       // Override the above if we're not using a gui
-       if (!use_gui)
-               gparams.display = graphics::NoDisplay;
+       gparams.display = eparams.display;
 
        return gparams;
 }
@@ -585,8 +503,7 @@ docstring screenLabel(InsetExternalParams const & params,
 
 static bool isPreviewWanted(InsetExternalParams const & params)
 {
-       return params.display == external::PreviewDisplay &&
-               params.filename.isReadableFile();
+       return params.display && params.filename.isReadableFile();
 }
 
 
@@ -632,44 +549,43 @@ void InsetExternal::setParams(InsetExternalParams const & p)
        // will use this.
        defaultTemplateName = params_.templatename();
 
-       switch (getRenderType(params_)) {
-       case RENDERBUTTON: {
+       if (!external::getTemplatePtr(params_) || params_.filename.empty()
+               || !params_.display
+               || !lyxrc.display_graphics
+               || params_.preview_mode == PREVIEW_OFF
+               || (params_.preview_mode == PREVIEW_INSTANT
+                   && RenderPreview::status() == LyXRC::PREVIEW_OFF)) {
                RenderButton * button_ptr = renderer_->asButton();
                if (!button_ptr) {
                        renderer_.reset(new RenderButton);
                        button_ptr = renderer_->asButton();
                }
-
                button_ptr->update(screenLabel(params_, buffer()), true);
-               break;
+               return;
        }
 
-       case RENDERGRAPHIC: {
+       switch (params_.preview_mode) {
+       case PREVIEW_OFF:
+               // Already taken care of above.
+               LASSERT(false, return);
+               break;
+       case PREVIEW_INSTANT: {
+               RenderMonitoredPreview * preview_ptr = renderer_->asMonitoredPreview();
+               renderer_.reset(new RenderMonitoredPreview(this));
+               preview_ptr = renderer_->asMonitoredPreview();
+               preview_ptr->fileChanged(boost::bind(&InsetExternal::fileChanged, this));
+               if (preview_ptr->monitoring())
+                       preview_ptr->stopMonitoring();
+               add_preview_and_start_loading(*preview_ptr, *this, buffer());
+               break;
+       } 
+       case PREVIEW_GRAPHICS: {
                RenderGraphic * graphic_ptr = renderer_->asGraphic();
                if (!graphic_ptr) {
                        renderer_.reset(new RenderGraphic(this));
                        graphic_ptr = renderer_->asGraphic();
                }
-
                graphic_ptr->update(get_grfx_params(params_));
-
-               break;
-       }
-
-       case RENDERPREVIEW: {
-               RenderMonitoredPreview * preview_ptr =
-                       renderer_->asMonitoredPreview();
-               if (!preview_ptr) {
-                       renderer_.reset(new RenderMonitoredPreview(this));
-                       preview_ptr = renderer_->asMonitoredPreview();
-                       preview_ptr->fileChanged(
-                               boost::bind(&InsetExternal::fileChanged, this));
-               }
-
-               if (preview_ptr->monitoring())
-                       preview_ptr->stopMonitoring();
-               add_preview_and_start_loading(*preview_ptr, *this, buffer());
-
                break;
        }
        }
index 22a9318a47b1e12a606df811d2ae09235af891f1..a9f8adbe5347b2ce7cef040a3c72d65d9fd3a636 100644 (file)
@@ -13,6 +13,7 @@
 #define INSET_EXTERNAL_H
 
 #include "Inset.h"
+#include "ExternalTemplate.h"
 #include "ExternalTransforms.h"
 
 #include "support/FileName.h"
@@ -44,20 +45,6 @@ private:
        support::FileName tempname_;
 };
 
-/// How is the image to be displayed on the LyX screen?
-enum DisplayType {
-       DefaultDisplay,
-       MonochromeDisplay,
-       GrayscaleDisplay,
-       ColorDisplay,
-       PreviewDisplay,
-       NoDisplay
-};
-
-
-/// The translator between the Display enum and corresponding lyx string.
-Translator<DisplayType, std::string> const & displayTranslator();
-
 } // namespace external
 
 
@@ -78,8 +65,10 @@ public:
 
        /// The external file.
        support::DocFileName filename;
-       /// How the inset is to be displayed by LyX.
-       external::DisplayType display;
+       /// If the inset is to be displayed by LyX.
+       bool display;
+       /// If the inset is to use the preview mechanism.
+       PreviewMode preview_mode;
        /// The scale of the displayed graphic (if shown).
        unsigned int lyxscale;
 
index b2b15f0ad3888187625553bfe6210a58cf94b791..ad796d7638ff0f3794bb27ec6ba11f9bdd7d3200 100644 (file)
@@ -64,7 +64,7 @@ void InsetGraphicsParams::init()
 {
        filename.erase();
        lyxscale = 100;                 // lyx scaling in percentage
-       display = graphics::DefaultDisplay; // display mode; see preferences
+       display = true;         // may be overriden by display mode in preferences
        scale = string("100");                  // output scaling in percentage
        width = Length();
        height = Length();
@@ -144,8 +144,8 @@ void InsetGraphicsParams::Write(ostream & os, Buffer const & buffer) const
                os << "\tfilename " << filename.outputFilename(buffer.filePath()) << '\n';
        if (lyxscale != 100)
                os << "\tlyxscale " << lyxscale << '\n';
-       if (display != graphics::DefaultDisplay)
-               os << "\tdisplay " << graphics::displayTranslator().find(display) << '\n';
+       if (!display)
+               os << "\tdisplay false\n";
        if (!scale.empty() && !float_equal(convert<double>(scale), 0.0, 0.05)) {
                if (!float_equal(convert<double>(scale), 100.0, 0.05))
                        os << "\tscale " << scale << '\n';
@@ -193,7 +193,7 @@ bool InsetGraphicsParams::Read(Lexer & lex, string const & token, string const &
        } else if (token == "display") {
                lex.next();
                string const type = lex.getString();
-               display = graphics::displayTranslator().find(type);
+               display = lex.getString() != "false";
        } else if (token == "scale") {
                lex.next();
                scale = lex.getString();
@@ -303,15 +303,11 @@ graphics::Params InsetGraphicsParams::as_grfxParams() const
                }
        }
 
-       if (display == graphics::DefaultDisplay) {
-               pars.display = graphics::DisplayType(lyxrc.display_graphics);
-       } else {
-               pars.display = display;
-       }
+       pars.display = display;
 
        // Override the above if we're not using a gui
        if (!use_gui)
-               pars.display = graphics::NoDisplay;
+               pars.display = false;
 
        return pars;
 }
index 348e7084068222d04a036c23d7b6e9ac04ebf223..0f9600971c69dd60fd16263d68e51bb628f59ffa 100644 (file)
@@ -37,8 +37,8 @@ public:
        support::DocFileName filename;
        /// Scaling the Screen inside Lyx
        unsigned int lyxscale;
-       /// How to display the image inside LyX
-       graphics::DisplayType display;
+       /// If to display the image inside LyX
+       bool display;
        /// Scaling for output (LaTeX)
        std::string scale;
        /// sizes for output (LaTeX)
index ca8008c65eede0baa308408834167d25e6ebf6bc..df1a93a1804f565301945bf8b5c60a94ef899a74 100644 (file)
@@ -67,8 +67,7 @@ namespace {
 
 bool displayGraphic(graphics::Params const & params)
 {
-       return params.display != graphics::NoDisplay &&
-               lyxrc.display_graphics != graphics::NoDisplay;
+       return params.display && lyxrc.display_graphics;
 }