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 {};
115 enum ScreenUpdateStrategy {
122 class ViewMetricsInfo
126 : p1(0), p2(0), y1(0), y2(0),
127 update_strategy(FullScreenUpdate), size(0)
129 ViewMetricsInfo(pit_type p1, pit_type p2, int y1, int y2,
130 ScreenUpdateStrategy updatestrategy, pit_type size)
131 : p1(p1), p2(p2), y1(y1), y2(y2),
132 update_strategy(updatestrategy), size(size)
139 ScreenUpdateStrategy update_strategy;
144 // Generic base for temporarily changing things.
145 // The original state gets restored when the Changer is destructed.
147 template <class Struct, class Temp = Struct>
151 Changer(Struct & orig) : orig_(orig) {}
161 // temporarily change some aspect of a font
162 class FontChanger : public Changer<FontInfo> {
165 FontChanger(FontInfo & orig, docstring const & font);
166 FontChanger(MetricsBase & mb, char const * const font);
172 // temporarily change a full font
173 class FontSetChanger : public Changer<MetricsBase> {
176 FontSetChanger(MetricsBase & mb, docstring const & font);
177 FontSetChanger(MetricsBase & mb, char const * const font);
183 // temporarily change the style
184 class StyleChanger : public Changer<MetricsBase> {
187 StyleChanger(MetricsBase & mb, Styles style);
193 // temporarily change the style to script style
194 class ScriptChanger : public StyleChanger {
197 ScriptChanger(MetricsBase & mb);
201 // temporarily change the style suitable for use in fractions
202 class FracChanger : public StyleChanger {
205 FracChanger(MetricsBase & mb);
209 // temporarily change the style suitable for use in tabulars and arrays
210 class ArrayChanger : public StyleChanger {
213 ArrayChanger(MetricsBase & mb);
218 // temporarily change the shape of a font
219 class ShapeChanger : public Changer<FontInfo, FontShape> {
222 ShapeChanger(FontInfo & font, FontShape shape);
228 // temporarily change the available text width
229 class WidthChanger : public Changer<MetricsBase>
233 WidthChanger(MetricsBase & mb, int width);
239 // temporarily change the used color
240 class ColorChanger : public Changer<FontInfo, std::string> {
243 ColorChanger(FontInfo & font, std::string const & color);