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.
15 #include "ColorCode.h"
17 #include "support/docstring.h"
24 namespace frontend { class Painter; }
27 /// Standard Sizes (mode styles)
41 // This is the part common to MetricsInfo and PainterInfo
48 MetricsBase(BufferView * bv, FontInfo 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, FontInfo 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, frontend::Painter & pain);
88 void draw(int x, int y, char_type c);
90 void draw(int x, int y, docstring const & str);
95 frontend::Painter & pain;
96 /// Whether the text at this point is right-to-left (for InsetNewline)
98 /// Whether the parent is deleted (change tracking)
103 ColorCode background_color;
106 class TextMetricsInfo {};
108 enum ScreenUpdateStrategy {
115 class ViewMetricsInfo
119 : p1(0), p2(0), y1(0), y2(0),
120 update_strategy(FullScreenUpdate), size(0)
122 ViewMetricsInfo(pit_type p1, pit_type p2, int y1, int y2,
123 ScreenUpdateStrategy updatestrategy, pit_type size)
124 : p1(p1), p2(p2), y1(y1), y2(y2),
125 update_strategy(updatestrategy), size(size)
132 ScreenUpdateStrategy update_strategy;
137 // Generic base for temporarily changing things.
138 // The original state gets restored when the Changer is destructed.
140 template <class Struct, class Temp = Struct>
144 Changer(Struct & orig) : orig_(orig) {}
154 // temporarily change some aspect of a font
155 class FontChanger : public Changer<FontInfo> {
158 FontChanger(FontInfo & orig, docstring const & font);
159 FontChanger(MetricsBase & mb, char const * const font);
165 // temporarily change a full font
166 class FontSetChanger : public Changer<MetricsBase> {
169 FontSetChanger(MetricsBase & mb, docstring const & font);
170 FontSetChanger(MetricsBase & mb, char const * const font);
176 // temporarily change the style
177 class StyleChanger : public Changer<MetricsBase> {
180 StyleChanger(MetricsBase & mb, Styles style);
186 // temporarily change the style to script style
187 class ScriptChanger : public StyleChanger {
190 ScriptChanger(MetricsBase & mb);
194 // temporarily change the style suitable for use in fractions
195 class FracChanger : public StyleChanger {
198 FracChanger(MetricsBase & mb);
202 // temporarily change the style suitable for use in tabulars and arrays
203 class ArrayChanger : public StyleChanger {
206 ArrayChanger(MetricsBase & mb);
211 // temporarily change the shape of a font
212 class ShapeChanger : public Changer<FontInfo, FontShape> {
215 ShapeChanger(FontInfo & font, FontShape shape);
221 // temporarily change the available text width
222 class WidthChanger : public Changer<MetricsBase>
226 WidthChanger(MetricsBase & mb, int width);
232 // temporarily change the used color
233 class ColorChanger : public Changer<FontInfo, std::string> {
236 ColorChanger(FontInfo & font, std::string const & color);