CPrintPreviewImage Class Reference

class CPrintPreviewImage : public CBase

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.

Inherits from

Public Member Functions
~CPrintPreviewImage()
IMPORT_C voidDrawL(const TPoint &, const TRect &)
IMPORT_C voidFormatL(TInt, TInt, TInt)
IMPORT_C CPrintPreviewImage *NewL(CPrintSetup &, MPageRegionPrinter &, RWsSession &, RWindow &, const TSize &, const TPrintPreviewFormat &)
IMPORT_C voidSetMargins(TMarginState)
IMPORT_C voidSetNumBands(TInt)
IMPORT_C voidSetObserver(MPrintProcessObserver &)
Private Member Functions
CPrintPreviewImage(CPrintSetup &, MPageRegionPrinter &, RWsSession &, RWindow &, const TSize &, const TPrintPreviewFormat &)
voidCalculateHeaderFooterRects(TRect &, TRect &)
voidConstructL()
voidDrawBorder(CGraphicsContext *)
voidDrawExtremities(CGraphicsContext *)
voidDrawLabel(CGraphicsContext *, TInt)
voidDrawMargins(CGraphicsContext *)
voidDrawToGutter(CGraphicsContext *, TInt)
TBool IsFirstPanel(TInt)
TBool IsLastPanel(TInt)
voidNotifyBandPrinted(TInt, TInt, TInt)
voidNotifyPrintEnded(TInt)
voidNotifyPrintStarted(TPrintParameters)
voidPrintBandL(CGraphicsDevice *, TInt, const TBandAttributes &)
voidScrollPanels()
voidSetLabelWidth()
TInt SetPanelArrayL(const TInt, const TInt)
Inherited Functions
CBase::CBase()
CBase::Delete(CBase *)
CBase::Extension_(TUint,TAny *&,TAny *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Public Member Enumerations
enumTMarginState { EShowMargins, EHideMargins }
Private Attributes
TSize iActualGutter
MPageRegionPrinter *iAppBodyPrinter
CPrintPreviewDevice *iDevice
TRange iDrawRange
TPrintPreviewFormat iFormat
CFont *iLabelFont
TSize iLabelSize
TMarginState iMarginState
TInt iNumBands
TInt iNumPagesInDoc
MPrintProcessObserver *iObserver
TPoint iOrigin
CArrayFix< TPreviewPanel > *iPanelArray
TSize iPanelSizeInPixels
TPrintParameters iPrintParams
CPrintSetup *iPrintSetup
TSize iRndError
TSize iWinSize
RWindow *iWindow
RWsSession *iWsSession

Constructor & Destructor Documentation

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

CPrintPreviewImage(CPrintSetup &aPrintSetup,
MPageRegionPrinter &aBodyPrinter,
RWsSession &aWsSession,
RWindow &aWindow,
const TSize &aMaxWindowSize,
const TPrintPreviewFormat &aStaticFormat
)[private]

Parameters

CPrintSetup & aPrintSetup
MPageRegionPrinter & aBodyPrinter
RWsSession & aWsSession
RWindow & aWindow
const TSize & aMaxWindowSize
const TPrintPreviewFormat & aStaticFormat

~CPrintPreviewImage()

IMPORT_C~CPrintPreviewImage()[virtual]

Destructor.

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

Member Functions Documentation

CalculateHeaderFooterRects(TRect &, TRect &)

voidCalculateHeaderFooterRects(TRect &aHeaderRectInPixels,
TRect &aFooterRectInPixels
)[private]

Parameters

TRect & aHeaderRectInPixels
TRect & aFooterRectInPixels

ConstructL()

voidConstructL()[private]

DrawBorder(CGraphicsContext *)

voidDrawBorder(CGraphicsContext *aGc)[private]

Parameters

CGraphicsContext * aGc

DrawExtremities(CGraphicsContext *)

voidDrawExtremities(CGraphicsContext *aGc)[private]

Parameters

CGraphicsContext * aGc

DrawL(const TPoint &, const TRect &)

IMPORT_C voidDrawL(const TPoint &aOrigin,
const TRect &aInvalidRegion
)

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.

leave
KErrNoMemory If there is an out of memory error.
panic
4 If the panel array has not been initialised. Call FormatL() to avoid this.

Parameters

const TPoint & aOriginThe drawing origin.
const TRect & aInvalidRegionThe invalid region. This is assumed to be relative to aOrigin.

DrawLabel(CGraphicsContext *, TInt)

voidDrawLabel(CGraphicsContext *aGc,
TIntaPageNo
)[private]

Parameters

CGraphicsContext * aGc
TInt aPageNo

DrawMargins(CGraphicsContext *)

voidDrawMargins(CGraphicsContext *aGc)[private]

Parameters

CGraphicsContext * aGc

DrawToGutter(CGraphicsContext *, TInt)

voidDrawToGutter(CGraphicsContext *aGc,
TIntaPageNo
)[private]

Parameters

CGraphicsContext * aGc
TInt aPageNo

FormatL(TInt, TInt, TInt)

IMPORT_C voidFormatL(TIntaNumPagesInDoc,
TIntaFirstPageToDisplay,
TIntaNumPagesToView
)

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.

panic
6 If the number of pages in the document or the number of pages to be previewed is not greater than zero.
panic
7 If aFirstPageToDisplay is not less than aNumPagesInDoc or if the first page to display is less than zero.

Parameters

TInt aNumPagesInDocThe number of pages in the document.
TInt aFirstPageToDisplayThe first page to display.
TInt aNumPagesToViewThe number of pages to preview.

IsFirstPanel(TInt)

TBool IsFirstPanel(TIntaPageNum)[private, inline]

Parameters

TInt aPageNum

IsLastPanel(TInt)

TBool IsLastPanel(TIntaPageNum)[private, inline]

Parameters

TInt aPageNum

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

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

Static constructor for a CPrintPreviewImage object.

Parameters

CPrintSetup & aPrintSetupThe printer setup.
MPageRegionPrinter & aBodyPrinterA page region printer. Defines a function to print the body of each page band by band.
RWsSession & aWsSessionA window server session. This may be the GUI framework session accessed through iEikonEnv->WsSession().
RWindow & aWindowThe window in which the image is to be drawn. Typically this is the window of the owning control.
const TSize & aMaxWindowSizeThe maximum size of the window aWindow.
const TPrintPreviewFormat & aStaticFormatThe print preview format.

NotifyBandPrinted(TInt, TInt, TInt)

voidNotifyBandPrinted(TIntaPercentageOfPagePrinted,
TIntaCurrentPageNum,
TIntaCurrentCopyNum
)[private, virtual]

Parameters

TInt aPercentageOfPagePrinted
TInt aCurrentPageNum
TInt aCurrentCopyNum

NotifyPrintEnded(TInt)

voidNotifyPrintEnded(TIntanErrorCode)[private, virtual]

Parameters

TInt anErrorCode

NotifyPrintStarted(TPrintParameters)

voidNotifyPrintStarted(TPrintParametersaPrintParams)[private, virtual]

Parameters

TPrintParameters aPrintParams

PrintBandL(CGraphicsDevice *, TInt, const TBandAttributes &)

voidPrintBandL(CGraphicsDevice *aDevice,
TIntaPageNo,
const TBandAttributes &aBand
)[private, virtual]

Parameters

CGraphicsDevice * aDevice
TInt aPageNo
const TBandAttributes & aBand

ScrollPanels()

voidScrollPanels()[private]

SetLabelWidth()

voidSetLabelWidth()[private]

SetMargins(TMarginState)

IMPORT_C voidSetMargins(TMarginStateaState)

Sets whether or not margins are displayed.

Parameters

TMarginState aStateThe margin state - on or off.

SetNumBands(TInt)

IMPORT_C voidSetNumBands(TIntaNum)

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 aNumThe number of print bands.

SetObserver(MPrintProcessObserver &)

IMPORT_C voidSetObserver(MPrintProcessObserver &aObserver)

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 & aObserverThe preview process observer.

SetPanelArrayL(const TInt, const TInt)

TInt SetPanelArrayL(const TIntaFirstPage,
const TIntaNumPagesToView
)[private]

Parameters

const TInt aFirstPage
const TInt aNumPagesToView

Member Enumerations Documentation

Enum TMarginState

Margin display state flags.

Enumerators

EShowMargins

Show margins in print preview image.

EHideMargins

Hide margins in print preview image.

Member Data Documentation

TSize iActualGutter

TSize iActualGutter[private]

MPageRegionPrinter * iAppBodyPrinter

MPageRegionPrinter *iAppBodyPrinter[private]

CPrintPreviewDevice * iDevice

CPrintPreviewDevice *iDevice[private]

TRange iDrawRange

TRange iDrawRange[private]

TPrintPreviewFormat iFormat

TPrintPreviewFormat iFormat[private]

CFont * iLabelFont

CFont *iLabelFont[private]

TSize iLabelSize

TSize iLabelSize[private]

TMarginState iMarginState

TMarginState iMarginState[private]

TInt iNumBands

TInt iNumBands[private]

TInt iNumPagesInDoc

TInt iNumPagesInDoc[private]

MPrintProcessObserver * iObserver

MPrintProcessObserver *iObserver[private]

TPoint iOrigin

TPoint iOrigin[private]

CArrayFix< TPreviewPanel > * iPanelArray

CArrayFix< TPreviewPanel > *iPanelArray[private]

TSize iPanelSizeInPixels

TSize iPanelSizeInPixels[private]

TPrintParameters iPrintParams

TPrintParameters iPrintParams[private]

CPrintSetup * iPrintSetup

CPrintSetup *iPrintSetup[private]

TSize iRndError

TSize iRndError[private]

TSize iWinSize

TSize iWinSize[private]

RWindow * iWindow

RWindow *iWindow[private]

RWsSession * iWsSession

RWsSession *iWsSession[private]