]> git.lyx.org Git - lyx.git/blob - src/mathed/InsetMathUnknown.cpp
* BufferView::buffer() returns a reference instead of a pointer.
[lyx.git] / src / mathed / InsetMathUnknown.cpp
1 /**
2  * \file InsetMathUnknown.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  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "InsetMathUnknown.h"
14 #include "MathSupport.h"
15 #include "MathAtom.h"
16 #include "MathStream.h"
17 #include "MathStream.h"
18
19
20 namespace lyx {
21
22 using std::string;
23 using std::auto_ptr;
24 using std::vector;
25
26
27 InsetMathUnknown::InsetMathUnknown(docstring const & nm, bool final, bool black)
28         : name_(nm), final_(final), black_(black)
29 {}
30
31
32 auto_ptr<Inset> InsetMathUnknown::doClone() const
33 {
34         return auto_ptr<Inset>(new InsetMathUnknown(*this));
35 }
36
37
38 docstring InsetMathUnknown::name() const
39 {
40         return name_;
41 }
42
43
44 void InsetMathUnknown::setName(docstring const & name)
45 {
46         name_ = name;
47 }
48
49
50 void InsetMathUnknown::normalize(NormalStream & os) const
51 {
52         os << "[unknown " << name_ << ']';
53 }
54
55
56 bool InsetMathUnknown::metrics(MetricsInfo & mi, Dimension & dim) const
57 {
58         mathed_string_dim(mi.base.font, name_, dim);
59         docstring::const_reverse_iterator rit = name_.rbegin();
60         kerning_ = mathed_char_kerning(mi.base.font, *rit);
61         if (dim_ == dim)
62                 return false;
63         dim_ = dim;
64         return true;
65 }
66
67
68 void InsetMathUnknown::draw(PainterInfo & pi, int x, int y) const
69 {
70         if (black_)
71                 drawStrBlack(pi, x, y, name_);
72         else
73                 drawStrRed(pi, x, y, name_);
74         setPosCache(pi, x, y);
75 }
76
77
78 void InsetMathUnknown::finalize()
79 {
80         final_ = true;
81 }
82
83
84 bool InsetMathUnknown::final() const
85 {
86         return final_;
87 }
88
89
90 void InsetMathUnknown::maple(MapleStream & os) const
91 {
92         os << name_;
93 }
94
95
96 void InsetMathUnknown::mathematica(MathematicaStream & os) const
97 {
98         os << name_;
99 }
100
101
102 void InsetMathUnknown::mathmlize(MathStream & os) const
103 {
104         os << MTag("mi") << name_ << ETag("mi");
105 }
106
107
108 void InsetMathUnknown::octave(OctaveStream & os) const
109 {
110         os << name_;
111 }
112
113
114 } // namespace lyx