]> git.lyx.org Git - lyx.git/blob - src/mathed/math_metricsinfo.h
enable insertion of spaces in all \textxxx modes.
[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         ///
51         bool fullredraw;
52 };
53
54
55 struct MathPainterInfo {
56         ///
57         MathPainterInfo(Painter & p);
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 MathScriptChanger : public MathChanger<MathMetricsBase> {
87         ///
88         MathScriptChanger(MathMetricsBase & orig);
89         ///
90         ~MathScriptChanger();
91 };
92
93
94 struct MathFracChanger : public MathChanger<MathMetricsBase> {
95         ///
96         MathFracChanger(MathMetricsBase & orig);
97         ///
98         ~MathFracChanger();
99 };
100
101
102
103 struct MathFontChanger : public MathChanger<LyXFont> {
104         ///
105         MathFontChanger(LyXFont & orig, char const * font);
106         ///
107         ~MathFontChanger();
108 };
109
110
111 struct MathFontSetChanger : public MathChanger<MathMetricsBase> {
112         ///
113         MathFontSetChanger(MathMetricsBase & mb, char const * font);
114         ///
115         ~MathFontSetChanger();
116 };
117
118
119 struct MathStyleChanger : public MathChanger<MathMetricsBase> {
120         ///
121         MathStyleChanger(MathMetricsBase & mb, MathStyles shape);
122         ///
123         ~MathStyleChanger();
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