]> git.lyx.org Git - lyx.git/blob - src/insets/RenderBase.h
Fix trailing whitespace in cpp files.
[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
18 namespace lyx {
19
20 class Inset;
21 class MetricsInfo;
22 class PainterInfo;
23
24 class RenderButton;
25 class RenderGraphic;
26 class RenderPreview;
27 class RenderMonitoredPreview;
28
29 class RenderBase {
30 public:
31         virtual ~RenderBase() {}
32
33         virtual RenderBase * clone(Inset const *) const = 0;
34
35         /// compute the size of the object returned in dim.
36         /// \retval true if the metrics has changed.
37         virtual void metrics(MetricsInfo & mi, Dimension & dim) const = 0;
38         /// draw inset and update (xo, yo)-cache
39         virtual void draw(PainterInfo & pi, int x, int y) const = 0;
40         ///
41         Dimension const & dimension() const { return dim_; }
42
43         /// render state, exact meaning of state is render-specific
44         void setRenderState(bool state) { state_ = state; }
45         /// get render state
46         bool renderState() const { return state_; }
47
48         /// equivalent to dynamic_cast
49         virtual RenderButton * asButton() { return 0; }
50         virtual RenderGraphic * asGraphic() { return 0; }
51         virtual RenderPreview * asPreview() { return 0; }
52         virtual RenderMonitoredPreview * asMonitoredPreview() { return 0; }
53
54 protected:
55         RenderBase() : state_(false) {}
56         RenderBase(RenderBase const & x) : state_(x.state_) {}
57         RenderBase & operator=(RenderBase const &) { return *this; }
58
59         /// render state. currently, render_button uses this to store mouse_hover_
60         bool state_;
61         /// Cached
62         mutable Dimension dim_;
63 };
64
65
66 } // namespace lyx
67
68 #endif // NOT RENDERBASE_H