#include "graphics/GraphicsImage.h"
#include "support/filetools.h"
+#include "support/LAssert.h"
+
+using namespace lyx::support;
RenderInset::RenderInset()
void ButtonRenderer::metrics(MetricsInfo & mi, Dimension & dim) const
{
- lyx::Assert(mi.base.bv);
+ Assert(mi.base.bv);
LyXFont font(LyXFont::ALL_SANE);
font.decSize();
void ButtonRenderer::draw(PainterInfo & pi, int x, int y) const
{
- lyx::Assert(pi.base.bv);
+ Assert(pi.base.bv);
view_ = pi.base.bv->owner()->view();
// Draw it as a box with the LaTeX text
}
-void GraphicRenderer::update(grfx::Params const & params)
+void GraphicRenderer::update(lyx::graphics::Params const & params)
{
params_ = params;
if (!params_.filename.empty()) {
- lyx::Assert(AbsolutePath(params_.filename));
+ Assert(AbsolutePath(params_.filename));
loader_.reset(params_.filename, params_);
}
}
string const GraphicRenderer::statusMessage() const
{
switch (loader_.status()) {
- case grfx::WaitingToLoad:
+ case lyx::graphics::WaitingToLoad:
return _("Not shown.");
- case grfx::Loading:
+ case lyx::graphics::Loading:
return _("Loading...");
- case grfx::Converting:
+ case lyx::graphics::Converting:
return _("Converting to loadable format...");
- case grfx::Loaded:
+ case lyx::graphics::Loaded:
return _("Loaded into memory. Must now generate pixmap.");
- case grfx::ScalingEtc:
+ case lyx::graphics::ScalingEtc:
return _("Scaling etc...");
- case grfx::Ready:
+ case lyx::graphics::Ready:
return _("Ready to display");
- case grfx::ErrorNoFile:
+ case lyx::graphics::ErrorNoFile:
return _("No file found!");
- case grfx::ErrorConverting:
+ case lyx::graphics::ErrorConverting:
return _("Error converting to loadable format");
- case grfx::ErrorLoading:
+ case lyx::graphics::ErrorLoading:
return _("Error loading file into memory");
- case grfx::ErrorGeneratingPixmap:
+ case lyx::graphics::ErrorGeneratingPixmap:
return _("Error generating the pixmap");
- case grfx::ErrorUnknown:
+ case lyx::graphics::ErrorUnknown:
return _("No image");
}
return string();
bool GraphicRenderer::readyToDisplay() const
{
- if (!loader_.image() || loader_.status() != grfx::Ready)
+ if (!loader_.image() || loader_.status() != lyx::graphics::Ready)
return false;
return loader_.image()->isDrawable();
}
if (image_ready) {
dim.wid = loader_.image()->getWidth() +
- 2 * Inset::TEXT_TO_INSET_OFFSET;
+ 2 * InsetOld::TEXT_TO_INSET_OFFSET;
} else {
int font_width = 0;
void GraphicRenderer::draw(PainterInfo & pi, int x, int y) const
{
- lyx::Assert(pi.base.bv);
+ Assert(pi.base.bv);
view_ = pi.base.bv->owner()->view();
#if 0
}
#endif
- if (params_.display != grfx::NoDisplay &&
- loader_.status() == grfx::WaitingToLoad)
+ if (params_.display != lyx::graphics::NoDisplay &&
+ loader_.status() == lyx::graphics::WaitingToLoad)
loader_.startLoading();
- if (params_.display != grfx::NoDisplay && !loader_.monitoring())
+ if (params_.display != lyx::graphics::NoDisplay &&
+ !loader_.monitoring())
loader_.startMonitoring();
// This will draw the graphics. If the graphics has not been loaded yet,
// we draw just a rectangle.
if (readyToDisplay()) {
- pi.pain.image(x + Inset::TEXT_TO_INSET_OFFSET,
+ pi.pain.image(x + InsetOld::TEXT_TO_INSET_OFFSET,
y - dim_.asc,
- dim_.wid - 2 * Inset::TEXT_TO_INSET_OFFSET,
+ dim_.wid - 2 * InsetOld::TEXT_TO_INSET_OFFSET,
dim_.asc + dim_.des,
*loader_.image());
} else {
- pi.pain.rectangle(x + Inset::TEXT_TO_INSET_OFFSET,
+ pi.pain.rectangle(x + InsetOld::TEXT_TO_INSET_OFFSET,
y - dim_.asc,
- dim_.wid - 2 * Inset::TEXT_TO_INSET_OFFSET,
+ dim_.wid - 2 * InsetOld::TEXT_TO_INSET_OFFSET,
dim_.asc + dim_.des);
// Print the file name.
if (!justname.empty()) {
msgFont.setSize(LyXFont::SIZE_FOOTNOTE);
- pi.pain.text(x + Inset::TEXT_TO_INSET_OFFSET + 6,
+ pi.pain.text(x + InsetOld::TEXT_TO_INSET_OFFSET + 6,
y - font_metrics::maxAscent(msgFont) - 4,
justname, msgFont);
}
string const msg = statusMessage();
if (!msg.empty()) {
msgFont.setSize(LyXFont::SIZE_TINY);
- pi.pain.text(x + Inset::TEXT_TO_INSET_OFFSET + 6,
+ pi.pain.text(x + InsetOld::TEXT_TO_INSET_OFFSET + 6,
y - 4, msg, msgFont);
}
}