Remove lyxerr statement; cosmetics.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8680 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2004-04-20 08:42:10 +00:00
parent 47c864967f
commit 66cd8361ff
2 changed files with 48 additions and 38 deletions

View File

@ -1,3 +1,9 @@
2004-04-20 Angus Leeming <leeming@lyx.org>
* render_preview.C (startLoading): remove lyxerr statement.
(draw): cosmetics.
(getPreviewLoader): new helper function.
2004-04-19 Angus Leeming <leeming@lyx.org> 2004-04-19 Angus Leeming <leeming@lyx.org>
* insetexternal.C: * insetexternal.C:
@ -41,7 +47,7 @@
* insetgraphics.C: * insetgraphics.C:
* insetinclude.C: ensuing simplification of the client code. * insetinclude.C: ensuing simplification of the client code.
(statusChanged): now superfluous. Removed. (statusChanged): now superfluous. Removed.
2004-04-12 Georg Baum <Georg.Baum@post.rwth-aachen.de> 2004-04-12 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* ExternalTemplate.[Ch]: remove editCommand * ExternalTemplate.[Ch]: remove editCommand
@ -57,7 +63,7 @@
2004-04-07 Angus Leeming <leeming@lyx.org> 2004-04-07 Angus Leeming <leeming@lyx.org>
* insetexternal.C (priv_dispatch): * insetexternal.C (priv_dispatch):
* insetinclude.C (priv_dispatch): prevent crash by invoking * insetinclude.C (priv_dispatch): prevent crash by invoking
InsetOld::priv_dispatch at the end of the switch, rather than InsetOld::priv_dispatch at the end of the switch, rather than
InsetOld::dispatch... InsetOld::dispatch...
@ -78,7 +84,7 @@
filename where appropriate filename where appropriate
2004-04-05 André Pönitz <poenitz@gmx.net> 2004-04-05 André Pönitz <poenitz@gmx.net>
* insetbase.h: use LCursor & in notifyCursorLeave * insetbase.h: use LCursor & in notifyCursorLeave
2004-04-05 Angus Leeming <leeming@lyx.org> 2004-04-05 Angus Leeming <leeming@lyx.org>
@ -107,7 +113,7 @@
2004-04-01 Jürgen Spitzmüller <j.spitzmueller@gmx.de> 2004-04-01 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* insetfloat.C (read): fix reading of float params * insetfloat.C (read): fix reading of float params
(recognize "type") (recognize "type")
2004-03-31 Alfredo Braunstein <abraunst@lyx.org> 2004-03-31 Alfredo Braunstein <abraunst@lyx.org>
@ -148,7 +154,7 @@
2004-03-29 Jürgen Spitzmüller <j.spitzmueller@gmx.de> 2004-03-29 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* insetbibtex.[Ch]: bibtopic support. * insetbibtex.[Ch]: bibtopic support.
* insetfloat.[Ch]: add param \sideways {true|false} * insetfloat.[Ch]: add param \sideways {true|false}
(support for sideways floats from rotating.sty). (support for sideways floats from rotating.sty).
@ -228,7 +234,7 @@
2004-03-09 Alfredo Braunstein <abraunst@lyx.org> 2004-03-09 Alfredo Braunstein <abraunst@lyx.org>
* insetcollapsable.[Ch] (metrics, draw): implemented an inlined-Open * insetcollapsable.[Ch] (metrics, draw): implemented an inlined-Open
submode. submode.
2004-03-07 Jürgen Spitzmüller <j.spitzmueller@gmx.de> 2004-03-07 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
@ -238,7 +244,7 @@
2004-03-05 Jürgen Spitzmüller <j.spitzmueller@gmx.de> 2004-03-05 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* insetcite.C: Support second \cite option. * insetcite.C: Support second \cite option.
* insetcommand.[Ch]: * insetcommand.[Ch]:
* insetcommandparams.[Ch]: add second optional argument. * insetcommandparams.[Ch]: add second optional argument.
@ -274,7 +280,7 @@
* insetbase.C: * insetbase.C:
* insetbase.[Ch]: remove explicit 'DispatchResult' return type and * insetbase.[Ch]: remove explicit 'DispatchResult' return type and
implicitly assume 'DispatchResult(true, true) with exception of implicitly assume 'DispatchResult(true, true) with exception of
InsetBase::priv_dispatch which does the equivalent of InsetBase::priv_dispatch which does the equivalent of
'retrun DispatchResult(false)' 'retrun DispatchResult(false)'
* inset*.[Ch] (priv_dispatch): adjust * inset*.[Ch] (priv_dispatch): adjust
@ -296,7 +302,7 @@
2004-02-04 Alfredo Braunstein <abraunst@lyx.org> 2004-02-04 Alfredo Braunstein <abraunst@lyx.org>
* insettext.C (edit): * insettext.C (edit):
(updateLocal): use the cur argument instead of the global cursor (updateLocal): use the cur argument instead of the global cursor
* insetcollapsable.C (edit): dont call inset.edit(x,y) when opening * insetcollapsable.C (edit): dont call inset.edit(x,y) when opening

View File

