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.
17 #include "ColorCode.h"
20 #include "support/strfwd.h"
21 #include "support/types.h"
29 namespace frontend { class Painter; }
34 /// Standard Sizes (mode styles)
48 // This is the part common to MetricsInfo and PainterInfo
55 MetricsBase(BufferView * bv, FontInfo const & font, int textwidth);
61 /// current math style (display/text/script/..)
63 /// name of current font - mathed specific
65 /// This is the width available in pixels
71 // This contains a MetricsBase and information that's only relevant during
72 // the first phase of the two-phase draw
79 MetricsInfo(BufferView * bv, FontInfo const & font, int textwidth, MacroContext const & mc);
83 /// The context to resolve macros
84 MacroContext const & macrocontext;
89 // This contains a MetricsBase and information that's only relevant during
90 // the second phase of the two-phase draw
95 PainterInfo(BufferView * bv, frontend::Painter & pain);
97 void draw(int x, int y, char_type c);
99 void draw(int x, int y, docstring const & str);
100 /// Determines the background color for the specified inset based on the
101 /// selection state, the background color inherited from the parent inset
102 /// and the inset's own background color.
103 /// \param sel whether to take the selection state into account
104 ColorCode backgroundColor(Inset const * inset, bool sel = true) const;
109 frontend::Painter & pain;
110 /// Whether the text at this point is right-to-left (for InsetNewline)
112 /// The change the parent is part of (change tracking)
114 /// Whether the parent is selected as a whole
118 /// Current background color
119 ColorCode background_color;
122 class TextMetricsInfo {};
125 /// Generic base for temporarily changing things.
126 /// The original state gets restored when the Changer is destructed.
127 template <class Struct, class Temp = Struct>
131 Changer(Struct & orig) : orig_(orig) {}
141 // temporarily change some aspect of a font
142 class FontChanger : public Changer<FontInfo> {
145 FontChanger(FontInfo & orig, docstring const & font);
146 FontChanger(MetricsBase & mb, char const * const font);
152 // temporarily change a full font
153 class FontSetChanger : public Changer<MetricsBase> {
156 FontSetChanger(MetricsBase & mb, docstring const & font);
157 FontSetChanger(MetricsBase & mb, char const * const font);
163 // temporarily change the style
164 class StyleChanger : public Changer<MetricsBase> {
167 StyleChanger(MetricsBase & mb, Styles style);
173 // temporarily change the style to script style
174 class ScriptChanger : public StyleChanger {
177 ScriptChanger(MetricsBase & mb);
181 // temporarily change the style suitable for use in fractions
182 class FracChanger : public StyleChanger {
185 FracChanger(MetricsBase & mb);
189 // temporarily change the style suitable for use in tabulars and arrays
190 class ArrayChanger : public StyleChanger {
193 ArrayChanger(MetricsBase & mb);
198 // temporarily change the shape of a font
199 class ShapeChanger : public Changer<FontInfo, FontShape> {
202 ShapeChanger(FontInfo & font, FontShape shape);
208 // temporarily change the available text width
209 class WidthChanger : public Changer<MetricsBase>
213 WidthChanger(MetricsBase & mb, int width);
219 // temporarily change the used color
220 class ColorChanger : public Changer<FontInfo, std::string> {
223 ColorChanger(FontInfo & font, std::string const & color);