]> git.lyx.org Git - lyx.git/blob - src/mathed/math_metricsinfo.C
remove a few unneeded 'include'
[lyx.git] / src / mathed / math_metricsinfo.C
1
2 #include <config.h>
3
4 #include "math_metricsinfo.h"
5 #include "math_support.h"
6 #include "frontends/Painter.h"
7
8
9
10 MathMetricsBase::MathMetricsBase()
11         : font(), style(LM_ST_TEXT), fontname("mathnormal"),
12           restrictwidth(false), textwidth(0)
13 {}
14
15
16
17 MathMetricsInfo::MathMetricsInfo()
18         : fullredraw(false)
19 {}
20
21
22
23 MathPainterInfo::MathPainterInfo(Painter & p)
24         : pain(p)
25 {}
26
27
28 void MathPainterInfo::draw(int x, int y, char c)
29 {
30         pain.text(x, y, c, base.font);
31 }
32
33
34
35
36 MathScriptChanger::MathScriptChanger(MathMetricsBase & mb)
37         : MathChanger<MathMetricsBase>(mb)
38 {
39         save_ = mb;
40         switch (mb.style) {
41                 case LM_ST_DISPLAY:
42                 case LM_ST_TEXT:
43                         mb.style = LM_ST_SCRIPT;
44                         mb.font.decSize();
45                         mb.font.decSize();
46                         break;
47                 case LM_ST_SCRIPT:
48                         mb.style = LM_ST_SCRIPTSCRIPT;
49                         mb.font.decSize();
50                 default:
51                         break;
52         }
53 }
54
55 MathScriptChanger::~MathScriptChanger()
56 {
57         orig_ = save_;
58 }
59
60
61
62
63 // decrease math size for fractions
64 MathFracChanger::MathFracChanger(MathMetricsBase & mb)
65         : MathChanger<MathMetricsBase>(mb)
66 {
67         save_ = mb;
68         switch (mb.style) {
69                 case LM_ST_DISPLAY:
70                         mb.style = LM_ST_TEXT;
71                         break;
72                 case LM_ST_TEXT:
73                         mb.style = LM_ST_SCRIPT;
74                         mb.font.decSize();
75                         mb.font.decSize();
76                         break;
77                 case LM_ST_SCRIPT:
78                         mb.style = LM_ST_SCRIPTSCRIPT;
79                         mb.font.decSize();
80                         break;
81                 default:
82                         break;
83         }
84 }
85
86 MathFracChanger::~MathFracChanger()
87 {
88         orig_ = save_;
89 }
90
91
92
93
94 MathShapeChanger::MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape)
95         : MathChanger<LyXFont, LyXFont::FONT_SHAPE>(font)
96 {
97         save_ = orig_.shape();
98         orig_.setShape(shape);
99 }
100
101 MathShapeChanger::~MathShapeChanger()
102 {
103         orig_.setShape(save_);
104 }
105
106
107
108
109 void changeSize(LyXFont & font, int diff)
110 {
111         if (diff < 0) {
112                 font.decSize();
113                 changeSize(font, diff + 1);
114         } else if (diff > 0) {
115                 font.incSize();
116                 changeSize(font, diff - 1);
117         }
118 }
119
120 MathStyleChanger::MathStyleChanger(MathMetricsBase & mb, MathStyles style)
121         :       MathChanger<MathMetricsBase>(mb)
122 {
123         save_ = mb;
124         changeSize(mb.font, mb.style - style);
125 }
126
127
128 MathStyleChanger::~MathStyleChanger()
129 {
130         orig_ = save_;
131 }
132
133
134
135
136 MathFontSetChanger::MathFontSetChanger(MathMetricsBase & mb, char const * name)
137         :       MathChanger<MathMetricsBase>(mb)
138 {
139         save_ = mb;     
140         mb.fontname = name;
141         augmentFont(mb.font, name);
142 }
143
144 MathFontSetChanger::~MathFontSetChanger()
145 {
146         orig_ = save_;
147 }
148
149
150 MathWidthChanger::MathWidthChanger(MathMetricsBase & mb, int w)
151         :       MathChanger<MathMetricsBase>(mb)
152 {
153         save_ = mb;     
154         mb.restrictwidth = true;
155         mb.textwidth     = w;
156 }
157
158
159 MathWidthChanger::~MathWidthChanger()
160 {
161         orig_ = save_;
162 }
163