1 | /* |
2 | SPDX-FileCopyrightText: 2002-2010 Anders Lund <anders@alweb.dk> |
3 | |
4 | Rewritten based on code of: |
5 | SPDX-FileCopyrightText: 2002 Michael Goffioul <kdeprint@swing.be> |
6 | |
7 | SPDX-License-Identifier: LGPL-2.0-or-later |
8 | */ |
9 | |
10 | #ifndef KATE_PRINT_PAINTER_H |
11 | #define KATE_PRINT_PAINTER_H |
12 | |
13 | #include <QColor> |
14 | #include <QFont> |
15 | #include <QString> |
16 | |
17 | namespace KTextEditor |
18 | { |
19 | class DocumentPrivate; |
20 | class ViewPrivate; |
21 | } |
22 | |
23 | class QPrinter; |
24 | class QPainter; |
25 | |
26 | class KateRenderer; |
27 | |
28 | namespace Kate |
29 | { |
30 | class TextFolding; |
31 | } |
32 | namespace KTextEditor |
33 | { |
34 | class Range; |
35 | } |
36 | |
37 | namespace KatePrinter |
38 | { |
39 | class PageLayout; |
40 | |
41 | class PrintPainter |
42 | { |
43 | public: |
44 | PrintPainter(KTextEditor::DocumentPrivate *doc, KTextEditor::ViewPrivate *view); |
45 | ~PrintPainter(); |
46 | |
47 | PrintPainter(const PrintPainter &) = delete; |
48 | PrintPainter &operator=(const PrintPainter &) = delete; |
49 | |
50 | void paint(QPrinter *printer) const; |
51 | |
52 | // Attributes |
53 | void setColorScheme(const QString &scheme); |
54 | |
55 | void setPrintGuide(const bool on) |
56 | { |
57 | m_printGuide = on; |
58 | } |
59 | void setPrintLineNumbers(const bool on) |
60 | { |
61 | m_printLineNumbers = on; |
62 | } |
63 | void setDontPrintFoldedCode(bool p) |
64 | { |
65 | m_dontPrintFoldedCode = p; |
66 | } |
67 | void (const bool on) |
68 | { |
69 | m_useHeader = on; |
70 | } |
71 | void (const bool on) |
72 | { |
73 | m_useFooter = on; |
74 | } |
75 | void setUseBackground(const bool on) |
76 | { |
77 | m_useBackground = on; |
78 | } |
79 | void setUseBox(const bool on); |
80 | void setBoxMargin(const int margin) |
81 | { |
82 | m_boxMargin = margin; |
83 | } |
84 | void setBoxWidth(const int width); |
85 | void setBoxColor(const QColor &color); |
86 | void (const QFont &font) |
87 | { |
88 | m_fhFont = font; |
89 | } |
90 | void setTextFont(const QFont &font); |
91 | |
92 | void (const QColor &color); |
93 | void (const QColor &color); |
94 | void (const bool on) |
95 | { |
96 | m_useHeaderBackground = on; |
97 | } |
98 | |
99 | void (const QColor &color); |
100 | void (const QColor &color); |
101 | void (const bool on) |
102 | { |
103 | m_useFooterBackground = on; |
104 | } |
105 | |
106 | void (const QStringList &list) |
107 | { |
108 | m_headerFormat = list; |
109 | } |
110 | void (const QStringList &list) |
111 | { |
112 | m_footerFormat = list; |
113 | } |
114 | |
115 | private: |
116 | void paintLineNumber(QPainter &painter, const uint number, const PageLayout &pl) const; |
117 | void paintLine(QPainter &painter, const uint line, uint &y, uint &remainder, const PageLayout &pl) const; |
118 | void paintNewPage(QPainter &painter, const uint currentPage, uint &y, const PageLayout &pl) const; |
119 | |
120 | void paintBackground(QPainter &painter, const uint y, const PageLayout &pl) const; |
121 | void paintBox(QPainter &painter, uint &y, const PageLayout &pl) const; |
122 | void paintGuide(QPainter &painter, uint &y, const PageLayout &pl) const; |
123 | |
124 | void (QPainter &painter, const uint currentPage, uint &y, const PageLayout &pl) const; |
125 | void (QPainter &painter, const uint currentPage, const PageLayout &pl) const; |
126 | void configure(const QPrinter *printer, PageLayout &layout) const; |
127 | |
128 | void updateCache(); |
129 | |
130 | private: |
131 | KTextEditor::ViewPrivate *m_view; |
132 | KTextEditor::DocumentPrivate *m_doc; |
133 | |
134 | bool m_printGuide; |
135 | bool m_printLineNumbers; |
136 | bool m_dontPrintFoldedCode; |
137 | bool ; |
138 | bool ; |
139 | bool m_useBackground; |
140 | bool m_useBox; |
141 | bool ; |
142 | bool ; |
143 | |
144 | int m_boxMargin; |
145 | int m_boxWidth; |
146 | QColor m_boxColor; |
147 | |
148 | QColor ; |
149 | QColor ; |
150 | QColor ; |
151 | QColor ; |
152 | |
153 | QFont m_fhFont; |
154 | |
155 | QStringList ; |
156 | QStringList ; |
157 | |
158 | /* Internal vars */ |
159 | KateRenderer *m_renderer; |
160 | |
161 | int m_fontHeight; |
162 | uint m_lineNumberWidth; |
163 | }; |
164 | |
165 | } |
166 | |
167 | #endif |
168 | |