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 
InsetMathDiagram(Buffer * buf)26 InsetMathDiagram::InsetMathDiagram(Buffer * buf) : InsetMathGrid(buf, 1, 1)
27 {
28 }
29 
30 
clone() const31 Inset * InsetMathDiagram::clone() const
32 {
33 	return new InsetMathDiagram(*this);
34 }
35 
36 
colsep() const37 int InsetMathDiagram::colsep() const
38 {
39 	return 10;
40 }
41 
42 
rowsep() const43 int InsetMathDiagram::rowsep() const
44 {
45 	return 10;
46 }
47 
48 
metrics(MetricsInfo & mi,Dimension & dim) const49 void InsetMathDiagram::metrics(MetricsInfo & mi, Dimension & dim) const
50 {
51 	Changer dummy2 = mi.base.changeEnsureMath();
52 	FontInfo & f = mi.base.font;
53 	Changer dummy = (f.style() == LM_ST_DISPLAY) ? f.changeStyle(LM_ST_TEXT)
54 		: Changer();
55 	InsetMathGrid::metrics(mi, dim);
56 }
57 
58 
draw(PainterInfo & pi,int x,int y) const59 void InsetMathDiagram::draw(PainterInfo & pi, int x, int y) const
60 {
61 	Changer dummy2 = pi.base.changeEnsureMath();
62 	FontInfo & f = pi.base.font;
63 	Changer dummy = (f.style() == LM_ST_DISPLAY) ? f.changeStyle(LM_ST_TEXT)
64 		: Changer();
65 	InsetMathGrid::draw(pi, x, y);
66 }
67 
68 
write(WriteStream & os) const69 void InsetMathDiagram::write(WriteStream & os) const
70 {
71 	MathEnsurer ensurer(os);
72 	os << "\\Diagram";
73 	bool open = os.startOuterRow();
74 	os << '{';
75 	InsetMathGrid::write(os);
76 	os << "}\n";
77 	if (open)
78 		os.startOuterRow();
79 }
80 
81 
infoize(odocstream & os) const82 void InsetMathDiagram::infoize(odocstream & os) const
83 {
84 	os << "Diagram ";
85 	InsetMathGrid::infoize(os);
86 }
87 
88 
normalize(NormalStream & os) const89 void InsetMathDiagram::normalize(NormalStream & os) const
90 {
91 	os << "[Diagram ";
92 	InsetMathGrid::normalize(os);
93 	os << ']';
94 }
95 
96 
maple(MapleStream & os) const97 void InsetMathDiagram::maple(MapleStream & os) const
98 {
99 	os << "Diagram(";
100 	InsetMathGrid::maple(os);
101 	os << ')';
102 }
103 
104 
validate(LaTeXFeatures & features) const105 void InsetMathDiagram::validate(LaTeXFeatures & features) const
106 {
107 	features.require("feyn");
108 	InsetMathGrid::validate(features);
109 }
110 
111 
112 } // namespace lyx
113