1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef PRINTOUT_H
5#define PRINTOUT_H
6
7#include <QFont>
8#include <QPainter>
9#include <QRect>
10#include <QTextOption>
11#include <QList>
12#include <QDateTime>
13
14QT_BEGIN_NAMESPACE
15
16class QPrinter;
17class QFontMetrics;
18
19class PrintOut
20{
21public:
22 enum Rule { NoRule, ThinRule, ThickRule };
23 enum Style { Normal, Strong, Emphasis };
24
25 PrintOut(QPrinter *printer);
26 ~PrintOut();
27
28 void setRule(Rule rule);
29 void setGuide(const QString &guide);
30 void vskip();
31 void flushLine(bool mayBreak = false);
32 void addBox(int percent, const QString &text = QString(),
33 Style style = Normal,
34 Qt::Alignment halign = Qt::AlignLeft);
35
36 int pageNum() const { return page; }
37
38 struct Box
39 {
40 QRect rect;
41 QString text;
42 QFont font;
43 QTextOption options;
44
45 Box( const QRect& r, const QString& t, const QFont& f, const QTextOption &o )
46 : rect( r ), text( t ), font( f ), options( o ) { }
47 };
48
49private:
50 void breakPage(bool init = false);
51 void drawRule( Rule rule );
52
53 struct Paragraph {
54 QRect rect;
55 QList<Box> boxes;
56
57 Paragraph() { }
58 Paragraph( QPoint p ) : rect( p, QSize(0, 0) ) { }
59 };
60
61 QPrinter *pr;
62 QPainter p;
63 QFont f8;
64 QFont f10;
65 QFontMetrics *fmetrics;
66 Rule nextRule;
67 Paragraph cp;
68 int page;
69 bool firstParagraph;
70 QString g;
71 QDateTime dateTime;
72
73 int hmargin;
74 int vmargin;
75 int voffset;
76 int hsize;
77 int vsize;
78};
79
80QT_END_NAMESPACE
81
82#endif
83

source code of qttools/src/linguist/linguist/printout.h