PageRenderTime 47ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/qtbase/src/plugins/platforms/cocoa/qprintengine_mac_p.h

https://review.tizen.org/git/
C Header | 160 lines | 86 code | 23 blank | 51 comment | 1 complexity | 86ba94ea0c036e96894e63cf25645a8c MD5 | raw file
Possible License(s): GPL-3.0, AGPL-3.0, GPL-2.0, MPL-2.0, JSON, WTFPL, CC-BY-SA-4.0, CC-BY-3.0, BSD-3-Clause, LGPL-2.0, MPL-2.0-no-copyleft-exception, AGPL-1.0, 0BSD, Zlib, Unlicense, BSD-2-Clause, Apache-2.0, LGPL-3.0, ISC, MIT, CC-BY-SA-3.0, CC0-1.0, LGPL-2.1
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
  4. ** Contact: http://www.qt-project.org/
  5. **
  6. ** This file is part of the plugins of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:LGPL$
  9. ** GNU Lesser General Public License Usage
  10. ** This file may be used under the terms of the GNU Lesser General Public
  11. ** License version 2.1 as published by the Free Software Foundation and
  12. ** appearing in the file LICENSE.LGPL included in the packaging of this
  13. ** file. Please review the following information to ensure the GNU Lesser
  14. ** General Public License version 2.1 requirements will be met:
  15. ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
  16. **
  17. ** In addition, as a special exception, Nokia gives you certain additional
  18. ** rights. These rights are described in the Nokia Qt LGPL Exception
  19. ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
  20. **
  21. ** GNU General Public License Usage
  22. ** Alternatively, this file may be used under the terms of the GNU General
  23. ** Public License version 3.0 as published by the Free Software Foundation
  24. ** and appearing in the file LICENSE.GPL included in the packaging of this
  25. ** file. Please review the following information to ensure the GNU General
  26. ** Public License version 3.0 requirements will be met:
  27. ** http://www.gnu.org/copyleft/gpl.html.
  28. **
  29. ** Other Usage
  30. ** Alternatively, this file may be used in accordance with the terms and
  31. ** conditions contained in a signed written agreement between you and Nokia.
  32. **
  33. **
  34. **
  35. **
  36. **
  37. **
  38. ** $QT_END_LICENSE$
  39. **
  40. ****************************************************************************/
  41. #ifndef QPRINTENGINE_MAC_P_H
  42. #define QPRINTENGINE_MAC_P_H
  43. //
  44. // W A R N I N G
  45. // -------------
  46. //
  47. // This file is not part of the Qt API. It exists purely as an
  48. // implementation detail. This header file may change from version to
  49. // version without notice, or even be removed.
  50. //
  51. // We mean it.
  52. //
  53. #ifndef QT_NO_PRINTER
  54. #include <QtPrintSupport/qprinter.h>
  55. #include <QtPrintSupport/qprintengine.h>
  56. #include <QtGui/private/qpainter_p.h>
  57. #include "qpaintengine_mac_p.h"
  58. #ifdef __OBJC__
  59. @class NSPrintInfo;
  60. #else
  61. typedef void NSPrintInfo;
  62. #endif
  63. QT_BEGIN_NAMESPACE
  64. class QPrinterPrivate;
  65. class QMacPrintEnginePrivate;
  66. class QMacPrintEngine : public QPaintEngine, public QPrintEngine
  67. {
  68. Q_DECLARE_PRIVATE(QMacPrintEngine)
  69. public:
  70. QMacPrintEngine(QPrinter::PrinterMode mode);
  71. Qt::HANDLE handle() const;
  72. bool begin(QPaintDevice *dev);
  73. bool end();
  74. virtual QPaintEngine::Type type() const { return QPaintEngine::MacPrinter; }
  75. QPaintEngine *paintEngine() const;
  76. void setProperty(PrintEnginePropertyKey key, const QVariant &value);
  77. QVariant property(PrintEnginePropertyKey key) const;
  78. QPrinter::PrinterState printerState() const;
  79. bool newPage();
  80. bool abort();
  81. int metric(QPaintDevice::PaintDeviceMetric) const;
  82. //forwarded functions
  83. void updateState(const QPaintEngineState &state);
  84. virtual void drawLines(const QLineF *lines, int lineCount);
  85. virtual void drawRects(const QRectF *r, int num);
  86. virtual void drawPoints(const QPointF *p, int pointCount);
  87. virtual void drawEllipse(const QRectF &r);
  88. virtual void drawPolygon(const QPointF *points, int pointCount, PolygonDrawMode mode);
  89. virtual void drawPixmap(const QRectF &r, const QPixmap &pm, const QRectF &sr);
  90. virtual void drawImage(const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags);
  91. virtual void drawTextItem(const QPointF &p, const QTextItem &ti);
  92. virtual void drawTiledPixmap(const QRectF &r, const QPixmap &pixmap, const QPointF &s);
  93. virtual void drawPath(const QPainterPath &);
  94. private:
  95. friend class QCocoaNativeInterface;
  96. };
  97. class QMacPrintEnginePrivate : public QPaintEnginePrivate
  98. {
  99. Q_DECLARE_PUBLIC(QMacPrintEngine)
  100. public:
  101. QPrinter::PrinterMode mode;
  102. QPrinter::PrinterState state;
  103. QPrinter::Orientation orient;
  104. NSPrintInfo *printInfo;
  105. PMResolution resolution;
  106. QString outputFilename;
  107. bool fullPage;
  108. QPaintEngine *paintEngine;
  109. bool hasCustomPaperSize;
  110. QSizeF customSize;
  111. bool hasCustomPageMargins;
  112. qreal leftMargin;
  113. qreal topMargin;
  114. qreal rightMargin;
  115. qreal bottomMargin;
  116. QHash<QMacPrintEngine::PrintEnginePropertyKey, QVariant> valueCache;
  117. QMacPrintEnginePrivate() : mode(QPrinter::ScreenResolution), state(QPrinter::Idle),
  118. orient(QPrinter::Portrait), printInfo(0), paintEngine(0),
  119. hasCustomPaperSize(false), hasCustomPageMargins(false) {}
  120. ~QMacPrintEnginePrivate();
  121. void initialize();
  122. void releaseSession();
  123. bool newPage_helper();
  124. void setPaperSize(QPrinter::PaperSize ps);
  125. QPrinter::PaperSize paperSize() const;
  126. QList<QVariant> supportedResolutions() const;
  127. inline bool isPrintSessionInitialized() const
  128. {
  129. return printInfo != 0;
  130. }
  131. PMPageFormat format() const { return static_cast<PMPageFormat>([printInfo PMPageFormat]); }
  132. PMPrintSession session() const { return static_cast<PMPrintSession>([printInfo PMPrintSession]); }
  133. PMPrintSettings settings() const { return static_cast<PMPrintSettings>([printInfo PMPrintSettings]); }
  134. };
  135. QT_END_NAMESPACE
  136. #endif // QT_NO_PRINTER
  137. #endif // QPRINTENGINE_WIN_P_H