]> git.lyx.org Git - lyx.git/blob - src/RowPainter.h
Use explicit macro to declare that we want to use C++11
[lyx.git] / src / RowPainter.h
1 // -*- C++ -*-
2 /**
3  * \file RowPainter.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author various
8  * \author John Levon
9  * \author André Pönitz
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef ROWPAINTER_H
15 #define ROWPAINTER_H
16
17 #include "Bidi.h"
18 #include "Changes.h"
19
20 #include "support/types.h"
21
22 namespace lyx {
23
24 class BufferView;
25 class Font;
26 class FontInfo;
27 class Inset;
28 class Language;
29 class PainterInfo;
30 class Paragraph;
31 class ParagraphList;
32 class ParagraphMetrics;
33 class Row;
34 class Text;
35 class TextMetrics;
36
37 namespace frontend { class Painter; }
38
39 /**
40  * FIXME: Re-implement row painting using row elements.
41  *
42  * This is not difficult in principle, but the code is intricate and
43  * needs some careful analysis. The first thing that needs to be done
44  * is to break row elements with the same criteria. Currently breakRow
45  * does not consider on-the-fly spell-checking, but it is not clear to
46  * me that it is required. Moreover, this thing would only work if we
47  * are sure that the Row object is up-to-date when drawing happens.
48  * This depends on the update machinery.
49  *
50  * This would allow to get rid of the Bidi class.
51  */
52
53
54 /**
55  * A class used for painting an individual row of text.
56  * FIXME: get rid of that class.
57  */
58 class RowPainter {
59 public:
60         /// initialise and run painter
61         RowPainter(PainterInfo & pi, Text const & text,
62                 pit_type pit, Row const & row, int x, int y);
63
64         /// paint various parts
65         /// FIXME: transfer to TextMetrics
66         void paintAppendix();
67         void paintDepthBar();
68         void paintChangeBar();
69         void paintTooLargeMarks(bool const left, bool const right);
70         void paintFirst();
71         void paintLast();
72         void paintText();
73         void paintOnlyInsets();
74         void paintSelection();
75
76 private:
77         void paintSeparator(double orig_x, double width, FontInfo const & font);
78         void paintForeignMark(double orig_x, Language const * lang, int desc = 0);
79         void paintMisspelledMark(double orig_x, bool changed);
80         void paintChars(pos_type & vpos, Font const & font);
81         int paintAppendixStart(int y);
82         void paintFromPos(pos_type & vpos, bool changed);
83         void paintInset(Inset const * inset, pos_type const pos);
84         void paintInlineCompletion(Font const & font);
85
86         /// return left margin
87         int leftMargin() const;
88
89         /// return the label font for this row
90         FontInfo labelFont() const;
91
92         ///
93         void paintLabel();
94         ///
95         void paintTopLevelLabel();
96
97
98         /// contains painting related information.
99         PainterInfo & pi_;
100
101         /// Text for the row
102         Text const & text_;
103         TextMetrics & text_metrics_;
104         ParagraphList const & pars_;
105
106         /// The row to paint
107         Row const & row_;
108
109         /// Row's paragraph
110         pit_type const pit_;
111         Paragraph const & par_;
112         ParagraphMetrics const & pm_;
113
114         /// bidi cache
115         Bidi bidi_;
116
117         /// row changed? (change tracking)
118         Change const change_;
119
120         // Looks ugly - is
121         double const xo_;
122         int const yo_;    // current baseline
123         double x_;
124         int width_;
125         float solid_line_thickness_;
126         int solid_line_offset_;
127         float dotted_line_thickness_;
128         int dotted_line_offset_;
129 };
130
131 } // namespace lyx
132
133 #endif // ROWPAINTER_H