]> git.lyx.org Git - lyx.git/blob - src/mathed/math_metricsinfo.h
small up/down tweaking
[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
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 MathFontChanger : public MathChanger<LyXFont> {
88         ///
89         MathFontChanger(LyXFont & orig, char const * font);
90         ///
91         ~MathFontChanger();
92 };
93
94
95 struct MathFontSetChanger : public MathChanger<MathMetricsBase> {
96         ///
97         MathFontSetChanger(MathMetricsBase & mb, char const * font);
98         ///
99         ~MathFontSetChanger();
100 };
101
102
103 struct MathStyleChanger : public MathChanger<MathMetricsBase> {
104         ///
105         MathStyleChanger(MathMetricsBase & mb, MathStyles shape);
106         ///
107         ~MathStyleChanger();
108 };
109
110
111 struct MathScriptChanger : public MathStyleChanger {
112         ///
113         MathScriptChanger(MathMetricsBase & mb);
114 };
115
116
117 struct MathFracChanger : public MathStyleChanger {
118         ///
119         MathFracChanger(MathMetricsBase & mb);
120 };
121
122
123 struct MathArrayChanger : public MathStyleChanger {
124         ///
125         MathArrayChanger(MathMetricsBase & mb);
126 };
127
128
129
130 struct MathShapeChanger : public MathChanger<LyXFont, LyXFont::FONT_SHAPE> {
131         ///
132         MathShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape);
133         ///
134         ~MathShapeChanger();
135 };
136
137
138 struct MathWidthChanger : public MathChanger<MathMetricsBase>
139 {
140         ///
141         MathWidthChanger(MathMetricsBase & mb, int width);
142         ///
143         ~MathWidthChanger();
144 };
145
146
147 #endif