From 9ebdc333a6a6485fd60a50a742a1d6edec211f53 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 17 Aug 2011 11:26:51 +0200 Subject: Introduce a paged paintdevice and use it Introduce a QPagedPaintDevice class that has a newPage() method and page dimensions. QPdfWriter and QPrinter inherit from it. Add a bit of API to QPdfWriter. Change-Id: Ibf23e7fe741f3a5ed854faf5d249a272acc75f35 Reviewed-on: http://codereview.qt.nokia.com/3206 Reviewed-by: Gunnar Sletta --- src/gui/painting/qpagedpaintdevice.h | 42 ++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/gui/painting/qpagedpaintdevice.h (limited to 'src/gui/painting/qpagedpaintdevice.h') diff --git a/src/gui/painting/qpagedpaintdevice.h b/src/gui/painting/qpagedpaintdevice.h new file mode 100644 index 0000000000..faba555adf --- /dev/null +++ b/src/gui/painting/qpagedpaintdevice.h @@ -0,0 +1,42 @@ + +#ifndef QPAGEDPAINTDEVICE_H +#define QPAGEDPAINTDEVICE_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QPagedPaintDevicePrivate; + +class Q_GUI_EXPORT QPagedPaintDevice : public QPaintDevice +{ +public: + QPagedPaintDevice(); + ~QPagedPaintDevice(); + + virtual bool newPage() = 0; + + enum PageSize { A4, B5, Letter, Legal, Executive, + A0, A1, A2, A3, A5, A6, A7, A8, A9, B0, B1, + B10, B2, B3, B4, B6, B7, B8, B9, C5E, Comm10E, + DLE, Folio, Ledger, Tabloid, Custom, NPageSize = Custom }; + + virtual void setPageSize(PageSize size); + PageSize pageSize() const; + + virtual void setPageSizeMM(const QSizeF &size); + QSizeF pageSizeMM() const; + +private: + QPagedPaintDevicePrivate *d; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif -- cgit v1.2.3 From 28f1c1b9ef10fc3a49a64a535c7747a009939453 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Thu, 18 Aug 2011 11:04:06 +0200 Subject: Restore feature compatibility with QPrinter in QTextDocument::print Add a margin method to QPagedPaintDevice. The other variables required are stored in QPagedPaintDevicePrivate without a public API for now. This needs cleaning up once we have a new printing system. Change-Id: Id3f2d7ac7f3cbce8619072a897d91f3a588add64 Reviewed-on: http://codereview.qt.nokia.com/3211 Reviewed-by: Qt Sanity Bot Reviewed-by: Gunnar Sletta --- src/gui/painting/qpagedpaintdevice.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/gui/painting/qpagedpaintdevice.h') diff --git a/src/gui/painting/qpagedpaintdevice.h b/src/gui/painting/qpagedpaintdevice.h index faba555adf..f3a133a8d9 100644 --- a/src/gui/painting/qpagedpaintdevice.h +++ b/src/gui/painting/qpagedpaintdevice.h @@ -31,7 +31,18 @@ public: virtual void setPageSizeMM(const QSizeF &size); QSizeF pageSizeMM() const; -private: + struct Margins { + qreal left; + qreal right; + qreal top; + qreal bottom; + }; + + virtual void setMargins(const Margins &margins); + Margins margins() const; + +protected: + friend class QPagedPaintDevicePrivate; QPagedPaintDevicePrivate *d; }; -- cgit v1.2.3