Eneboo - Documentación para desarrolladores
|
00001 /********************************************************************** 00002 ** Copyright (C) 2000-2005 Trolltech AS. All rights reserved. 00003 ** 00004 ** This file is part of Qt Linguist. 00005 ** 00006 ** This file may be distributed and/or modified under the terms of the 00007 ** GNU General Public License version 2 as published by the Free Software 00008 ** Foundation and appearing in the file LICENSE.GPL included in the 00009 ** packaging of this file. 00010 ** 00011 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition 00012 ** licenses may use this file in accordance with the Qt Commercial License 00013 ** Agreement provided with the Software. 00014 ** 00015 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 00016 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00017 ** 00018 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 00019 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for 00020 ** information about Qt Commercial License Agreements. 00021 ** 00022 ** Contact info@trolltech.com if any conditions of this licensing are 00023 ** not clear to you. 00024 ** 00025 **********************************************************************/ 00026 00027 #ifndef PRINTOUT_H 00028 #define PRINTOUT_H 00029 00030 #include <qfont.h> 00031 #include <qpaintdevicemetrics.h> 00032 #include <qpainter.h> 00033 #include <qrect.h> 00034 #include <qvaluelist.h> 00035 #include <qdatetime.h> 00036 00037 class QPrinter; 00038 class QFontMetrics; 00039 00040 class PrintOut 00041 { 00042 public: 00043 enum Rule { NoRule, ThinRule, ThickRule }; 00044 enum Style { Normal, Strong, Emphasis }; 00045 00046 PrintOut( QPrinter *printer ); 00047 ~PrintOut(); 00048 00049 void setRule( Rule rule ); 00050 void setGuide( const QString& guide ); 00051 void vskip(); 00052 void flushLine( bool mayBreak = FALSE ); 00053 void addBox( int percent, const QString& text = QString::null, 00054 Style style = Normal, 00055 int halign = Qt::AlignLeft | Qt::WordBreak ); 00056 00057 int pageNum() const { return page; } 00058 00059 struct Box 00060 { 00061 QRect rect; 00062 QString text; 00063 QFont font; 00064 int align; 00065 00066 Box() : align( 0 ) { } 00067 Box( const QRect& r, const QString& t, const QFont& f, int a ) 00068 : rect( r ), text( t ), font( f ), align( a ) { } 00069 Box( const Box& b ) 00070 : rect( b.rect ), text( b.text ), font( b.font ), 00071 align( b.align ) { } 00072 00073 Box& operator=( const Box& b ) { 00074 rect = b.rect; 00075 text = b.text; 00076 font = b.font; 00077 align = b.align; 00078 return *this; 00079 } 00080 00081 bool operator==( const Box& b ) const { 00082 return rect == b.rect && text == b.text && font == b.font && 00083 align == b.align; 00084 } 00085 }; 00086 00087 private: 00088 void breakPage(); 00089 void drawRule( Rule rule ); 00090 00091 struct Paragraph { 00092 QRect rect; 00093 QValueList<Box> boxes; 00094 00095 Paragraph() { } 00096 Paragraph( QPoint p ) : rect( p, QSize(0, 0) ) { } 00097 }; 00098 00099 QPrinter *pr; 00100 QPainter p; 00101 QFont f8; 00102 QFont f10; 00103 QFontMetrics *fmetrics; 00104 QPaintDeviceMetrics pdmetrics; 00105 Rule nextRule; 00106 Paragraph cp; 00107 int page; 00108 bool firstParagraph; 00109 QString g; 00110 QDateTime dateTime; 00111 00112 int hmargin; 00113 int vmargin; 00114 int voffset; 00115 int hsize; 00116 int vsize; 00117 }; 00118 00119 #endif