| 1 | ///////////////////////////////////////////////////////////////////////////////cxx . . $ `<file>/src/textprinter.h`/ |
| 2 | // textprinter.h |
| 3 | // ------------------- |
| 4 | // Copyright (c) 2007 David Johnson <[email protected]> |
| 5 | // All rights reserved. |
| 6 | // |
| 7 | // Redistribution and use in source and binary forms, with or without |
| 8 | // modification, are permitted provided that the following conditions |
| 9 | // are met: |
| 10 | // |
| 11 | // 1. Redistributions of source code must retain the above copyright |
| 12 | // notice, this list of conditions and the following disclaimer. |
| 13 | // |
| 14 | // 2. Redistributions in binary form must reproduce the above copyright |
| 15 | // notice, this list of conditions and the following disclaimer in the |
| 16 | // documentation and/or other materials provided with the distribution. |
| 17 | // |
| 18 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 | /////////////////////////////////////////////////////////////////////////////// |
| 30 | |
| 31 | #ifndef TEXTPRINTER_H |
| 32 | #define TEXTPRINTER_Hcxx . . $ `src/textprinter.h:32:9`! |
| 33 | |
| 34 | #include <QObject> |
| 35 | #include <QPrinter> |
| 36 | |
| 37 | class QTextDocumentcxx . . $ QTextDocument#; |
| 38 | class QWidgetcxx . . $ QWidget#; |
| 39 | |
| 40 | /////////////////////////////////////////////////////////////////////////////// |
| 41 | /// \class TextPrinter |
| 42 | /// \version 0.3 |
| 43 | /// |
| 44 | /// TextPrinter is a printing utility class. It provides methods to print, |
| 45 | /// preview, and export to PDF. The page format, including header and footers, |
| 46 | /// can be defined. The content to be printed is provided as a QTextDocument |
| 47 | /// object. |
| 48 | /////////////////////////////////////////////////////////////////////////////// |
| 49 | |
| 50 | class TextPrintercxx . . $ TextPrinter# : public QObjectcxx . . $ QObject# |
| 51 | { |
| 52 | Q_OBJECTcxx . . $ QMetaObject#Call# |
| 53 | public: |
| 54 | /// Default constructor |
| 55 | explicit TextPrintercxx . . $ TextPrinter#TextPrinter(749de1b6ae65bddd).(QObjectcxx . . $ QObject# *parent=0); |
| 56 | /// Destructor |
| 57 | ~cxx . . $ TextPrinter#`~TextPrinter`(ced63f7c635d850d).TextPrintercxx . . $ TextPrinter#(); |
| 58 | |
| 59 | /// Print the document |
| 60 | void printcxx . . $ TextPrinter#print(cbbf3cfeb0227921).(const QTextDocumentcxx . . $ QTextDocument# *document, |
| 61 | const QStringcxx . . $ QString# &caption=QStringcxx . . $ QString#QString(ced63f7c635d850d).()); |
| 62 | /// Export the document to PDF |
| 63 | void exportPdfcxx . . $ TextPrinter#exportPdf(760d0a8378c561f9).(const QTextDocumentcxx . . $ QTextDocument# *document, |
| 64 | const QStringcxx . . $ QString# &caption=QStringcxx . . $ QString#QString(ced63f7c635d850d).(), |
| 65 | const QStringcxx . . $ QString# &filename=QStringcxx . . $ QString#QString(ced63f7c635d850d).()); |
| 66 | /// Display the document in a preview dialog |
| 67 | void previewcxx . . $ TextPrinter#preview(cbbf3cfeb0227921).(const QTextDocumentcxx . . $ QTextDocument# *document, |
| 68 | const QStringcxx . . $ QString# &caption=QStringcxx . . $ QString#QString(ced63f7c635d850d).()); |
| 69 | |
| 70 | /// Get page size |
| 71 | QPrintercxx . . $ QPrinter#::PageSizecxx . . $ QPagedPaintDevice#PageSize# pageSizecxx . . $ TextPrinter#pageSize(61cb6e000139ab9e).() const; |
| 72 | /// Set page size |
| 73 | void setPageSizecxx . . $ TextPrinter#setPageSize(2d3228afb9a7f667).(QPrintercxx . . $ QPrinter#::PageSizecxx . . $ QPagedPaintDevice#PageSize# size); |
| 74 | /// Get page orientation |
| 75 | QPrintercxx . . $ QPrinter#::Orientationcxx . . $ QPrinter#Orientation# orientationcxx . . $ TextPrinter#orientation(a4823aa019839abf).() const; |
| 76 | /// Set page orientation |
| 77 | void setOrientationcxx . . $ TextPrinter#setOrientation(bebccd7395ab37d4).(QPrintercxx . . $ QPrinter#::Orientationcxx . . $ QPrinter#Orientation# orientation); |
| 78 | |
| 79 | /// Get left margin width |
| 80 | double leftMargincxx . . $ TextPrinter#leftMargin(21b6c25e127938e2).() const; |
| 81 | /// Set left margin width |
| 82 | void setLeftMargincxx . . $ TextPrinter#setLeftMargin(ba8836b59fb42830).(double margin); |
| 83 | /// Get right margin width |
| 84 | double rightMargincxx . . $ TextPrinter#rightMargin(21b6c25e127938e2).() const; |
| 85 | /// Set right margin width |
| 86 | void setRightMargincxx . . $ TextPrinter#setRightMargin(ba8836b59fb42830).(double margin); |
| 87 | /// Get top margin width |
| 88 | double topMargincxx . . $ TextPrinter#topMargin(21b6c25e127938e2).() const; |
| 89 | /// Set top margin width |
| 90 | void setTopMargincxx . . $ TextPrinter#setTopMargin(ba8836b59fb42830).(double margin); |
| 91 | /// Get bottom margin width |
| 92 | double bottomMargincxx . . $ TextPrinter#bottomMargin(21b6c25e127938e2).() const; |
| 93 | /// Set bottom margin width |
| 94 | void setBottomMargincxx . . $ TextPrinter#setBottomMargin(ba8836b59fb42830).(double margin); |
| 95 | /// Set all margins |
| 96 | void setMarginscxx . . $ TextPrinter#setMargins(ba8836b59fb42830).(double margin); |
| 97 | |
| 98 | /// Get spacing between content and header and footer |
| 99 | double spacingcxx . . $ TextPrinter#spacing(21b6c25e127938e2).() const; |
| 100 | /// Set spacing between content and header and footer |
| 101 | void setSpacingcxx . . $ TextPrinter#setSpacing(ba8836b59fb42830).(double spacing); |
| 102 | |
| 103 | /// Get header size |
| 104 | double headerSizecxx . . $ TextPrinter#headerSize(21b6c25e127938e2).() const; |
| 105 | /// Set header size |
| 106 | void setHeaderSizecxx . . $ TextPrinter#setHeaderSize(ba8836b59fb42830).(double size); |
| 107 | /// Set header rule size |
| 108 | double headerRulecxx . . $ TextPrinter#headerRule(21b6c25e127938e2).() const; |
| 109 | /// Get header rule size |
| 110 | void setHeaderRulecxx . . $ TextPrinter#setHeaderRule(ba8836b59fb42830).(double pointsize); |
| 111 | /// Get header text |
| 112 | const QStringcxx . . $ QString# &headerTextcxx . . $ TextPrinter#headerText(a2fb7a6ce195d51).() const; |
| 113 | /// Set header text |
| 114 | void setHeaderTextcxx . . $ TextPrinter#setHeaderText(3520e46b33348bf6).(const QStringcxx . . $ QString# &text); |
| 115 | |
| 116 | /// Get footer size |
| 117 | double footerSizecxx . . $ TextPrinter#footerSize(21b6c25e127938e2).() const; |
| 118 | /// Set footer size |
| 119 | void setFooterSizecxx . . $ TextPrinter#setFooterSize(ba8836b59fb42830).(double size); |
| 120 | /// Get footer rule size |
| 121 | double footerRulecxx . . $ TextPrinter#footerRule(21b6c25e127938e2).() const; |
| 122 | /// Set footer rule size |
| 123 | void setFooterRulecxx . . $ TextPrinter#setFooterRule(ba8836b59fb42830).(double pointsize); |
| 124 | /// Get footer text |
| 125 | const QStringcxx . . $ QString# &footerTextcxx . . $ TextPrinter#footerText(a2fb7a6ce195d51).() const; |
| 126 | /// Set footer text |
| 127 | void setFooterTextcxx . . $ TextPrinter#setFooterText(3520e46b33348bf6).(const QStringcxx . . $ QString# &text); |
| 128 | |
| 129 | /// Get date format |
| 130 | const QStringcxx . . $ QString# &dateFormatcxx . . $ TextPrinter#dateFormat(a2fb7a6ce195d51).() const; |
| 131 | /// Set date format |
| 132 | void setDateFormatcxx . . $ TextPrinter#setDateFormat(3520e46b33348bf6).(const QStringcxx . . $ QString# &format); |
| 133 | |
| 134 | private: |
| 135 | // not copyable |
| 136 | TextPrintercxx . . $ TextPrinter#TextPrinter(350a2ad3701a3537).(const TextPrintercxx . . $ TextPrinter#&); |
| 137 | TextPrintercxx . . $ TextPrinter# &operatorcxx . . $ TextPrinter#`operator=`(78a1a317dacdffb5).=(const TextPrintercxx . . $ TextPrinter#&); |
| 138 | |
| 139 | // return paper rect |
| 140 | QRectFcxx . . $ QRectF# paperRectcxx . . $ TextPrinter#paperRect(e8444818cd8ea5d7).(QPaintDevicecxx . . $ QPaintDevice# *device); |
| 141 | // return printable rects |
| 142 | QRectFcxx . . $ QRectF# contentRectcxx . . $ TextPrinter#contentRect(e8444818cd8ea5d7).(QPaintDevicecxx . . $ QPaintDevice# *device); |
| 143 | QRectFcxx . . $ QRectF# headerRectcxx . . $ TextPrinter#headerRect(e8444818cd8ea5d7).(QPaintDevicecxx . . $ QPaintDevice# *device); |
| 144 | QRectFcxx . . $ QRectF# footerRectcxx . . $ TextPrinter#footerRect(e8444818cd8ea5d7).(QPaintDevicecxx . . $ QPaintDevice# *device); |
| 145 | |
| 146 | // paint specific page |
| 147 | void paintPagecxx . . $ TextPrinter#paintPage(862c914bdbdf5904).(QPaintercxx . . $ QPainter# *painter, |
| 148 | QTextDocumentcxx . . $ QTextDocument# *document, |
| 149 | int pagenum); |
| 150 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 151 | // common print routine |
| 152 | void printcxx . . $ TextPrinter#print(7b1a7783bf77ba8d).(QPrintercxx . . $ QPrinter# *printer); |
| 153 | |
| 154 | private: |
| 155 | QWidgetcxx . . $ QWidget# *parent_cxx . . $ TextPrinter#parent_.; |
| 156 | QPrintercxx . . $ QPrinter# *printer_cxx . . $ TextPrinter#printer_.; |
| 157 | |
| 158 | QTextDocumentcxx . . $ QTextDocument# *tempdoc_cxx . . $ TextPrinter#tempdoc_.; |
| 159 | |
| 160 | double leftmargin_cxx . . $ TextPrinter#leftmargin_.; |
| 161 | double rightmargin_cxx . . $ TextPrinter#rightmargin_.; |
| 162 | double topmargin_cxx . . $ TextPrinter#topmargin_.; |
| 163 | double bottommargin_cxx . . $ TextPrinter#bottommargin_.; |
| 164 | double spacing_cxx . . $ TextPrinter#spacing_.; |
| 165 | |
| 166 | double headersize_cxx . . $ TextPrinter#headersize_.; |
| 167 | double headerrule_cxx . . $ TextPrinter#headerrule_.; |
| 168 | QStringcxx . . $ QString# headertext_cxx . . $ TextPrinter#headertext_.; |
| 169 | double footersize_cxx . . $ TextPrinter#footersize_.; |
| 170 | double footerrule_cxx . . $ TextPrinter#footerrule_.; |
| 171 | QStringcxx . . $ QString# footertext_cxx . . $ TextPrinter#footertext_.; |
| 172 | |
| 173 | QStringcxx . . $ QString# dateformat_cxx . . $ TextPrinter#dateformat_.; |
| 174 | }; |
| 175 | |
| 176 | #endif // TEXTPRINTER_H |