epoc32/include/prnprev.h
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
     1.1 --- a/epoc32/include/prnprev.h	Tue Nov 24 13:55:44 2009 +0000
     1.2 +++ b/epoc32/include/prnprev.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -1,1 +1,200 @@
     1.4 -prnprev.h
     1.5 +// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +// All rights reserved.
     1.7 +// This component and the accompanying materials are made available
     1.8 +// 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
     1.9 +// which accompanies this distribution, and is available
    1.10 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.11 +//
    1.12 +// Initial Contributors:
    1.13 +// Nokia Corporation - initial contribution.
    1.14 +//
    1.15 +// Contributors:
    1.16 +//
    1.17 +// Description:
    1.18 +//
    1.19 +
    1.20 +#if !defined (__PRNPREV_H__)
    1.21 +#define __PRNPREV_H__
    1.22 +
    1.23 +#if !defined(__E32STD_H__)
    1.24 +#include  <e32std.h>
    1.25 +#endif
    1.26 +#if !defined(__E32BASE_H__)
    1.27 +#include  <e32base.h>
    1.28 +#endif
    1.29 +#if !defined(__PRNSETUP_H__)
    1.30 +#include <prnsetup.h>
    1.31 +#endif
    1.32 +
    1.33 +// classes defined:
    1.34 +class TPrintPreviewFormat;
    1.35 +class TPreviewPanel;
    1.36 +class CPrintPreviewImage;
    1.37 +//
    1.38 +
    1.39 +// forward references:
    1.40 +class RWsSession;
    1.41 +class RWindow;
    1.42 +class CPrintPreviewDevice;
    1.43 +//
    1.44 +
    1.45 +
    1.46 +class TPrintPreviewFormat
    1.47 +/** Print preview format information.
    1.48 +
    1.49 +The print preview format information is accessed via its public data members. 
    1.50 +Typically there is a system wide TPrintPreviewFormat supplied by the GUI framework. 
    1.51 +
    1.52 +Preview information includes:
    1.53 +
    1.54 +- panel settings: multiple pages can be previewed at once; the display area 
    1.55 +for each page is termed a panel.
    1.56 +
    1.57 +- label settings: each panel can have an associated label, which specifies the 
    1.58 +corresponding document page number 
    1.59 +
    1.60 +@publishedAll 
    1.61 +@released */
    1.62 +	{
    1.63 +public:
    1.64 +	/** The minimum panel gutter size, in pixels. */
    1.65 +	TSize iMinPanelGutterInPixels;
    1.66 +	/** The width of the panel shadow, in pixels. */
    1.67 +	TInt iPanelShadowWidthInPixels;
    1.68 +	/** The colour of the panel shadow. */
    1.69 +	TRgb iPanelShadowColor;
    1.70 +	/** The panel margin colour. */
    1.71 +	TRgb iPanelMarginColor;
    1.72 +	/** The color of both the paper and the window background. */
    1.73 +	TRgb iPreviewBackgroundColor;
    1.74 +	/** X pixel offset of the label text from the panel edge. */
    1.75 +	TInt iLabelOffsetInPixels;
    1.76 +	/** Font specification for the label text. */
    1.77 +	TFontSpec iLabelFontSpecInPixels;
    1.78 +	};
    1.79 +
    1.80 +
    1.81 +class CPrintPreviewImage : public CBase, private MPrintProcessObserver, private MPageRegionPrinter
    1.82 +/** Print preview image.
    1.83 +
    1.84 +This class provides a standard print preview image. An object of this type 
    1.85 +should be owned by a control, which is in turn owned by the print preview 
    1.86 +dialog. The control's window provides the region into which this object draws 
    1.87 +the preview image.
    1.88 +
    1.89 +The class provides a callback to the application code that draws the preview 
    1.90 +pages. 
    1.91 +
    1.92 +@publishedAll 
    1.93 +@released */
    1.94 +	{
    1.95 +public:
    1.96 +	/** Margin display state flags. */
    1.97 +	enum TMarginState {
    1.98 +		/** Show margins in print preview image. */
    1.99 +		EShowMargins,
   1.100 +		/** Hide margins in print preview image. */
   1.101 +		EHideMargins
   1.102 +		};
   1.103 +public:
   1.104 +	IMPORT_C static CPrintPreviewImage* NewL(CPrintSetup& aPrintSetup,MPageRegionPrinter& aBodyPrinter,
   1.105 +											RWsSession& aWsSession,RWindow& aWindow,const TSize& aMaxWindowSize,
   1.106 +											const TPrintPreviewFormat& aStaticFormat);
   1.107 +	IMPORT_C virtual ~CPrintPreviewImage();
   1.108 +	IMPORT_C void SetMargins(TMarginState aState); // whether  or not to show margins
   1.109 +	IMPORT_C void SetObserver(MPrintProcessObserver& aObserver);
   1.110 +	IMPORT_C void SetNumBands(TInt aNum);
   1.111 +	IMPORT_C void FormatL(TInt aNumPagesInDoc,TInt aFirstPageToDisplay,TInt aNumPagesToView); // call when scrolling or changing num pages to view
   1.112 +	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)
   1.113 +	//
   1.114 +private:
   1.115 +	class TPreviewPanel;
   1.116 +	class TRange
   1.117 +		{
   1.118 +	public:
   1.119 +		TInt iFrom;
   1.120 +		TInt iTo;
   1.121 +		};
   1.122 +private:
   1.123 +	CPrintPreviewImage(CPrintSetup& aPrintSetup,MPageRegionPrinter& aBodyPrinter,RWsSession& aWsSession,
   1.124 +						RWindow& aWindow,const TSize& aMaxWindowSize,const TPrintPreviewFormat& aStaticFormat);
   1.125 +	void ConstructL();
   1.126 +	void CalculateHeaderFooterRects(TRect& aHeaderRectInPixels,TRect& aFooterRectInPixels);
   1.127 +	TInt SetPanelArrayL(const TInt aFirstPage,const TInt aNumPagesToView); 
   1.128 +	void SetLabelWidth();
   1.129 +	void ScrollPanels();
   1.130 +	void DrawBorder(CGraphicsContext* aGc); // and shadow
   1.131 +	void DrawMargins(CGraphicsContext* aGc); // including header/footer lines
   1.132 +	void DrawLabel(CGraphicsContext* aGc,TInt aPageNo);
   1.133 +	void DrawToGutter(CGraphicsContext* aGc,TInt aPageNo); // blanks all the gutter areas associated to a particular panel
   1.134 +	void DrawExtremities(CGraphicsContext* aGc); // blanks very left and right of the window
   1.135 +	inline TBool IsFirstPanel(TInt aPageNum);
   1.136 +	inline TBool IsLastPanel(TInt aPageNum);
   1.137 +	// from MPrintProcessObserver
   1.138 +	virtual void NotifyPrintStarted(TPrintParameters aPrintParams);
   1.139 +	virtual void NotifyBandPrinted(TInt aPercentageOfPagePrinted, TInt aCurrentPageNum, TInt aCurrentCopyNum);
   1.140 +	virtual void NotifyPrintEnded(TInt anErrorCode);
   1.141 +	// from MPageRegionPrinter
   1.142 +	virtual void PrintBandL(CGraphicsDevice* aDevice,TInt aPageNo,const TBandAttributes& aBand);
   1.143 +private:
   1.144 +	CPrintPreviewDevice* iDevice;
   1.145 +	CPrintSetup* iPrintSetup;
   1.146 +	MPageRegionPrinter* iAppBodyPrinter;
   1.147 +	MPrintProcessObserver* iObserver; // may be null
   1.148 +	RWsSession* iWsSession;
   1.149 +	RWindow* iWindow;
   1.150 +	CFont* iLabelFont;
   1.151 +	CArrayFix<TPreviewPanel>* iPanelArray;
   1.152 +	//
   1.153 +	TPrintPreviewFormat iFormat;
   1.154 +	TPrintParameters iPrintParams; // current preview range
   1.155 +	TMarginState iMarginState; // whether the margins are on or not
   1.156 +	TSize iPanelSizeInPixels;
   1.157 +	TSize iWinSize; // size of the window (for layout purposes)
   1.158 +	TPoint iOrigin; // origin in the window to use for drawing
   1.159 +	TSize iLabelSize;
   1.160 +	TSize iActualGutter; // gap from the edge of the panel to either screen edge or adjacent panel
   1.161 +	TInt iNumPagesInDoc; 
   1.162 +	TInt iNumBands;
   1.163 +	TSize iRndError; // rounding error from calculation of iActualGutter
   1.164 +	TRange iDrawRange; // the pages that actually require drawing - ie have not been scrolled 
   1.165 +	};
   1.166 +
   1.167 +
   1.168 +/** Internalises the margin state from a read stream.
   1.169 +
   1.170 +@param aThing The margin state to be internalised - on or off.
   1.171 +@param aStream The read stream from which the margin state is to be internalised. 
   1.172 +
   1.173 +@publishedAll 
   1.174 +@released */
   1.175 +IMPORT_C void InternalizeL(CPrintPreviewImage::TMarginState& aThing,RReadStream& aStream);
   1.176 +
   1.177 +inline RWriteStream& operator<<(RWriteStream& aStream,const CPrintPreviewImage::TMarginState& aThing) 
   1.178 +/**
   1.179 +@publishedAll 
   1.180 +@released 
   1.181 +*/
   1.182 +	{aStream.WriteUint8L(aThing);return aStream;}
   1.183 +
   1.184 +inline RReadStream& operator>>(RReadStream& aStream,CPrintPreviewImage::TMarginState& aThing) 
   1.185 +/**
   1.186 +@publishedAll 
   1.187 +@released 
   1.188 +*/
   1.189 +	{InternalizeL(aThing,aStream);return aStream;}
   1.190 +
   1.191 +//
   1.192 +// inlines
   1.193 +//
   1.194 +
   1.195 +// move to private source...
   1.196 +
   1.197 +inline TBool CPrintPreviewImage::IsFirstPanel(TInt aPageNum) 
   1.198 +	{ return aPageNum==iPrintParams.iFirstPage; }
   1.199 +
   1.200 +inline TBool CPrintPreviewImage::IsLastPanel(TInt aPageNum) 
   1.201 +	{ return aPageNum==iPrintParams.iLastPage; }
   1.202 +
   1.203 +
   1.204 +#endif