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; }
33 /// Standard Sizes (mode styles)
47 // This is the part common to MetricsInfo and PainterInfo
54 MetricsBase(BufferView * bv, FontInfo const & font, int textwidth);
60 /// current math style (display/text/script/..)
62 /// name of current font - mathed specific
64 /// This is the width available in pixels
70 // This contains a MetricsBase and information that's only relevant during
71 // the first phase of the two-phase draw
78 MetricsInfo(BufferView * bv, FontInfo const & font, int textwidth, MacroContext const & mc);
82 /// The context to resolve macros
83 MacroContext const & macrocontext;
88 // This contains a MetricsBase and information that's only relevant during
89 // the second phase of the two-phase draw
94 PainterInfo(BufferView * bv, frontend::Painter & pain);
96 void draw(int x, int y, char_type c);
98 void draw(int x, int y, docstring const & str);
99 /// Determines the background color for the specified inset based on the
100 /// selection state, the background color inherited from the parent inset
101 /// and the inset's own background color.
102 /// \param sel whether to take the selection state into account
103 ColorCode backgroundColor(Inset const * inset, bool sel = true) const;
108 frontend::Painter & pain;
109 /// Whether the text at this point is right-to-left (for InsetNewline)
111 /// Whether the parent is deleted (change tracking)
113 /// Whether the parent is selected as a whole
117 /// Current background color
118 ColorCode background_color;
121 class TextMetricsInfo {};
124 /// Generic base for temporarily changing things.
125 /// 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<FontInfo> {
144 FontChanger(FontInfo & orig, docstring const & font);
145 FontChanger(MetricsBase & mb, char const * const font);
151 // temporarily change a full font
152 class FontSetChanger : public Changer<MetricsBase> {
155 FontSetChanger(MetricsBase & mb, docstring const & font);
156 FontSetChanger(MetricsBase & mb, char const * const font);
162 // temporarily change the style
163 class StyleChanger : public Changer<MetricsBase> {
166 StyleChanger(MetricsBase & mb, Styles style);
172 // temporarily change the style to script style
173 class ScriptChanger : public StyleChanger {
176 ScriptChanger(MetricsBase & mb);
180 // temporarily change the style suitable for use in fractions
181 class FracChanger : public StyleChanger {
184 FracChanger(MetricsBase & mb);
188 // temporarily change the style suitable for use in tabulars and arrays
189 class ArrayChanger : public StyleChanger {
192 ArrayChanger(MetricsBase & mb);
197 // temporarily change the shape of a font
198 class ShapeChanger : public Changer<FontInfo, FontShape> {
201 ShapeChanger(FontInfo & font, FontShape shape);
207 // temporarily change the available text width
208 class WidthChanger : public Changer<MetricsBase>
212 WidthChanger(MetricsBase & mb, int width);
218 // temporarily change the used color
219 class ColorChanger : public Changer<FontInfo, std::string> {
222 ColorChanger(FontInfo & font, std::string const & color);