]> git.lyx.org Git - lyx.git/blob - src/rowpainter.h
6a4561835aa07ab7fcc7c8a30785bf4d09717e3a
[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 "support/types.h"
18
19 namespace lyx {
20
21 class Bidi;
22 class BufferView;
23 class Font;
24 class PainterInfo;
25 class Paragraph;
26 class ParagraphList;
27 class ParagraphMetrics;
28 class Row;
29 class Text;
30 class TextMetrics;
31 class ViewMetricsInfo;
32
33 namespace frontend { class Painter; }
34
35 /**
36  * A class used for painting an individual row of text.
37  * FIXME: get rid of that class.
38  */
39 class RowPainter {
40 public:
41         /// initialise and run painter
42         RowPainter(PainterInfo & pi, Text const & text,
43                 pit_type pit, Row const & row, Bidi & bidi, int x, int y);
44
45         /// paint various parts
46         /// FIXME: transfer to TextMetrics
47         void paintAppendix();
48         void paintDepthBar();
49         void paintChangeBar();
50         void paintFirst();
51         void paintLast();
52         void paintText();
53
54 private:
55         void paintForeignMark(double orig_x, Font const & font, int desc = 0);
56         void paintHebrewComposeChar(pos_type & vpos, Font const & font);
57         void paintArabicComposeChar(pos_type & vpos, Font const & font);
58         void paintChars(pos_type & vpos, Font const & font,
59                         bool hebrew, bool arabic);
60         int paintAppendixStart(int y);
61         void paintFromPos(pos_type & vpos);
62         void paintInset(pos_type const pos, Font const & font);
63
64         /// return left margin
65         int leftMargin() const;
66
67         /// return the label font for this row
68         Font const getLabelFont() const;
69
70         /// bufferview to paint on
71         BufferView & bv_;
72
73         /// Painter to use
74         frontend::Painter & pain_;
75
76         /// Text for the row
77         Text const & text_;
78         TextMetrics & text_metrics_;
79         ParagraphList const & pars_;
80
81         /// The row to paint
82         Row const & row_;
83
84         /// Row's paragraph
85         pit_type const pit_;
86         Paragraph const & par_;
87         ParagraphMetrics const & pm_;
88
89         /// bidi cache, comes from outside the rowpainter because
90         /// rowpainters are normally created in a for loop and there only
91         /// one of them is active at a time.
92         Bidi & bidi_;
93
94         /// is row erased? (change tracking)
95         bool erased_;
96
97         // Looks ugly - is
98         double const xo_;
99         int const yo_;    // current baseline
100         double x_;
101         int width_;
102         double separator_;
103         double hfill_;
104         double label_hfill_;
105 };
106
107 /// some space for drawing the 'nested' markers (in pixel)
108 inline int nestMargin() { return 15; }
109
110 /// margin for changebar
111 inline int changebarMargin() { return 12; }
112
113 /// right margin
114 inline int rightMargin() { return 10; }
115
116 } // namespace lyx
117
118 #endif // ROWPAINTER_H