4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
16 #include "dimension.h"
18 #include "graphics/GraphicsLoader.h"
19 #include "graphics/GraphicsParams.h"
21 #include <boost/weak_ptr.hpp>
22 #include <boost/signals/signal0.hpp>
33 virtual ~RenderInset();
35 virtual RenderInset * clone() const = 0;
37 /// compute the size of the object returned in dim
38 virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
39 /// draw inset and update (xo, yo)-cache
40 virtual void draw(PainterInfo & pi, int x, int y) const = 0;
42 /// An accessor function to the cached store.
43 BufferView * view() const;
47 RenderInset(RenderInset const &);
48 RenderInset & operator=(RenderInset const &);
50 /// These are cached variables (are not copied).
51 mutable boost::weak_ptr<BufferView> view_;
52 mutable Dimension dim_;
56 class ButtonRenderer : public RenderInset
61 virtual RenderInset * clone() const;
63 /// This should provide the text for the button
64 void update(string const &, bool editable);
66 /// compute the size of the object returned in dim
67 virtual void metrics(MetricsInfo & mi, Dimension & dim) const;
68 /// draw inset and update (xo, yo)-cache
69 virtual void draw(PainterInfo & pi, int x, int y) const;
71 /// The "sensitive area" box, i.e., the button area
72 Box box() const { return button_box_; }
74 void setBox(Box b) { button_box_ = b; }
84 class GraphicRenderer : public RenderInset
88 GraphicRenderer(GraphicRenderer const &);
90 virtual RenderInset * clone() const;
92 /// Refresh the info about which file to display and how to display it.
93 void update(lyx::graphics::Params const & params);
95 /// compute the size of the object returned in dim
96 virtual void metrics(MetricsInfo & mi, Dimension & dim) const;
97 /// draw inset and update (xo, yo)-cache
98 virtual void draw(PainterInfo & pi, int x, int y) const;
100 /// Is the stored checksum different to that of the graphics loader?
101 bool hasFileChanged() const;
103 /** Connect and you'll be informed when the loading status of the image
106 typedef boost::signal0<void>::slot_type slot_type;
107 virtual boost::signals::connection connect(slot_type const &) const;
111 GraphicRenderer & operator=(GraphicRenderer const &);
113 /// The message to display instead of the graphic itself.
114 string const statusMessage() const;
116 /// Is the image ready to draw, or should we display a message instead?
117 bool readyToDisplay() const;
120 lyx::graphics::Loader loader_;
121 lyx::graphics::Params params_;
123 /// Cached variable (not copied).
124 mutable unsigned long checksum_;
128 #endif // NOT RENDERERS_H