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/Changer.h"
23 #include "insets/Inset.h"
31 namespace frontend { class Painter; }
38 // This is the part common to MetricsInfo and PainterInfo
43 MetricsBase(BufferView * bv = 0, FontInfo font = FontInfo(),
50 /// name of current font - mathed specific
52 /// This is the width available in pixels
54 /// count wether the current mathdata is nested in macro(s)
57 /// Temporarily change a full font.
58 Changer changeFontSet(std::string const & font);
59 /// Temporarily change the font to math if needed.
60 Changer changeEnsureMath(Inset::mode_type mode = Inset::MATH_MODE);
61 // Temporarily change to the style suitable for use in fractions
63 // Temporarily change to the style suitable for use in arrays
64 // or to style suitable for smallmatrix when \c small is true.
65 Changer changeArray(bool small = false);
66 // Temporarily change the style to (script)script style
67 Changer changeScript();
69 int solidLineThickness() const { return solid_line_thickness_; }
71 int solidLineOffset() const { return solid_line_offset_; }
73 int dottedLineThickness() const { return dotted_line_thickness_; }
74 /** return the on-screen size of this length
76 * This version of the function uses the current inset width as
77 * width and the EM value of the current font.
79 int inPixels(Length const & len) const;
82 int solid_line_thickness_;
83 int solid_line_offset_;
84 int dotted_line_thickness_;
89 // This contains a MetricsBase and information that's only relevant during
90 // the first phase of the two-phase draw
97 MetricsInfo(BufferView * bv, FontInfo font, int textwidth,
98 MacroContext const & mc);
102 /// The context to resolve macros
103 MacroContext const & macrocontext;
108 // This contains a MetricsBase and information that's only relevant during
109 // the second phase of the two-phase draw
114 PainterInfo(BufferView * bv, frontend::Painter & pain);
116 void draw(int x, int y, char_type c);
118 void draw(int x, int y, docstring const & str);
119 /// Determines the background color for the specified inset based on the
120 /// selection state, the background color inherited from the parent inset
121 /// and the inset's own background color.
122 /// \param sel whether to take the selection state into account
123 ColorCode backgroundColor(Inset const * inset, bool sel = true) const;
125 /// Determines the text color based on the intended color, the
126 /// change tracking state and the selection state.
127 /// \param color what the color should be by default
128 Color textColor(Color const & color) const;
133 frontend::Painter & pain;
134 /// Whether the text at this point is right-to-left (for insets)
136 /// The change the parent is part of (change tracking)
138 /// Whether the parent is selected as a whole
140 /// Whether the spell checker is enabled for the parent
142 /// True when it can be assumed that the screen has been cleared
144 /// Current background color
145 ColorCode background_color;
146 /// Useful for drawing display math numbering
150 class TextMetricsInfo {};