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 /// font of the containing inset
52 /// name of current font - mathed specific
54 /// This is the width available in pixels
56 /// count wether the current mathdata is nested in macro(s)
59 /// Temporarily change a full font.
60 Changer changeFontSet(std::string const & name);
61 /// Temporarily change font size in text mode, only record it in math mode.
62 Changer changeFontSize(std::string const & fontsize, bool mathmode);
63 /// Temporarily change the font to math if needed.
64 Changer changeEnsureMath(Inset::mode_type mode = Inset::MATH_MODE);
65 // Temporarily change to the style suitable for use in fractions
67 // Temporarily change to the style suitable for use in arrays
68 // or to style suitable for smallmatrix when \c small is true.
69 Changer changeArray(bool small = false);
70 // Temporarily change the style to (script)script style
71 Changer changeScript();
73 int solidLineThickness() const { return solid_line_thickness_; }
75 int solidLineOffset() const { return solid_line_offset_; }
77 int dottedLineThickness() const { return dotted_line_thickness_; }
78 /** return the on-screen size of this length
80 * This version of the function uses the current inset width as
81 * width and the EM value of the current font.
83 int inPixels(Length const & len) const;
86 int solid_line_thickness_;
87 int solid_line_offset_;
88 int dotted_line_thickness_;
93 // This contains a MetricsBase and information that's only relevant during
94 // the first phase of the two-phase draw
101 MetricsInfo(BufferView * bv, FontInfo font, int textwidth,
102 MacroContext const & mc, bool vm, bool tight_insets);
106 /// The context to resolve macros
107 MacroContext const & macrocontext;
108 /// Are we at the start of a paragraph (vertical mode)?
110 /// if true, do not expand insets to max width artificially
112 /// Extra width required by an inset, in addition to its dimension
118 // This contains a MetricsBase and information that's only relevant during
119 // the second phase of the two-phase draw
124 PainterInfo(BufferView * bv, frontend::Painter & pain);
126 void draw(int x, int y, char_type c);
128 void draw(int x, int y, docstring const & str);
129 /// Determines the background color based on the
130 /// selection state, the background color inherited from the parent inset
131 /// and the inset's own background color (if one is specified).
132 /// \param sel whether to take the selection state into account
133 ColorCode backgroundColor(Inset const * inset = nullptr, bool sel = true) const;
135 /// Determines the text color based on the intended color, the
136 /// change tracking state and the selection state.
137 /// \param color what the color should be by default
138 Color textColor(Color const & color) const;
143 frontend::Painter & pain;
144 /// Whether the text at this point is right-to-left (for insets)
146 /// The change the parent is part of (change tracking)
148 /// Whether the parent is selected as a whole
150 /// Whether the left/right margins are selected
151 bool selected_left, selected_right;
152 /// Whether the spell checker is enabled for the parent
154 /// True when it can be assumed that the screen has been cleared
156 /// Current background color
157 ColorCode background_color;
158 /// The left and right position of current line (inside margins).
159 /// Useful for drawing display math numbering
163 class TextMetricsInfo {};