Qt 4.8
Public Functions | List of all members
QPreviewPaintEngine Class Reference

#include <qpaintengine_preview_p.h>

Inheritance diagram for QPreviewPaintEngine:
QPaintEngine QPrintEngine

Public Functions

bool abort ()
 Instructs the print engine to abort the printing process. More...
 
bool begin (QPaintDevice *dev)
 Reimplement this function to initialise your paint engine when painting is to start on the paint device pdev. More...
 
void drawPath (const QPainterPath &path)
 The default implementation ignores the path and does nothing. More...
 
void drawPixmap (const QRectF &r, const QPixmap &pm, const QRectF &sr)
 Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r. More...
 
void drawPolygon (const QPointF *points, int pointCount, PolygonDrawMode mode)
 Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode. More...
 
void drawTextItem (const QPointF &p, const QTextItem &textItem)
 This function draws the text item textItem at position p. More...
 
void drawTiledPixmap (const QRectF &r, const QPixmap &pm, const QPointF &p)
 Reimplement this function to draw the pixmap in the given rect, starting at the given p. More...
 
bool end ()
 Reimplement this function to finish painting on the current paint device. More...
 
int metric (QPaintDevice::PaintDeviceMetric) const
 Returns the metric for the given id. More...
 
bool newPage ()
 Instructs the print engine to start a new page. More...
 
QList< const QPicture * > pages ()
 
QPrinter::PrinterState printerState () const
 Returns the current state of the printer being used by the print engine. More...
 
QVariant property (PrintEnginePropertyKey key) const
 Returns the print engine's property specified by key. More...
 
 QPreviewPaintEngine ()
 
void setProperty (PrintEnginePropertyKey key, const QVariant &value)
 Sets the print engine's property specified by key to the given value. More...
 
void setProxyEngines (QPrintEngine *printEngine, QPaintEngine *paintEngine)
 
QPaintEngine::Type type () const
 Reimplement this function to return the paint engine Type. More...
 
void updateState (const QPaintEngineState &state)
 Reimplement this function to update the state of a paint engine. More...
 
 ~QPreviewPaintEngine ()
 
- Public Functions inherited from QPaintEngine
void clearDirty (DirtyFlags df)
 
virtual QPoint coordinateOffset () const
 Returns the offset from the painters origo to the engines origo. More...
 
virtual void drawEllipse (const QRectF &r)
 Reimplement this function to draw the largest ellipse that can be contained within rectangle rect. More...
 
virtual void drawEllipse (const QRect &r)
 The default implementation of this function calls the floating point version of this function. More...
 
virtual void drawImage (const QRectF &r, const QImage &pm, const QRectF &sr, Qt::ImageConversionFlags flags=Qt::AutoColor)
 Reimplement this function to draw the part of the image specified by the sr rectangle in the given rectangle using the given conversion flags flags, to convert it to a pixmap. More...
 
virtual void drawLines (const QLine *lines, int lineCount)
 The default implementation converts the first lineCount lines in lines to a QLineF and calls the floating point version of this function. More...
 
virtual void drawLines (const QLineF *lines, int lineCount)
 The default implementation splits the list of lines in lines into lineCount separate calls to drawPath() or drawPolygon() depending on the feature set of the paint engine. More...
 
virtual void drawPoints (const QPointF *points, int pointCount)
 Draws the first pointCount points in the buffer points. More...
 
virtual void drawPoints (const QPoint *points, int pointCount)
 Draws the first pointCount points in the buffer points. More...
 
virtual void drawPolygon (const QPoint *points, int pointCount, PolygonDrawMode mode)
 Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode. More...
 
virtual void drawRects (const QRect *rects, int rectCount)
 The default implementation converts the first rectCount rectangles in the buffer rects to a QRectF and calls the floating point version of this function. More...
 
virtual void drawRects (const QRectF *rects, int rectCount)
 Draws the first rectCount rectangles in the buffer rects. More...
 
