williamr@2: // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@2: // All rights reserved. williamr@2: // This component and the accompanying materials are made available williamr@2: // under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: // which accompanies this distribution, and is available williamr@2: // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: // williamr@2: // Initial Contributors: williamr@2: // Nokia Corporation - initial contribution. williamr@2: // williamr@2: // Contributors: williamr@2: // williamr@2: // Description: williamr@2: // williamr@2: williamr@2: #if !defined (__PRNPREV_H__) williamr@2: #define __PRNPREV_H__ williamr@2: williamr@2: #if !defined(__E32STD_H__) williamr@2: #include williamr@2: #endif williamr@2: #if !defined(__E32BASE_H__) williamr@2: #include williamr@2: #endif williamr@2: #if !defined(__PRNSETUP_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: // classes defined: williamr@2: class TPrintPreviewFormat; williamr@2: class TPreviewPanel; williamr@2: class CPrintPreviewImage; williamr@2: // williamr@2: williamr@2: // forward references: williamr@2: class RWsSession; williamr@2: class RWindow; williamr@2: class CPrintPreviewDevice; williamr@2: // williamr@2: williamr@2: williamr@2: class TPrintPreviewFormat williamr@2: /** Print preview format information. williamr@2: williamr@2: The print preview format information is accessed via its public data members. williamr@2: Typically there is a system wide TPrintPreviewFormat supplied by the GUI framework. williamr@2: williamr@2: Preview information includes: williamr@2: williamr@2: - panel settings: multiple pages can be previewed at once; the display area williamr@2: for each page is termed a panel. williamr@2: williamr@2: - label settings: each panel can have an associated label, which specifies the williamr@2: corresponding document page number williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: { williamr@2: public: williamr@2: /** The minimum panel gutter size, in pixels. */ williamr@2: TSize iMinPanelGutterInPixels; williamr@2: /** The width of the panel shadow, in pixels. */ williamr@2: TInt iPanelShadowWidthInPixels; williamr@2: /** The colour of the panel shadow. */ williamr@2: TRgb iPanelShadowColor; williamr@2: /** The panel margin colour. */ williamr@2: TRgb iPanelMarginColor; williamr@2: /** The color of both the paper and the window background. */ williamr@2: TRgb iPreviewBackgroundColor; williamr@2: /** X pixel offset of the label text from the panel edge. */ williamr@2: TInt iLabelOffsetInPixels; williamr@2: /** Font specification for the label text. */ williamr@2: TFontSpec iLabelFontSpecInPixels; williamr@2: }; williamr@2: williamr@2: williamr@2: class CPrintPreviewImage : public CBase, private MPrintProcessObserver, private MPageRegionPrinter williamr@2: /** Print preview image. williamr@2: williamr@2: This class provides a standard print preview image. An object of this type williamr@2: should be owned by a control, which is in turn owned by the print preview williamr@2: dialog. The control's window provides the region into which this object draws williamr@2: the preview image. williamr@2: williamr@2: The class provides a callback to the application code that draws the preview williamr@2: pages. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: { williamr@2: public: williamr@2: /** Margin display state flags. */ williamr@2: enum TMarginState { williamr@2: /** Show margins in print preview image. */ williamr@2: EShowMargins, williamr@2: /** Hide margins in print preview image. */ williamr@2: EHideMargins williamr@2: }; williamr@2: public: williamr@2: IMPORT_C static CPrintPreviewImage* NewL(CPrintSetup& aPrintSetup,MPageRegionPrinter& aBodyPrinter, williamr@2: RWsSession& aWsSession,RWindow& aWindow,const TSize& aMaxWindowSize, williamr@2: const TPrintPreviewFormat& aStaticFormat); williamr@2: IMPORT_C virtual ~CPrintPreviewImage(); williamr@2: IMPORT_C void SetMargins(TMarginState aState); // whether or not to show margins williamr@2: IMPORT_C void SetObserver(MPrintProcessObserver& aObserver); williamr@2: IMPORT_C void SetNumBands(TInt aNum); williamr@2: IMPORT_C void FormatL(TInt aNumPagesInDoc,TInt aFirstPageToDisplay,TInt aNumPagesToView); // call when scrolling or changing num pages to view williamr@2: IMPORT_C void DrawL(const TPoint& aOrigin,const TRect& aInvalidRegion); // aOrigin is the point in the window I will treat as the origin (ie offset) williamr@2: // williamr@2: private: williamr@2: class TPreviewPanel; williamr@2: class TRange williamr@2: { williamr@2: public: williamr@2: TInt iFrom; williamr@2: TInt iTo; williamr@2: }; williamr@2: private: williamr@2: CPrintPreviewImage(CPrintSetup& aPrintSetup,MPageRegionPrinter& aBodyPrinter,RWsSession& aWsSession, williamr@2: RWindow& aWindow,const TSize& aMaxWindowSize,const TPrintPreviewFormat& aStaticFormat); williamr@2: void ConstructL(); williamr@2: void CalculateHeaderFooterRects(TRect& aHeaderRectInPixels,TRect& aFooterRectInPixels); williamr@2: TInt SetPanelArrayL(const TInt aFirstPage,const TInt aNumPagesToView); williamr@2: void SetLabelWidth(); williamr@2: void ScrollPanels(); williamr@2: void DrawBorder(CGraphicsContext* aGc); // and shadow williamr@2: void DrawMargins(CGraphicsContext* aGc); // including header/footer lines williamr@2: void DrawLabel(CGraphicsContext* aGc,TInt aPageNo); williamr@2: void DrawToGutter(CGraphicsContext* aGc,TInt aPageNo); // blanks all the gutter areas associated to a particular panel williamr@2: void DrawExtremities(CGraphicsContext* aGc); // blanks very left and right of the window williamr@2: inline TBool IsFirstPanel(TInt aPageNum); williamr@2: inline TBool IsLastPanel(TInt aPageNum); williamr@2: // from MPrintProcessObserver williamr@2: virtual void NotifyPrintStarted(TPrintParameters aPrintParams); williamr@2: virtual void NotifyBandPrinted(TInt aPercentageOfPagePrinted, TInt aCurrentPageNum, TInt aCurrentCopyNum); williamr@2: virtual void NotifyPrintEnded(TInt anErrorCode); williamr@2: // from MPageRegionPrinter williamr@2: virtual void PrintBandL(CGraphicsDevice* aDevice,TInt aPageNo,const TBandAttributes& aBand); williamr@2: private: williamr@2: CPrintPreviewDevice* iDevice; williamr@2: CPrintSetup* iPrintSetup; williamr@2: MPageRegionPrinter* iAppBodyPrinter; williamr@2: MPrintProcessObserver* iObserver; // may be null williamr@2: RWsSession* iWsSession; williamr@2: RWindow* iWindow; williamr@2: CFont* iLabelFont; williamr@2: CArrayFix* iPanelArray; williamr@2: // williamr@2: TPrintPreviewFormat iFormat; williamr@2: TPrintParameters iPrintParams; // current preview range williamr@2: TMarginState iMarginState; // whether the margins are on or not williamr@2: TSize iPanelSizeInPixels; williamr@2: TSize iWinSize; // size of the window (for layout purposes) williamr@2: TPoint iOrigin; // origin in the window to use for drawing williamr@2: TSize iLabelSize; williamr@2: TSize iActualGutter; // gap from the edge of the panel to either screen edge or adjacent panel williamr@2: TInt iNumPagesInDoc; williamr@2: TInt iNumBands; williamr@2: TSize iRndError; // rounding error from calculation of iActualGutter williamr@2: TRange iDrawRange; // the pages that actually require drawing - ie have not been scrolled williamr@2: }; williamr@2: williamr@2: williamr@2: /** Internalises the margin state from a read stream. williamr@2: williamr@2: @param aThing The margin state to be internalised - on or off. williamr@2: @param aStream The read stream from which the margin state is to be internalised. williamr@2: williamr@2: @publishedAll williamr@2: @released */ williamr@2: IMPORT_C void InternalizeL(CPrintPreviewImage::TMarginState& aThing,RReadStream& aStream); williamr@2: williamr@2: inline RWriteStream& operator<<(RWriteStream& aStream,const CPrintPreviewImage::TMarginState& aThing) williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: {aStream.WriteUint8L(aThing);return aStream;} williamr@2: williamr@2: inline RReadStream& operator>>(RReadStream& aStream,CPrintPreviewImage::TMarginState& aThing) williamr@2: /** williamr@2: @publishedAll williamr@2: @released williamr@2: */ williamr@2: {InternalizeL(aThing,aStream);return aStream;} williamr@2: williamr@2: // williamr@2: // inlines williamr@2: // williamr@2: williamr@2: // move to private source... williamr@2: williamr@2: inline TBool CPrintPreviewImage::IsFirstPanel(TInt aPageNum) williamr@2: { return aPageNum==iPrintParams.iFirstPage; } williamr@2: williamr@2: inline TBool CPrintPreviewImage::IsLastPanel(TInt aPageNum) williamr@2: { return aPageNum==iPrintParams.iLastPage; } williamr@2: williamr@2: williamr@2: #endif