]> git.lyx.org Git - lyx.git/blob - src/mathed/math_metricsinfo.h
Jean-Marc's fix for wrong descent
[lyx.git] / src / mathed / math_metricsinfo.h
1 #ifndef MATH_METRICSINFO_H
2 #define MATH_METRICSINFO_H
3
4
5 #include "lyxfont.h"
6 #include "LString.h"
7
8 class Painter;
9
10
11 /// Standard Math Sizes (Math mode styles)
12 enum MathStyles {
13         ///
14         LM_ST_DISPLAY = 0,
15         ///
16         LM_ST_TEXT,
17         ///
18         LM_ST_SCRIPT,
19         ///
20         LM_ST_SCRIPTSCRIPT
21 };
22
23
24 struct MathMetricsBase {
25         ///
26         MathMetricsBase();
27
28         ///
29         LyXFont font;
30         ///
31         MathStyles style;
32         ///
33         string fontname;
34         /// if this is set...
35         bool restrictwidth;
36         /// ... this is valid
37         int textwidth;
38 };
39
40
41 struct MathMetricsInfo {
42         ///
43         MathMetricsInfo();
44
45         ///
46         MathMetricsBase base;
47         ///
48         bool fullredraw;
49 };
50
51
52 struct MathPainterInfo {
53         ///
54         MathPainterInfo(Painter & pain);
55         ///
56         void draw(int x, int y, char c);
57
58         ///
59         MathMetricsBase base;
60         ///
61         Painter & pain;
62 };
63
64
65 struct TextMetricsInfo {};
66
67
68 // Generic base for temporarily changing things.
69 // The original state gets restored when the Changer is destructed.
70
71 template <class Struct, class Temp = Struct>
72 struct MathChanger {
73         ///
74         MathChanger(Struct & orig) : orig_(orig) {}
75 protected:
76         ///
77         Struct & orig_;
78         ///
79         Temp save_;
80 };
81
82
83
84 struct MathFontChanger : public MathChanger<LyXFont> {
85         ///
86         MathFontChanger(LyXFont & orig, char const * font);
87         ///
88         ~MathFontChanger();
89 };
90
91
92 struct MathFontSetChanger : public MathChanger<MathMetricsBase> {
93         ///
94         MathFontSetChanger(MathMetricsBase & mb, char const * font);
95         ///
96         ~MathFontSetChanger();
97 };
98
99
100 struct MathStyleChanger : public MathChanger<MathMetricsBase> {
101         ///
102         MathStyleChanger(MathMetricsBase & mb, MathStyles shape);
103         ///
104         ~MathStyleChanger();
105 };
106
107
108 struct MathScriptChanger : public MathStyleChanger {
109         ///
110         MathScriptChanger(MathMetricsBase & mb);
111 };
112
113
114 struct MathFracChanger : public MathStyleChanger {
115         ///
116         MathFracChanger(MathMetricsBase & mb);
117 };
118
119
120 struct MathArrayChanger : public MathStyleChanger {
121         ///
122         MathArrayChanger(MathMetricsBase & mb);
123 };
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 struct MathWidthChanger : public MathChanger<MathMetricsBase>
136 {
137         ///
138         MathWidthChanger(MathMetricsBase & mb, int width);
139         ///
140         ~MathWidthChanger();
141 };
142
143
144 #endif