1 | /**********************************************************************
|
---|
2 | ** Copyright (C) 2000-2007 Trolltech ASA. All rights reserved.
|
---|
3 | **
|
---|
4 | ** This file is part of Qt Linguist.
|
---|
5 | **
|
---|
6 | ** This file may be distributed and/or modified under the terms of the
|
---|
7 | ** GNU General Public License version 2 as published by the Free Software
|
---|
8 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
9 | ** packaging of this file.
|
---|
10 | **
|
---|
11 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
12 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
13 | ** Agreement provided with the Software.
|
---|
14 | **
|
---|
15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
17 | **
|
---|
18 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
19 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
20 | ** information about Qt Commercial License Agreements.
|
---|
21 | **
|
---|
22 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
23 | ** not clear to you.
|
---|
24 | **
|
---|
25 | **********************************************************************/
|
---|
26 |
|
---|
27 | #ifndef PRINTOUT_H
|
---|
28 | #define PRINTOUT_H
|
---|
29 |
|
---|
30 | #include <qfont.h>
|
---|
31 | #include <qpaintdevicemetrics.h>
|
---|
32 | #include <qpainter.h>
|
---|
33 | #include <qrect.h>
|
---|
34 | #include <qvaluelist.h>
|
---|
35 | #include <qdatetime.h>
|
---|
36 |
|
---|
37 | class QPrinter;
|
---|
38 | class QFontMetrics;
|
---|
39 |
|
---|
40 | class PrintOut
|
---|
41 | {
|
---|
42 | public:
|
---|
43 | enum Rule { NoRule, ThinRule, ThickRule };
|
---|
44 | enum Style { Normal, Strong, Emphasis };
|
---|
45 |
|
---|
46 | PrintOut( QPrinter *printer );
|
---|
47 | ~PrintOut();
|
---|
48 |
|
---|
49 | void setRule( Rule rule );
|
---|
50 | void setGuide( const QString& guide );
|
---|
51 | void vskip();
|
---|
52 | void flushLine( bool mayBreak = FALSE );
|
---|
53 | void addBox( int percent, const QString& text = QString::null,
|
---|
54 | Style style = Normal,
|
---|
55 | int halign = Qt::AlignLeft | Qt::WordBreak );
|
---|
56 |
|
---|
57 | int pageNum() const { return page; }
|
---|
58 |
|
---|
59 | struct Box
|
---|
60 | {
|
---|
61 | QRect rect;
|
---|
62 | QString text;
|
---|
63 | QFont font;
|
---|
64 | int align;
|
---|
65 |
|
---|
66 | Box() : align( 0 ) { }
|
---|
67 | Box( const QRect& r, const QString& t, const QFont& f, int a )
|
---|
68 | : rect( r ), text( t ), font( f ), align( a ) { }
|
---|
69 | Box( const Box& b )
|
---|
70 | : rect( b.rect ), text( b.text ), font( b.font ),
|
---|
71 | align( b.align ) { }
|
---|
72 |
|
---|
73 | Box& operator=( const Box& b ) {
|
---|
74 | rect = b.rect;
|
---|
75 | text = b.text;
|
---|
76 | font = b.font;
|
---|
77 | align = b.align;
|
---|
78 | return *this;
|
---|
79 | }
|
---|
80 |
|
---|
81 | bool operator==( const Box& b ) const {
|
---|
82 | return rect == b.rect && text == b.text && font == b.font &&
|
---|
83 | align == b.align;
|
---|
84 | }
|
---|
85 | };
|
---|
86 |
|
---|
87 | private:
|
---|
88 | void breakPage();
|
---|
89 | void drawRule( Rule rule );
|
---|
90 |
|
---|
91 | struct Paragraph {
|
---|
92 | QRect rect;
|
---|
93 | QValueList<Box> boxes;
|
---|
94 |
|
---|
95 | Paragraph() { }
|
---|
96 | Paragraph( QPoint p ) : rect( p, QSize(0, 0) ) { }
|
---|
97 | };
|
---|
98 |
|
---|
99 | QPrinter *pr;
|
---|
100 | QPainter p;
|
---|
101 | QFont f8;
|
---|
102 | QFont f10;
|
---|
103 | QFontMetrics *fmetrics;
|
---|
104 | QPaintDeviceMetrics pdmetrics;
|
---|
105 | Rule nextRule;
|
---|
106 | Paragraph cp;
|
---|
107 | int page;
|
---|
108 | bool firstParagraph;
|
---|
109 | QString g;
|
---|
110 | QDateTime dateTime;
|
---|
111 |
|
---|
112 | int hmargin;
|
---|
113 | int vmargin;
|
---|
114 | int voffset;
|
---|
115 | int hsize;
|
---|
116 | int vsize;
|
---|
117 | };
|
---|
118 |
|
---|
119 | #endif
|
---|