]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathDiagram.cpp
Simplify Changers interface
[lyx.git] / src / mathed / InsetMathDiagram.cpp
1 /**
2  * \file InsetMathDiagram.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author André Pönitz
7  * \author Ronen Abravanel
8 *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "InsetMathDiagram.h"
15
16 #include "MathStream.h"
17
18 #include "LaTeXFeatures.h"
19 #include "MetricsInfo.h"
20
21 #include <ostream>
22
23 namespace lyx {
24
25
26 InsetMathDiagram::InsetMathDiagram(Buffer * buf) : InsetMathGrid(buf, 1, 1)
27 {
28 }
29
30
31 Inset * InsetMathDiagram::clone() const
32 {
33         return new InsetMathDiagram(*this);
34 }
35
36
37 int InsetMathDiagram::colsep() const
38 {
39         return 10;
40 }
41
42
43 int InsetMathDiagram::rowsep() const
44 {
45         return 10;
46 }
47
48
49 void InsetMathDiagram::metrics(MetricsInfo & mi, Dimension & dim) const
50 {
51         FontInfo & f = mi.base.font;
52         Changer dummy = (f.style() == LM_ST_DISPLAY) ? f.changeStyle(LM_ST_TEXT)
53                 : Changer();
54         InsetMathGrid::metrics(mi, dim);
55 }
56
57
58 void InsetMathDiagram::draw(PainterInfo & pi, int x, int y) const
59 {
60         setPosCache(pi, x, y);
61         FontInfo & f = pi.base.font;
62         Changer dummy = (f.style() == LM_ST_DISPLAY) ? f.changeStyle(LM_ST_TEXT)
63                 : Changer();
64         InsetMathGrid::draw(pi, x, y);
65 }
66
67
68 void InsetMathDiagram::write(WriteStream & os) const
69 {
70         MathEnsurer ensurer(os);
71         os << "\\Diagram";
72         bool open = os.startOuterRow();
73         os << '{';
74         InsetMathGrid::write(os);
75         os << "}\n";
76         if (open)
77                 os.startOuterRow();
78 }
79
80
81 void InsetMathDiagram::infoize(odocstream & os) const
82 {
83         os << "Diagram ";
84         InsetMathGrid::infoize(os);
85 }
86
87
88 void InsetMathDiagram::normalize(NormalStream & os) const
89 {
90         os << "[Diagram ";
91         InsetMathGrid::normalize(os);
92         os << ']';
93 }
94
95
96 void InsetMathDiagram::maple(MapleStream & os) const
97 {
98         os << "Diagram(";
99         InsetMathGrid::maple(os);
100         os << ')';
101 }
102
103
104 void InsetMathDiagram::validate(LaTeXFeatures & features) const
105 {
106         features.require("feyn");
107         InsetMathGrid::validate(features);
108 }
109
110
111 } // namespace lyx