void fix_neg_rect (int *x, int *y, int *w, int *h)
 
virtual HDC getDC () const
 Empty default implementation. More...
 
bool hasFeature (PaintEngineFeatures feature) const
 Returns true if the paint engine supports the specified feature; otherwise returns false. More...
 
bool isActive () const
 Returns true if the paint engine is actively drawing; otherwise returns false. More...
 
bool isExtended () const
 Returns true if the paint engine is a QPaintEngineEx derivative. More...
 
QPaintDevicepaintDevice () const
 Returns the device that this engine is painting on, if painting is active; otherwise returns 0. More...
 
QPainterpainter () const
 Returns the paint engine's painter. More...
 
 QPaintEngine (PaintEngineFeatures features=0)
 Creates a paint engine with the featureset specified by caps. More...
 
virtual void releaseDC (HDC hdc) const
 Empty default implementation. More...
 
void setActive (bool newState)
 Sets the active state of the paint engine to state. More...
 
void setDirty (DirtyFlags df)
 
void setPaintDevice (QPaintDevice *device)
 
void setSystemClip (const QRegion &baseClip)
 Sets the system clip for this engine. More...
 
void setSystemRect (const QRect &rect)
 Sets the target rect for drawing within the backing store. More...
 
void syncState ()
 Updates all dirty states in this engine. More...
 
QRegion systemClip () const
 Returns the system clip. More...
 
QRect systemRect () const
 Retrieves the rect for drawing within the backing store. More...
 
bool testDirty (DirtyFlags df)
 
virtual ~QPaintEngine ()
 Destroys the paint engine. More...
 
- Public Functions inherited from QPrintEngine
virtual HDC getPrinterDC () const
 
virtual void releasePrinterDC (HDC) const
 
virtual ~QPrintEngine ()
 Destroys the print engine. More...
 

Additional Inherited Members

- Public Types inherited from QPaintEngine
enum  DirtyFlag {
  DirtyPen = 0x0001, DirtyBrush = 0x0002, DirtyBrushOrigin = 0x0004, DirtyFont = 0x0008,
  DirtyBackground = 0x0010, DirtyBackgroundMode = 0x0020, DirtyTransform = 0x0040, DirtyClipRegion = 0x0080,
  DirtyClipPath = 0x0100, DirtyHints = 0x0200, DirtyCompositionMode = 0x0400, DirtyClipEnabled = 0x0800,
  DirtyOpacity = 0x1000, AllDirty = 0xffff
}
 QPaintEngine::updateState(). More...
 
enum  PaintEngineFeature {
  PrimitiveTransform = 0x00000001, PatternTransform = 0x00000002, PixmapTransform = 0x00000004, PatternBrush = 0x00000008,
  LinearGradientFill = 0x00000010, RadialGradientFill = 0x00000020, ConicalGradientFill = 0x00000040, AlphaBlend = 0x00000080,
  PorterDuff = 0x00000100, PainterPaths = 0x00000200, Antialiasing = 0x00000400, BrushStroke = 0x00000800,
  ConstantOpacity = 0x00001000, MaskedBrush = 0x00002000, PerspectiveTransform = 0x00004000, BlendModes = 0x00008000,
  ObjectBoundingModeGradients = 0x00010000, RasterOpModes = 0x00020000, PaintOutsidePaintEvent = 0x20000000, AllFeatures = 0xffffffff
}
 This enum is used to describe the features or capabilities that the paint engine has. More...
 
enum  PolygonDrawMode { OddEvenMode, WindingMode, ConvexMode, PolylineMode }
 
enum  Type {
  X11, Windows, QuickDraw, CoreGraphics,
  MacPrinter, QWindowSystem, PostScript, OpenGL,
  Picture, SVG, Raster, Direct3D,
  Pdf, OpenVG, OpenGL2, PaintBuffer,
  Blitter, User = 50, MaxUser = 100
}
 