@ -14,7 +14,6 @@
#include "insets/inset.h" #include "insets/inset.h"
#include "BufferView.h" #include "BufferView.h"
#include "debug.h"
#include "dimension.h" #include "dimension.h"
#include "gettext.h" #include "gettext.h"
#include "LColor.h" #include "LColor.h"
@ -68,13 +67,19 @@ auto_ptr<RenderBase> RenderPreview::clone(InsetBase const * inset) const
namespace { namespace {
graphics::PreviewLoader & getPreviewLoader(Buffer const & buffer)
{
graphics::Previews const & previews = graphics::Previews::get();
return previews.loader(buffer);
}
string const statusMessage(BufferView const * bv, string const & snippet) string const statusMessage(BufferView const * bv, string const & snippet)
{ {
BOOST_ASSERT(bv && bv->buffer()); BOOST_ASSERT(bv && bv->buffer());
Buffer const & buffer = *bv->buffer(); Buffer const & buffer = *bv->buffer();
graphics::Previews const & previews = graphics::Previews::get(); graphics::PreviewLoader const & loader = getPreviewLoader(buffer);
graphics::PreviewLoader const & loader = previews.loader(buffer);
graphics::PreviewLoader::Status const status = loader.status(snippet); graphics::PreviewLoader::Status const status = loader.status(snippet);
string message; string message;
@ -100,11 +105,10 @@ string const statusMessage(BufferView const * bv, string const & snippet)
graphics::PreviewImage const * graphics::PreviewImage const *
RenderPreview::getPreviewImage(Buffer const & buffer) const RenderPreview::getPreviewImage(Buffer const & buffer) const
{ {
graphics::Previews & previews = graphics::Previews::get(); graphics::PreviewLoader const & loader = getPreviewLoader(buffer);
graphics::PreviewLoader & loader = previews.loader(buffer);
return loader.preview(snippet_); return loader.preview(snippet_);
} }
void RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const void RenderPreview::metrics(MetricsInfo & mi, Dimension & dim) const
{ {
@ -139,25 +143,29 @@ void RenderPreview::draw(PainterInfo & pi, int x, int y) const
graphics::PreviewImage const * const pimage = graphics::PreviewImage const * const pimage =
getPreviewImage(*pi.base.bv->buffer()); getPreviewImage(*pi.base.bv->buffer());
graphics::Image const * const image = pimage ? pimage->image() : 0;
if (pimage && pimage->image()) { if (image) {
pi.pain.image(x, y - dim_.asc, dim_.wid, dim_.height(), pi.pain.image(x, y - dim_.asc, dim_.wid, dim_.height(),
*(pimage->image())); *image);
return;
} else {
int const offset = InsetOld::TEXT_TO_INSET_OFFSET;
pi.pain.rectangle(x + offset,
y - dim_.asc,
dim_.wid - 2 * offset,
dim_.asc + dim_.des,
LColor::foreground);
LyXFont font(pi.base.font);
font.setFamily(LyXFont::SANS_FAMILY);
font.setSize(LyXFont::SIZE_FOOTNOTE);
pi.pain.text(x + offset + 6,
y - font_metrics::maxAscent(font) - 4,
statusMessage(pi.base.bv, snippet_), font);
} }
pi.pain.rectangle(x + InsetOld::TEXT_TO_INSET_OFFSET,
y - dim_.asc,
dim_.wid - 2 * InsetOld::TEXT_TO_INSET_OFFSET,
dim_.asc + dim_.des,
LColor::foreground);
LyXFont font(pi.base.font);
font.setFamily(LyXFont::SANS_FAMILY);
font.setSize(LyXFont::SIZE_FOOTNOTE);
pi.pain.text(x + InsetOld::TEXT_TO_INSET_OFFSET + 6,
y - font_metrics::maxAscent(font) - 4,
statusMessage(pi.base.bv, snippet_), font);
} }
@ -166,10 +174,8 @@ void RenderPreview::startLoading(Buffer const & buffer) const
if (status() == LyXRC::PREVIEW_OFF || snippet_.empty()) if (status() == LyXRC::PREVIEW_OFF || snippet_.empty())
return; return;
graphics::Previews & previews = graphics::Previews::get(); graphics::PreviewLoader const & loader = getPreviewLoader(buffer);
graphics::PreviewLoader & loader = previews.loader(buffer);
loader.startLoading(); loader.startLoading();
lyxerr << "RenderPreview::startLoading: " << snippet_ << std::endl;
} }
@ -179,8 +185,7 @@ void RenderPreview::addPreview(string const & latex_snippet,
if (status() == LyXRC::PREVIEW_OFF) if (status() == LyXRC::PREVIEW_OFF)
return; return;
graphics::Previews & previews = graphics::Previews::get(); graphics::PreviewLoader & loader = getPreviewLoader(buffer);
graphics::PreviewLoader & loader = previews.loader(buffer);
addPreview(latex_snippet, loader); addPreview(latex_snippet, loader);
} }
@ -215,8 +220,7 @@ void RenderPreview::removePreview(Buffer const & buffer)
if (snippet_.empty()) if (snippet_.empty())
return; return;
graphics::Previews & previews = graphics::Previews::get(); graphics::PreviewLoader & loader = getPreviewLoader(buffer);
graphics::PreviewLoader & loader = previews.loader(buffer);
loader.remove(snippet_); loader.remove(snippet_);
snippet_.erase(); snippet_.erase();
} }