]> git.lyx.org Git - lyx.git/blob - src/insets/RenderBase.h
34b84f92e3f3eb6dc487a1f134574c5cd474ce3a
[lyx.git] / src / insets / RenderBase.h
1 // -*- C++ -*-
2 /**
3  * \file RenderBase.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef RENDERBASE_H
13 #define RENDERBASE_H
14
15 #include "Dimension.h"
16
17 #include <memory>
18
19
20 namespace lyx {
21
22 class Inset;
23 class MetricsInfo;
24 class PainterInfo;
25
26 class RenderButton;
27 class RenderGraphic;
28 class RenderPreview;
29 class RenderMonitoredPreview;
30
31 class RenderBase {
32 public:
33         virtual ~RenderBase() {}
34
35         virtual RenderBase * clone(Inset const *) const = 0;
36
37         /// compute the size of the object returned in dim.
38         /// \retval true if the metrics has changed.
39         virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
40         /// draw inset and update (xo, yo)-cache
41         virtual void draw(PainterInfo & pi, int x, int y) const = 0;
42         ///
43         Dimension const & dimension() const { return dim_; };
44
45         /// render state, exact meaning of state is render-specific
46         void setRenderState(int state) { state_ = state; }
47         /// get render state
48         int renderState() const { return state_; }
49
50         /// equivalent to dynamic_cast
51         virtual RenderButton * asButton() { return 0; }
52         virtual RenderGraphic * asGraphic() { return 0; }
53         virtual RenderPreview * asPreview() { return 0; }
54         virtual RenderMonitoredPreview * asMonitoredPreview() { return 0; }
55
56 protected:
57         RenderBase() {}
58         RenderBase(RenderBase const &) {}
59         RenderBase & operator=(RenderBase const &) { return *this; }
60
61         /// render state. currently, render_button uses this to store mouse_hover_
62         int state_;
63         /// Cached
64         mutable Dimension dim_;
65 };
66
67
68 } // namespace lyx
69
70 #endif // NOT RENDERBASE_H