- Public Types inherited from QPrintEngine
enum  PrintEnginePropertyKey {
  PPK_CollateCopies, PPK_ColorMode, PPK_Creator, PPK_DocumentName,
  PPK_FullPage, PPK_NumberOfCopies, PPK_Orientation, PPK_OutputFileName,
  PPK_PageOrder, PPK_PageRect, PPK_PageSize, PPK_PaperRect,
  PPK_PaperSource, PPK_PrinterName, PPK_PrinterProgram, PPK_Resolution,
  PPK_SelectionOption, PPK_SupportedResolutions, PPK_WindowsPageSize, PPK_FontEmbedding,
  PPK_SuppressSystemPrintStatus, PPK_Duplex, PPK_PaperSources, PPK_CustomPaperSize,
  PPK_PageMargins, PPK_CopyCount, PPK_SupportsMultipleCopies, PPK_PaperSize = PPK_PageSize,
  PPK_CustomBase = 0xff00
}
 This enum is used to communicate properties between the print engine and QPrinter. More...
 
- Protected Functions inherited from QPaintEngine
 QPaintEngine (QPaintEnginePrivate &data, PaintEngineFeatures devcaps=0)
 
- Protected Variables inherited from QPaintEngine
uint active: 1
 
QScopedPointer< QPaintEnginePrivated_ptr
 
uint extended: 1
 
PaintEngineFeatures gccaps
 
uint selfDestruct: 1
 
QPaintEngineStatestate
 

Detailed Description

Definition at line 66 of file qpaintengine_preview_p.h.

Constructors and Destructors

◆ QPreviewPaintEngine()

QPreviewPaintEngine::QPreviewPaintEngine ( )

Definition at line 71 of file qpaintengine_preview.cpp.

73 {
75  d->proxy_print_engine = 0;
76  d->proxy_paint_engine = 0;
77 }
double d
Definition: qnumeric_p.h:62
QPaintEngine(PaintEngineFeatures features=0)
Creates a paint engine with the featureset specified by caps.
#define Q_D(Class)
Definition: qglobal.h:2482

◆ ~QPreviewPaintEngine()

QPreviewPaintEngine::~QPreviewPaintEngine ( )

Definition at line 79 of file qpaintengine_preview.cpp.

