| 1 | /********************************************************************** | 
|---|
| 2 | ** $Id: qprinter.h 2 2005-11-16 15:49:26Z dmik $ | 
|---|
| 3 | ** | 
|---|
| 4 | ** Definition of QPrinter class | 
|---|
| 5 | ** | 
|---|
| 6 | ** Created : 940927 | 
|---|
| 7 | ** | 
|---|
| 8 | ** Copyright (C) 1992-2000 Trolltech AS.  All rights reserved. | 
|---|
| 9 | ** | 
|---|
| 10 | ** This file is part of the kernel module of the Qt GUI Toolkit. | 
|---|
| 11 | ** | 
|---|
| 12 | ** This file may be distributed under the terms of the Q Public License | 
|---|
| 13 | ** as defined by Trolltech AS of Norway and appearing in the file | 
|---|
| 14 | ** LICENSE.QPL included in the packaging of this file. | 
|---|
| 15 | ** | 
|---|
| 16 | ** This file may be distributed and/or modified under the terms of the | 
|---|
| 17 | ** GNU General Public License version 2 as published by the Free Software | 
|---|
| 18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 
|---|
| 19 | ** packaging of this file. | 
|---|
| 20 | ** | 
|---|
| 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | 
|---|
| 22 | ** licenses may use this file in accordance with the Qt Commercial License | 
|---|
| 23 | ** Agreement provided with the Software. | 
|---|
| 24 | ** | 
|---|
| 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 
|---|
| 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 
|---|
| 27 | ** | 
|---|
| 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 
|---|
| 29 | **   information about Qt Commercial License Agreements. | 
|---|
| 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 
|---|
| 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 
|---|
| 32 | ** | 
|---|
| 33 | ** Contact info@trolltech.com if any conditions of this licensing are | 
|---|
| 34 | ** not clear to you. | 
|---|
| 35 | ** | 
|---|
| 36 | **********************************************************************/ | 
|---|
| 37 |  | 
|---|
| 38 | #ifndef QPRINTER_H | 
|---|
| 39 | #define QPRINTER_H | 
|---|
| 40 |  | 
|---|
| 41 | #ifndef QT_H | 
|---|
| 42 | #include "qpaintdevice.h" | 
|---|
| 43 | #include "qstring.h" | 
|---|
| 44 | #include "qstringlist.h" | 
|---|
| 45 | #endif // QT_H | 
|---|
| 46 |  | 
|---|
| 47 | #ifndef QT_NO_PRINTER | 
|---|
| 48 |  | 
|---|
| 49 | #if defined(B0) | 
|---|
| 50 | #undef B0 // Terminal hang-up.  We assume that you do not want that. | 
|---|
| 51 | #endif | 
|---|
| 52 |  | 
|---|
| 53 | class QPrinterPrivate; | 
|---|
| 54 |  | 
|---|
| 55 | class Q_EXPORT QPrinter : public QPaintDevice | 
|---|
| 56 | { | 
|---|
| 57 | public: | 
|---|
| 58 | enum PrinterMode { ScreenResolution, PrinterResolution, HighResolution, Compatible }; | 
|---|
| 59 |  | 
|---|
| 60 | QPrinter( PrinterMode mode = ScreenResolution ); | 
|---|
| 61 | ~QPrinter(); | 
|---|
| 62 |  | 
|---|
| 63 | enum Orientation { Portrait, Landscape }; | 
|---|
| 64 |  | 
|---|
| 65 | enum PageSize    { A4, B5, Letter, Legal, Executive, | 
|---|
| 66 | A0, A1, A2, A3, A5, A6, A7, A8, A9, B0, B1, | 
|---|
| 67 | B10, B2, B3, B4, B6, B7, B8, B9, C5E, Comm10E, | 
|---|
| 68 | DLE, Folio, Ledger, Tabloid, Custom, NPageSize = Custom }; | 
|---|
| 69 |  | 
|---|
| 70 | enum PageOrder   { FirstPageFirst, LastPageFirst }; | 
|---|
| 71 |  | 
|---|
| 72 | enum ColorMode   { GrayScale, Color }; | 
|---|
| 73 |  | 
|---|
| 74 | enum PaperSource { OnlyOne, Lower, Middle, Manual, Envelope, | 
|---|
| 75 | EnvelopeManual, Auto, Tractor, SmallFormat, | 
|---|
| 76 | LargeFormat, LargeCapacity, Cassette, FormSource }; | 
|---|
| 77 |  | 
|---|
| 78 | enum PrintRange   { AllPages, | 
|---|
| 79 | Selection, | 
|---|
| 80 | PageRange }; | 
|---|
| 81 |  | 
|---|
| 82 | enum PrinterOption { PrintToFile, | 
|---|
| 83 | PrintSelection, | 
|---|
| 84 | PrintPageRange }; | 
|---|
| 85 |  | 
|---|
| 86 | QString printerName() const; | 
|---|
| 87 | virtual void setPrinterName( const QString &); | 
|---|
| 88 | bool outputToFile() const; | 
|---|
| 89 | virtual void setOutputToFile( bool ); | 
|---|
| 90 | QString outputFileName()const; | 
|---|
| 91 | virtual void setOutputFileName( const QString &); | 
|---|
| 92 |  | 
|---|
| 93 | QString printProgram() const; | 
|---|
| 94 | virtual void setPrintProgram( const QString &); | 
|---|
| 95 |  | 
|---|
| 96 | QString printerSelectionOption() const; | 
|---|
| 97 | virtual void setPrinterSelectionOption( const QString & ); | 
|---|
| 98 |  | 
|---|
| 99 | QString docName() const; | 
|---|
| 100 | virtual void setDocName( const QString &); | 
|---|
| 101 | QString creator() const; | 
|---|
| 102 | virtual void setCreator( const QString &); | 
|---|
| 103 |  | 
|---|
| 104 | Orientation orientation()   const; | 
|---|
| 105 | virtual void setOrientation( Orientation ); | 
|---|
| 106 | PageSize pageSize()      const; | 
|---|
| 107 | virtual void setPageSize( PageSize ); | 
|---|
| 108 | #ifdef Q_WS_WIN | 
|---|
| 109 | void setWinPageSize( short winPageSize ); | 
|---|
| 110 | short winPageSize() const; | 
|---|
| 111 | #endif | 
|---|
| 112 | #ifdef Q_WS_MAC | 
|---|
| 113 | bool printSetup(); | 
|---|
| 114 | bool pageSetup(); | 
|---|
| 115 | #endif | 
|---|
| 116 | virtual void setPageOrder( PageOrder ); | 
|---|
| 117 | PageOrder   pageOrder() const; | 
|---|
| 118 |  | 
|---|
| 119 | void setResolution( int ); | 
|---|
| 120 | int resolution() const; | 
|---|
| 121 |  | 
|---|
| 122 | virtual void setColorMode( ColorMode ); | 
|---|
| 123 | ColorMode   colorMode() const; | 
|---|
| 124 |  | 
|---|
| 125 | virtual void        setFullPage( bool ); | 
|---|
| 126 | bool                fullPage() const; | 
|---|
| 127 | QSize       margins()       const; | 
|---|
| 128 | void setMargins( uint top, uint left, uint bottom, uint right ); | 
|---|
| 129 | void margins( uint *top, uint *left, uint *bottom, uint *right ) const; | 
|---|
| 130 |  | 
|---|
| 131 | int         fromPage()      const; | 
|---|
| 132 | int         toPage()        const; | 
|---|
| 133 | virtual void setFromTo( int fromPage, int toPage ); | 
|---|
| 134 | int         minPage()       const; | 
|---|
| 135 | int         maxPage()       const; | 
|---|
| 136 | virtual void setMinMax( int minPage, int maxPage ); | 
|---|
| 137 | int         numCopies()     const; | 
|---|
| 138 | virtual void setNumCopies( int ); | 
|---|
| 139 |  | 
|---|
| 140 | bool        collateCopiesEnabled() const; | 
|---|
| 141 | void        setCollateCopiesEnabled(bool ); | 
|---|
| 142 |  | 
|---|
| 143 | bool        collateCopies() const; | 
|---|
| 144 | void        setCollateCopies( bool ); | 
|---|
| 145 |  | 
|---|
| 146 | PrintRange  printRange() const; | 
|---|
| 147 | void        setPrintRange( PrintRange range ); | 
|---|
| 148 |  | 
|---|
| 149 | bool        newPage(); | 
|---|
| 150 | bool        abort(); | 
|---|
| 151 | bool        aborted()       const; | 
|---|
| 152 |  | 
|---|
| 153 | bool        setup( QWidget *parent = 0 ); | 
|---|
| 154 |  | 
|---|
| 155 | PaperSource paperSource()   const; | 
|---|
| 156 | virtual void setPaperSource( PaperSource ); | 
|---|
| 157 |  | 
|---|
| 158 | void setOptionEnabled( PrinterOption, bool enable ); | 
|---|
| 159 | bool isOptionEnabled( PrinterOption ); | 
|---|
| 160 |  | 
|---|
| 161 | protected: | 
|---|
| 162 | bool        cmd( int, QPainter *, QPDevCmdParam * ); | 
|---|
| 163 | int         metric( int ) const; | 
|---|
| 164 |  | 
|---|
| 165 | #if defined(Q_WS_WIN) | 
|---|
| 166 | virtual void        setActive(); | 
|---|
| 167 | virtual void        setIdle(); | 
|---|
| 168 | #endif | 
|---|
| 169 |  | 
|---|
| 170 | private: | 
|---|
| 171 | #if defined(Q_WS_X11) || defined(Q_WS_QWS) | 
|---|
| 172 | QPaintDevice *pdrv; | 
|---|
| 173 | int         pid; | 
|---|
| 174 | #endif | 
|---|
| 175 | #if defined(Q_WS_MAC) | 
|---|
| 176 | friend class QPrinterPrivate; | 
|---|
| 177 | PMPageFormat pformat; | 
|---|
| 178 | PMPrintSettings psettings; | 
|---|
| 179 | PMPrintSession psession; | 
|---|
| 180 | bool prepare(PMPrintSettings *); | 
|---|
| 181 | bool prepare(PMPageFormat *); | 
|---|
| 182 | void interpret(PMPrintSettings *); | 
|---|
| 183 | void interpret(PMPageFormat *); | 
|---|
| 184 | #endif | 
|---|
| 185 | #if defined(Q_WS_WIN) | 
|---|
| 186 | void        readPdlg( void* ); | 
|---|
| 187 | void        readPdlgA( void* ); | 
|---|
| 188 | void        writeDevmode( Qt::HANDLE ); | 
|---|
| 189 | void        writeDevmodeA( Qt::HANDLE ); | 
|---|
| 190 | void        reinit(); | 
|---|
| 191 |  | 
|---|
| 192 | bool        viewOffsetDone; | 
|---|
| 193 | QPainter*   painter; | 
|---|
| 194 | Qt::HANDLE hdevmode; | 
|---|
| 195 | Qt::HANDLE hdevnames; | 
|---|
| 196 | #endif | 
|---|
| 197 |  | 
|---|
| 198 | int         state; | 
|---|
| 199 | QString     printer_name; | 
|---|
| 200 | QString     option_string; | 
|---|
| 201 | QString     output_filename; | 
|---|
| 202 | bool        output_file; | 
|---|
| 203 | QString     print_prog; | 
|---|
| 204 | QString     doc_name; | 
|---|
| 205 | QString     creator_name; | 
|---|
| 206 |  | 
|---|
| 207 | PageSize    page_size; | 
|---|
| 208 | PaperSource paper_source; | 
|---|
| 209 | PageOrder   page_order; | 
|---|
| 210 | ColorMode   color_mode; | 
|---|
| 211 | Orientation orient; | 
|---|
| 212 | uint        to_edge : 1; | 
|---|
| 213 | uint        appcolcopies : 1; | 
|---|
| 214 | uint        usercolcopies : 1; | 
|---|
| 215 | uint        res_set : 1; | 
|---|
| 216 | short       from_pg, to_pg; | 
|---|
| 217 | short       min_pg,  max_pg; | 
|---|
| 218 | short       ncopies; | 
|---|
| 219 | int         res; | 
|---|
| 220 | QPrinterPrivate *d; | 
|---|
| 221 |  | 
|---|
| 222 | private:        // Disabled copy constructor and operator= | 
|---|
| 223 | #if defined(Q_DISABLE_COPY) | 
|---|
| 224 | QPrinter( const QPrinter & ); | 
|---|
| 225 | QPrinter &operator=( const QPrinter & ); | 
|---|
| 226 | #endif | 
|---|
| 227 | }; | 
|---|
| 228 |  | 
|---|
| 229 |  | 
|---|
| 230 | inline QString QPrinter::printerName() const | 
|---|
| 231 | { return printer_name; } | 
|---|
| 232 |  | 
|---|
| 233 | inline bool QPrinter::outputToFile() const | 
|---|
| 234 | { return output_file; } | 
|---|
| 235 |  | 
|---|
| 236 | inline QString QPrinter::outputFileName() const | 
|---|
| 237 | { return output_filename; } | 
|---|
| 238 |  | 
|---|
| 239 | inline QString QPrinter::printProgram() const | 
|---|
| 240 | { return print_prog; } | 
|---|
| 241 |  | 
|---|
| 242 | inline QString QPrinter::docName() const | 
|---|
| 243 | { return doc_name; } | 
|---|
| 244 |  | 
|---|
| 245 | inline QString QPrinter::creator() const | 
|---|
| 246 | { return creator_name; } | 
|---|
| 247 |  | 
|---|
| 248 | inline QPrinter::PageSize QPrinter::pageSize() const | 
|---|
| 249 | { return page_size; } | 
|---|
| 250 |  | 
|---|
| 251 | inline QPrinter::Orientation QPrinter::orientation() const | 
|---|
| 252 | { return orient; } | 
|---|
| 253 |  | 
|---|
| 254 | inline int QPrinter::fromPage() const | 
|---|
| 255 | { return from_pg; } | 
|---|
| 256 |  | 
|---|
| 257 | inline int QPrinter::toPage() const | 
|---|
| 258 | { return to_pg; } | 
|---|
| 259 |  | 
|---|
| 260 | inline int QPrinter::minPage() const | 
|---|
| 261 | { return min_pg; } | 
|---|
| 262 |  | 
|---|
| 263 | inline int QPrinter::maxPage() const | 
|---|
| 264 | { return max_pg; } | 
|---|
| 265 |  | 
|---|
| 266 | inline int QPrinter::numCopies() const | 
|---|
| 267 | { return ncopies; } | 
|---|
| 268 |  | 
|---|
| 269 | inline bool QPrinter::collateCopiesEnabled() const | 
|---|
| 270 | { return appcolcopies; } | 
|---|
| 271 |  | 
|---|
| 272 | inline void QPrinter::setCollateCopiesEnabled(bool v) | 
|---|
| 273 | { appcolcopies = v; } | 
|---|
| 274 |  | 
|---|
| 275 | inline bool QPrinter::collateCopies() const | 
|---|
| 276 | { return usercolcopies; } | 
|---|
| 277 |  | 
|---|
| 278 |  | 
|---|
| 279 | #endif // QT_NO_PRINTER | 
|---|
| 280 |  | 
|---|
| 281 | #endif // QPRINTER_H | 
|---|