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