4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
16 #include "support/docstring.h"
27 /// Standard Sizes (mode styles)
41 // This is the part common to MetricsInfo and PainterInfo
48 MetricsBase(BufferView * bv, LyXFont const & font, int textwidth);
54 /// current math style (display/text/script/..)
56 /// name of current font - mathed specific
58 /// This is the width available in pixels
64 // This contains a MetricsBase and information that's only relevant during
65 // the first phase of the two-phase draw
72 MetricsInfo(BufferView * bv, LyXFont const & font, int textwidth);
80 // This contains a MetricsBase and information that's only relevant during
81 // the second phase of the two-phase draw
86 PainterInfo(BufferView * bv, lyx::frontend::Painter & pain);
88 void draw(int x, int y, lyx::char_type c);
90 void draw(int x, int y, lyx::docstring const & str);
95 lyx::frontend::Painter & pain;
96 /// Whether the text at this point is right-to-left (for InsetNewline)
98 /// Whether the parent is deleted (change tracking)
102 class TextMetricsInfo {};
104 class ViewMetricsInfo
108 : p1(0), p2(0), y1(0), y2(0),
109 singlepar(false), size(0) {}
110 ViewMetricsInfo(lyx::pit_type p1, lyx::pit_type p2, int y1, int y2,
111 bool singlepar, lyx::pit_type size)
112 : p1(p1), p2(p2), y1(y1), y2(y2),
113 singlepar(singlepar), size(size) {}
123 // Generic base for temporarily changing things.
124 // The original state gets restored when the Changer is destructed.
126 template <class Struct, class Temp = Struct>
130 Changer(Struct & orig) : orig_(orig) {}
140 // temporarily change some aspect of a font
141 class FontChanger : public Changer<LyXFont> {
144 FontChanger(LyXFont & orig, char const * font);
150 // temporarily change a full font
151 class FontSetChanger : public Changer<MetricsBase> {
154 FontSetChanger(MetricsBase & mb, char const * font);
160 // temporarily change the style
161 class StyleChanger : public Changer<MetricsBase> {
164 StyleChanger(MetricsBase & mb, Styles style);
170 // temporarily change the style to script style
171 class ScriptChanger : public StyleChanger {
174 ScriptChanger(MetricsBase & mb);
178 // temporarily change the style suitable for use in fractions
179 class FracChanger : public StyleChanger {
182 FracChanger(MetricsBase & mb);
186 // temporarily change the style suitable for use in tabulars and arrays
187 class ArrayChanger : public StyleChanger {
190 ArrayChanger(MetricsBase & mb);
195 // temporarily change the shape of a font
196 class ShapeChanger : public Changer<LyXFont, LyXFont::FONT_SHAPE> {
199 ShapeChanger(LyXFont & font, LyXFont::FONT_SHAPE shape);
205 // temporarily change the available text width
206 class WidthChanger : public Changer<MetricsBase>
210 WidthChanger(MetricsBase & mb, int width);
216 // temporarily change the used color
217 class ColorChanger : public Changer<LyXFont, std::string> {
220 ColorChanger(LyXFont & font, std::string const & color);