]> git.lyx.org Git - lyx.git/blob - src/MetricsInfo.h
Enable InsetQuote in verbatim and Hebrew
[lyx.git] / src / MetricsInfo.h
1 // -*- C++ -*-
2 /**
3  * \file MetricsInfo.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author André Pönitz
8  * \author Stefan Schimanski
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef METRICSINFO_H
14 #define METRICSINFO_H
15
16 #include "Changes.h"
17 #include "ColorCode.h"
18 #include "FontInfo.h"
19
20 #include "support/strfwd.h"
21 #include "support/Changer.h"
22
23
24 #include <string>
25
26
27 namespace lyx {
28
29 namespace frontend { class Painter; }
30 class BufferView;
31 class Inset;
32 class MacroContext;
33
34
35 //
36 // This is the part common to MetricsInfo and PainterInfo
37 //
38 class MetricsBase {
39 public:
40         ///
41         MetricsBase(BufferView * bv = 0, FontInfo font = FontInfo(),
42                     int textwidth = 0);
43
44         /// the current view
45         BufferView * bv;
46         /// current font
47         FontInfo font;
48         /// name of current font - mathed specific
49         std::string fontname;
50         /// This is the width available in pixels
51         int textwidth;
52         /// count wether the current mathdata is nested in macro(s)
53         int macro_nesting;
54
55         /// Temporarily change a full font.
56         Changer changeFontSet(std::string const & font);
57         /// Temporarily change the font to math if needed.
58         Changer changeEnsureMath();
59         // Temporarily change to the style suitable for use in fractions
60         Changer changeFrac();
61         // Temporarily change to the style suitable for use in arrays
62         Changer changeArray();
63         // Temporarily change the style to (script)script style
64         Changer changeScript();
65         ///
66         int solidLineThickness() const { return solid_line_thickness_; }
67         ///
68         int solidLineOffset() const { return solid_line_offset_; }
69         ///
70         int dottedLineThickness() const { return dotted_line_thickness_; }
71 private:
72         int solid_line_thickness_;
73         int solid_line_offset_;
74         int dotted_line_thickness_;
75 };
76
77
78 //
79 // This contains a MetricsBase and information that's only relevant during
80 // the first phase of the two-phase draw
81 //
82 class MetricsInfo {
83 public:
84         ///
85         MetricsInfo();
86         ///
87         MetricsInfo(BufferView * bv, FontInfo font, int textwidth,
88                     MacroContext const & mc);
89
90         ///
91         MetricsBase base;
92         /// The context to resolve macros
93         MacroContext const & macrocontext;
94 };
95
96
97 //
98 // This contains a MetricsBase and information that's only relevant during
99 // the second phase of the two-phase draw
100 //
101 class PainterInfo {
102 public:
103         ///
104         PainterInfo(BufferView * bv, frontend::Painter & pain);
105         ///
106         void draw(int x, int y, char_type c);
107         ///
108         void draw(int x, int y, docstring const & str);
109         /// Determines the background color for the specified inset based on the
110         /// selection state, the background color inherited from the parent inset 
111         /// and the inset's own background color.
112         /// \param sel whether to take the selection state into account
113         ColorCode backgroundColor(Inset const * inset, bool sel = true) const;
114
115         /// Determines the text color based on the intended color, the
116         /// change tracking state and the selection state. 
117         /// \param color what the color should be by default
118         Color textColor(Color const & color) const;
119
120         ///
121         MetricsBase base;
122         ///
123         frontend::Painter & pain;
124         /// Whether the text at this point is right-to-left (for InsetNewline)
125         bool ltr_pos;
126         /// The change the parent is part of (change tracking)
127         Change change_;
128         /// Whether the parent is selected as a whole
129         bool selected;
130         /// Whether the spell checker is enabled for the parent
131         bool do_spellcheck;
132         ///
133         bool full_repaint;
134         /// Current background color
135         ColorCode background_color;
136 };
137
138 class TextMetricsInfo {};
139
140 } // namespace lyx
141
142 #endif