2003-06-12 08:52:36 +00:00
|
|
|
// -*- C++ -*-
|
|
|
|
/**
|
|
|
|
* \file renderers.h
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author Angus Leeming
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RENDERERS_H
|
|
|
|
#define RENDERERS_H
|
|
|
|
|
|
|
|
#include "dimension.h"
|
|
|
|
|
|
|
|
#include "graphics/GraphicsLoader.h"
|
|
|
|
#include "graphics/GraphicsParams.h"
|
|
|
|
#include "graphics/GraphicsTypes.h"
|
|
|
|
|
|
|
|
#include <boost/weak_ptr.hpp>
|
|
|
|
#include <boost/signals/signal0.hpp>
|
|
|
|
|
|
|
|
|
|
|
|
class BufferView;
|
|
|
|
class MetricsInfo;
|
|
|
|
class PainterInfo;
|
|
|
|
|
|
|
|
|
2003-07-04 08:23:23 +00:00
|
|
|
class RenderInset
|
2003-06-12 08:52:36 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~RenderInset();
|
|
|
|
|
|
|
|
virtual RenderInset * clone() const = 0;
|
|
|
|
|
|
|
|
/// compute the size of the object returned in dim
|
|
|
|
virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
|
|
|
|
/// draw inset and update (xo, yo)-cache
|
|
|
|
virtual void draw(PainterInfo & pi, int x, int y) const = 0;
|
|
|
|
|
|
|
|
/// An accessor function to the cached store.
|
|
|
|
BufferView * view() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
RenderInset();
|
|
|
|
RenderInset(RenderInset const &);
|
|
|
|
RenderInset & operator=(RenderInset const &);
|
|
|
|
|
|
|
|
/// These are cached variables (are not copied).
|
|
|
|
mutable boost::weak_ptr<BufferView> view_;
|
|
|
|
mutable Dimension dim_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class ButtonRenderer : public RenderInset
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ButtonRenderer();
|
|
|
|
|
|
|
|
virtual RenderInset * clone() const;
|
|
|
|
|
|
|
|
/// This should provide the text for the button
|
|
|
|
void update(string const &, bool editable);
|
2003-07-04 08:23:23 +00:00
|
|
|
|
2003-06-12 08:52:36 +00:00
|
|
|
/// compute the size of the object returned in dim
|
|
|
|
virtual void metrics(MetricsInfo & mi, Dimension & dim) const;
|
|
|
|
/// draw inset and update (xo, yo)-cache
|
|
|
|
virtual void draw(PainterInfo & pi, int x, int y) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// The stored data.
|
|
|
|
string text_;
|
|
|
|
bool editable_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class GraphicRenderer : public RenderInset
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
GraphicRenderer();
|
|
|
|
GraphicRenderer(GraphicRenderer const &);
|
|
|
|
|
|
|
|
virtual RenderInset * clone() const;
|
|
|
|
|
|
|
|
/// Refresh the info about which file to display and how to display it.
|
2003-07-04 08:23:23 +00:00
|
|
|
void update(lyx::graphics::Params const & params);
|
2003-06-12 08:52:36 +00:00
|
|
|
|
|
|
|
/// compute the size of the object returned in dim
|
|
|
|
virtual void metrics(MetricsInfo & mi, Dimension & dim) const;
|
|
|
|
/// draw inset and update (xo, yo)-cache
|
|
|
|
virtual void draw(PainterInfo & pi, int x, int y) const;
|
|
|
|
|
|
|
|
/// Is the stored checksum different to that of the graphics loader?
|
|
|
|
bool hasFileChanged() const;
|
|
|
|
|
|
|
|
/** Connect and you'll be informed when the loading status of the image
|
|
|
|
* changes.
|
|
|
|
*/
|
|
|
|
typedef boost::signal0<void>::slot_type slot_type;
|
|
|
|
virtual boost::signals::connection connect(slot_type const &) const;
|
|
|
|
|
|
|
|
private:
|
|
|
|
/// Not implemented.
|
|
|
|
GraphicRenderer & operator=(GraphicRenderer const &);
|
|
|
|
|
|
|
|
/// The message to display instead of the graphic itself.
|
|
|
|
string const statusMessage() const;
|
|
|
|
|
|
|
|
/// Is the image ready to draw, or should we display a message instead?
|
|
|
|
bool readyToDisplay() const;
|
2003-07-04 08:23:23 +00:00
|
|
|
|
2003-06-12 08:52:36 +00:00
|
|
|
/// The stored data.
|
2003-07-04 08:23:23 +00:00
|
|
|
lyx::graphics::Loader loader_;
|
|
|
|
lyx::graphics::Params params_;
|
2003-06-12 08:52:36 +00:00
|
|
|
|
|
|
|
/// Cached variable (not copied).
|
|
|
|
mutable unsigned long checksum_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // NOT RENDERERS_H
|