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"
18 #include "support/strfwd.h"
19 #include "support/types.h"
27 namespace frontend { class Painter; }
30 /// Standard Sizes (mode styles)
44 // This is the part common to MetricsInfo and PainterInfo
51 MetricsBase(BufferView * bv, FontInfo const & font, int textwidth);
57 /// current math style (display/text/script/..)
59 /// name of current font - mathed specific
61 /// This is the width available in pixels
67 // This contains a MetricsBase and information that's only relevant during
68 // the first phase of the two-phase draw
75 MetricsInfo(BufferView * bv, FontInfo const & font, int textwidth);
83 // This contains a MetricsBase and information that's only relevant during
84 // the second phase of the two-phase draw
89 PainterInfo(BufferView * bv, frontend::Painter & pain);
91 void draw(int x, int y, char_type c);
93 void draw(int x, int y, docstring const & str);
98 frontend::Painter & pain;
99 /// Whether the text at this point is right-to-left (for InsetNewline)
101 /// Whether the parent is deleted (change tracking)
106 ColorCode background_color;
109 class TextMetricsInfo {};
111 enum ScreenUpdateStrategy {
118 class ViewMetricsInfo
122 : p1(0), p2(0), y1(0), y2(0),
123 update_strategy(FullScreenUpdate), size(0)
125 ViewMetricsInfo(pit_type p1, pit_type p2, int y1, int y2,
126 ScreenUpdateStrategy updatestrategy, pit_type size)
127 : p1(p1), p2(p2), y1(y1), y2(y2),
128 update_strategy(updatestrategy), size(size)
135 ScreenUpdateStrategy update_strategy;
140 // Generic base for temporarily changing things.
141 // The original state gets restored when the Changer is destructed.
143 template <class Struct, class Temp = Struct>
147 Changer(Struct & orig) : orig_(orig) {}
157 // temporarily change some aspect of a font
158 class FontChanger : public Changer<FontInfo> {
161 FontChanger(FontInfo & orig, docstring const & font);
162 FontChanger(MetricsBase & mb, char const * const font);
168 // temporarily change a full font
169 class FontSetChanger : public Changer<MetricsBase> {
172 FontSetChanger(MetricsBase & mb, docstring const & font);
173 FontSetChanger(MetricsBase & mb, char const * const font);
179 // temporarily change the style
180 class StyleChanger : public Changer<MetricsBase> {
183 StyleChanger(MetricsBase & mb, Styles style);
189 // temporarily change the style to script style
190 class ScriptChanger : public StyleChanger {
193 ScriptChanger(MetricsBase & mb);
197 // temporarily change the style suitable for use in fractions
198 class FracChanger : public StyleChanger {
201 FracChanger(MetricsBase & mb);
205 // temporarily change the style suitable for use in tabulars and arrays
206 class ArrayChanger : public StyleChanger {
209 ArrayChanger(MetricsBase & mb);
214 // temporarily change the shape of a font
215 class ShapeChanger : public Changer<FontInfo, FontShape> {
218 ShapeChanger(FontInfo & font, FontShape shape);
224 // temporarily change the available text width
225 class WidthChanger : public Changer<MetricsBase>
229 WidthChanger(MetricsBase & mb, int width);
235 // temporarily change the used color
236 class ColorChanger : public Changer<FontInfo, std::string> {
239 ColorChanger(FontInfo & font, std::string const & color);