]> git.lyx.org Git - lyx.git/blob - src/mathed/math_metricsinfo.h
revert to 1.1.6 behaviour for \macroname{
[lyx.git] / src / mathed / math_metricsinfo.h
1 #ifndef MATH_METRICSINFO_H
2 #define MATH_METRICSINFO_H
3
4 #ifdef __GNUG__
5 #pragma interface
6 #endif
7
8 #include "lyxfont.h"
9 #include "LString.h"
10
11 class Painter;
12
13
14 /// Standard Math Sizes (Math mode styles)
15 enum MathStyles {
16         ///
17         LM_ST_DISPLAY = 0,
18         ///
19         LM_ST_TEXT,
20         ///
21         LM_ST_SCRIPT,
22         ///
23         LM_ST_SCRIPTSCRIPT
24 };
25
26
27 struct MathMetricsBase {
28         ///
29         MathMetricsBase();
30
31         ///
32         LyXFont font;
33         ///
34         MathStyles style;
35         ///
36         string fontname;
37         /// if this is set...
38         bool restrictwidth;
39         /// ... this is valid
40         int textwidth;
41 };
42
43
44 struct MathMetricsInfo {
45         ///
46         MathMetricsInfo();
47
48         ///
49         MathMetricsBase base;
50         ///
51         bool fullredraw;
52 };
53
54
55 struct MathPainterInfo {
56         ///
57         MathPainterInfo(Painter & pain);
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 MathFontChanger : public MathChanger<LyXFont> {
87         ///
88         MathFontChanger(LyXFont & orig, char const * font);
89         ///
90         ~MathFontChanger();
91 };
92
93
94 struct MathFontSetChanger : public MathChanger<MathMetricsBase> {
95         ///
96         MathFontSetChanger(MathMetricsBase & mb, char const * font);
97         ///
98         ~MathFontSetChanger();
99 };
100
101
102 struct MathStyleChanger : public MathChanger<MathMetricsBase> {
103         ///
104         MathStyleChanger(MathMetricsBase & mb, MathStyles shape);
105         ///
106         ~MathStyleChanger();
107 };
108
109
110 struct MathScriptChanger : public MathStyleChanger {
111         ///
112         MathScriptChanger(MathMetricsBase & mb);
113 };
114
115
116 struct MathFracChanger : public MathStyleChanger {
117         ///
118         MathFracChanger(MathMetricsBase & mb);
119 };
120
121
122 struct MathShapeChanger : public MathChanger<LyXFont, LyXFont::FONT_SHAPE> {
123         ///
124         MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape);
125         ///
126         ~MathShapeChanger();
127 };
128
129
130 struct MathWidthChanger : public MathChanger<MathMetricsBase>
131 {
132         ///
133         MathWidthChanger(MathMetricsBase & mb, int width);
134         ///
135         ~MathWidthChanger();
136 };
137
138
139 #endif