00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef QPRINTER_H
00025 #define QPRINTER_H
00026
00027 #include <QtGui/qpaintdevice.h>
00028 #include <QtCore/qstring.h>
00029
00030 QT_BEGIN_HEADER
00031
00032 QT_MODULE(Gui)
00033
00034 #ifndef QT_NO_PRINTER
00035
00036 #if defined(B0)
00037 #undef B0 // Terminal hang-up. We assume that you do not want that.
00038 #endif
00039
00040 class QPrinterPrivate;
00041 class QPaintEngine;
00042 class QPrintEngine;
00043
00044 class Q_GUI_EXPORT QPrinter : public QPaintDevice
00045 {
00046 Q_DECLARE_PRIVATE(QPrinter)
00047 public:
00048 enum PrinterMode { ScreenResolution, PrinterResolution, HighResolution };
00049
00050 explicit QPrinter(PrinterMode mode = ScreenResolution);
00051 ~QPrinter();
00052
00053 int devType() const;
00054
00055 enum Orientation { Portrait, Landscape };
00056
00057 enum PageSize { A4, B5, Letter, Legal, Executive,
00058 A0, A1, A2, A3, A5, A6, A7, A8, A9, B0, B1,
00059 B10, B2, B3, B4, B6, B7, B8, B9, C5E, Comm10E,
00060 DLE, Folio, Ledger, Tabloid, Custom, NPageSize = Custom };
00061
00062 enum PageOrder { FirstPageFirst,
00063 LastPageFirst };
00064
00065 enum ColorMode { GrayScale,
00066 Color };
00067
00068 enum PaperSource { OnlyOne,
00069 Lower,
00070 Middle,
00071 Manual,
00072 Envelope,
00073 EnvelopeManual,
00074 Auto,
00075 Tractor,
00076 SmallFormat,
00077 LargeFormat,
00078 LargeCapacity,
00079 Cassette,
00080 FormSource };
00081
00082 enum PrinterState { Idle,
00083 Active,
00084 Aborted,
00085 Error };
00086
00087 enum OutputFormat { NativeFormat, PdfFormat, PostScriptFormat };
00088
00089
00090 enum PrintRange { AllPages, Selection, PageRange };
00091
00092 #ifdef QT3_SUPPORT
00093 enum PrinterOption { PrintToFile, PrintSelection, PrintPageRange };
00094 #endif // QT3_SUPPORT
00095
00096 void setOutputFormat(OutputFormat format);
00097 OutputFormat outputFormat() const;
00098
00099 void setPrinterName(const QString &);
00100 QString printerName() const;
00101
00102 void setOutputFileName(const QString &);
00103 QString outputFileName()const;
00104
00105 void setPrintProgram(const QString &);
00106 QString printProgram() const;
00107
00108 void setDocName(const QString &);
00109 QString docName() const;
00110
00111 void setCreator(const QString &);
00112 QString creator() const;
00113
00114 void setOrientation(Orientation);
00115 Orientation orientation() const;
00116
00117 void setPageSize(PageSize);
00118 PageSize pageSize() const;
00119
00120 void setPageOrder(PageOrder);
00121 PageOrder pageOrder() const;
00122
00123 void setResolution(int);
00124 int resolution() const;
00125
00126 void setColorMode(ColorMode);
00127 ColorMode colorMode() const;
00128
00129 void setCollateCopies(bool collate);
00130 bool collateCopies() const;
00131
00132 void setFullPage(bool);
00133 bool fullPage() const;
00134
00135 void setNumCopies(int);
00136 int numCopies() const;
00137
00138 void setPaperSource(PaperSource);
00139 PaperSource paperSource() const;
00140
00141 QList<int> supportedResolutions() const;
00142
00143 void setFontEmbeddingEnabled(bool enable);
00144 bool fontEmbeddingEnabled() const;
00145
00146 void setDoubleSidedPrinting(bool enable);
00147 bool doubleSidedPrinting() const;
00148
00149 #ifdef Q_WS_WIN
00150 void setWinPageSize(int winPageSize);
00151 int winPageSize() const;
00152 #endif
00153
00154 QRect paperRect() const;
00155 QRect pageRect() const;
00156
00157 #if !defined(Q_WS_WIN) || defined(qdoc)
00158 QString printerSelectionOption() const;
00159 void setPrinterSelectionOption(const QString &);
00160 #endif
00161
00162 bool newPage();
00163 bool abort();
00164
00165 PrinterState printerState() const;
00166
00167 QPaintEngine *paintEngine() const;
00168 QPrintEngine *printEngine() const;
00169
00170 #ifdef Q_WS_WIN
00171 HDC getDC() const;
00172 void releaseDC(HDC hdc) const;
00173 #endif
00174
00175 void setFromTo(int fromPage, int toPage);
00176 int fromPage() const;
00177 int toPage() const;
00178
00179 #ifndef QT_NO_PRINTDIALOG
00180 void setPrintRange(PrintRange range);
00181 PrintRange printRange() const;
00182 #endif
00183
00184 #ifdef QT3_SUPPORT
00185 #ifdef Q_WS_MAC
00186 QT3_SUPPORT bool pageSetup(QWidget *parent = 0);
00187 QT3_SUPPORT bool printSetup(QWidget *parent = 0);
00188 #endif
00189
00190 QT3_SUPPORT bool setup(QWidget *parent = 0);
00191
00192 QT3_SUPPORT void setMinMax(int minPage, int maxPage);
00193 QT3_SUPPORT int minPage() const;
00194 QT3_SUPPORT int maxPage() const;
00195
00196 QT3_SUPPORT void setCollateCopiesEnabled(bool);
00197 QT3_SUPPORT bool collateCopiesEnabled() const;
00198
00199 QT3_SUPPORT void setOptionEnabled(PrinterOption, bool enable);
00200 QT3_SUPPORT bool isOptionEnabled(PrinterOption) const;
00201
00202 inline QT3_SUPPORT QSize margins() const;
00203 inline QT3_SUPPORT void margins(uint *top, uint *left, uint *bottom, uint *right) const;
00204
00205 inline QT3_SUPPORT bool aborted() { return printerState() == Aborted; }
00206
00207 QT3_SUPPORT void setOutputToFile(bool);
00208 inline QT3_SUPPORT bool outputToFile() const { return !outputFileName().isEmpty(); }
00209 #endif
00210
00211 protected:
00212 int metric(PaintDeviceMetric) const;
00213 void setEngines(QPrintEngine *printEngine, QPaintEngine *paintEngine);
00214
00215 private:
00216 Q_DISABLE_COPY(QPrinter)
00217
00218 QPrinterPrivate *d_ptr;
00219
00220 friend class QPrintDialogWin;
00221 friend class QAbstractPrintDialog;
00222 };
00223
00224 #ifdef QT3_SUPPORT
00225 inline QSize QPrinter::margins() const
00226 {
00227 QRect page = pageRect();
00228 QRect paper = paperRect();
00229 return QSize(page.left() - paper.left(), page.top() - paper.top());
00230 }
00231
00232 inline void QPrinter::margins(uint *top, uint *left, uint *bottom, uint *right) const
00233 {
00234 QRect page = pageRect();
00235 QRect paper = paperRect();
00236 if (top)
00237 *top = page.top() - paper.top();
00238 if (left)
00239 *left = page.left() - paper.left();
00240 if (bottom)
00241 *bottom = paper.bottom() - page.bottom();
00242 if (right)
00243 *right = paper.right() - page.right();
00244 }
00245 #endif
00246
00247 #endif // QT_NO_PRINTER
00248
00249 QT_END_HEADER
00250
00251 #endif // QPRINTER_H