1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Linguist of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#ifndef PRINTOUT_H
30#define PRINTOUT_H
31
32#include <QFont>
33#include <QPainter>
34#include <QRect>
35#include <QTextOption>
36#include <QList>
37#include <QDateTime>
38
39QT_BEGIN_NAMESPACE
40
41class QPrinter;
42class QFontMetrics;
43
44class PrintOut
45{
46public:
47 enum Rule { NoRule, ThinRule, ThickRule };
48 enum Style { Normal, Strong, Emphasis };
49
50 PrintOut(QPrinter *printer);
51 ~PrintOut();
52
53 void setRule(Rule rule);
54 void setGuide(const QString &guide);
55 void vskip();
56 void flushLine(bool mayBreak = false);
57 void addBox(int percent, const QString &text = QString(),
58 Style style = Normal,
59 Qt::Alignment halign = Qt::AlignLeft);
60
61 int pageNum() const { return page; }
62
63 struct Box
64 {
65 QRect rect;
66 QString text;
67 QFont font;
68 QTextOption options;
69
70 Box( const QRect& r, const QString& t, const QFont& f, const QTextOption &o )
71 : rect( r ), text( t ), font( f ), options( o ) { }
72 };
73
74private:
75 void breakPage(bool init = false);
76 void drawRule( Rule rule );
77
78 struct Paragraph {
79 QRect rect;
80 QList<Box> boxes;
81
82 Paragraph() { }
83 Paragraph( QPoint p ) : rect( p, QSize(0, 0) ) { }
84 };
85
86 QPrinter *pr;
87 QPainter p;
88 QFont f8;
89 QFont f10;
90 QFontMetrics *fmetrics;
91 Rule nextRule;
92 Paragraph cp;
93 int page;
94 bool firstParagraph;
95 QString g;
96 QDateTime dateTime;
97
98 int hmargin;
99 int vmargin;
100 int voffset;
101 int hsize;
102 int vsize;
103};
104
105QT_END_NAMESPACE
106
107#endif
108

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