williamr@2
|
1 |
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
|
williamr@2
|
2 |
// All rights reserved.
|
williamr@2
|
3 |
// This component and the accompanying materials are made available
|
williamr@4
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
williamr@2
|
5 |
// which accompanies this distribution, and is available
|
williamr@4
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
williamr@2
|
7 |
//
|
williamr@2
|
8 |
// Initial Contributors:
|
williamr@2
|
9 |
// Nokia Corporation - initial contribution.
|
williamr@2
|
10 |
//
|
williamr@2
|
11 |
// Contributors:
|
williamr@2
|
12 |
//
|
williamr@2
|
13 |
// Description:
|
williamr@2
|
14 |
//
|
williamr@2
|
15 |
|
williamr@2
|
16 |
#if !defined (__PRNPREV_H__)
|
williamr@2
|
17 |
#define __PRNPREV_H__
|
williamr@2
|
18 |
|
williamr@2
|
19 |
#if !defined(__E32STD_H__)
|
williamr@2
|
20 |
#include <e32std.h>
|
williamr@2
|
21 |
#endif
|
williamr@2
|
22 |
#if !defined(__E32BASE_H__)
|
williamr@2
|
23 |
#include <e32base.h>
|
williamr@2
|
24 |
#endif
|
williamr@2
|
25 |
#if !defined(__PRNSETUP_H__)
|
williamr@2
|
26 |
#include <prnsetup.h>
|
williamr@2
|
27 |
#endif
|
williamr@2
|
28 |
|
williamr@2
|
29 |
// classes defined:
|
williamr@2
|
30 |
class TPrintPreviewFormat;
|
williamr@2
|
31 |
class TPreviewPanel;
|
williamr@2
|
32 |
class CPrintPreviewImage;
|
williamr@2
|
33 |
//
|
williamr@2
|
34 |
|
williamr@2
|
35 |
// forward references:
|
williamr@2
|
36 |
class RWsSession;
|
williamr@2
|
37 |
class RWindow;
|
williamr@2
|
38 |
class CPrintPreviewDevice;
|
williamr@2
|
39 |
//
|
williamr@2
|
40 |
|
williamr@2
|
41 |
|
williamr@2
|
42 |
class TPrintPreviewFormat
|
williamr@2
|
43 |
/** Print preview format information.
|
williamr@2
|
44 |
|
williamr@2
|
45 |
The print preview format information is accessed via its public data members.
|
williamr@2
|
46 |
Typically there is a system wide TPrintPreviewFormat supplied by the GUI framework.
|
williamr@2
|
47 |
|
williamr@2
|
48 |
Preview information includes:
|
williamr@2
|
49 |
|
williamr@2
|
50 |
- panel settings: multiple pages can be previewed at once; the display area
|
williamr@2
|
51 |
for each page is termed a panel.
|
williamr@2
|
52 |
|
williamr@2
|
53 |
- label settings: each panel can have an associated label, which specifies the
|
williamr@2
|
54 |
corresponding document page number
|
williamr@2
|
55 |
|
williamr@2
|
56 |
@publishedAll
|
williamr@2
|
57 |
@released */
|
williamr@2
|
58 |
{
|
williamr@2
|
59 |
public:
|
williamr@2
|
60 |
/** The minimum panel gutter size, in pixels. */
|
williamr@2
|
61 |
TSize iMinPanelGutterInPixels;
|
williamr@2
|
62 |
/** The width of the panel shadow, in pixels. */
|
williamr@2
|
63 |
TInt iPanelShadowWidthInPixels;
|
williamr@2
|
64 |
/** The colour of the panel shadow. */
|
williamr@2
|
65 |
TRgb iPanelShadowColor;
|
williamr@2
|
66 |
/** The panel margin colour. */
|
williamr@2
|
67 |
TRgb iPanelMarginColor;
|
williamr@2
|
68 |
/** The color of both the paper and the window background. */
|
williamr@2
|
69 |
TRgb iPreviewBackgroundColor;
|
williamr@2
|
70 |
/** X pixel offset of the label text from the panel edge. */
|
williamr@2
|
71 |
TInt iLabelOffsetInPixels;
|
williamr@2
|
72 |
/** Font specification for the label text. */
|
williamr@2
|
73 |
TFontSpec iLabelFontSpecInPixels;
|
williamr@2
|
74 |
};
|
williamr@2
|
75 |
|
williamr@2
|
76 |
|
williamr@2
|
77 |
class CPrintPreviewImage : public CBase, private MPrintProcessObserver, private MPageRegionPrinter
|
williamr@2
|
78 |
/** Print preview image.
|
williamr@2
|
79 |
|
williamr@2
|
80 |
This class provides a standard print preview image. An object of this type
|
williamr@2
|
81 |
should be owned by a control, which is in turn owned by the print preview
|
williamr@2
|
82 |
dialog. The control's window provides the region into which this object draws
|
williamr@2
|
83 |
the preview image.
|
williamr@2
|
84 |
|
williamr@2
|
85 |
The class provides a callback to the application code that draws the preview
|
williamr@2
|
86 |
pages.
|
williamr@2
|
87 |
|
williamr@2
|
88 |
@publishedAll
|
williamr@2
|
89 |
@released */
|
williamr@2
|
90 |
{
|
williamr@2
|
91 |
public:
|
williamr@2
|
92 |
/** Margin display state flags. */
|
williamr@2
|
93 |
enum TMarginState {
|
williamr@2
|
94 |
/** Show margins in print preview image. */
|
williamr@2
|
95 |
EShowMargins,
|
williamr@2
|
96 |
/** Hide margins in print preview image. */
|
williamr@2
|
97 |
EHideMargins
|
williamr@2
|
98 |
};
|
williamr@2
|
99 |
public:
|
williamr@2
|
100 |
IMPORT_C static CPrintPreviewImage* NewL(CPrintSetup& aPrintSetup,MPageRegionPrinter& aBodyPrinter,
|
williamr@2
|
101 |
RWsSession& aWsSession,RWindow& aWindow,const TSize& aMaxWindowSize,
|
williamr@2
|
102 |
const TPrintPreviewFormat& aStaticFormat);
|
williamr@2
|
103 |
IMPORT_C virtual ~CPrintPreviewImage();
|
williamr@2
|
104 |
IMPORT_C void SetMargins(TMarginState aState); // whether or not to show margins
|
williamr@2
|
105 |
IMPORT_C void SetObserver(MPrintProcessObserver& aObserver);
|
williamr@2
|
106 |
IMPORT_C void SetNumBands(TInt aNum);
|
williamr@2
|
107 |
IMPORT_C void FormatL(TInt aNumPagesInDoc,TInt aFirstPageToDisplay,TInt aNumPagesToView); // call when scrolling or changing num pages to view
|
williamr@2
|
108 |
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
|
109 |
//
|
williamr@2
|
110 |
private:
|
williamr@2
|
111 |
class TPreviewPanel;
|
williamr@2
|
112 |
class TRange
|
williamr@2
|
113 |
{
|
williamr@2
|
114 |
public:
|
williamr@2
|
115 |
TInt iFrom;
|
williamr@2
|
116 |
TInt iTo;
|
williamr@2
|
117 |
};
|
williamr@2
|
118 |
private:
|
williamr@2
|
119 |
CPrintPreviewImage(CPrintSetup& aPrintSetup,MPageRegionPrinter& aBodyPrinter,RWsSession& aWsSession,
|
williamr@2
|
120 |
RWindow& aWindow,const TSize& aMaxWindowSize,const TPrintPreviewFormat& aStaticFormat);
|
williamr@2
|
121 |
void ConstructL();
|
williamr@2
|
122 |
void CalculateHeaderFooterRects(TRect& aHeaderRectInPixels,TRect& aFooterRectInPixels);
|
williamr@2
|
123 |
TInt SetPanelArrayL(const TInt aFirstPage,const TInt aNumPagesToView);
|
williamr@2
|
124 |
void SetLabelWidth();
|
williamr@2
|
125 |
void ScrollPanels();
|
williamr@2
|
126 |
void DrawBorder(CGraphicsContext* aGc); // and shadow
|
williamr@2
|
127 |
void DrawMargins(CGraphicsContext* aGc); // including header/footer lines
|
williamr@2
|
128 |
void DrawLabel(CGraphicsContext* aGc,TInt aPageNo);
|
williamr@2
|
129 |
void DrawToGutter(CGraphicsContext* aGc,TInt aPageNo); // blanks all the gutter areas associated to a particular panel
|
williamr@2
|
130 |
void DrawExtremities(CGraphicsContext* aGc); // blanks very left and right of the window
|
williamr@2
|
131 |
inline TBool IsFirstPanel(TInt aPageNum);
|
williamr@2
|
132 |
inline TBool IsLastPanel(TInt aPageNum);
|
williamr@2
|
133 |
// from MPrintProcessObserver
|
williamr@2
|
134 |
virtual void NotifyPrintStarted(TPrintParameters aPrintParams);
|
williamr@2
|
135 |
virtual void NotifyBandPrinted(TInt aPercentageOfPagePrinted, TInt aCurrentPageNum, TInt aCurrentCopyNum);
|
williamr@2
|
136 |
virtual void NotifyPrintEnded(TInt anErrorCode);
|
williamr@2
|
137 |
// from MPageRegionPrinter
|
williamr@2
|
138 |
virtual void PrintBandL(CGraphicsDevice* aDevice,TInt aPageNo,const TBandAttributes& aBand);
|
williamr@2
|
139 |
private:
|
williamr@2
|
140 |
CPrintPreviewDevice* iDevice;
|
williamr@2
|
141 |
CPrintSetup* iPrintSetup;
|
williamr@2
|
142 |
MPageRegionPrinter* iAppBodyPrinter;
|
williamr@2
|
143 |
MPrintProcessObserver* iObserver; // may be null
|
williamr@2
|
144 |
RWsSession* iWsSession;
|
williamr@2
|
145 |
RWindow* iWindow;
|
williamr@2
|
146 |
CFont* iLabelFont;
|
williamr@2
|
147 |
CArrayFix<TPreviewPanel>* iPanelArray;
|
williamr@2
|
148 |
//
|
williamr@2
|
149 |
TPrintPreviewFormat iFormat;
|
williamr@2
|
150 |
TPrintParameters iPrintParams; // current preview range
|
williamr@2
|
151 |
TMarginState iMarginState; // whether the margins are on or not
|
williamr@2
|
152 |
TSize iPanelSizeInPixels;
|
williamr@2
|
153 |
TSize iWinSize; // size of the window (for layout purposes)
|
williamr@2
|
154 |
TPoint iOrigin; // origin in the window to use for drawing
|
williamr@2
|
155 |
TSize iLabelSize;
|
williamr@2
|
156 |
TSize iActualGutter; // gap from the edge of the panel to either screen edge or adjacent panel
|
williamr@2
|
157 |
TInt iNumPagesInDoc;
|
williamr@2
|
158 |
TInt iNumBands;
|
williamr@2
|
159 |
TSize iRndError; // rounding error from calculation of iActualGutter
|
williamr@2
|
160 |
TRange iDrawRange; // the pages that actually require drawing - ie have not been scrolled
|
williamr@2
|
161 |
};
|
williamr@2
|
162 |
|
williamr@2
|
163 |
|
williamr@2
|
164 |
/** Internalises the margin state from a read stream.
|
williamr@2
|
165 |
|
williamr@2
|
166 |
@param aThing The margin state to be internalised - on or off.
|
williamr@2
|
167 |
@param aStream The read stream from which the margin state is to be internalised.
|
williamr@2
|
168 |
|
williamr@2
|
169 |
@publishedAll
|
williamr@2
|
170 |
@released */
|
williamr@2
|
171 |
IMPORT_C void InternalizeL(CPrintPreviewImage::TMarginState& aThing,RReadStream& aStream);
|
williamr@2
|
172 |
|
williamr@2
|
173 |
inline RWriteStream& operator<<(RWriteStream& aStream,const CPrintPreviewImage::TMarginState& aThing)
|
williamr@2
|
174 |
/**
|
williamr@2
|
175 |
@publishedAll
|
williamr@2
|
176 |
@released
|
williamr@2
|
177 |
*/
|
williamr@2
|
178 |
{aStream.WriteUint8L(aThing);return aStream;}
|
williamr@2
|
179 |
|
williamr@2
|
180 |
inline RReadStream& operator>>(RReadStream& aStream,CPrintPreviewImage::TMarginState& aThing)
|
williamr@2
|
181 |
/**
|
williamr@2
|
182 |
@publishedAll
|
williamr@2
|
183 |
@released
|
williamr@2
|
184 |
*/
|
williamr@2
|
185 |
{InternalizeL(aThing,aStream);return aStream;}
|
williamr@2
|
186 |
|
williamr@2
|
187 |
//
|
williamr@2
|
188 |
// inlines
|
williamr@2
|
189 |
//
|
williamr@2
|
190 |
|
williamr@2
|
191 |
// move to private source...
|
williamr@2
|
192 |
|
williamr@2
|
193 |
inline TBool CPrintPreviewImage::IsFirstPanel(TInt aPageNum)
|
williamr@2
|
194 |
{ return aPageNum==iPrintParams.iFirstPage; }
|
williamr@2
|
195 |
|
williamr@2
|
196 |
inline TBool CPrintPreviewImage::IsLastPanel(TInt aPageNum)
|
williamr@2
|
197 |
{ return aPageNum==iPrintParams.iLastPage; }
|
williamr@2
|
198 |
|
williamr@2
|
199 |
|
williamr@2
|
200 |
#endif
|