Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: 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:
DrawL(), EHideMargins, EShowMargins, FormatL(), NewL(), NotifyBandPrinted(), NotifyPrintEnded(), NotifyPrintStarted(), PrintBandL(), SetMargins(), SetNumBands(), SetObserver(), TMarginState, ~CPrintPreviewImage()

Inherited from CBase:
Delete(), Extension_(), operator new()


Construction and destruction


NewL()

static IMPORT_C 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()

virtual IMPORT_C ~CPrintPreviewImage();

Description

Destructor.

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

[Top]


Member functions


SetMargins()

IMPORT_C void SetMargins(TMarginState aState);

Description

Sets whether or not margins are displayed.

Parameters

TMarginState aState

The margin state - on or off.


SetObserver()

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()

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()

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()

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 DrawL() 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()

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()

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()

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()

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(). 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.