80 {
82 
83  qDeleteAll(d->pages);
84 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

Functions

◆ abort()

bool QPreviewPaintEngine::abort ( )
virtual

Instructs the print engine to abort the printing process.

Returns true if successful; otherwise returns false.

Implements QPrintEngine.

Definition at line 174 of file qpaintengine_preview.cpp.

Referenced by type().

175 {
177  end();
178  qDeleteAll(d->pages);
179  d->state = QPrinter::Aborted;
180 
181  return true;
182 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
bool end()
Reimplement this function to finish painting on the current paint device.
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

◆ begin()

bool QPreviewPaintEngine::begin ( QPaintDevice pdev)
virtual

Reimplement this function to initialise your paint engine when painting is to start on the paint device pdev.

Return true if the initialization was successful; otherwise return false.

See also
end() isActive()

Implements QPaintEngine.

Definition at line 86 of file qpaintengine_preview.cpp.

87 {
89 
90  qDeleteAll(d->pages);
91  d->pages.clear();
92 
93  QPicture *page = new QPicture;
94  page->d_func()->in_memory_only = true;
95  d->painter = new QPainter(page);
96  d->engine = d->painter->paintEngine();
97  d->pages.append(page);
98  d->state = QPrinter::Active;
99  return true;
100 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
friend class QPainter
Definition: qpaintengine.h:277
The QPicture class is a paint device that records and replays QPainter commands.
Definition: qpicture.h:58
Q_OUTOFLINE_TEMPLATE void qDeleteAll(ForwardIterator begin, ForwardIterator end)
Definition: qalgorithms.h:319

◆ drawPath()

void QPreviewPaintEngine::drawPath ( const QPainterPath path)
virtual

The default implementation ignores the path and does nothing.

Reimplemented from QPaintEngine.

Definition at line 119 of file qpaintengine_preview.cpp.

120 {
122  d->engine->drawPath(path);
123 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ drawPixmap()

void QPreviewPaintEngine::drawPixmap ( const QRectF r,
const QPixmap pm,
const QRectF sr 
)
virtual

Reimplement this function to draw the part of the pm specified by the sr rectangle in the given r.

Implements QPaintEngine.

Definition at line 137 of file qpaintengine_preview.cpp.

138 {
140  d->engine->drawPixmap(r, pm, sr);
141 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ drawPolygon()

void QPreviewPaintEngine::drawPolygon ( const QPointF points,
int  pointCount,
PolygonDrawMode  mode 
)
virtual

Reimplement this virtual function to draw the polygon defined by the pointCount first points in points, using mode mode.

Note
At least one of the drawPolygon() functions must be reimplemented.

Reimplemented from QPaintEngine.

Definition at line 125 of file qpaintengine_preview.cpp.

126 {
128  d->engine->drawPolygon(points, pointCount, mode);
129 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ drawTextItem()

void QPreviewPaintEngine::drawTextItem ( const QPointF p,
const QTextItem textItem 
)
virtual

This function draws the text item textItem at position p.

The default implementation of this function converts the text to a QPainterPath and paints the resulting path.

Reimplemented from QPaintEngine.

Definition at line 131 of file qpaintengine_preview.cpp.

132 {
134  d->engine->drawTextItem(p, textItem);
135 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ drawTiledPixmap()

void QPreviewPaintEngine::drawTiledPixmap ( const QRectF rect,
const QPixmap pixmap,
const QPointF p 
)
virtual

Reimplement this function to draw the pixmap in the given rect, starting at the given p.

The pixmap will be drawn repeatedly until the rect is filled.

Reimplemented from QPaintEngine.

Definition at line 143 of file qpaintengine_preview.cpp.

144 {
146  d->engine->drawTiledPixmap(r, pm, p);
147 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ end()

bool QPreviewPaintEngine::end ( )
virtual

Reimplement this function to finish painting on the current paint device.

Return true if painting was finished successfully; otherwise return false.

See also
begin() isActive()

Implements QPaintEngine.

Definition at line 102 of file qpaintengine_preview.cpp.

Referenced by abort().

103 {
105 
106  delete d->painter;
107  d->painter = 0;
108  d->engine = 0;
109  d->state = QPrinter::Idle;
110  return true;
111 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ metric()

int QPreviewPaintEngine::metric ( QPaintDevice::PaintDeviceMetric  id) const
virtual

Returns the metric for the given id.

Implements QPrintEngine.

Definition at line 209 of file qpaintengine_preview.cpp.

Referenced by type().

210 {
211  Q_D(const QPreviewPaintEngine);
212  return d->proxy_print_engine->metric(id);
213 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ newPage()

bool QPreviewPaintEngine::newPage ( )
virtual

Instructs the print engine to start a new page.

Returns true if the printer was able to create the new page; otherwise returns false.

Implements QPrintEngine.

Definition at line 149 of file qpaintengine_preview.cpp.

Referenced by type().

150 {
152 
153  QPicture *page = new QPicture;
154  page->d_func()->in_memory_only = true;
155  QPainter *tmp_painter = new QPainter(page);
156  QPaintEngine *tmp_engine = tmp_painter->paintEngine();
157 
158  // copy the painter state from the original painter
159  Q_ASSERT(painter()->d_func()->state && tmp_painter->d_func()->state);
160  *tmp_painter->d_func()->state = *painter()->d_func()->state;
161 
162  // composition modes aren't supported on a QPrinter and yields a
163  // warning, so ignore it for now
164  tmp_engine->setDirty(DirtyFlags(AllDirty & ~DirtyCompositionMode));
165  tmp_engine->syncState();
166 
167  delete d->painter;
168  d->painter = tmp_painter;
169  d->pages.append(page);
170  d->engine = tmp_engine;
171  return true;
172 }
The QPainter class performs low-level painting on widgets and other paint devices.
Definition: qpainter.h:86
double d
Definition: qnumeric_p.h:62
void syncState()
Updates all dirty states in this engine.
QPaintEngineState * state
Definition: qpaintengine.h:239
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
#define Q_D(Class)
Definition: qglobal.h:2482
QPainter * painter() const
Returns the paint engine&#39;s painter.
QPaintEngine * paintEngine() const
Returns the paint engine that the painter is currently operating on if the painter is active; otherwi...
Definition: qpainter.cpp:1991
void setDirty(DirtyFlags df)
Definition: qpaintengine.h:349
The QPaintEngine class provides an abstract definition of how QPainter draws to a given device on a g...
Definition: qpaintengine.h:90
friend class QPainter
Definition: qpaintengine.h:277
The QPicture class is a paint device that records and replays QPainter commands.
Definition: qpicture.h:58

◆ pages()

QList< const QPicture * > QPreviewPaintEngine::pages ( )

Definition at line 184 of file qpaintengine_preview.cpp.

Referenced by QPrinterPrivate::previewPages().

185 {
187  return d->pages;
188 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ printerState()

QPrinter::PrinterState QPreviewPaintEngine::printerState ( ) const
virtual

Returns the current state of the printer being used by the print engine.

Implements QPrintEngine.

Definition at line 215 of file qpaintengine_preview.cpp.

Referenced by type().

216 {
217  Q_D(const QPreviewPaintEngine);
218  return d->state;
219 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ property()

QVariant QPreviewPaintEngine::property ( PrintEnginePropertyKey  key) const
virtual

Returns the print engine's property specified by key.

See also
setProperty()

Implements QPrintEngine.

Definition at line 203 of file qpaintengine_preview.cpp.

Referenced by type().

204 {
205  Q_D(const QPreviewPaintEngine);
206  return d->proxy_print_engine->property(key);
207 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
int key

◆ setProperty()

void QPreviewPaintEngine::setProperty ( PrintEnginePropertyKey  key,
const QVariant value 
)
virtual

Sets the print engine's property specified by key to the given value.

See also
property()

Implements QPrintEngine.

Definition at line 197 of file qpaintengine_preview.cpp.

Referenced by type().

198 {
200  d->proxy_print_engine->setProperty(key, value);
201 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
int key

◆ setProxyEngines()

void QPreviewPaintEngine::setProxyEngines ( QPrintEngine printEngine,
QPaintEngine paintEngine 
)

Definition at line 190 of file qpaintengine_preview.cpp.

Referenced by QPrinterPrivate::setPreviewMode(), and type().

191 {
193  d->proxy_print_engine = printEngine;
194  d->proxy_paint_engine = paintEngine;
195 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ type()

QPaintEngine::Type QPreviewPaintEngine::type ( ) const
inlinevirtual

Reimplement this function to return the paint engine Type.

Implements QPaintEngine.

Definition at line 87 of file qpaintengine_preview_p.h.

◆ updateState()

void QPreviewPaintEngine::updateState ( const QPaintEngineState state)
virtual

Reimplement this function to update the state of a paint engine.

When implemented, this function is responsible for checking the paint engine's current state and update the properties that are changed. Use the QPaintEngineState::state() function to find out which properties that must be updated, then use the corresponding GetFunction{get function} to retrieve the current values for the given properties.

See also
QPaintEngineState

Implements QPaintEngine.

Definition at line 113 of file qpaintengine_preview.cpp.

114 {
116  d->engine->updateState(state);
117 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

The documentation for this class was generated from the following files: