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