Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <PRNPREV.H>
Link against: prev.lib

Class CPrintPreviewImage

class CPrintPreviewImage : public CBase, private MPrintProcessObserver, private MPageRegionPrinter;

Description

Print preview image.

This class provides a standard print preview image. An object of this type should be owned by a control, which is in turn owned by the print preview dialog. The control's window provides the region into which this object draws the preview image.

The class provides a callback to the application code that draws the preview pages.

Derivation

Members

Defined in CPrintPreviewImage:

Inherited from CBase:


Construction and destruction


NewL(CPrintSetup &,MPageRegionPrinter &,RWsSession &,RWindow &,const TSize &,const TPrintPreviewFormat &)

IMPORT_C static CPrintPreviewImage* NewL(CPrintSetup &aPrintSetup, MPageRegionPrinter &aBodyPrinter, RWsSession &aWsSession, RWindow &aWindow, const TSize &aMaxWindowSize, const TPrintPreviewFormat &aStaticFormat);

Description

Static constructor for a CPrintPreviewImage object.

Parameters

CPrintSetup &aPrintSetup

The printer setup.

MPageRegionPrinter &aBodyPrinter

A page region printer. Defines a function to print the body of each page band by band.

RWsSession &aWsSession

A window server session. This may be the GUI framework session accessed through iEikonEnv->WsSession().

RWindow &aWindow

The window in which the image is to be drawn. Typically this is the window of the owning control.

const TSize &aMaxWindowSize

The maximum size of the window aWindow.

const TPrintPreviewFormat &aStaticFormat

The print preview format.

Return value

CPrintPreviewImage *

The newly created print preview image.


~CPrintPreviewImage()

IMPORT_C virtual ~CPrintPreviewImage();

Description

Destructor.

This ends printing, and frees all resources owned by the CPrintPreviewImage object, prior to its destruction.

[Top]


Member functions


SetMargins(TMarginState)

IMPORT_C void SetMargins(TMarginState aState);

Description

Sets whether or not margins are displayed.

Parameters

CPrintPreviewImage::TMarginState aState

The margin state - on or off.


SetObserver(MPrintProcessObserver &)

IMPORT_C void SetObserver(MPrintProcessObserver &aObserver);

Description

Sets the process observer.

The observer is informed of events occurring during print previewing. It allows error dialogs to be displayed by the GUI print preview dialogs if there are problems during previewing.

Parameters

MPrintProcessObserver &aObserver

The preview process observer.


SetNumBands(TInt)

IMPORT_C void SetNumBands(TInt aNum);

Description

Sets the number of print bands to be drawn in the preview.

On construction, the number of bands is initialised to to 1.

Parameters

TInt aNum

The number of print bands.


FormatL(TInt,TInt,TInt)

IMPORT_C void FormatL(TInt aNumPagesInDoc, TInt aFirstPageToDisplay, TInt aNumPagesToView);

Description

Sets preview formatting information.

This function can be called prior to previewing, or dynamically during previewing. It is used to alter the display parameters, e.g. turn margin indicator lines on or off, show/hide labels, change the number of panels viewed, or scroll the preview to show different pages.

Note:

The panels are fitted to the maximum window area available. This means that the print preview dialog will always be the same size irrespective of the number of panels displayed.

Parameters

TInt aNumPagesInDoc

The number of pages in the document.

TInt aFirstPageToDisplay

The first page to display.

TInt aNumPagesToView

The number of pages to preview.

Panic codes

6

If the number of pages in the document or the number of pages to be previewed is not greater than zero.

7

If aFirstPageToDisplay is not less than aNumPagesInDoc or if the first page to display is less than zero.


DrawL(const TPoint &,const TRect &)

IMPORT_C void DrawL(const TPoint &aOrigin, const TRect &aInvalidRegion);

Description

Draws the preview.

This function should be called every time the window needs to be refreshed.

Note that typically this function is called in the owning control's Draw() function. Since CPrintPreviewImage::DrawL(const TPoint &,const TRect &) can leave it must be called within a trap harness. The normal behaviour is to clear the image rectangle if a leave occurs.

Parameters

const TPoint &aOrigin

The drawing origin.

const TRect &aInvalidRegion

The invalid region. This is assumed to be relative to aOrigin.

Leave codes

KErrNoMemory

If there is an out of memory error.

Panic codes

4

If the panel array has not been initialised. Call FormatL() to avoid this.


NotifyPrintStarted(TPrintParameters)

private: virtual void NotifyPrintStarted(TPrintParameters aPrintParams);

Description

Notifies that a print or print preview operation is about to begin.

It may be used to display information about the document to be printed. It is called once, immediately before printing or print previewing begins.

When subclassing, add variables to store initialisation information as required.

Parameters

TPrintParameters aPrintParams

The parameters for the print job.


NotifyBandPrinted(TInt,TInt,TInt)

private: virtual void NotifyBandPrinted(TInt aPercentageOfPagePrinted, TInt aCurrentPageNum, TInt aCurrentCopyNum);

Description

Notifies that a band is about to be printed.

It may be used to display print progress information, including the current page number. It is called immediately before each band is printed.

Parameters

TInt aPercentageOfPagePrinted

The percentage of the page that has been printed.

TInt aCurrentPageNum

The number of the page currently being printed.

TInt aCurrentCopyNum

The number of the copy currently being printed (if multiple copies are being printed).


NotifyPrintEnded(TInt)

private: virtual void NotifyPrintEnded(TInt anErrorCode);

Description

Notifies that the print or print preview operation has completed.

It may be used to display information about how the operation completed, for example any errors that occurred. It is called once, immediately after the print job terminates.

Parameters

TInt anErrorCode

KErrNone if the print job completed successfully, otherwise another of the system-wide error codes.


PrintBandL(CGraphicsDevice *,TInt,const TBandAttributes &)

private: virtual void PrintBandL(CGraphicsDevice *aDevice, TInt aPageNo, const TBandAttributes &aBand);

Description

Prints a band.

Implementations should set up a graphics context to which all drawing should take place using CGraphicsDevice::CreateContext(CGraphicsContext *&). All co-ordinate calculations should be done in twips, and converted into pixels before starting the print job.

Parameters

CGraphicsDevice *aDevice

Pointer to the graphics device representing the printer.

TInt aPageNo

The number of the page containing the band to be printed.

const TBandAttributes &aBand

[Top]


Member enumerations


Enum TMarginState

TMarginState

Description

Margin display state flags.

EShowMargins

Show margins in print preview image.

EHideMargins

Hide margins in print preview image.