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 void DrawL (const TPoint &, const TRect &)
IMPORT_C void FormatL ( TInt , TInt , TInt )
IMPORT_C CPrintPreviewImage * NewL ( CPrintSetup &, MPageRegionPrinter &, RWsSession &, RWindow &, const TSize &, const TPrintPreviewFormat &)
IMPORT_C void SetMargins ( TMarginState )
IMPORT_C void SetNumBands ( TInt )
IMPORT_C void SetObserver ( MPrintProcessObserver &)
Private Member Functions
CPrintPreviewImage ( CPrintSetup &, MPageRegionPrinter &, RWsSession &, RWindow &, const TSize &, const TPrintPreviewFormat &)
void CalculateHeaderFooterRects ( TRect &, TRect &)
void ConstructL ()
void DrawBorder ( CGraphicsContext *)
void DrawExtremities ( CGraphicsContext *)
void DrawLabel ( CGraphicsContext *, TInt )
void DrawMargins ( CGraphicsContext *)
void DrawToGutter ( CGraphicsContext *, TInt )
TBool IsFirstPanel ( TInt )
TBool IsLastPanel ( TInt )
void NotifyBandPrinted ( TInt , TInt , TInt )
void NotifyPrintEnded ( TInt )
void NotifyPrintStarted ( TPrintParameters )
void PrintBandL ( CGraphicsDevice *, TInt , const TBandAttributes &)
void ScrollPanels ()
void SetLabelWidth ()
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
enum TMarginState { 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 &)

void CalculateHeaderFooterRects ( TRect & aHeaderRectInPixels,
TRect & aFooterRectInPixels
) [private]

Parameters

TRect & aHeaderRectInPixels
TRect & aFooterRectInPixels

ConstructL()

void ConstructL ( ) [private]

DrawBorder(CGraphicsContext *)

void DrawBorder ( CGraphicsContext * aGc ) [private]

Parameters

CGraphicsContext * aGc

DrawExtremities(CGraphicsContext *)

void DrawExtremities ( CGraphicsContext * aGc ) [private]

Parameters

CGraphicsContext * aGc

DrawL(const TPoint &, const TRect &)

IMPORT_C void DrawL ( 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 & aOrigin The drawing origin.
const TRect & aInvalidRegion The invalid region. This is assumed to be relative to aOrigin.

DrawLabel(CGraphicsContext *, TInt)

void DrawLabel ( CGraphicsContext * aGc,
TInt aPageNo
) [private]

Parameters

CGraphicsContext * aGc
TInt aPageNo

DrawMargins(CGraphicsContext *)

void DrawMargins ( CGraphicsContext * aGc ) [private]

Parameters

CGraphicsContext * aGc

DrawToGutter(CGraphicsContext *, TInt)

void DrawToGutter ( CGraphicsContext * aGc,
TInt aPageNo
) [private]

Parameters

CGraphicsContext * aGc
TInt aPageNo

FormatL(TInt, TInt, TInt)

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

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 aNumPagesInDoc The number of pages in the document.
TInt aFirstPageToDisplay The first page to display.
TInt aNumPagesToView The number of pages to preview.

IsFirstPanel(TInt)

TBool IsFirstPanel ( TInt aPageNum ) [private, inline]

Parameters

TInt aPageNum

IsLastPanel(TInt)

TBool IsLastPanel ( TInt aPageNum ) [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 & 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.

NotifyBandPrinted(TInt, TInt, TInt)

void NotifyBandPrinted ( TInt aPercentageOfPagePrinted,
TInt aCurrentPageNum,
TInt aCurrentCopyNum
) [private, virtual]

Parameters

TInt aPercentageOfPagePrinted
TInt aCurrentPageNum
TInt aCurrentCopyNum

NotifyPrintEnded(TInt)

void NotifyPrintEnded ( TInt anErrorCode ) [private, virtual]

Parameters

TInt anErrorCode

NotifyPrintStarted(TPrintParameters)

void NotifyPrintStarted ( TPrintParameters aPrintParams ) [private, virtual]

Parameters

TPrintParameters aPrintParams

PrintBandL(CGraphicsDevice *, TInt, const TBandAttributes &)

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

Parameters

CGraphicsDevice * aDevice
TInt aPageNo
const TBandAttributes & aBand

ScrollPanels()

void ScrollPanels ( ) [private]

SetLabelWidth()

void SetLabelWidth ( ) [private]

SetMargins(TMarginState)

IMPORT_C void SetMargins ( TMarginState aState )

Sets whether or not margins are displayed.

Parameters

TMarginState aState The margin state - on or off.

SetNumBands(TInt)

IMPORT_C void SetNumBands ( TInt aNum )

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.

SetObserver(MPrintProcessObserver &)

IMPORT_C void SetObserver ( 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 & aObserver The preview process observer.

SetPanelArrayL(const TInt, const TInt)

TInt SetPanelArrayL ( const TInt aFirstPage,
const TInt aNumPagesToView
) [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]