Enable the user to preview xfig figures (f.ex.) without previewing mathed.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8670 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2004-04-19 13:31:17 +00:00
parent 005545f281
commit f16199abd2
18 changed files with 237 additions and 97 deletions

View File

@ -353,7 +353,7 @@ void BufferView::Pimpl::setBuffer(Buffer * b)
owner_->updateLayoutChoice();
owner_->updateWindowTitle();
if (lyx::graphics::Previews::activated() && buffer_)
if (buffer_ && lyx::graphics::Previews::status() != LyXRC::PREVIEW_OFF)
lyx::graphics::Previews::get().generateBufferPreviews(*buffer_);
}

View File

@ -1,3 +1,10 @@
2004-04-19 Angus Leeming <leeming@lyx.org>
* BufferView_pimpl.C (setBuffer): changed preview interface.
* lyxrc.[Ch] (preview): no longer a bool. Now an enum with three
possible values.
2004-04-19 John Levon <levon@movementarian.org>
* BufferView_pimpl.C:

View File

@ -181,15 +181,25 @@ void QPrefs::apply()
QPrefDisplayModule * displaymod(dialog_->displayModule);
rc.preview = displaymod->previewCB->isChecked();
switch (displaymod->instantPreviewCO->currentItem()) {
case 0:
rc.preview = LyXRC::PREVIEW_OFF;
break;
case 1:
rc.preview = LyXRC::PREVIEW_NO_MATH;
break;
case 2:
rc.preview = LyXRC::PREVIEW_ON;
break;
}
lyx::graphics::DisplayType dtype(lyx::graphics::ColorDisplay);
switch (displaymod->displayGraphicsCO->currentItem()) {
case 3: dtype = lyx::graphics::NoDisplay; break;
case 2: dtype = lyx::graphics::ColorDisplay; break;
case 1: dtype = lyx::graphics::GrayscaleDisplay; break;
case 0: dtype = lyx::graphics::MonochromeDisplay; break;
case 3: dtype = lyx::graphics::NoDisplay; break;
case 2: dtype = lyx::graphics::ColorDisplay; break;
case 1: dtype = lyx::graphics::GrayscaleDisplay; break;
case 0: dtype = lyx::graphics::MonochromeDisplay; break;
}
rc.display_graphics = dtype;
@ -490,8 +500,18 @@ void QPrefs::update_contents()
QPrefDisplayModule * displaymod(dialog_->displayModule);
displaymod->previewCB->setChecked(rc.preview);
switch (rc.preview) {
case LyXRC::PREVIEW_OFF:
displaymod->instantPreviewCO->setCurrentItem(0);
break;
case LyXRC::PREVIEW_NO_MATH :
displaymod->instantPreviewCO->setCurrentItem(1);
break;
case LyXRC::PREVIEW_ON :
displaymod->instantPreviewCO->setCurrentItem(2);
break;
}
int item = 2;
switch (rc.display_graphics) {

View File

@ -206,7 +206,7 @@ QPrefsDialog::QPrefsDialog(QPrefs * form)
connect(latexModule->latexAutoresetCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
connect(latexModule->latexDviPaperED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(latexModule->latexPaperSizeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
connect(displayModule->previewCB, SIGNAL(toggled(bool)), this, SLOT(change_adaptor()));
connect(displayModule->instantPreviewCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
connect(displayModule->displayGraphicsCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
connect(pathsModule->workingDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));
connect(pathsModule->templateDirED, SIGNAL(textChanged(const QString&)), this, SLOT(change_adaptor()));

View File

@ -13,15 +13,15 @@
<rect>
<x>0</x>
<y>0</y>
<width>240</width>
<height>102</height>
<width>264</width>
<height>133</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Display insets</string>
</property>
<vbox>
<grid>
<property stdset="1">
<name>margin</name>
<number>11</number>
@ -30,11 +30,11 @@
<name>spacing</name>
<number>6</number>
</property>
<widget>
<widget row="0" column="0" >
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout1</cstring>
<cstring>Layout3</cstring>
</property>
<grid>
<property stdset="1">
@ -45,6 +45,46 @@
<name>spacing</name>
<number>6</number>
</property>
<widget row="0" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>displayGraphicsLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Display &amp;Graphics:</string>
</property>
<property>
<name>buddy</name>
<cstring>displayGraphicsCO</cstring>
</property>
</widget>
<widget row="1" column="1" >
<class>QComboBox</class>
<item>
<property>
<name>text</name>
<string>Off</string>
</property>
</item>
<item>
<property>
<name>text</name>
<string>No math</string>
</property>
</item>
<item>
<property>
<name>text</name>
<string>On</string>
</property>
</item>
<property stdset="1">
<name>name</name>
<cstring>instantPreviewCO</cstring>
</property>
</widget>
<widget row="0" column="1" >
<class>QComboBox</class>
<item>
@ -76,35 +116,24 @@
<cstring>displayGraphicsCO</cstring>
</property>
</widget>
<widget row="0" column="0" >
<widget row="1" column="0" >
<class>QLabel</class>
<property stdset="1">
<name>name</name>
<cstring>displayGraphicsLA</cstring>
<cstring>instantPreviewLA</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Display &amp;Graphics:</string>
<string>Instant &amp;Preview:</string>
</property>
<property>
<name>buddy</name>
<cstring>displayGraphicsCO</cstring>
<cstring>instantPreviewCO</cstring>
</property>
</widget>
</grid>
</widget>
<widget>
<class>QCheckBox</class>
<property stdset="1">
<name>name</name>
<cstring>previewCB</cstring>
</property>
<property stdset="1">
<name>text</name>
<string>Instant &amp;preview</string>
</property>
</widget>
<spacer>
<spacer row="1" column="0" >
<property>
<name>name</name>
<cstring>Spacer1</cstring>
@ -125,6 +154,6 @@
</size>
</property>
</spacer>
</vbox>
</grid>
</widget>
</UI>

View File

@ -1607,7 +1607,19 @@ void FormPreferences::LnFmisc::apply(LyXRC & rc) const
fl_get_button(dialog_->check_cursor_follows_scrollbar);
rc.dialogs_iconify_with_main =
fl_get_button(dialog_->check_dialogs_iconify_with_main);
rc.preview = fl_get_button(dialog_->check_preview_latex);
switch (fl_get_choice(dialog_->choice_instant_preview)) {
case 1:
rc.preview = LyXRC::PREVIEW_OFF;
break;
case 2:
rc.preview = LyXRC::PREVIEW_NO_MATH;
break;
case 3:
rc.preview = LyXRC::PREVIEW_ON;
break;
}
rc.autosave = static_cast<unsigned int>
(fl_get_counter_value(dialog_->counter_autosave));
rc.wheel_jump = static_cast<unsigned int>
@ -1615,7 +1627,7 @@ void FormPreferences::LnFmisc::apply(LyXRC & rc) const
// See FIXME below
// lyx::graphics::DisplayType old_value = rc.display_graphics;
switch (fl_get_choice(dialog_->choice_display)) {
switch (fl_get_choice(dialog_->choice_graphics_display)) {
case 4:
rc.display_graphics = lyx::graphics::NoDisplay;
break;
@ -1660,11 +1672,14 @@ void FormPreferences::LnFmisc::build()
setPrehandler(dialog_->counter_autosave);
setPrehandler(dialog_->check_cursor_follows_scrollbar);
setPrehandler(dialog_->check_dialogs_iconify_with_main);
setPrehandler(dialog_->check_preview_latex);
setPrehandler(dialog_->choice_instant_preview);
setPrehandler(dialog_->counter_wm_jump);
fl_addto_choice(dialog_->choice_display,
fl_addto_choice(dialog_->choice_graphics_display,
_("Monochrome|Grayscale|Color|Do not display").c_str());
fl_addto_choice(dialog_->choice_instant_preview,
_("Off|No math|On").c_str());
}
@ -1677,13 +1692,13 @@ FormPreferences::LnFmisc::feedback(FL_OBJECT const * const ob) const
return LyXRC::getDescription(LyXRC::RC_CURSOR_FOLLOWS_SCROLLBAR);
if (ob == dialog_->check_dialogs_iconify_with_main)
return LyXRC::getDescription(LyXRC::RC_DIALOGS_ICONIFY_WITH_MAIN);
if (ob == dialog_->check_preview_latex)
if (ob == dialog_->choice_instant_preview)
return LyXRC::getDescription(LyXRC::RC_PREVIEW);
if (ob == dialog_->counter_autosave)
return LyXRC::getDescription(LyXRC::RC_AUTOSAVE);
if (ob == dialog_->counter_wm_jump)
return LyXRC::getDescription(LyXRC::RC_WHEEL_JUMP);
if (ob == dialog_->choice_display)
if (ob == dialog_->choice_graphics_display)
return LyXRC::getDescription(LyXRC::RC_DISPLAY_GRAPHICS);
return string();
}
@ -1697,26 +1712,37 @@ void FormPreferences::LnFmisc::update(LyXRC const & rc)
rc.cursor_follows_scrollbar);
fl_set_button(dialog_->check_dialogs_iconify_with_main,
rc.dialogs_iconify_with_main);
fl_set_button(dialog_->check_preview_latex,
rc.preview);
switch (rc.preview) {
case LyXRC::PREVIEW_OFF:
fl_set_choice(dialog_->choice_instant_preview, 1);
break;
case LyXRC::PREVIEW_NO_MATH:
fl_set_choice(dialog_->choice_instant_preview, 2);
break;
case LyXRC::PREVIEW_ON:
fl_set_choice(dialog_->choice_instant_preview, 3);
break;
}
fl_set_counter_value(dialog_->counter_autosave, rc.autosave);
fl_set_counter_value(dialog_->counter_wm_jump, rc.wheel_jump);
switch (rc.display_graphics) {
case lyx::graphics::NoDisplay:
fl_set_choice(dialog_->choice_display, 4);
fl_set_choice(dialog_->choice_graphics_display, 4);
break;
case lyx::graphics::ColorDisplay:
fl_set_choice(dialog_->choice_display, 3);
fl_set_choice(dialog_->choice_graphics_display, 3);
break;
case lyx::graphics::GrayscaleDisplay:
fl_set_choice(dialog_->choice_display, 2);
fl_set_choice(dialog_->choice_graphics_display, 2);
break;
case lyx::graphics::MonochromeDisplay:
fl_set_choice(dialog_->choice_display, 1);
fl_set_choice(dialog_->choice_graphics_display, 1);
break;
default:
fl_set_choice(dialog_->choice_display, 3);
fl_set_choice(dialog_->choice_graphics_display, 3);
break;
}
}

View File

@ -883,10 +883,10 @@ argument:
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 15 25 30 30
box: 300 20 30 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
@ -902,10 +902,10 @@ argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 15 75 30 30
box: 300 60 30 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
@ -921,10 +921,10 @@ argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 15 130 30 30
box: 300 100 30 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
@ -940,7 +940,7 @@ argument: 0
--------------------
class: FL_COUNTER
type: NORMAL_COUNTER
box: 310 190 115 30
box: 300 260 115 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_BLUE
alignment: FL_ALIGN_TOP
@ -962,7 +962,7 @@ argument: 0
--------------------
class: FL_COUNTER
type: NORMAL_COUNTER
box: 310 115 115 30
box: 80 260 115 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_BLUE
alignment: FL_ALIGN_TOP
@ -981,40 +981,39 @@ argument: 0
value: 300
sstep: 1
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 15 185 30 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Instant Preview|#P
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: check_preview_latex
callback: C_FormDialogView_InputCB
argument: 0
value: 1
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 305 40 130 30
box: 300 150 130 30
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_TOP
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Graphics display:|#G
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_NoGravity FL_NoGravity
name: choice_display
name: choice_graphics_display
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 300 200 130 30
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Instant Preview:|#p
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_NoGravity FL_NoGravity
name: choice_instant_preview
callback: C_FormDialogView_InputCB
argument: 0

View File

@ -24,7 +24,7 @@
namespace lyx {
namespace graphics {
bool Previews::activated()
LyXRC_PreviewStatus Previews::status()
{
return lyxrc.preview;
}

View File

@ -19,6 +19,7 @@
#include <boost/scoped_ptr.hpp>
class Buffer;
class LyXRC_PreviewStatus;
namespace lyx {
namespace graphics {
@ -28,7 +29,7 @@ class PreviewLoader;
class Previews : boost::noncopyable {
public:
/// a wrapper for lyxrc.preview
static bool activated();
static LyXRC_PreviewStatus status();
/// This is a singleton class. Get the instance.
static Previews & get();

View File

@ -1,3 +1,9 @@
2004-04-19 Angus Leeming <leeming@lyx.org>
* insetexternal.C:
* insetinclude.C:
* render_preview.[Ch]: changes due to changes to LyXRC::preview.
2004-04-19 Angus Leeming <leeming@lyx.org>
* insetexternal.C (priv_dispatch): remove unnecessary invocation of

View File

@ -503,7 +503,7 @@ RenderType getRenderType(InsetExternalParams const & p)
return RENDERBUTTON;
if (p.display == external::PreviewDisplay) {
if (RenderPreview::activated())
if (RenderPreview::status() != LyXRC::PREVIEW_OFF)
return RENDERPREVIEW;
return RENDERBUTTON;
}
@ -779,7 +779,7 @@ void add_preview_and_start_loading(RenderMonitoredPreview & renderer,
{
InsetExternalParams const & params = inset.params();
if (RenderPreview::activated() &&
if (RenderPreview::status() != LyXRC::PREVIEW_OFF &&
preview_wanted(params)) {
renderer.setAbsFile(params.filename.absFilename());
string const snippet = latex_string(inset, buffer);

View File

@ -24,6 +24,7 @@
#include "gettext.h"
#include "LaTeXFeatures.h"
#include "lyx_main.h"
#include "lyxrc.h"
#include "lyxlex.h"
#include "metricsinfo.h"
#include "outputparams.h"
@ -572,7 +573,7 @@ void InsetInclude::metrics(MetricsInfo & mi, Dimension & dim) const
BOOST_ASSERT(mi.base.bv && mi.base.bv->buffer());
bool use_preview = false;
if (RenderPreview::activated()) {
if (RenderPreview::status() != LyXRC::PREVIEW_OFF) {
lyx::graphics::PreviewImage const * pimage =
preview_->getPreviewImage(*mi.base.bv->buffer());
use_preview = pimage && pimage->image();
@ -605,7 +606,7 @@ void InsetInclude::draw(PainterInfo & pi, int x, int y) const
BOOST_ASSERT(pi.base.bv && pi.base.bv->buffer());
bool use_preview = false;
if (RenderPreview::activated()) {
if (RenderPreview::status() == LyXRC::PREVIEW_OFF) {
lyx::graphics::PreviewImage const * pimage =
preview_->getPreviewImage(*pi.base.bv->buffer());
use_preview = pimage && pimage->image();
@ -661,7 +662,8 @@ void add_preview(RenderMonitoredPreview & renderer, InsetInclude const & inset,
Buffer const & buffer)
{
InsetCommandParams const & params = inset.params();
if (RenderPreview::activated() && preview_wanted(params, buffer)) {
if (RenderPreview::status() == LyXRC::PREVIEW_OFF &&
preview_wanted(params, buffer)) {
renderer.setAbsFile(includedFilename(buffer, params));
string const snippet = latex_string(inset, buffer);
renderer.addPreview(snippet, buffer);

View File

@ -19,6 +19,7 @@
#include "gettext.h"
#include "LColor.h"
#include "lyx_main.h"
#include "lyxrc.h"
#include "metricsinfo.h"
#include "frontends/font_metrics.h"
@ -39,9 +40,9 @@ namespace graphics = lyx::graphics;
namespace support = lyx::support;
bool RenderPreview::activated()
LyXRC_PreviewStatus RenderPreview::status()
{
return graphics::Previews::activated();
return graphics::Previews::status();
}
@ -162,7 +163,7 @@ void RenderPreview::draw(PainterInfo & pi, int x, int y) const
void RenderPreview::startLoading(Buffer const & buffer) const
{
if (!activated() && !snippet_.empty())
if (status() == LyXRC::PREVIEW_OFF || snippet_.empty())
return;
graphics::Previews & previews = graphics::Previews::get();
@ -175,7 +176,7 @@ void RenderPreview::startLoading(Buffer const & buffer) const
void RenderPreview::addPreview(string const & latex_snippet,
Buffer const & buffer)
{
if (!activated())
if (status() == LyXRC::PREVIEW_OFF)
return;
graphics::Previews & previews = graphics::Previews::get();
@ -187,7 +188,7 @@ void RenderPreview::addPreview(string const & latex_snippet,
void RenderPreview::addPreview(string const & latex_snippet,
graphics::PreviewLoader & ploader)
{
if (!activated())
if (status() == LyXRC::PREVIEW_OFF)
return;
snippet_ = support::trim(latex_snippet);

View File

@ -26,6 +26,7 @@
class Buffer;
class BufferView;
class LyXRC_PreviewStatus;
class MetricsInfo;
class PainterInfo;
@ -41,8 +42,8 @@ class PreviewLoader;
class RenderPreview : public RenderBase, public boost::signals::trackable {
public:
/// a wrapper for Previews::activated()
static bool activated();
/// a wrapper for Previews::status()
static LyXRC_PreviewStatus status();
RenderPreview(InsetBase const *);
RenderPreview(RenderPreview const &, InsetBase const *);

View File

@ -265,7 +265,7 @@ void LyXRC::setDefaults() {
cursor_follows_scrollbar = false;
dialogs_iconify_with_main = false;
label_init_length = 3;
preview = false;
preview = PREVIEW_OFF;
preview_hashed_labels = false;
preview_scale_factor = 0.9;
@ -1064,7 +1064,18 @@ int LyXRC::read(LyXLex & lexrc)
case RC_PREVIEW:
if (lexrc.next()) {
preview = lexrc.getBool();
string const tmp = lexrc.getString();
if (tmp == "true" || tmp == "on")
preview = PREVIEW_ON;
else if (tmp == "no_math")
preview = PREVIEW_NO_MATH;
else {
preview = PREVIEW_OFF;
if (tmp != "false" && tmp != "off")
lyxerr << "Unrecognized "
"preview status \""
<< tmp << '\n' << endl;
}
}
break;
@ -1286,7 +1297,19 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc) const
case RC_PREVIEW:
if (ignore_system_lyxrc ||
preview != system_lyxrc.preview) {
os << "\\preview " << tostr(preview) << '\n';
string status;
switch (preview) {
case PREVIEW_ON:
status = "on";
break;
case PREVIEW_NO_MATH:
status = "no_math";
break;
case PREVIEW_OFF:
status = "off";
break;
}
os << "\\preview " << status << '\n';
}
case RC_PREVIEW_HASHED_LABELS:

View File

@ -355,7 +355,13 @@ public:
///
bool show_banner;
///
bool preview;
enum PreviewStatus {
PREVIEW_OFF,
PREVIEW_NO_MATH,
PREVIEW_ON
};
///
PreviewStatus preview;
///
bool preview_hashed_labels;
///
@ -366,6 +372,19 @@ public:
std::string user_email;
};
/** \c LyXRC_PreviewStatus is a wrapper for LyXRC::PreviewStatus.
* It can be forward-declared and passed as a function argument without
* having to expose lyxrc.h.
*/
class LyXRC_PreviewStatus {
LyXRC::PreviewStatus val_;
public:
LyXRC_PreviewStatus(LyXRC::PreviewStatus val) : val_(val) {}
operator LyXRC::PreviewStatus() const{ return val_; }
};
///
extern LyXRC lyxrc;
///

View File

@ -1,3 +1,7 @@
2004-04-19 Angus Leeming <leeming@lyx.org>
* math_hullinset.C: changes due to changes to LyXRC::preview.
2004-04-19 Angus Leeming <leeming@lyx.org>
* math_hullinset.C (metrics, draw): changes due to the changed

View File

@ -232,7 +232,8 @@ void MathHullInset::metrics(MetricsInfo & mi, Dimension & dim) const
BOOST_ASSERT(mi.base.bv && mi.base.bv->buffer());
bool use_preview = false;
if (!editing(mi.base.bv) && RenderPreview::activated()) {
if (!editing(mi.base.bv) &&
RenderPreview::status() == LyXRC::PREVIEW_ON) {
lyx::graphics::PreviewImage const * pimage =
preview_->getPreviewImage(*mi.base.bv->buffer());
use_preview = pimage && pimage->image();
@ -285,7 +286,8 @@ void MathHullInset::draw(PainterInfo & pi, int x, int y) const
BOOST_ASSERT(pi.base.bv && pi.base.bv->buffer());
bool use_preview = false;
if (!editing(pi.base.bv) && RenderPreview::activated()) {
if (!editing(pi.base.bv) &&
RenderPreview::status() == LyXRC::PREVIEW_ON) {
lyx::graphics::PreviewImage const * pimage =
preview_->getPreviewImage(*pi.base.bv->buffer());
use_preview = pimage && pimage->image();
@ -364,7 +366,7 @@ void MathHullInset::addPreview(lyx::graphics::PreviewLoader & ploader) const
void MathHullInset::notifyCursorLeaves(LCursor & cur)
{
if (!RenderPreview::activated())
if (RenderPreview::status() != LyXRC::PREVIEW_ON)
return;
Buffer const & buffer = cur.buffer();