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