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;
106 /// Determines the text color based on the intended color, the
107 /// change tracking state and the selection state.
108 /// \param color what the color should be by default
109 Color textColor(Color const & color) const;
114 frontend::Painter & pain;
115 /// Whether the text at this point is right-to-left (for InsetNewline)
117 /// The change the parent is part of (change tracking)
119 /// Whether the parent is selected as a whole
123 /// Current background color
124 ColorCode background_color;
127 class TextMetricsInfo {};
130 /// Generic base for temporarily changing things.
131 /// The original state gets restored when the Changer is destructed.
132 template <class Struct, class Temp = Struct>
136 Changer(Struct & orig) : orig_(orig) {}
146 // temporarily change some aspect of a font
147 class FontChanger : public Changer<FontInfo> {
150 FontChanger(FontInfo & orig, docstring const & font);
151 FontChanger(MetricsBase & mb, char const * const font);
157 // temporarily change a full font
158 class FontSetChanger : public Changer<MetricsBase> {
161 FontSetChanger(MetricsBase & mb, docstring const & font,
162 bool really_change_font = true);
163 FontSetChanger(MetricsBase & mb, char const * const font,
164 bool really_change_font = true);
173 // temporarily change the style
174 class StyleChanger : public Changer<MetricsBase> {
177 StyleChanger(MetricsBase & mb, Styles style);
183 // temporarily change the style to script style
184 class ScriptChanger : public StyleChanger {
187 ScriptChanger(MetricsBase & mb);
191 // temporarily change the style suitable for use in fractions
192 class FracChanger : public StyleChanger {
195 FracChanger(MetricsBase & mb);
199 // temporarily change the style suitable for use in tabulars and arrays
200 class ArrayChanger : public StyleChanger {
203 ArrayChanger(MetricsBase & mb);
208 // temporarily change the shape of a font
209 class ShapeChanger : public Changer<FontInfo, FontShape> {
212 ShapeChanger(FontInfo & font, FontShape shape);
218 // temporarily change the available text width
219 class WidthChanger : public Changer<MetricsBase>
223 WidthChanger(MetricsBase & mb, int width);
229 // temporarily change the used color
230 class ColorChanger : public Changer<FontInfo, ColorCode> {
233 ColorChanger(FontInfo & font, ColorCode color,
234 bool really_change_color = true);