]> git.lyx.org Git - lyx.git/blob - src/mathed/math_metricsinfo.h
try to fix rounding errors
[lyx.git] / src / mathed / math_metricsinfo.h
1 #ifndef MATH_METRICSINFO_H
2 #define MATH_METRICSINFO_H
3
4 #include "lyxfont.h"
5 #include "math_defs.h"
6
7 class BufferView;
8 class Painter;
9 class MathNestInset;
10
11
12 /// Standard Math Sizes (Math mode styles)
13 enum MathStyles {
14         ///
15         LM_ST_DISPLAY = 0,
16         ///
17         LM_ST_TEXT,
18         ///
19         LM_ST_SCRIPT,
20         ///
21         LM_ST_SCRIPTSCRIPT
22 };
23
24
25 struct MathMetricsBase {
26         ///
27         MathMetricsBase();
28
29         ///
30         LyXFont font;
31         ///
32         MathStyles style;
33         ///
34         bool fontinset;
35 };
36
37
38 struct MathMetricsInfo {
39         ///
40         MathMetricsInfo();
41
42         ///
43         MathMetricsBase base;
44         ///
45         BufferView * view;
46         /// used to pass some info down
47         MathNestInset const * inset;
48         ///
49         int idx;
50         ///
51         bool fullredraw;
52 };
53
54
55 struct MathPainterInfo {
56         ///
57         MathPainterInfo(Painter & p);
58         ///
59         void draw(int x, int y, char c);
60
61         ///
62         MathMetricsBase base;
63         ///
64         Painter & pain;
65 };
66
67
68 struct TextMetricsInfo {};
69
70
71 // Generic base for temporarily changing things.
72 // The original state gets restored when the Changer is destructed
73 template <class Struct, class Temp = Struct>
74 struct MathChanger {
75         ///
76         MathChanger(Struct & orig) : orig_(orig) {}
77 protected:
78         ///
79         Struct & orig_;
80         ///
81         Temp save_;
82 };
83
84
85
86 struct MathScriptChanger : public MathChanger<MathMetricsBase> {
87         ///
88         MathScriptChanger(MathMetricsBase & orig);
89         ///
90         ~MathScriptChanger();
91 };
92
93
94 struct MathFracChanger : public MathChanger<MathMetricsBase> {
95         ///
96         MathFracChanger(MathMetricsBase & orig);
97         ///
98         ~MathFracChanger();
99 };
100
101
102
103 struct MathFontChanger : public MathChanger<LyXFont> {
104         ///
105         MathFontChanger(LyXFont & orig, char const * font);
106         ///
107         ~MathFontChanger();
108 };
109
110
111 struct MathFontSetChanger : public MathChanger<MathMetricsBase> {
112         ///
113         MathFontSetChanger(MathMetricsBase & mb, char const * font);
114         ///
115         ~MathFontSetChanger();
116 };
117
118
119 struct MathStyleChanger : public MathChanger<MathMetricsBase> {
120         ///
121         MathStyleChanger(MathMetricsBase & mb, MathStyles shape);
122         ///
123         ~MathStyleChanger();
124 };
125
126
127 struct MathShapeChanger : public MathChanger<LyXFont, LyXFont::FONT_SHAPE> {
128         ///
129         MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape);
130         ///
131         ~MathShapeChanger();
132 };
133
134
135 #endif