4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Stefan Schimanski
10 * Full author contact details are available in file CREDITS.
16 #include "ColorCode.h"
19 #include "support/strfwd.h"
20 #include "support/types.h"
28 namespace frontend { class Painter; }
32 /// Standard Sizes (mode styles)
46 // This is the part common to MetricsInfo and PainterInfo
53 MetricsBase(BufferView * bv, FontInfo const & font, int textwidth);
59 /// current math style (display/text/script/..)
61 /// name of current font - mathed specific
63 /// This is the width available in pixels
69 // This contains a MetricsBase and information that's only relevant during
70 // the first phase of the two-phase draw
77 MetricsInfo(BufferView * bv, FontInfo const & font, int textwidth, MacroContext const & mc);
81 /// The context to resolve macros
82 MacroContext const & macrocontext;
87 // This contains a MetricsBase and information that's only relevant during
88 // the second phase of the two-phase draw
93 PainterInfo(BufferView * bv, frontend::Painter & pain);
95 void draw(int x, int y, char_type c);
97 void draw(int x, int y, docstring const & str);
102 frontend::Painter & pain;
103 /// Whether the text at this point is right-to-left (for InsetNewline)
105 /// Whether the parent is deleted (change tracking)
110 ColorCode background_color;
113 class TextMetricsInfo {};
116 /// Generic base for temporarily changing things.
117 /// The original state gets restored when the Changer is destructed.
118 template <class Struct, class Temp = Struct>
122 Changer(Struct & orig) : orig_(orig) {}
132 // temporarily change some aspect of a font
133 class FontChanger : public Changer<FontInfo> {
136 FontChanger(FontInfo & orig, docstring const & font);
137 FontChanger(MetricsBase & mb, char const * const font);
143 // temporarily change a full font
144 class FontSetChanger : public Changer<MetricsBase> {
147 FontSetChanger(MetricsBase & mb, docstring const & font);
148 FontSetChanger(MetricsBase & mb, char const * const font);
154 // temporarily change the style
155 class StyleChanger : public Changer<MetricsBase> {
158 StyleChanger(MetricsBase & mb, Styles style);
164 // temporarily change the style to script style
165 class ScriptChanger : public StyleChanger {
168 ScriptChanger(MetricsBase & mb);
172 // temporarily change the style suitable for use in fractions
173 class FracChanger : public StyleChanger {
176 FracChanger(MetricsBase & mb);
180 // temporarily change the style suitable for use in tabulars and arrays
181 class ArrayChanger : public StyleChanger {
184 ArrayChanger(MetricsBase & mb);
189 // temporarily change the shape of a font
190 class ShapeChanger : public Changer<FontInfo, FontShape> {
193 ShapeChanger(FontInfo & font, FontShape shape);
199 // temporarily change the available text width
200 class WidthChanger : public Changer<MetricsBase>
204 WidthChanger(MetricsBase & mb, int width);
210 // temporarily change the used color
211 class ColorChanger : public Changer<FontInfo, std::string> {
214 ColorChanger(FontInfo & font, std::string const & color);