lyx_mirror/src/insets/renderers.h
Angus Leeming 0be0fcfd59 If I ever see another licence blurb again, it'll be too soon...
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7598 a592a061-630c-0410-9148-cb99ea01b6c8
2003-08-23 00:17:00 +00:00

123 lines
2.9 KiB
C++

// -*- 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;
class RenderInset
{
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);
/// 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.
void update(lyx::graphics::Params const & params);
/// 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;
/// The stored data.
lyx::graphics::Loader loader_;
lyx::graphics::Params params_;
/// Cached variable (not copied).
mutable unsigned long checksum_;
};
#endif // NOT RENDERERS_H