]> git.lyx.org Git - lyx.git/blob - src/insets/render_base.h
Get rid of hte dynamic_casts in InsetExternal.
[lyx.git] / src / insets / render_base.h
1 // -*- C++ -*-
2 /**
3  * \file render_base.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 RENDER_BASE_H
13 #define RENDER_BASE_H
14
15 #include "dimension.h"
16
17 class MetricsInfo;
18 class PainterInfo;
19
20 class RenderButton;
21 class RenderGraphic;
22 class RenderPreview;
23 class RenderMonitoredPreview;
24
25 class RenderBase {
26 public:
27         virtual ~RenderBase() {}
28
29         virtual RenderBase * clone() const = 0;
30
31         /// compute the size of the object returned in dim
32         virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
33         /// draw inset and update (xo, yo)-cache
34         virtual void draw(PainterInfo & pi, int x, int y) const = 0;
35
36         /// equivalent to dynamic_cast
37         virtual RenderButton * asButton() { return 0; }
38         virtual RenderGraphic * asGraphic() { return 0; }
39         virtual RenderPreview * asPreview() { return 0; }
40         virtual RenderMonitoredPreview * asMonitoredPreview() { return 0; }
41
42 protected:
43         RenderBase() {}
44         RenderBase(RenderBase const &) {}
45         void operator=(RenderBase const &) {}
46
47         /// Cached
48         mutable Dimension dim_;
49 };
50
51 #endif // NOT RENDER_BASE_H