KTextEditor

printpainter.h
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
17namespace KTextEditor
18{
19class DocumentPrivate;
20class ViewPrivate;
21}
22
23class QPrinter;
24class QPainter;
25
26class KateRenderer;
27
28namespace Kate
29{
30class TextFolding;
31}
32namespace KTextEditor
33{
34class Range;
35}
36
37namespace KatePrinter
38{
39class PageLayout;
40
41class PrintPainter
42{
43public:
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 setUseHeader(const bool on)
68 {
69 m_useHeader = on;
70 }
71 void setUseFooter(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 setHeadersFont(const QFont &font)
87 {
88 m_fhFont = font;
89 }
90 void setTextFont(const QFont &font);
91
92 void setHeaderBackground(const QColor &color);
93 void setHeaderForeground(const QColor &color);
94 void setUseHeaderBackground(const bool on)
95 {
96 m_useHeaderBackground = on;
97 }
98
99 void setFooterBackground(const QColor &color);
100 void setFooterForeground(const QColor &color);
101 void setUseFooterBackground(const bool on)
102 {
103 m_useFooterBackground = on;
104 }
105
106 void setHeaderFormat(const QStringList &list)
107 {
108 m_headerFormat = list;
109 }
110 void setFooterFormat(const QStringList &list)
111 {
112 m_footerFormat = list;
113 }
114
115private:
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 paintHeader(QPainter &painter, const uint currentPage, uint &y, const PageLayout &pl) const;
125 void paintFooter(QPainter &painter, const uint currentPage, const PageLayout &pl) const;
126 void configure(const QPrinter *printer, PageLayout &layout) const;
127
128 void updateCache();
129
130private:
131 const KTextEditor::ViewPrivate *const m_view;
132 const KTextEditor::DocumentPrivate *const m_doc;
133
134 bool m_printGuide;
135 bool m_printLineNumbers;
136 bool m_dontPrintFoldedCode;
137 bool m_useHeader;
138 bool m_useFooter;
139 bool m_useBackground;
140 bool m_useBox;
141 bool m_useHeaderBackground;
142 bool m_useFooterBackground;
143
144 int m_boxMargin;
145 int m_boxWidth;
146 QColor m_boxColor;
147
148 QColor m_headerBackground;
149 QColor m_headerForeground;
150 QColor m_footerBackground;
151 QColor m_footerForeground;
152
153 QFont m_fhFont;
154
155 QStringList m_headerFormat;
156 QStringList m_footerFormat;
157
158 /* Internal vars */
159 KateRenderer *m_renderer;
160
161 int m_fontHeight;
162 uint m_lineNumberWidth;
163};
164
165}
166
167#endif
Backend of KTextEditor::Document related public KTextEditor interfaces.
Handles all of the work of rendering the text (used for the views and printing)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
The KTextEditor namespace contains all the public API that is required to use the KTextEditor compone...
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:56:00 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.