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.
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
AutomaticProduction true
Transform Rotate
Transform Resize
+ Preview InstantPreview
Format LaTeX
TransformCommand Rotate RotationLatexCommand
TransformCommand Resize ResizeLatexCommand
InputFormat fen
FileFilter "*.fen"
AutomaticProduction true
+ Preview InstantPreview
Format LaTeX
Product "\\loadgame{$$AbsOrRelPathMaster$$Basename}\\showboard"
Requirement "chess"
Transform Resize
Transform Clip
Transform Extra
+ Preview InstantPreview
Format LaTeX
TransformOption Rotate RotationLatexOption
TransformOption Resize ResizeLatexOption
InputFormat date
FileFilter "*"
AutomaticProduction true
+ Preview Off
Format LaTeX
Product "$$Contents(\"$$Tempname\")"
UpdateFormat dateout
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)
[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, []],
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;
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";
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:
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)
///
int label_init_length;
///
- ///graphics::DisplayType
- int display_graphics;
+ bool display_graphics;
///
bool show_banner;
///
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)),
bc().addReadOnly(externalCO);
bc().addReadOnly(draftCB);
bc().addReadOnly(displayscaleED);
- bc().addReadOnly(showCO);
bc().addReadOnly(displayGB);
bc().addReadOnly(angleED);
bc().addReadOnly(originCO);
}
-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)
{
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);
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);
// 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&)),
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)
scaleCB->setChecked(scaleChecked);
scaleCB->blockSignals(false);
Scale->setEnabled(scaleChecked);
+ displayGB->setEnabled(lyxrc.display_graphics);
groupId->setText(toqstr(igp.groupId));
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()) {
}
-// 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();
: 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()));
}
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
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);
}
</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&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&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><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
+<html><head><meta name="qrichtext" content="1" /><style type="text/css">
+p, li { white-space: pre-wrap; }
+</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;">
+<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:8pt;">Enable LyX to preview this material; only if graphics previewing is not disabled at application level (see Preference dialog).</span></p>
+<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;"></p></body></html></string>
</property>
<property name="title" >
<string>&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>&Display:</string>
+ <string>Sca&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&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&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>
<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&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&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&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&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>
<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 &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 &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 &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 &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>
{}
-Loader::Loader(FileName const & file, DisplayType type)
+Loader::Loader(FileName const & file, bool display)
: pimpl_(new Impl)
{
- reset(file, type);
+ reset(file, display);
}
}
-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);
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());
/// 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 &);
///
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;
///
namespace graphics {
Params::Params()
- : display(ColorDisplay),
+ : display(true),
scale(100),
angle(0)
{}
public:
Params();
- DisplayType display;
+ bool display;
unsigned int scale;
/// The image filename.
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
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
<< "\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();
TO_INPUTFORMAT,
TO_FILTER,
TO_AUTOMATIC,
+ TO_PREVIEW,
TO_TRANSFORM,
TO_FORMAT,
TO_END
LexerKeyword templateoptiontags[] = {
{ "automaticproduction", TO_AUTOMATIC },
+ { "preview", TO_PREVIEW },
{ "filefilter", TO_FILTER },
{ "format", TO_FORMAT },
{ "guiname", TO_GUINAME },
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);
class Lexer;
+enum PreviewMode {
+ PREVIEW_OFF = 0,
+ PREVIEW_GRAPHICS,
+ PREVIEW_INSTANT
+};
+
namespace external {
class Template {
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;
#include "InsetExternal.h"
#include "insets/ExternalSupport.h"
-#include "insets/ExternalTemplate.h"
#include "insets/RenderButton.h"
#include "insets/RenderGraphic.h"
#include "insets/RenderPreview.h"
namespace {
-lyx::external::DisplayType const defaultDisplayType = lyx::external::NoDisplay;
-
unsigned int const defaultLyxScale = 100;
string defaultTemplateName;
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)
{
clearIfNotFound(extradata, external::Extra, ids);
clearIfNotFound(resizedata, external::Resize, ids);
clearIfNotFound(rotationdata, external::Rotate, ids);
+
+ //
+ preview_mode = et->preview_mode;
}
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';
case EX_DISPLAY: {
lex.next();
- string const name = lex.getString();
- display = external::displayTranslator().find(name);
+ display = lex.getString() != "false";
break;
}
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;
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;
}
static bool isPreviewWanted(InsetExternalParams const & params)
{
- return params.display == external::PreviewDisplay &&
- params.filename.isReadableFile();
+ return params.display && params.filename.isReadableFile();
}
// 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;
}
}
#define INSET_EXTERNAL_H
#include "Inset.h"
+#include "ExternalTemplate.h"
#include "ExternalTransforms.h"
#include "support/FileName.h"
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
/// 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;
{
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();
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';
} 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();
}
}
- 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;
}
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)
bool displayGraphic(graphics::Params const & params)
{
- return params.display != graphics::NoDisplay &&
- lyxrc.display_graphics != graphics::NoDisplay;
+ return params.display && lyxrc.display_graphics;
}